timescale 1 ns 1 ns module main reg

  • Slides: 14
Download presentation

仿真验证原理 `timescale 1 ns / 1 ns module main; reg a, b, c; wire

仿真验证原理 `timescale 1 ns / 1 ns module main; reg a, b, c; wire sum, carry; fulladder UUT(a, b, c, sum, carry); initial begin a = 0; b = 0; #5; a = 0; b = 1; #5; a = 1; b = 0; #5; a = 1; b = 1; #5; endmodule c = 0; c = 1;

系统任务及函数 $stop; //暂停仿真 $finish; //结束仿 真 `timescale 1 ns/1 ns module test_tb; initial begin

系统任务及函数 $stop; //暂停仿真 $finish; //结束仿 真 `timescale 1 ns/1 ns module test_tb; initial begin $display("step"); #100; $display("stop simulation"); $stop; //暂停仿真 $display("continue simulation"); #100; $display("finish simulation"); $finish; //结束仿真 endmodule

系统任务及函数 $time 间 $random //时间函数,返回 64位当前仿真时 //随机函数,返回随机数 `timescale 1 ns/1 ns module test_tb; reg

系统任务及函数 $time 间 $random //时间函数,返回 64位当前仿真时 //随机函数,返回随机数 `timescale 1 ns/1 ns module test_tb; reg [3: 0] a; always #10 a = $random; initial $monitor("a=%d @time %d", a, $time); endmodule

系统任务及函数 $readmemb //读文件函数 $readmemh //读文件函数 //格式 $readmemb("<数据文件名>", <存贮器名>); $readmemh("<数据文件名>", <存贮器名>); `timescale 1 ns/1 ns

系统任务及函数 $readmemb //读文件函数 $readmemh //读文件函数 //格式 $readmemb("<数据文件名>", <存贮器名>); $readmemh("<数据文件名>", <存贮器名>); `timescale 1 ns/1 ns module test_tb; integer i; reg [7: 0] a [15: 0]; initial begin $readmemb("step. txt", a); for(i=0; i<=15; i=i+1) begin #10; $write("%s", a[i]); end endmodule 0111 01100101 01101100011 01101101 01100101 00100000 01110100 01101111 00100000 01110011 01110100 01100101 01110000 00100001 // w // e // l // c // o // m // e //空格 // t // o //空格 // s // t // e // p // !