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> linkLinking design 'top'Using the following designs and libraries:--------------------------------------------------------------------------Information: Building the design 'adder' instantiated from design 'top' withthe 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' withthe 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