I 다음 MWE 있습니다의 Verilog : 와이어 값이 업데이트되지
module test(
input wire clock,
input wire start
);
reg [7:0] x = 8'b10101010;
reg processing = 0;
wire [7:0] x_wire0 = x;
wire [7:0] x_wire1 = {4'hf, x};
wire [11:0] x_wire2 = {4'hf, x};
always @(posedge clock) begin
if (start & ~processing) begin
x = 8'h0f;
processing = 1;
end
$display("---> x=%h x_wire0=%h x_wire1=%h x_wire2=%h",
x, x_wire0, x_wire1, x_wire2);
end
endmodule
이카루스의 Verilog 0.9.7을 사용하여
module test_test();
reg clock = 0;
reg start = 0;
test test(
.clock(clock),
.start(start)
);
always #5 clock = ~clock;
initial begin
$monitor("%b %b", clock, start);
#20 start = 1;
#20 start = 0;
#200 $finish;
end
endmodule
나에게 출력을 제공하는 테스트 벤치와를
0 0
---> x=aa x_wire0=aa x_wire1=aa x_wire2=faa
1 0
0 0
---> x=aa x_wire0=aa x_wire1=aa x_wire2=faa
1 0
0 1
---> x=0f x_wire0=0f x_wire1=aa x_wire2=f0f
1 1
0 1
---> x=0f x_wire0=0f x_wire1=0f x_wire2=f0f
1 1
0 0
...
나는 x_wire1이 다음 클럭 틱 (tick)까지 업데이트되지 않는 이유와 이런 종류의 상황을 피하기 위해 엄지 손가락 규칙이 있는지 궁금하다. 표시 명령 앞에 "# 0"을 사용하면 업데이트됩니다.
순차 논리에서 비 차단 할당을 사용하십시오 :'x <= 8'h0f; processing <= 1;' – toolic
RHS에'x_wire1'을 가진 블로킹 할당이 같은'always' 블록에 있습니다. 최소로 유지하기 위해 예제 코드에 해당 코드를 포함시키지 않았습니다. 한 번 읽으면 논 블로킹 할당과 블로킹 할당이 같은 '항상'블럭에 섞여서는 안된다. – apriori
차단 및 비 차단 할당을 _same_ 변수에 혼합해서는 안됩니다. –