HDL Compiler:生成块结构(Generate)的识别

相关阅读

HDL Compilerhttps://blog.csdn.net/weixin_45791458/category_12893238.html?spm=1001.2014.3001.5482


简介

生成块结构(Generate)用于有条件地(称为条件生成块)或重复地(称为循环生成块)将生成块实例化到模块中,由Verilog 2001标准借鉴VHDL引入。HDL Compiler默认使用Verilog 2005标准读取设计,控制hdlin_vrlg_std变量(默认值为2005)可以改变读取规则,并同时支持Verilog 2001标准和Verilog 2005标准中的生成块结构。

有关生成块结构的更多介绍,可以参考下面的博客。

Verilog基础:生成块结构(Generate)https://blog.csdn.net/weixin_45791458/article/details/142169395?ops_request_misc=elastic_search_misc&request_id=70c1c7b274d985d21319b02fb19fd7f0&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~ElasticSearch~search_v2-1-142169395-null-null.541^v3^pc_search_result_blog1&utm_term=%E7%94%9F%E6%88%90%E5%9D%97%E7%BB%93%E6%9E%84&spm=1018.2226.3001.4450

生成块的种类

普通生成块

循环生成块结构允许使用类似for循环语句的语法,而条件生成块结构(包括if-generate和case-generate)用于在多个选项生成块中选择至多一个实例化。它们可以互相嵌套,如例1所示。

复制代码
// 例1
module top(input D1, input clk, output Q1);
    genvar i, j;
    parameter param1 = 0;
    parameter param2 = 1;

    generate
        for (i = 0; i < 3; i = i + 1) begin : loop1
            for (j = 0; j < 2; j = j + 1) begin : loop2
                if (j == param1) begin : if1_label
                    memory U_00 (D1,clk,Q1);
                end
                if (j == param2) begin : if2_label
                    memory U_00 (D1,clk,Q1);
                end
            end //loop2
        end //loop1
    endgenerate

endmodule

module memory(input D1, input clk, output Q1);
endmodule

下面展示了HDL Compiler读取例1后report_cell命令的结果,可以看出即使对于仿真器,会为生成块结构中的命名块创建新的层次,但对于HDL Compiler,所有实例被视为同一个模块层次,而命名块层次则使用实例名中的.分隔。

复制代码
Cell                             Reference    Library    Area       Attributes
------------------------------------------------------------------------------
loop1[0].loop2[0].if1_label.U_00
                                 memory                  0.000000   b
loop1[0].loop2[1].if2_label.U_00
                                 memory                  0.000000   b
loop1[1].loop2[0].if1_label.U_00
                                 memory                  0.000000   b
loop1[1].loop2[1].if2_label.U_00
                                 memory                  0.000000   b
loop1[2].loop2[0].if1_label.U_00
                                 memory                  0.000000   b
loop1[2].loop2[1].if2_label.U_00
                                 memory                  0.000000   b
------------------------------------------------------------------------------
Total 6 cells                                            0.000000

这不代表标识符的引用无需遵守Verilog标准中的规则,HDL Compiler在读取例2后会出现VER-956错误,因为标识符w实际上被定义在命名块中,而却在顶层引用。

复制代码
// 例2
module top(input in, output out);

    generate
        if (1) begin: label1
            wire w = in;
        end
    endgenerate

    assign out = w;

endmodule

独立生成块

复制代码
// 例3
module top (input in1, output out1);

    generate
        begin : b1
            mod1 U1(in1, out1);
        end
    endgenerate

endmodule

module mod1 (input in1, output out1);
endmodule

Verilog 2001标准支持一种不属于普通生成块的生成块结构,即不使用for、if或case语句,如例3所示。当使用Verilog 2001标准时,下面展示了HDL Compiler读取例3后report_cell命令的结果。

复制代码
Cell          Reference    Library    Area        Attributes
------------------------------------------------------------
b1.U1         mod1                    0.000000    b
------------------------------------------------------------
Total 1 cells                         0.000000

当使用Verilog 2005标准时,HDL Compiler在读取例3后会出现VER-946错误。

匿名生成块

复制代码
// 例4
module top(input [0:3] in1, output [0:3] out1);
    genvar I;

    generate
        for (I = 0; I < 3; I = I+1) begin : b1
            if (1) begin : b2
                if (1) begin
                    if (1) begin
                        if (1) begin
                            mod1 U1(in1[I], out1[I]);
                        end
                    end
                end
            end
        end
    endgenerate

endmodule

module mod1(input in1, output out1);
endmodule

