Convert a signed binary number into a signed one ?

Discussion in 'VHDL' started by Rob1bureau, Feb 26, 2010.

  1. Rob1bureau

    Rob1bureau

    Joined:
    Feb 26, 2010
    Messages:
    1
    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 ?
     
    Rob1bureau, Feb 26, 2010
    #1
    1. Advertising

  2. Rob1bureau

    joris

    Joined:
    Jan 29, 2009
    Messages:
    152
    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);
    
     
    joris, Feb 27, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. makok
    Replies:
    1
    Views:
    6,886
    Anders Hellerup Madsen
    Feb 23, 2004
  2. hari
    Replies:
    6
    Views:
    7,026
    hamilton
    May 2, 2004
  3. Eric Sosman
    Replies:
    0
    Views:
    1,012
    Eric Sosman
    Mar 4, 2010
  4. markspace
    Replies:
    0
    Views:
    451
    markspace
    Mar 4, 2010
  5. Bob Sanders
    Replies:
    5
    Views:
    232
    Ryan Lewis
    May 30, 2008
Loading...

Share This Page