Design Compiler:使用read_file命令读取RTL设计

相关阅读

Design Compilerhttps://blog.csdn.net/weixin_45791458/category_12738116.html?spm=1001.2014.3001.5482


        Design Compiler可以使用read_file读取RTL设计,本文将对此进行详细阐述。

read_file命令

        使用read_file命令不同于analyze/elaborate命令,默认不会产生中间文件(.syn、.pvl、.mr文件)而是直接将设计读取进内存。

read_file -format verilog/sverilog/vhdl **

        以下是支持的RTL格式:

  • Verilog源代码格式以及gzip压缩格式
  • SystemVerilog源代码格式以及gzip压缩格式
  • VHDL源代码格式以及gzip压缩格式

        虽然推荐始终使用-format选项指定格式,但如果未指定该选项,则会尝试根据文件扩展名自动推断格式,以下是支持的RTL文件拓展名(不区分大小写):

  • Verilog拓展名:.v、.verilog、.v.gz、.verilog.gz
  • SystemVerilog拓展名:.sv、.sverilog、.sv.gz、.sverilog.gz
  • VHDL拓展名:.vhd、.vhdl、.vhd.gz、.vhdl.gz

        如果文件扩展名不属于已知类型,工具会默认使用ddc格式。需要注意的是,ddc文件压缩后不支持使用read_file命令读取,因为这种文件已经是压缩格式了。

        尽管read_file命令会执行隐式的link命令(手册中并没有说明这点),还是建议在使用读取命令后执行link命令,因为如果设计存在链接问题,显式执行link命令可以帮助设计者发现并修正这些问题。

        link命令将会搜索link_path以及search_path并尝试解析引用,随后尝试在默认设计库WORK中解析引用。

        关于默认设计库,参考下面这篇博客。

Design Compiler:使用analyze/elaborate命令读取RTL设计https://blog.csdn.net/weixin_45791458/article/details/144949582?sharetype=blogdetail&sharerId=144949582&sharerefer=PC&sharesource=weixin_45791458&spm=1011.2480.3001.8118        关于link_path以及search_path的详细信息,参考下面这篇博客。

Design Compiler:目标(target)库、链接(link)库、符号(symbol)库、综合(synthetic)库和物理(physical)库的详细解析https://blog.csdn.net/weixin_45791458/article/details/143029536?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522502d65d2eef7fed72c9e2e11697448a3%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=502d65d2eef7fed72c9e2e11697448a3&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-3-143029536-null-null.nonecase&utm_term=link&spm=1018.2226.3001.4450

读取参数化设计

        当使用read_file命令读取参数化设计时,可能会出现问题,如下例所示。

// 文件:adder.v
module adder #(
    parameter WIDTH = 8
)(
    input  wire [WIDTH-1:0] a,
    input  wire [WIDTH-1:0] b,
    output wire [WIDTH-1:0] sum
);
    assign sum = a + b;
endmodule

// 文件:top.v
module top (
    input  wire [7:0]   a8,  b8,
    input  wire [15:0]  a16, b16,
    input  wire [3:0]   a4,  b4,
    output wire [7:0]   sum8,
    output wire [15:0]  sum16,
    output wire [3:0]   sum4
);

    adder #(.WIDTH(8)) u_adder8 (
        .a(a8),
        .b(b8),
        .sum(sum8)
    );

    adder #(.WIDTH(16)) u_adder16 (
        .a(a16),
        .b(b16),
        .sum(sum16)
    );

    adder #(.WIDTH(4)) u_adder4 (
        .a(a4),
        .b(b4),
        .sum(sum4)
    );

endmodule

        首先使用read_file命令读取设计文件。

dc_shell> read_file -format verilog "top.v adder.v"

         当使用link命令尝试链接时却出现了错误,如下所示。

dc_shell> link
  Linking design 'top'
  Using the following designs and libraries:
  --------------------------------------------------------------------------

Information: Building the design 'adder' instantiated from design 'top' with
        the parameters "WIDTH=16". (HDL-193)
Warning: Cannot find the design 'adder' in the library 'WORK'. (LBR-1)
Information: Building the design 'adder' instantiated from design 'top' with
        the parameters "WIDTH=4". (HDL-193)
Warning: Cannot find the design 'adder' in the library 'WORK'. (LBR-1)
Warning: Unable to resolve reference 'adder' in 'top'. (LINK-5)

        警告显示,除了默认的WIDTH参数为8的情况,另外两个设计尝试在默认设计库WORK中读取失败了。

        这是因为读取参数化设计时需要中间文件,而read_file命令默认不产生中间文件(使用analyze/elaborate命令读取时不存在该问题),需要将hdlin_auto_save_templates变量设置为true允许保存中间文件。

dc_shell> set_app_var hdlin_auto_save_templates true

举例说明

        下面是三个分属于三个文件的模块,其中顶层模块top定义在top.v文件中,其中例化了adder模块,而adder模块定义在ADDER.v和adder.v文件中。 

// 文件:adder.v
module adder(
    input wire [7:0] a,      
    input wire [7:0] b,      
    output wire [7:0] sum    
);
    assign sum = a * b;       
endmodule
 
// 文件:ADDER.v
module adder(
    input wire [7:0] a,      
    input wire [7:0] b,      
    output wire [7:0] sum    
);
    assign sum = a + b;       
endmodule
 
// 文件:top.v
module top(
    input wire [7:0] in_a,    
    input wire [7:0] in_b,   
    output wire [7:0] out_sum 
);
  
    adder u_adder (
        .a(in_a),
        .b(in_b),
        .sum(out_sum)
    );
endmodule

        假设已经将ADDER.v保存为ADDER.ddc文件,并且在link_library中指定了该文件,而adder模块(来自adder.v文件)在默认设计库WORK中,read_file命令读取top模块后会优先使用该.ddc文件,而不是设计库中的adder模块(来自adder.v文件),如下脚本所示。

define_design_lib -path ./work/ WORK
analyze -format verilog "adder.v"
set_app_var link_library ADDER.ddc
read_file -format verilog "top.v"  // 使用ADDER.ddc而不是WORK库中的adder.v

写在最后

        不建议使用read_file命令读取除ddc格式外的设计文件,使用analyze/elaborate命令读取RTL设计更稳妥,功能也更加强大。

Design Compiler:使用analyze/elaborate命令读取RTL设计https://blog.csdn.net/weixin_45791458/article/details/144949582?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522c5dbc40c5cdd020929332522dc608988%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=c5dbc40c5cdd020929332522dc608988&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-4-144949582-null-null.nonecase&utm_term=Design&spm=1018.2226.3001.4450

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

日晨难再

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值