只模拟的话直接终端运行会快很多
计数器举例
c
mkdir src
counter.v
c
module counter(
input wire clk,
input wire rst_n,
output reg[31:0] cnt
);
always @(posedge clk or negedge rst_n)
if(!rst_n)
cnt <= 31'h0;
else
cnt <= cnt+1;
endmodule
tb.v
c
module tb;
wire[31:0] out;
reg clk;
reg rst_n;
initial begin
#10 clk <= 1'b0;
#10 rst_n = 1'b0;
#10 rst_n = 1'b1;
#5000 $finish;
end
always #1 clk = ~clk;
counter c1(clk,rst_n,out);
endmodule
编译 创建模拟snapshot
c
mkdir sim
cd sim
xvlog ../src/counter.v ../src/tb.v
xelab -debug typical -top tb -snapshot tb
创建脚本
xsim_cfg.tcl
c
log_wave -recursive *
run all
exit
c
xsim tb --tclbatch xsim_cfg.tcl
打开gui
c
xsim --gui tb.wdb