Skip to content

Commit 498aa7f

Browse files
committed
verilog: fsm one hot
1 parent 31fb749 commit 498aa7f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

verilog/review2015_fsmonehot.v

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module top_module(
2+
input d,
3+
input done_counting,
4+
input ack,
5+
input [9:0] state, // 10-bit one-hot current state
6+
output B3_next,
7+
output S_next,
8+
output S1_next,
9+
output Count_next,
10+
output Wait_next,
11+
output done,
12+
output counting,
13+
output shift_ena
14+
);
15+
16+
// You may use these parameters to access state bits using e.g., state[B2] instead of state[6].
17+
parameter S=0, S1=1, S11=2, S110=3, B0=4, B1=5, B2=6, B3=7, Count=8, Wait=9;
18+
19+
assign B3_next = state[B2];
20+
assign S_next = (state[S] & ~d) | (state[S1] & ~d) | (state[S110] & ~d) | (state[Wait] & ack);
21+
assign S1_next = (state[S] & d);
22+
assign Count_next = state[B3] | (state[Count] & !done_counting);
23+
assign Wait_next = (state[Wait] & ~ack) | (state[Count] & done_counting);
24+
assign done = state[Wait];
25+
assign counting = state[Count];
26+
assign shift_ena = state[B0] | state[B1] | state[B2] | state[B3];
27+
28+
// assign B3_next = ...;
29+
// assign S_next = ...;
30+
// etc.
31+
32+
endmodule

0 commit comments

Comments
 (0)