@@ -537,9 +537,9 @@ module bit_diff_fsmd_2p_2
537
537
next_state = RESTART ;
538
538
539
539
// For us to be able to assert done in the next cycle, we need
540
- // to send it to the result register this cycle. Also, we need
541
- // to use the next version of diff since the register won't be
542
- // updated yet.
540
+ // to send the new diff to the result register this cycle. Also,
541
+ // we need to use the next version of diff since the register
542
+ // won't be updated yet.
543
543
next_result = next_diff;
544
544
end
545
545
end
@@ -648,7 +648,7 @@ module bit_diff_fsmd_2p_3
648
648
end
649
649
end
650
650
651
- // Since we actually want register for all the code above, it is not
651
+ // Since we actually want registers for all the code above, it is not
652
652
// necessary to add next signals for any of them, including the state_r.
653
653
// Instead, we'll just pull out the done_r signal and make it combinational
654
654
// logic in this process.
@@ -674,6 +674,10 @@ module bit_diff_fsmd_2p_3
674
674
endmodule
675
675
676
676
677
+ // Module: fsmd_2p_4
678
+ // Description: This extends the previous module by also separating
679
+ // state_r and next_state, in addition to having done as combinational logic.
680
+
677
681
module bit_diff_fsmd_2p_4
678
682
# (
679
683
parameter WIDTH
@@ -697,8 +701,6 @@ module bit_diff_fsmd_2p_4
697
701
698
702
assign result = result_r;
699
703
700
- // Note that this code is almost identical to a 1-process FSMD. We have
701
- // simply removed the done logic.
702
704
always @ (posedge clk or posedge rst) begin
703
705
if (rst == 1'b1 ) begin
704
706
result_r <= '0 ;
@@ -713,7 +715,7 @@ module bit_diff_fsmd_2p_4
713
715
// the state register.
714
716
state_r <= next_state;
715
717
716
- // All other signals are still registered with a next version, since
718
+ // All other signals are still registered without a next version, since
717
719
// we don't have a need for the next version.
718
720
case (state_r)
719
721
START : begin
@@ -817,7 +819,7 @@ module bit_diff_fsmd_3p
817
819
// The second process is another always_ff (usually assuming no blocking
818
820
// assignments) that handles all the other registered logic. In other words,
819
821
// we have simply taken the one always_ff block from the previous module and
820
- // separated it into two: one of the state register, and one for everything
822
+ // separated it into two: one for the state register, and one for everything
821
823
// else.
822
824
always @ (posedge clk or posedge rst) begin
823
825
if (rst == 1'b1 ) begin
0 commit comments