一个VERILOG仿真程序,求大神讲解一下?
时间:10-02
整理:3721RD
点击:
这是个带清零端的4位寄存器的检验程序,好多看不懂
`include "d.jc"
module d_jc_test;
reg clk,clrb;
reg[3:0] data;
wire [3:0] qout;
`define stim #100 data=4'b /?/
event end_first_past;
d_jc r1(.d(data),.clk(clk),.clrb(clrb),.q(qout));
initial
begin
clk=0;
clrb=1;
end
always #50 clk=~clk;
always @(end_first_past)
clrb=~clrb;
always @(posedge clk)
$display("at time %0d clrb=%0b qout=%d",$time,clrb,data,qout);
initial
begin
repeat(4)
begin
data=4'b0000;
`stim 0001;
`stim 0010;
`stim 0011;`stim 0100;
`stim 0101;`stim 0110;
`stim 0111;
`stim 1000;
`stim 1001;
`stim 1010;
`stim 1011;
`stim 1100;
`stim 1101;
`stim 1110;
`stim 1111;/?/
#200 -> end_first_past;/?/
end
$finish;
end
endmodule
`include "d.jc"
module d_jc_test;
reg clk,clrb;
reg[3:0] data;
wire [3:0] qout;
`define stim #100 data=4'b /?/
event end_first_past;
d_jc r1(.d(data),.clk(clk),.clrb(clrb),.q(qout));
initial
begin
clk=0;
clrb=1;
end
always #50 clk=~clk;
always @(end_first_past)
clrb=~clrb;
always @(posedge clk)
$display("at time %0d clrb=%0b qout=%d",$time,clrb,data,qout);
initial
begin
repeat(4)
begin
data=4'b0000;
`stim 0001;
`stim 0010;
`stim 0011;`stim 0100;
`stim 0101;`stim 0110;
`stim 0111;
`stim 1000;
`stim 1001;
`stim 1010;
`stim 1011;
`stim 1100;
`stim 1101;
`stim 1110;
`stim 1111;/?/
#200 -> end_first_past;/?/
end
$finish;
end
endmodule
奖励1积分