Easy way to define lots of zeroes

Discussion in 'VHDL' started by Peter Bluer, May 9, 2006.

  1. Peter Bluer

    Peter Bluer Guest

    Hi,

    Please could someone help with the following:

    I have an output on an entity which is a std_ulogic_vector(31 DOWNTO 0) and
    is called data_out.
    Within the VHDL I have a std_ulogic called c_store.
    At one point I want to do data_out <= "0000000000000000000000000000000" &
    c_store;
    (so all zeroes apart from the lsb which is replaced by the value of
    c_store).

    Is there any better way of defining it so I don't have to put in all those
    zeroes?

    ie: somehow using OTHERS => '0' etc.

    Hope this makes sense,

    Thanks.
     
    Peter Bluer, May 9, 2006
    #1
    1. Advertising

  2. Peter Bluer

    jens Guest

    Put this inside a process:

    data_out <= (others => '0');
    data_out(0) <= c_store;

    I think this would work too (more generic):

    data_out <= (others => '0');
    data_out(c_store'range) <= c_store;
     
    jens, May 9, 2006
    #2
    1. Advertising

  3. Peter Bluer wrote:

    > I have an output on an entity which is a std_ulogic_vector(31 DOWNTO
    > 0) and is called data_out. Within the VHDL I have a std_ulogic called
    > c_store. At one point I want to do data_out <=
    > "0000000000000000000000000000000" & c_store; (so all zeroes apart
    > from the lsb which is replaced by the value of c_store).
    >
    > Is there any better way of defining it so I don't have to put in all
    > those zeroes?


    <http://www.codecomments.com/archive378-2005-10-659444.html>

    --
    Mark McDougall, Engineer
    Virtual Logic Pty Ltd, <http://www.vl.com.au>
    21-25 King St, Rockdale, 2216
    Ph: +612-9599-3255 Fax: +612-9599-3266
     
    Mark McDougall, May 10, 2006
    #3
  4. Hi,

    jens schrieb:
    > Put this inside a process:
    >
    > data_out <= (others => '0');
    > data_out(0) <= c_store;


    maybe you should try
    data_out <= (0 => c_store, others => '0');
    to short your code by one statement :). This should work even outside a
    process.

    bye Thomas
     
    Thomas Stanka, May 10, 2006
    #4
  5. Peter Bluer

    Peter Bluer Guest

    Thanks very much for all the replies.

    "Peter Bluer" <> wrote in message
    news:vM68g.249143$...
    > Hi,
    >
    >
    > Thanks.
    >
     
    Peter Bluer, May 10, 2006
    #5
    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. Michal Prinke
    Replies:
    0
    Views:
    353
    Michal Prinke
    Oct 19, 2004
  2. Piotr B.
    Replies:
    2
    Views:
    534
    CBFalconer
    Oct 19, 2004
  3. cjl
    Replies:
    11
    Views:
    856
    Bengt Richter
    Mar 26, 2005
  4. brad
    Replies:
    9
    Views:
    401
    Bruno Desthuilliers
    Jun 19, 2008
  5. coolneo
    Replies:
    9
    Views:
    228
    coolneo
    Jan 30, 2007
Loading...

Share This Page