Verilog 2005标准规定,在一个命名空间内的每个生成块结构都会被分配一个编号。在该命名空间中文本上最先出现的生成块结构编号为1,每出现一个新的生成块结构,编号就加1(注意,即使生成块结构不是匿名的,其依然拥有编号)。生成块结构中的匿名生成块将拥有隐式名称genblk<n>,其中<n>是其所在生成块结构被分配的编号。如果这样的隐式名称与该命名空间中显式声明的名称发生冲突,那么将在编号前添加前导零,直到名称不再冲突为止。当使用Verilog 2005标准时,下面展示了HDL Compiler读取例4后report_cell命令的结果,出现VER-944警告。

复制代码
Cell                                    Reference  Library    Area        Attributes
----------------------------------------------------------------------------------------
b1[0].b2.genblk1.genblk1.genblk1.U1     mod1                  0.000000    b
b1[1].b2.genblk1.genblk1.genblk1.U1     mod1                  0.000000    b
b1[2].b2.genblk1.genblk1.genblk1.U1     mod1                  0.000000    b
----------------------------------------------------------------------------------------
Total 3 cells                                                 0.000000

Verilog 2001标准没有对匿名生成块有额外规定,因此不创建新的层次,当使用Verilog 2001标准时,下面展示了HDL Compiler读取例4后report_cell命令的结果。

复制代码
Cell               Reference    Library    Area       Attributes
----------------------------------------------------------------
b1[0].b2.U1        mod1                   0.000000    b
b1[1].b2.U1        mod1                   0.000000    b
b1[2].b2.U1        mod1                   0.000000    b
----------------------------------------------------------------
Total 3 cells                             0.000000
直接嵌套
复制代码
// 例5
module top(input [0:3] in1, output [0:3] out1);
    genvar I;

    generate
        for (I = 0; I < 3; I = I+1) begin : b1
            if (1) begin : b2
                if (1)
                    if (1)
                        if (1)
                            mod1 U1(in1[I], out1[I]);
            end
        end
    endgenerate

endmodule

module mod1(input in1, output out1);
endmodule

Verilog 2005标准规定,如果条件生成块结构中的生成块只包含一个项目(并且没有使用begin-end块),而这个项目本身又是一个条件生成块结构,那么,这个外层条件生成块结构不会被视为一个单独的层次结构和命名空间,这种情况称为直接嵌套(direct nesting),直接嵌套的生成块会被视为属于外层条件生成块结构。当使用Verilog 2005标准时,下面展示了HDL Compiler读取例5后report_cell命令的结果,其中的genblk1层次来自最内层if语句。

复制代码
Cell                  Reference    Library    Area        Attributes
--------------------------------------------------------------------
b1[0].b2.genblk1.U1    mod1                    0.000000    b
b1[1].b2.genblk1.U1    mod1                    0.000000    b
b1[2].b2.genblk1.U1    mod1                    0.000000    b
--------------------------------------------------------------------
Total 3 cells                                  0.000000

Verilog 2001标准没有对匿名生成块有额外规定,因此不创建新的层次,当使用Verilog 2001标准时,下面展示了HDL Compiler读取例5后report_cell命令的结果。

复制代码
Cell          Reference    Library    Area        Attributes
------------------------------------------------------------
b1[0].b2.U1   mod1                    0.000000    b
b1[1].b2.U1   mod1                    0.000000    b
b1[2].b2.U1   mod1                    0.000000    b
------------------------------------------------------------
Total 3 cells                         0.000000
相关推荐
日晨难再1 个月前
SDC命令详解:使用all_fanin命令进行查询
数字ic
景芯SoC芯片实战2 个月前
景芯SoC USB2.0 PHY上电后CLK不输出60MHz,Controller一直挂死——问题到底出在哪?
数字ic
景芯SoC芯片实战3 个月前
❓ 问题:流片前做功能ECO,后端改完 ecoPlace 和 ecoRoute 就可以交片了吗?
数字ic
景芯SoC芯片实战3 个月前
ICG的TE端到底该接scan_enable还是test_mode?
数字ic
日晨难再3 个月前
Design Compiler:精确映射(-exact_map选项)
数字ic
日晨难再4 个月前
SDC命令详解:使用set_size_only命令进行约束
数字ic
景芯SoC芯片实战4 个月前
Hard Macro的Float Pin设错了,skew balance全白干
数字ic·soc后端
景芯SoC芯片实战4 个月前
12nm工艺下,6T-Turbo Cell的Filler到底该怎么插?
数据库·数字ic·dft·soc后端
日晨难再5 个月前
SDC命令详解:使用quit、exit和return命令进行控制
数字ic