Skip to content

Commit 96d5c72

Browse files
committed
common: Make sure to always assign all 'reg's in processes to avoid latches
If you don't assign all 'reg's in a process, this effectively describes a latch, and the HW doesn't have any HW latches which leads yosys to create a logic loop, which is definitely not good in FPGA ! Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
1 parent a3f7a71 commit 96d5c72

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

common/usb_fs_in_arb.v

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ module usb_fs_in_arb #(
2020
always @* begin
2121
grant = 0;
2222

23+
arb_in_ep_data <= 0;
24+
2325
for (i = 0; i < NUM_IN_EPS; i = i + 1) begin
2426
in_ep_grant[i] <= 0;
2527

@@ -29,9 +31,5 @@ module usb_fs_in_arb #(
2931
grant = 1;
3032
end
3133
end
32-
33-
if (!grant) begin
34-
arb_in_ep_data <= 0;
35-
end
3634
end
3735
endmodule

common/usb_fs_in_pe.v

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ module usb_fs_in_pe #(
166166
always @* begin
167167
in_ep_acked[ep_num] <= 0;
168168

169+
ep_state_next[ep_num] <= ep_state[ep_num];
170+
169171
if (in_ep_stall[ep_num]) begin
170172
ep_state_next[ep_num] <= STALL;
171173

@@ -277,9 +279,11 @@ module usb_fs_in_pe #(
277279
reg rollback_in_xfr;
278280

279281
always @* begin
282+
in_xfr_state_next <= in_xfr_state;
280283
in_xfr_start <= 0;
281284
in_xfr_end <= 0;
282285
tx_pkt_start <= 0;
286+
tx_pid <= 4'b0000;
283287
rollback_in_xfr <= 0;
284288

285289
case (in_xfr_state)

common/usb_fs_out_pe.v

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ module usb_fs_out_pe #(
154154
for (ep_num = 0; ep_num < NUM_OUT_EPS; ep_num = ep_num + 1) begin
155155
always @* begin
156156

157+
ep_state_next[ep_num] <= ep_state[ep_num];
158+
157159
if (out_ep_stall[ep_num]) begin
158160
ep_state_next[ep_num] <= STALL;
159161

@@ -272,7 +274,9 @@ module usb_fs_out_pe #(
272274
////////////////////////////////////////////////////////////////////////////////
273275

274276
always @* begin
277+
out_ep_acked <= 0;
275278
out_xfr_start <= 0;
279+
out_xfr_state_next <= out_xfr_state;
276280
tx_pkt_start <= 0;
277281
tx_pid <= 0;
278282
new_pkt_end <= 0;

0 commit comments

Comments
 (0)