這裏是箱子在時序邏輯信號在某些情況下不改性
always @ (posedge clk or negedge rst_n) begin
if (!rst_n) begin
enable <= 1'b0;
t_A <= 1'b0;
t_B <= 1'b0;
t_C <= 1'b0;
end
else begin
case (nxt_state)
IDLE: begin
enable <= 1'b0;
t_A <= 1'b0;
t_B <= 1'b0;
t_C <= 1'b0;
end
LOAD: begin
enable <= 1'b0;
t_A <= A;
t_B <= B;
t_C <= C;
end
BUSY: begin
enable <= 1'b1;
end
DONE: begin
enable <= 1'b0;
end
default: begin
enable <= enable;
t_A <= t_A;
t_B <= t_B;
t_C <= t_C;
end
endcase
end
信號T_而nxt_state是「LOAD」 *僅加載新值的簡化示例。如果我沒有列出信號t_ *的情況下,「忙」和「完成,他們會保持其值?
我試過在case子句之前添加一些代碼如下,但它顯示一些警告,而運行linting工具
always @ (posedge clk or negedge rst_n) begin
if (!rst_n) begin
enable <= 1'b0;
t_A <= 1'b0;
t_B <= 1'b0;
t_C <= 1'b0;
end
else begin
enable <= enable;
t_A <= t_A;
t_B <= t_B;
t_C <= t_C;
case (nxt_state)
IDLE: begin
enable <= 1'b0;
t_A <= 1'b0;
t_B <= 1'b0;
t_C <= 1'b0;
end
LOAD: begin
enable <= 1'b0;
t_A <= A;
t_B <= B;
t_C <= C;
end
BUSY: begin
enable <= 1'b1;
end
DONE: begin
enable <= 1'b0;
end
default: begin
enable <= enable;
t_A <= t_A;
t_B <= t_B;
t_C <= t_C;
end
endcase
end
我怎樣才能解決這個問題,以保持代碼的簡單和清晰?