我需要从以下代码构建波形:
module HW7P1 (A1, A0, B1, B0, O);
input A1, A0, B1, B0;
output O;
assign O = (!A1 & B1) | (!A1 & !A0 & B0) | (!A0 & B1 & B0);
endmodule
module counter (clr, clk, OC);
input clr, clk;
output reg [3:0] OC;
initial begin
OC = 0;
end
always @(posedge clk) begin
if (clr == 0)
OC = 0;
else
OC = OC + 1;
end
endmodule
module test_bench ();
wire HW7P1A1, HW7P1A0, HW7P1B1, HW7P1B0, HW7P1O;
wire clr, clk;
wire [3:0] counterO;
reg osc;
initial begin
osc = 0;
end
always begin
#10 osc = ~osc;
end
assign clr=1;
assign clk=osc;
counter C1(clr, clk, counterO);
assign HW7P1A1 = counterO[3];
assign HW7P1A0 = counterO[2];
assign HW7P1B1 = counterO[1];
assign HW7P1B0 = counterO[0];
HW7P1 P1(HW7P1A1, HW7P1A0, HW7P1B1, HW7P1B0, HW7P1O);
endmodule
Run Code Online (Sandbox Code Playgroud)
我想使用EDA游乐场这样做,因为我的计算机上没有安装Verilog模拟软件.但是,当我选择"运行后打开EPWave"选项后,我点击运行后似乎没有任何事情发生.有人可以告诉我我做错了什么吗?
首先你需要结束模拟,否则sim将永远运行,最终进程将被杀死.您可以通过添加对$ finish的调用来完成此操作:
#10000 $finish
Run Code Online (Sandbox Code Playgroud)
其次,你需要创建一个VCD.一旦你添加了上面的代码,EDAPlayground将给你一个有用的错误信息:
找不到*.vcd文件.EPWave无法打开.你使用'$ dumpfile("dump.vcd"); $ dumpvars;'?
所以通过添加以下代码:
initial begin
$dumpfile("dump.vcd");
$dumpvars;
#10000 $finish;
end
Run Code Online (Sandbox Code Playgroud)
您的示例代码在波形查看器中运行并可查看:http://www.edaplayground.com/x/3v2