I would like to convert HEX to BINARY in VHDL. I am going to convert
decimal numbers to hex on my PC, then send the hex to the FPGA. Once
on the FPGA I will need to convert the hex to binary. My range is 8
bits(so max 255 decimal and FF hex). Im looking for the easiest way.
I suppose I could just write a buntch of if statements and be done
with it.
Anyone have a better idea, or is there a built in function in VHDL
that will do this for me??
Thanks in advance
Scott
constant hex_number: integer := 16#FEC#;
constant binary: STD_LOGIC_VECTOR (13 downto 0) :=
std_logic_vector(to_unsigned(hex_number,14));
remember to include the numeric.std
regards,
juza
: I would like to convert HEX to BINARY in VHDL. I am going to convert
: Thanks in advance
: Scott
--
Juza
Regards,
Benoit.
"Scott" <scot...@yahoo.com> a écrit dans le message news:
ad642abe.03041...@posting.google.com...
> I would like to convert HEX to BINARY in VHDL.
I posted a quick&dirty solution some days ago:
Message-ID: <b6kouh$6ab5i$3...@ID-8609.news.dfncis.de>
news://b6kouh$6ab5i$3...@ID-8609.news.dfncis.de
Ralf
thanks
scott
Ralf Hildebrandt <Ralf-Hil...@gmx.de> wrote in message news:<b7h5mp$s0gu$2...@ID-8609.news.dfncis.de>...
> hey Ralf...i wasnt able to connect to the link you sent, something to
> do with my lack of authorization.
This is a Message-ID. Use http://groups.google.com or a good newsreader.
But now: the source:
-- convert hex character to 4 bit signed
function char_to_sulv4(char : character) return std_ulogic_vector is
variable res_sulv4: std_ulogic_vector(3 downto 0);
begin
case char is
when ' ' => res_sulv4:="0000";
when '0' => res_sulv4:="0000";
when '1' => res_sulv4:="0001";
when '2' => res_sulv4:="0010";
when '3' => res_sulv4:="0011";
when '4' => res_sulv4:="0100";
when '5' => res_sulv4:="0101";
when '6' => res_sulv4:="0110";
when '7' => res_sulv4:="0111";
when '8' => res_sulv4:="1000";
when '9' => res_sulv4:="1001";
when 'A' => res_sulv4:="1010";
when 'B' => res_sulv4:="1011";
when 'C' => res_sulv4:="1100";
when 'D' => res_sulv4:="1101";
when 'E' => res_sulv4:="1110";
when 'F' => res_sulv4:="1111";
when others => ASSERT (false) REPORT "no hex character read" SEVERITY
failure;
end case;
return res_sulv4;
end char_to_sulv4;
Ralf