我在Verilog中写了此代码,没有错误消息,但是它没有工作

发布于 2025-01-29 04:52:00 字数 1002 浏览 5 评论 0原文

这是模块:

module test (output reg [7:0] Q_out, input [2:0] data_in); 
always 
    begin
        case (data_in)
        3'b000: Q_out = 8'b10000000;
        3'b001: Q_out = 8'b01000000;
        3'b010: Q_out = 8'b00100000;
        3'b011: Q_out = 8'b00010000;
        3'b100: Q_out = 8'b00001000;
        3'b101: Q_out = 8'b00000100;
        3'b110: Q_out = 8'b00000010;
        3'b111: Q_out = 8'b00000001;
        endcase
    end
endmodule

这是测试台的

module test2();

reg [2:0]data_in;
wire [7:0] Q_out;

test uut (.data_in(data_in), .Q_out(Q_out));

initial begin

data_in=000;
#5;

data_in=001;
#5;

data_in=010;
#5;

data_in=011;
#5;

data_in=100;
#5;

data_in=101;
#5;

data_in=110;
#5;

data_in=111;
#5;
end

endmodule

一切似乎都起作用,直到我到达仿真部分。

然后,在我尝试模拟它之后,没有真正出现在波形中。有什么问题?

This is the module:

module test (output reg [7:0] Q_out, input [2:0] data_in); 
always 
    begin
        case (data_in)
        3'b000: Q_out = 8'b10000000;
        3'b001: Q_out = 8'b01000000;
        3'b010: Q_out = 8'b00100000;
        3'b011: Q_out = 8'b00010000;
        3'b100: Q_out = 8'b00001000;
        3'b101: Q_out = 8'b00000100;
        3'b110: Q_out = 8'b00000010;
        3'b111: Q_out = 8'b00000001;
        endcase
    end
endmodule

and this is the testbench

module test2();

reg [2:0]data_in;
wire [7:0] Q_out;

test uut (.data_in(data_in), .Q_out(Q_out));

initial begin

data_in=000;
#5;

data_in=001;
#5;

data_in=010;
#5;

data_in=011;
#5;

data_in=100;
#5;

data_in=101;
#5;

data_in=110;
#5;

data_in=111;
#5;
end

endmodule

Everything seems to work until I get to the simulation part.

waves

Then, after I try to simulate it, nothing really shows up in waveforms. What could be the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妄断弥空 2025-02-05 04:52:00

您在test模块中具有无限循环。
更改:

always

TO:

always @*

由于您的总是没有延迟块,因此它会在时间0触发,并且时间不会在模拟中推进。通过添加灵敏度列表(@*),仅在任何一个输入(data_in)会更改状态时,该块仅触发。

您也可以使用ewndy_comb。请参阅IEEE STD 1800-2017,第9.2.2.2.2节 ewansewans_comb与始终 @*相比

You have an infinite loop in the test module.
Change:

always

to:

always @*

Since there is no delay in your always block, it keeps triggering at time 0, and time does not advance in the simulation. By adding a sensitivity list (@*), the block only triggers when any of it inputs (data_in) changes state.

You could also use always_comb. Refer to IEEE Std 1800-2017, section 9.2.2.2.2 always_comb compared to always @*

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文