EmbDev.net

Forum: FPGA, VHDL & Verilog is it possible for bcd to ascii module?


Author: John B. (Company: USF) (noitabrutsam)
Posted on:

Rate this post
0 useful
not useful
is it possible for bcd to ascii module?

if so, can you help me where to start?

Author: alex (Guest)
Posted on:

Rate this post
0 useful
not useful
1. Ensure that BCD is in range of borders 0...99
2. Per Byte: Byte to Hi/Lo nibble ( shift by 4 and with 0x0F for hi, and 
with 0x0F for lo nibble)
3. Per Nibble: ASCII = nibblevalue + 0x30

See also wiki

ASCII      char 0x30 = '0'

Author: Luke Wren (Guest)
Posted on:

Rate this post
0 useful
not useful
Something like
module bcd2ascii #(
    parameter N_DIGITS = ...
) (
    input wire [4*N_DIGITS-1:0] bcd_in,
    output reg [8*N_DIGITS-1:0] ascii_out
);

integer i;

always @ (*) begin
    for (i = 0; i < N_DIGITS; i = i + 1) begin
        ascii_out[i * 8 +: 8] = 8'h30 + bcd_in[4 * i +: 4];
    end
end

endmodule

Could be what you need. It would require some effort on your part to 
adapt this to your needs and make sure that it works. You didn't mention 
language, so I assumed Verilog.

Author: S. R. (svenska)
Posted on:

Rate this post
0 useful
not useful
John B. wrote:
> is it possible for bcd to ascii module?

Yes, it is possible.

John B. wrote:
> if so, can you help me where to start?

a) convert 4 bit BCD to binary (easy: use a table)
b) convert binary to ASCII digit (easy: add 0x30)

Repeat for every digit.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig