// Hex_to_ascii.v
module Binary2Ascii(ascii, binary);

	parameter LO = 1'b0, HI = 1'b1;

	output [15:0] ascii;
	input  [7:0] binary;

	// ASCII Output is swapted so that UART can print MSB and LSB then
	Nibble2Ascii MSB 
	(.ascii(ascii[7:0]), .nibble(binary[7:4]));

	Nibble2Ascii LSB 
	(.ascii(ascii[15:8]), .nibble(binary[3:0]));



endmodule

module Nibble2Ascii(ascii, nibble);

	parameter LO = 1'b0, HI = 1'b1;

	output [7:0] ascii;
	input  [3:0] nibble;

	wire IsDecimal;

	assign IsDecimal = ((nibble < 4'd10)? HI : LO);

	assign ascii[7:4] = ((IsDecimal == HI)? 4'b0011:4'b0100);
	assign ascii[3:0] = nibble - ((IsDecimal == HI)? 4'd0:4'd9);

endmodule