我正在尝试为 1-hot-encoded 简单 LED 开关按钮构建 StateMachine。
特别是我试图用我的例子来理解阻塞和非阻塞分配。
您会认为以下可以做得更好,还是在任何区块中都是完全错误的?
module example (
input clk,
input rst,
input push,
output reg led_on
);
reg on;
reg off;
reg t_on_off;
reg t_off_on;
always @* begin
t_on_off = on & (push);
end
always @* begin
t_off_on = off & (push);
end
always @(posedge clk or posedge rst) begin
if (rst) on <= 1'b0;
else if (t_off_on) on <= 1'b1;
else if (t_on_off) on <= 1'b0;
end
always @(posedge clk or posedge rst) begin
if (rst) off <= 1'b1;
else if (t_off_on) off <= 1'b0;
else if (t_on_off) off <= 1'b1;
end
always @* begin
led_on = on;
end
endmodule
特别是我想知道:我可以将转换的分配合并到一个块中,例如:
always @* begin
t_on_off = on & (push);
t_off_on = off & (push);
end
?