← All problems

Binary to BCD

Medium · Sequential · SystemVerilog · VHDL

Design a sequential binary-to-BCD converter.

Binary-coded decimal (BCD) writes a number one decimal digit at a time, four bits per digit, so 8'd123 becomes 12'h123.

start begins a conversion of the binary_in present with it and abandons any conversion in progress. DATA_WIDTH+1 cycles after the cycle with start, done is high for one cycle and bcd_out is that value in BCD: the hundreds digit in bcd_out[11:8], the tens in bcd_out[7:4] and the ones in bcd_out[3:0]. An abandoned conversion never raises done. bcd_out is defined only while done is high.

resetn is a synchronous, active-low reset that clears done and abandons any conversion in progress.

  • Encoding

Open this challenge in the editor →