R
rik
Guest
I have this following state machine. My question is though I have
default values for all the signals, why "req" and "dir" is inferred as
latches?
always@ (pres_st, bus_go, bus_write, wready, rready, timeout)
begin
// State Machine defaults
latch_data = 0;
ld_cmd = 0;
set_error = 0;
clr_error = 0;
set_done = 0;
clr_done = 0;
req = req;
dir = dir;
case (pres_st)
`IDLE_ST: if (bus_go)
begin
ld_cmd = 1;
req = 1;
clr_error = 1;
clr_done = 1;
if (bus_write==1)
begin
next_st = `WRITE_ST;
dir = 0;
end
else if(!bus_write)
begin
next_st = `READ_ST;
dir = 1;
end
end
else if(!bus_go)
next_st = `IDLE_ST;
`WRITE_ST: if (wready)
begin
next_st = `DONE_ST;
req = 0;
set_done = 1;
end
else if (timeout)
next_st = `ERROR_ST;
else if (!timeout)
next_st = `WRITE_ST;
`READ_ST: if(rready)
begin
latch_data = 1;
req = 0;
set_done = 1;
next_st = `DONE_ST;
end
else if (timeout)
next_st = `ERROR_ST;
else if (!timeout)
next_st = `READ_ST;
`DONE_ST: if (!bus_go)
begin
next_st = `IDLE_ST;
clr_done = 1;
end
else if (bus_go)
next_st = `DONE_ST;
`ERROR_ST: begin
set_error = 1;
set_done = 1;
next_st = `DONE_ST;
end
default: next_st = `IDLE_ST;
endcase
end
Thanks
Rik
default values for all the signals, why "req" and "dir" is inferred as
latches?
always@ (pres_st, bus_go, bus_write, wready, rready, timeout)
begin
// State Machine defaults
latch_data = 0;
ld_cmd = 0;
set_error = 0;
clr_error = 0;
set_done = 0;
clr_done = 0;
req = req;
dir = dir;
case (pres_st)
`IDLE_ST: if (bus_go)
begin
ld_cmd = 1;
req = 1;
clr_error = 1;
clr_done = 1;
if (bus_write==1)
begin
next_st = `WRITE_ST;
dir = 0;
end
else if(!bus_write)
begin
next_st = `READ_ST;
dir = 1;
end
end
else if(!bus_go)
next_st = `IDLE_ST;
`WRITE_ST: if (wready)
begin
next_st = `DONE_ST;
req = 0;
set_done = 1;
end
else if (timeout)
next_st = `ERROR_ST;
else if (!timeout)
next_st = `WRITE_ST;
`READ_ST: if(rready)
begin
latch_data = 1;
req = 0;
set_done = 1;
next_st = `DONE_ST;
end
else if (timeout)
next_st = `ERROR_ST;
else if (!timeout)
next_st = `READ_ST;
`DONE_ST: if (!bus_go)
begin
next_st = `IDLE_ST;
clr_done = 1;
end
else if (bus_go)
next_st = `DONE_ST;
`ERROR_ST: begin
set_error = 1;
set_done = 1;
next_st = `DONE_ST;
end
default: next_st = `IDLE_ST;
endcase
end
Thanks
Rik