Skip to content

Commit 955b393

Browse files
committed
Refactor the FSM
1 parent e971dc5 commit 955b393

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

rtl/booth_algorithm.vhd

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -124,47 +124,47 @@ begin
124124
nxt_state <= ONES_END;
125125
end if;
126126
when ONES_START =>
127-
incr_counter <= '1';
128-
shift_accumulator <= '1';
129127
if (end_of_loop = '1') then
130-
incr_counter <= '0';
131-
shift_accumulator <= '0';
132128
nxt_state <= DONE;
133-
elsif (end_of_ones = '1') then
134-
add_multiplicand <= '1';
135-
nxt_state <= ONES_END;
136129
else
137-
nxt_state <= ONES_OR_ZEROS_STREAM;
130+
incr_counter <= '1';
131+
shift_accumulator <= '1';
132+
if (end_of_ones = '1') then
133+
add_multiplicand <= '1';
134+
nxt_state <= ONES_END;
135+
else
136+
nxt_state <= ONES_OR_ZEROS_STREAM;
137+
end if;
138138
end if;
139139
when ONES_OR_ZEROS_STREAM =>
140-
incr_counter <= '1';
141-
shift_accumulator <= '1';
142140
if (end_of_loop = '1') then
143-
incr_counter <= '0';
144-
shift_accumulator <= '0';
145141
nxt_state <= DONE;
146-
elsif (start_of_ones = '1') then
147-
sub_multiplicand <= '1';
148-
nxt_state <= ONES_START;
149-
elsif (end_of_ones = '1') then
150-
add_multiplicand <= '1';
151-
nxt_state <= ONES_END;
152-
else
153-
nxt_state <= ONES_OR_ZEROS_STREAM;
154-
end if;
142+
else
143+
incr_counter <= '1';
144+
shift_accumulator <= '1';
145+
if (start_of_ones = '1') then
146+
sub_multiplicand <= '1';
147+
nxt_state <= ONES_START;
148+
elsif (end_of_ones = '1') then
149+
add_multiplicand <= '1';
150+
nxt_state <= ONES_END;
151+
else
152+
nxt_state <= ONES_OR_ZEROS_STREAM;
153+
end if;
154+
end if;
155155
when ONES_END =>
156-
incr_counter <= '1';
157-
shift_accumulator <= '1';
158156
if (end_of_loop = '1') then
159-
incr_counter <= '0';
160-
shift_accumulator <= '0';
161157
nxt_state <= DONE;
162-
elsif (start_of_ones = '1') then
163-
sub_multiplicand <= '1';
164-
nxt_state <= ONES_START;
165-
else
166-
nxt_state <= ONES_OR_ZEROS_STREAM;
167-
end if;
158+
else
159+
incr_counter <= '1';
160+
shift_accumulator <= '1';
161+
if (start_of_ones = '1') then
162+
sub_multiplicand <= '1';
163+
nxt_state <= ONES_START;
164+
else
165+
nxt_state <= ONES_OR_ZEROS_STREAM;
166+
end if;
167+
end if;
168168
when DONE =>
169169
c_valid_o <= '1';
170170
nxt_state <= IDLE;

0 commit comments

Comments
 (0)