我正在用verilog编写一个简单的控制单元。它是这样的。
module controlUnit(
output reg wreg,
input wire [5:0] op, func
);
// wreg sub-handles. Beware: wreg is 0 if any of these s high
wire isBranch = (op[5:3] == 3'b0) & (|op[2:0]);
wire isStrWrd = op == 6'b101011;
wire isJumpReg = (op == 6'd0) & (func == 6'b001000);
// wreg handle
always @(*) begin
if(isBranch | isStrWrd | isJumpReg)
wreg <= op == 6'b000011;
else
wreg <= 1'b1;
end
endmodule
module testbench;
integer i;
wire out;
reg [11:0] in;
controlUnit CU0(
.wreg(out),
.op(in[11:6]), .func(in[5:0])
);
initial begin
$dumpfile("test.vcd");
$dumpvars(0, testbench);
#4 in = 0;
for(i=0; i<1024; i=i+1) begin
#1 in = i;
end
#1 in = 10'hXX; // Garbage input here
#1000;
end
endmodule
然而在模拟中,当输入变为垃圾时,wreg 信号是一个稳定的逻辑高电平。我已经在 iverilog-10/GTKwave 和 Vivado 2019.1 中看到了这种行为。以下是波形:
所以为什么?