问题描述
我有两个模块,每个模块都在单独的 verilog 文件中。一个文件是 double_shift_reg.v
,顶部模块为 double_shift_reg
:
`include "./shift_reg.v"
`default_nettype none
module double_shift_reg(clk,shi,in,out);
input wire clk; // Clock
input wire shi; // Shift enable
input wire in; // Input information
output wire out; // Output information
wire d1; // Data 1
wire d2; // Data 2
shift_reg r1(.clk(clk),.rst(1'b0),.shi(shi),.in(in),.out(d1));
shift_reg r2(.clk(clk),.out(d2));
assign out = d1 ^ d2;
`ifdef FORMAL
reg [2:0] f_counter;
always @(posedge clk)
begin
assert(out == 0);
f_counter = f_counter + 1;
if (f_counter == 1'b1111)
assume(shi);
end
`endif // FORMAL
endmodule
另一个文件是一个 shift_reg.v
,带有一个模块 shift_reg
,在顶层模块中使用:
`default_nettype none
module shift_reg(clk,rst,out);
input wire clk; // Input clock
input wire rst; // Input reset
input wire shi; // Shift enable
input wire in; // Input information
output wire out; // Output bit
parameter wid = 8; // Shift register's width
parameter ini = {{(wid - 1){1'b0}},1'b1}; // Shift register's initial state
reg [(wid - 1):0] s_reg;
initial s_reg = ini;
always @(posedge clk)
begin
if(rst)
s_reg <= ini;
else if(shi)
s_reg[(wid - 1):0] <= {in,s_reg[(wid - 1):1]};
end
assign out = s_reg[0];
endmodule
然后我尝试使用以下命令创建和预览 .dot
文件:
yosys \
-p "read_verilog -sv -formal double_shift_reg.v" \
-p "hierarchy -check -top double_shift_reg" \
-p "proc" \
-p "show -prefix $(file_main) -notitle -colors 2 -width -format dot"
xdot $(file_main).dot
最后一部分的编译消息,即 -p "show -prefix $(file_main) -notitle -colors 2 -width -format dot"
看起来像这样:
-- Running command `show -prefix double_shift_reg -notitle -colors 2 -width -format dot' --
4. Generating Graphviz representation of design.
Writing dot description to `double_shift_reg.dot'.
Dumping module double_shift_reg to page 1.
Dumping module shift_reg to page 2.
Warnings: 1 unique messages,1 total
End of script. Logfile hash: e53dd145db
cpu: user 0.02s system 0.01s,
只有一个警告,没有错误...但是当我用预览器打开 .dot
时,我收到一个错误:
当我为一个内部只有一个模块的单个 verilog 文件创建 .dot
文件时,这从未发生过。我错过了一些关键部分吗?
解决方法
我不知道这是否是您问题的解决方案(遗憾的是我无法发表评论),但我注意到我会尝试多种方法:
- 您只读取了顶层模块,而没有读取第二个设计实体。
- 在声明层次结构时使用显式的“-top”选项。
- 尝试扁平化您的设计。如果您只对顶层模块感兴趣,请将另一个模块声明为黑盒。
这一直对我有用,但我直接使用 graphviz 的点工具。