Convert a signed binary number into a signed one ?

Joined
Feb 26, 2010
Messages
1
Reaction score
0
Hello, I'm new in VHDL.


I have a basic question, but 3 hours of searches didn't provide any useful answer.

I got two SIGNALs, one unsigned, the other signed. I want to do something like :

Code:
SIGNAL Consigne_TMP : signed(7 DOWNTO 0);
SIGNAL Mot_Labview : unsigned(7 DOWNTO 0);

Mot_Labview(7) <= to_unsigned(Consigne_TMP(7), 8);

How should I do ?
 
Joined
Jan 29, 2009
Messages
152
Reaction score
0
Uhm writing only Mot_Labview(7) doesn't need any "conversion" (just copies the individual bit) :
Code:
Mot_Labview(7) <= Consigne_TMP(7);

Copying a larger part does need a "conversion" (reinterpretation of the bits) :
Code:
Mot_Labview(6 downto 0) <= unsigned(Consigne_TMP(6 downto 0));

"to_unsigned" is used to "convert" an integer into an unsigned:
Code:
SIGNAL int_Mot_Labview : integer range -128 to 127;
SIGNAL Mot_Labview : unsigned(7 DOWNTO 0);

Mot_Labview <= to_unsigned(int_Mot_Labview, 8);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top