Talk About Network

Google





Electronic Equipment > VHDL > Re: String to s...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 11 Topic 6055 of 6445
Post > Topic >>

Re: String to std_logic_vector

by Shannon <sgomes@[EMAIL PROTECTED] > May 30, 2008 at 11:09 AM

On May 30, 10:31=A0am, KJ <kkjenni...@[EMAIL PROTECTED]
> wrote:
> On May 30, 1:03=A0pm, Shannon <sgo...@[EMAIL PROTECTED]
> wrote:
>
> > On May 30, 9:47=A0am, KJ <kkjenni...@[EMAIL PROTECTED]
> wrote:
>
> > Or something like that?
>
> Except that each character only returns a nibble not a byte.
>
> KJ

My finished version:

FUNCTION char_to_slv (c : CHARACTER) RETURN STD_LOGIC_VECTOR IS
    variable Return_Value : STD_LOGIC_VECTOR(7 downto 0);
BEGIN
    case c is
	when '0' =3D> Return_Value :=3D STD_LOGIC_VECTOR(TO_UNSIGNED(0,8));
	when '1' =3D> Return_Value :=3D STD_LOGIC_VECTOR(TO_UNSIGNED(1,8));
	when '2' =3D> Return_Value :=3D STD_LOGIC_VECTOR(TO_UNSIGNED(2,8));
	when '3' =3D> Return_Value :=3D STD_LOGIC_VECTOR(TO_UNSIGNED(3,8));
	when '4' =3D> Return_Value :=3D STD_LOGIC_VECTOR(TO_UNSIGNED(4,8));
	when '5' =3D> Return_Value :=3D STD_LOGIC_VECTOR(TO_UNSIGNED(5,8));
	when '6' =3D> Return_Value :=3D STD_LOGIC_VECTOR(TO_UNSIGNED(6,8));
	when '7' =3D> Return_Value :=3D STD_LOGIC_VECTOR(TO_UNSIGNED(7,8));
	when '8' =3D> Return_Value :=3D STD_LOGIC_VECTOR(TO_UNSIGNED(8,8));
	when '9' =3D> Return_Value :=3D STD_LOGIC_VECTOR(TO_UNSIGNED(9,8));
	when '-' =3D> Return_Value :=3D STD_LOGIC_VECTOR(TO_UNSIGNED(45,8));
	when others =3D> Return_Value :=3D (OTHERS =3D> '1');
   end case;

Later I will add the lowercase letters but this gets me through the
day.  Thanks for you help everyone.

Mike -- Your answers are always amazing to me.  You find super compact
ways of doing clever things.  I confess I don't understand your
version this time but as usual, I will synthesize it and look at the
RTL viewer to see how yours does the same thing as mine in a tenth the
number of lines!

Shannon
	return(Return_Value);

	END char_to_slv;
 




 11 Posts in Topic:
String to std_logic_vector
Shannon <sgomes@[EMAIL  2008-05-30 09:16:54 
Re: String to std_logic_vector
KJ <kkjennings@[EMAIL   2008-05-30 09:47:43 
Re: String to std_logic_vector
Shannon <sgomes@[EMAIL  2008-05-30 10:03:12 
Re: String to std_logic_vector
Mike Treseler <mike_tr  2008-05-30 10:24:50 
Re: String to std_logic_vector
KJ <kkjennings@[EMAIL   2008-05-30 10:31:50 
Re: String to std_logic_vector
Shannon <sgomes@[EMAIL  2008-05-30 11:09:46 
Re: String to std_logic_vector
Mike Treseler <mike_tr  2008-05-30 11:40:44 
Re: String to std_logic_vector
Shannon <sgomes@[EMAIL  2008-05-30 12:59:27 
Re: String to std_logic_vector
"KJ" <kkjenn  2008-05-30 16:55:55 
Re: String to std_logic_vector
"KJ" <kkjenn  2008-05-30 17:06:25 
Re: String to std_logic_vector
Shannon <sgomes@[EMAIL  2008-05-30 15:49:35 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Thu Jan 8 17:36:26 PST 2009.