2015-02-03 2 views
0

나는 7 세그먼트 디코더에 bcd 시뮬레이션을위한 코드를 작성하고 있습니다. 내가 그렇게 할 때, 나는 (ModelSim에서) 파형 창에 빨간색과 파란색 선이 표시되는데 이는 입력이 구동되지 않고 출력이 정의되지 않은 상태임을 의미합니다. 하지만 값을 강제로 코드를 실행하면 올바른 결과가 표시됩니다. 이 문제는 내 테스트 벤치에 있다는 것을 알 수 있습니다. 아무도 m 코드를 살펴보고 내가 뭘 잘못하고 있는지 지적 할 수 있으면 감사하겠습니다. CODE세그먼트 BCD 7 Verilog에 디코더

//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 
+0

코드를 실행하려고했습니다. 입력이 구동되고 출력이 정의되지 않았습니다. 괜찮을 것 같습니다. 어떤 행동을 기대합니까? – e19293001

+0

u 시뮬레이터에서 실행 했습니까? –

+0

테스트 벤치를 제외하고 제대로 작동하고 따라서 내가 원하는 파형을 얻을 코드를 실행 –

답변

0

나는 코드에 통보 한 버그를했다. BCD = 9에 대한 case 문이 누락되었습니다. 그러나 이는 다른 문제를 설명하지는 않습니다.