如何在不从外部获取任何输入时始终执行@*块(测试平台)
How to get always @* block executed all the time when it's not taking any input from outside(testbench)
我的代码如下:
module command_FSM(sys_R_Wn,sys_ADSn,,cState,.....);
input sys_R_Wn;
input sys_ADSn;
output [4:0] cState;
initial
begin
cState=c_idle;
end
always @*
begin
if (sys_INIT_DONE==1'b1)
if(~sys_REF_REQ && ~sys_ADSn)
begin
case (cState)
5'b10000: begin
cState=c_ACTIVE;
#10;
end
5'b10110:
if(sys_R_Wn)
begin
cState=c_tRCD;
#10;
cState=c_REDA;
end
else
begin
cState=c_tRCD;
#10;
cState=c_WRITEA;
end
5'b11000: cState=c_cl;
5'b10101: cState=c_rdata;
5'b11010: cState=c_wdata;
5'b10111: cState=c_tDAL;
endcase
end
end
endmodule
我没有得到这个总是@* 块永远执行并且只有在更新 cstate 的值后,才不会使用 cstate 的其他值。我应该为 cstate
使用 assign 语句而不是 case 语句吗
always@* 是一个组合块。任何 fsm 的基本块都是这样的。
共有三个街区。两个组合和一个顺序。两个状态,一个 next_state 和另一个 current_state。 Current_state 总是在时钟事件上更新,因为那是你从一个状态移动到另一个状态的时间。因此,它应该是翻牌的输出。翻牌的输入应该是 next_state.
现在 next_state 使用组合逻辑分配,该逻辑采用输入 current_state 和外部输入(在 mealy 的情况下)。
第二个组合逻辑将用于输出状态,它可以只是给定条件的赋值语句。
我的代码如下:
module command_FSM(sys_R_Wn,sys_ADSn,,cState,.....);
input sys_R_Wn;
input sys_ADSn;
output [4:0] cState;
initial
begin
cState=c_idle;
end
always @*
begin
if (sys_INIT_DONE==1'b1)
if(~sys_REF_REQ && ~sys_ADSn)
begin
case (cState)
5'b10000: begin
cState=c_ACTIVE;
#10;
end
5'b10110:
if(sys_R_Wn)
begin
cState=c_tRCD;
#10;
cState=c_REDA;
end
else
begin
cState=c_tRCD;
#10;
cState=c_WRITEA;
end
5'b11000: cState=c_cl;
5'b10101: cState=c_rdata;
5'b11010: cState=c_wdata;
5'b10111: cState=c_tDAL;
endcase
end
end
endmodule
我没有得到这个总是@* 块永远执行并且只有在更新 cstate 的值后,才不会使用 cstate 的其他值。我应该为 cstate
使用 assign 语句而不是 case 语句吗always@* 是一个组合块。任何 fsm 的基本块都是这样的。
共有三个街区。两个组合和一个顺序。两个状态,一个 next_state 和另一个 current_state。 Current_state 总是在时钟事件上更新,因为那是你从一个状态移动到另一个状态的时间。因此,它应该是翻牌的输出。翻牌的输入应该是 next_state.
现在 next_state 使用组合逻辑分配,该逻辑采用输入 current_state 和外部输入(在 mealy 的情况下)。
第二个组合逻辑将用于输出状态,它可以只是给定条件的赋值语句。