【问题标题】:segment BCD to 7 decoder in verilog在verilog中将BCD分段到7解码器
【发布时间】:2015-02-05 04:31:51
【问题描述】:

我正在编写一个模拟 bcd 到七段解码器的代码。当我这样做时,我在波形窗口(在 Modelsim 中)中出现红线和蓝线,这意味着输入没有被驱动并且输出处于未定义状态。但是当我通过强制值运行代码时,它会显示正确的结果。由此我能够找出问题出在我的测试台上。如果有人可以查看 m 代码并指出我做错了什么,我将不胜感激。 代码

//BCD to seven segment display
module seven_segment;
reg [3:0] BCD;
wire [6:0] display;
parameter stop_time = 200;


bcd_seven n(display,BCD);       //Instantiation of the bcd to seven segment      display code

initial #stop_time $finish;

initial
begin
BCD = 0;
#10 BCD = 1;
#10 BCD = 2;
#10 BCD = 3;
#10 BCD = 4;
#10 BCD = 5;
#10 BCD = 6;
#10 BCD = 7;
#10 BCD = 8;
#10 BCD = 9;
end
initial begin
$monitor("display = %d BCD = %b",display,BCD);
end
endmodule 

//Decsription of the BCD to seven segment display
module bcd_seven(D,BCD);
output  D; 
reg [6:0] D;
input [3:0] BCD;

parameter BLANK = 7'b0000000;
parameter ZERO = 7'b1111110;
parameter ONE = 7'b0110000;
parameter TWO = 7'b1101101;
parameter THREE = 7'b1111001;
parameter FOUR = 7'b0110011;
parameter FIVE = 7'b1011011;
parameter SIX = 7'b1011111;
parameter SEVEN = 7'b1110000;
parameter EIGHT = 7'b1111111;
parameter NINE = 7'b1111011;

//I have doubt especially in this section
always @(BCD)
case(BCD)
0: D = ZERO;
1: D = ONE;
2: D = TWO;
3: D = THREE;
4: D = FOUR;
5: D = FIVE;
6: D = SIX;
7: D = SEVEN;
8: D = EIGHT;
default: D = BLANK;
endcase
endmodule

【问题讨论】:

  • 我试图运行你的代码。输入被驱动,输出不是未定义的。好像没问题。你期望什么行为?
  • 你是在哪个模拟器上运行的?
  • 我除了测试台正常工作,因此当我运行代码时,我应该得到所需的波形
  • 在 icarus verilog 中运行代码应该可以工作。
  • 你能告诉我在知道特定代码将在模拟器中工作之前我应该​​寻找什么吗?我的意思是我们能否知道特定的代码编写风格是否适用于这个模拟器而不是这个?

标签: verilog modelsim


【解决方案1】:

我确实注意到您的代码中有一个错误。您缺少 BCD = 9 的案例陈述。但这并不能解释您看到的其他问题。

【讨论】:

    猜你喜欢
    • 2014-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-12
    相关资源
    最近更新 更多