summaryrefslogtreecommitdiff
path: root/bin2bcd.sv
diff options
context:
space:
mode:
authorJulian Blake Kongslie2021-03-23 21:52:41 -0700
committerJulian Blake Kongslie2021-03-23 21:54:44 -0700
commit8056863ce3e95db52e027a0f0babe51df1cb9a4e (patch)
treed35ce72f92e8a9b6f1dce49572a49b3117c5827e /bin2bcd.sv
parentAdding olamic hook to autobuild source archives. (diff)
downloadtoycpu-8056863ce3e95db52e027a0f0babe51df1cb9a4e.tar.xz
Additional cleanup to make it Quartus-friendly.
Diffstat (limited to 'bin2bcd.sv')
-rw-r--r--bin2bcd.sv13
1 files changed, 7 insertions, 6 deletions
diff --git a/bin2bcd.sv b/bin2bcd.sv
index 5e2dbd3..9b1609b 100644
--- a/bin2bcd.sv
+++ b/bin2bcd.sv
@@ -1,23 +1,24 @@
1`include "utils.svh"
2
1module bin2bcd 3module bin2bcd
2 #( BITS = 8 4 #( BITS = 8
3 , BASE = 10 5 , BASE = 10
6 , BASE_BITS = $clog2(BASE)
7 , DIGITS = 3 // should be ceil[log(2**BITS) base BASE] which is hard to do in Verilog :-(
4 , MAX_SKIP = BITS 8 , MAX_SKIP = BITS
5 ) 9 )
6 ( input bit clk 10 ( input bit clk
7 , input bit reset 11 , input bit reset
8 12
9 , output bit bin_ready 13 , output bit bin_ready
10 , input bit bin_valid `define bin_valid $past(bin_valid) 14 , input bit bin_valid `define bin_valid `past(bin_valid)
11 , input bit [BITS-1:0] bin_data `define bin_data $past(bin_data) 15 , input bit [BITS-1:0] bin_data `define bin_data `past(bin_data)
12 16
13 , input bit bcd_ready `define bcd_ready $past(bcd_ready) 17 , input bit bcd_ready `define bcd_ready `past(bcd_ready)
14 , output bit bcd_valid 18 , output bit bcd_valid
15 , output bit [DIGITS-1:0][BASE_BITS-1:0] bcd_data 19 , output bit [DIGITS-1:0][BASE_BITS-1:0] bcd_data
16 ); 20 );
17 21
18localparam BASE_BITS = $clog2(BASE);
19localparam DIGITS = $rtoi($ceil($ln(1 << BITS) / $ln(BASE)));
20
21bit bin_b_valid; 22bit bin_b_valid;
22bit [BITS-1:0] bin_b_data; 23bit [BITS-1:0] bin_b_data;
23 24