이 카운터에 문제가 있습니다. 출력은 모두 xxxxxxxx입니다. 카운트의 초기 값을 설정하고 0으로 오버플로해야한다는 것을 알고 있지만 그런 식으로 오류가 발생합니다.카운터 시스템 Verilog 코드
// Code your testbench here
// or browse Examples
module tb();
reg [3:0] in;
reg clk,start;
wire [7:0] count;
reg overflow = 1'b0;
initial begin
$display ("time\t clk start in count overflow");
$monitor ("%g\t %b %b %b %b", $time, clk, start, in, count, overflow);
clk=0;
in=0;
start=0;
// overflow=0;
// count=0;
#5 in=4'd1;
#5 in=4'd5;
#5 in=4'd4;
#5 in=5'd5;
#5 in=4'd1;
#5 in=4'd5;
#5 in=4'd4;
#5 in=5'd5;
#5 in=4'd1;
#5 in=4'd5;
#5 in=4'd4;
#5 in=5'd5;
#5 in=4'd1;
#5 in=4'd5;
#5 in=4'd4;
#5 in=5'd5;
#50 $finish;
end
always #5 clk=~clk;
counter u0(.*);
endmodule
나는 그것이 간단한 질문입니다 알지만, 너희들이 도와 만약 내가 그것을 감사 :
// Code your design here
module counter (in, start, count, clk, overflow);
input [3:0] in;
input clk;
input start;
output reg [7:0] count;
output reg overflow;
//reg count;
//count =0;
//overflow=0;
always @ (posedge clk)
begin
if (start) begin
count <= 8'b0;
overflow <= 1'b0;
end
else if (in == 4'b0101) begin
count <= count+1;
end
if (count == 4'b1111) begin
overflow <=1'b1;
end
end
endmodule
이 테스트 벤치입니다 :이 코드입니다.
카운트는 X에서 유지됩니다 (테스트 벤치의 데이터를 구동하기 위해 posedge 이벤트를 사용)? –
예 시작 신호를 통해 카운터를 재설정하지 않았습니다. –