Binary To Bcd Verilog Code ((new)) «Easy»
After the shift, that 3 becomes 6. Adding 6 compensates for the 6 "wasted" states (10–15) in a 4-bit binary nibble that are unused in BCD. Combinational Verilog Implementation
binary_to_bcd_seq uut ( .clk(clk), .rst_n(rst_n), .start(start), .binary(binary), .bcd(bcd), .done(done) ); Binary To Bcd Verilog Code
In software, converting binary to BCD is trivial: hundreds = bin / 100; tens = (bin % 100) / 10; units = bin % 10; After the shift, that 3 becomes 6
This shows that the binary number 01101010 is equivalent to the BCD number 00011010 , which represents the decimal number 26. After the shift