summaryrefslogtreecommitdiff
path: root/bin2bcd.sv
diff options
context:
space:
mode:
authorJulian Blake Kongslie2021-03-23 12:29:00 -0700
committerJulian Blake Kongslie2021-03-23 12:29:22 -0700
commited2f2d8e5df20768fd23c45d97478e19f7346725 (patch)
tree6e4a50dda735c23deb6d7a15c01ad2348c98ba88 /bin2bcd.sv
parentInitial commit. (diff)
downloadtoycpu-ed2f2d8e5df20768fd23c45d97478e19f7346725.tar.xz
Clean up the preshifts on bin2bcd and ntoa.
Diffstat (limited to 'bin2bcd.sv')
-rw-r--r--bin2bcd.sv3
1 files changed, 2 insertions, 1 deletions
diff --git a/bin2bcd.sv b/bin2bcd.sv
index 80dc633..266860c 100644
--- a/bin2bcd.sv
+++ b/bin2bcd.sv
@@ -1,6 +1,7 @@
1module bin2bcd 1module bin2bcd
2 #( BITS = 8 2 #( BITS = 8
3 , BASE = 10 3 , BASE = 10
4 , MAX_SKIP = BITS
4 ) 5 )
5 ( input bit clk 6 ( input bit clk
6 , input bit reset 7 , input bit reset
@@ -64,7 +65,7 @@ always_ff @(posedge clk) begin
64 bin_b_data = `bin_data; 65 bin_b_data = `bin_data;
65 bcd = 0; 66 bcd = 0;
66 work = BITS; 67 work = BITS;
67 for (int i = BITS; i > 0; i = i - 1) begin 68 for (int i = 0; i < BITS && i < MAX_SKIP; i = i + 1) begin
68 if (bin_b_data[BITS-1]) break; 69 if (bin_b_data[BITS-1]) break;
69 bin_b_data = { bin_b_data[BITS-2:0], 1'b0 }; 70 bin_b_data = { bin_b_data[BITS-2:0], 1'b0 };
70 work = work - 1; 71 work = work - 1;