资讯详情

资讯详情

HDL Compiler:hdlin_preserve_sequential变量和preserve_sequential综合指令的使用

相关阅读HDL Compilerhttps://blog.csdn.net/weixin_45791458/category_12893238.html?spm1001.2014.3001.5482综合指令(Synthesis Directives)是一些特殊注释用于影响综合工具如何处理RTL代码这些注释会被综合工具识别但会被其他工具如仿真器忽略。关于综合指令相关概念的更多介绍可以参考下面的博客。HDL Compiler综合指令https://chenzhang.blog.csdn.net/article/details/148695750首先回顾一下不可读的概念不可读是一种状态单元触发器、组合逻辑门都可能位于这种状态简单来说不可读就是单元直接或间接没有驱动任何输出端口。当RTL代码中包含不可读或无驱动触发器/组合逻辑门时HDL Compiler会把它们删除因此并不会有不可读或无驱动触发器的推断报告例1展示了不可读触发器的删除。// 例1 module unread(input a, b, c, clk, output z); reg a_r1, a_r2; wire d; assign z a_r1; assign d a_r2 c; always(posedge clk) begin a_r1 a; a_r2 a b; end endmodule下面为HDL Compiler读取例1时产生的触发器推断报告可以看出其中并未识别出不可读触发器a_r2_reg。 | Register Name | Type | Width | Bus | MB | Set | Reset | ST | Line | | a_r1_reg | Flip-flop | 1 | N | N | None | None | N | 6 | 图1为此时的GTECH网表可以看出一个触发器和两个与门都因为被认定为是直接/间接不可读状态而删除只有触发器a_r1_reg以通用时序单元SEQGEN的形式存在。图1 例1的GETCH网表可以通过设置hdlin_preserve_sequential变量默认值为none控制是否保留不可读或无驱动触发器如果将该变量设置为all或者true触发器推断报告如下所示。 | Register Name | Type | Width | Bus | MB | Set | Reset | ST | Line | | a_r1_reg | Flip-flop | 1 | N | N | None | None | N | 6 | | a_r2_reg | Flip-flop | 1 | N | N | None | None | N | 6 | 图2为此时的GTECH网表可以看出只有不可读触发器a_r2_reg后面的与门都因为被认定为是直接不可读状态而删除不可读触发器a_r2_reg和其前面的与门间接都得到了保留。图2 例1的GETCH网表例1展示了不可读触发器的保留如果无驱动触发器使用该方法保留下来了会将无驱动引脚连接到常量0。hdlin_preserve_sequential变量当该变量被设置为all或者true时保留所有不可读时序单元不包括仅作为循环变量使用的不可读时序单元当该变量被设置为allloop_variables或者trueloop_variables时保留所有不可读时序单元包括仅作为循环变量使用的不可读时序单元当该变量被设置为ff时仅保留所有不可读触发器不包括仅作为循环变量使用的不可读触发器当该变量被设置为ffloop_variables时仅保留所有不可读触发器包括仅作为循环变量使用的不可读触发器当该变量被设置为latch时仅保留所有不可读锁存器不包括仅作为循环变量使用的不可读锁存器当该变量被设置为latchloop_variables时仅保留所有不可读触发器包括仅作为循环变量使用的不可读锁存器例2展示了仅作为循环变量使用的不可读触发器其中i信号作为integer类型的变量作为for循环内的索引变量默认不会被推断为触发器。// 例2 module test (input clk, rst, error); parameter N 4; reg [N-1:0] fail; integer i, j; always (posedge clk or posedge rst) if (rst) fail {N-1{1b0}}; else for ( i 0; i N; i i 1 ) fail[i] fail[i] | error; endmodule当hdlin_preserve_sequential变量被设置为none时所有不可读触发器fail_reg[i]都被删除了当hdlin_preserve_sequential变量被设置为all时触发器推断报告如下所示GETCH网表如图3所示 | Register Name | Type | Width | Bus | MB | Set | Reset | ST | Line | | fail_reg | Flip-flop | 4 | Y | N | None | Async | N | 7 | 图3 例2的GETCH网表当hdlin_preserve_sequential变量被设置为allloop_variables时触发器推断报告如下所示GETCH网表如图4所示。 | Register Name | Type | Width | Bus | MB | Set | Reset | ST | Line | | fail_reg | Flip-flop | 4 | Y | N | None | Async | N | 7 | | i_reg | Flip-flop | 32 | Y | N | None | None | N | 7 | 图4 例2的GETCH网表preserve_sequential综合指令hdlin_preserve_sequential变量只能进行粗粒度的控制如果想要更细粒度的控制可以使用preserve_sequential综合指令。需要强调preserve_sequential综合指令只能用于保留有可能被推断出的时序单元对于组合逻辑的保留是间接的。例3展示了该综合指令的使用方法。// 例3 module mydesign (input in1, in2, in3, input clk, output out); reg sum1; reg sum2 /* synopsys preserve_sequential */; wire save; always (posedge clk) begin sum1 in1 | in2; sum2 in1 in2 in3; // 该组合逻辑会被保留间接 end assign out ~sum1; assign save sum1 sum2; // 该组合逻辑不会被保留因为它位于被保留触发器sum2_reg后面 endmodule此时的触发器推断报告如下所示GETCH网表如图5所示。 | Register Name | Type | Width | Bus | MB | Set | Reset | ST | Line | | sum1_reg | Flip-flop | 1 | N | N | None | None | N | 6 | | sum2_reg | Flip-flop | 1 | N | N | None | None | N | 6 | 图5 例3的GETCH网表例4展示了该综合指令的使用方法。// 例4 module mydesign (input in1, in2, in3, input clk, output out); reg sum1; reg sum2, save /* synopsys preserve_sequential */; always (posedge clk) begin sum1 in1 | in2; sum2 in1 in2 in3; // 该组合逻辑会被保留间接 end assign out ~sum1; always (posedge clk) begin save sum1 sum2; // 该组合逻辑也会被保留间接因为save信号被定义为reg类型且添加了综合指令 end endmodule此时的触发器推断报告如下所示GETCH网表如图6所示。 | Register Name | Type | Width | Bus | MB | Set | Reset | ST | Line | | sum1_reg | Flip-flop | 1 | N | N | None | None | N | 6 | | sum2_reg | Flip-flop | 1 | N | N | None | None | N | 6 | | save_reg | Flip-flop | 1 | N | N | None | None | N | 13 | 图6 例4的GETCH网表Design Compiler NXT在2022版本推出了report_transformed_registers命令该命令可以报告工具在优化过程中对寄存器包括触发器和锁存器进行的所有变换详细内容可以参考下面的博客。SDC命令详解使用report_transformed_registers命令进行报告https://blog.csdn.net/weixin_45791458/article/details/158101563?sharetypeblogdetailsharerId158101563sharereferPCsharesourceweixin_45791458spm1011.2480.3001.8118不管是使用hdlin_preserve_sequential变量还是preserve_sequential综合指令它只能影响HDL Compiler在读取RTL代码时的行为对于Design Compiler在综合时对于不可读触发器的优化可以参考下面的博客。Design Compiler不可读单元的移除https://blog.csdn.net/weixin_45791458/article/details/157099538?ops_request_misc%257B%2522request%255Fid%2522%253A%252227bdd50e3fb6d8469484e6eb17894502%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257Drequest_id27bdd50e3fb6d8469484e6eb17894502biz_id0utm_mediumdistribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-1-157099538-null-null.nonecaseutm_termDesign%20Compiler%EF%BC%9A%E4%B8%8D%E5%8F%AF%E8%AF%BBspm1018.2226.3001.4450
觉得有用,分享给同行:

为您的企业打造数字门面

稳重轻奢商务风格,端正雅致视觉,长效耐看不易过时。

立即咨询 →