Values larger than 32 bit using conv_std_logic_vector

Discussion in 'VHDL' started by Willem Oosthuizen, Jul 1, 2003.

  1. signal D is defined as std_logic_vector(51 downto 0)

    D <= conv_std_logic_vector(2**n+16#ff#,D'length); only works correctly for
    integer n < 31. How can I make it work for integer n < 52 ?

    Any suggestions? Why is there this 32 bit limit?
     
    Willem Oosthuizen, Jul 1, 2003
    #1
    1. Advertising

  2. Willem Oosthuizen

    Alan Fitch Guest

    "Jon" <> wrote in message
    news:...
    > "Willem Oosthuizen" <> wrote in message

    news:<bdrp4d$i48$>...
    > > signal D is defined as std_logic_vector(51 downto 0)
    > >
    > > D <= conv_std_logic_vector(2**n+16#ff#,D'length); only

    works correctly for
    > > integer n < 31. How can I make it work for integer n <

    52 ?
    > >
    > > Any suggestions? Why is there this 32 bit limit?

    >
    > Hi Willem,
    > VHDL defined the minimum supported range of an integer

    to be -2^32
    > to (2^31)-1. Some simulators extended the range for

    integers and you
    > would have to check to see if yours did.
    > One way not very efficient is to break up the number

    into a sum of
    > integers each no greater than 2^32.
    >
    > jon


    I know this is very pedantic :) but the range is guaranteed
    to be
    (-2^32)+1 to (2^31)-1, i.e. the most negative number is not
    guaranteed by
    the standard to be included. Of course in practice is always
    is!

    Regarding the original question, you might be able to
    achieve something
    similar using shifts. It's not clear from your original code
    if n is a
    constant or a signal. I shall assume it's a signal.

    process(n)
    begin
    D <= (others => '0'); -- all bits 0
    D(n) <= '1'); -- e.g. n = 0 => set bit 0, n = 1 =>
    set bit 1
    D(7 downto 0) <= X"FF";
    end process;

    If n is locally static (i.e. a constant), then you *should*
    be able to write

    D <= (n=> '1', 7 downto 0 => '1', others => '0');


    kind regards

    Alan

    --
    Alan Fitch
    Consultant

    DOULOS - Developing Design Know-how
    VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification *
    Project Services

    Doulos Ltd. Church Hatch, 22 Market Place, Ringwood,
    Hampshire, BH24 1AW, UK
    Tel: +44 (0)1425 471223 mail:

    Fax: +44 (0)1425 471573 Web:
    http://www.doulos.com

    The contents of this message may contain personal views
    which are not the
    views of Doulos Ltd., unless specifically stated.
     
    Alan Fitch, Jul 2, 2003
    #2
    1. Advertising

  3. On 1 Jul 2003 08:16:13 -0700, (Jon) wrote:

    >"Willem Oosthuizen" <> wrote in message news:<bdrp4d$i48$>...
    >> signal D is defined as std_logic_vector(51 downto 0)
    >>
    >> D <= conv_std_logic_vector(2**n+16#ff#,D'length); only works correctly for
    >> integer n < 31. How can I make it work for integer n < 52 ?
    >>
    >> Any suggestions? Why is there this 32 bit limit?

    >
    >Hi Willem,
    > VHDL defined the minimum supported range of an integer to be -2^32
    >to (2^31)-1.


    Minor correction: the minimum supported range of an integer is
    -((2^32)-1) to +((2^32)-1)

    Amost all tools do extend the lower range to -(2^32) though.

    Regards,
    Allan.
     
    Allan Herriman, Jul 2, 2003
    #3
  4. I said:
    D <= conv_std_logic_vector(2**n+16#ff#,D'length);

    Alan Said:
    > process(n)
    > begin
    > D <= (others => '0'); -- all bits 0
    > D(n) <= '1'); -- e.g. n = 0 => set bit 0, n = 1 =>
    > set bit 1
    > D(7 downto 0) <= X"FF";
    > end process;


    This is not equivalent. What about the carry when n < 8 ?

    "Alan Fitch" <> wrote in message
    news:bdu5fd$6h4$1$...
    >
    > "Jon" <> wrote in message
    > news:...
    > > "Willem Oosthuizen" <> wrote in message

    > news:<bdrp4d$i48$>...
    > > > signal D is defined as std_logic_vector(51 downto 0)
    > > >
    > > > D <= conv_std_logic_vector(2**n+16#ff#,D'length); only

    > works correctly for
    > > > integer n < 31. How can I make it work for integer n <

    > 52 ?
    > > >
    > > > Any suggestions? Why is there this 32 bit limit?

    > >
    > > Hi Willem,
    > > VHDL defined the minimum supported range of an integer

    > to be -2^32
    > > to (2^31)-1. Some simulators extended the range for

    > integers and you
    > > would have to check to see if yours did.
    > > One way not very efficient is to break up the number

    > into a sum of
    > > integers each no greater than 2^32.
    > >
    > > jon

    >
    > I know this is very pedantic :) but the range is guaranteed
    > to be
    > (-2^32)+1 to (2^31)-1, i.e. the most negative number is not
    > guaranteed by
    > the standard to be included. Of course in practice is always
    > is!
    >
    > Regarding the original question, you might be able to
    > achieve something
    > similar using shifts. It's not clear from your original code
    > if n is a
    > constant or a signal. I shall assume it's a signal.
    >
    > process(n)
    > begin
    > D <= (others => '0'); -- all bits 0
    > D(n) <= '1'); -- e.g. n = 0 => set bit 0, n = 1 =>
    > set bit 1
    > D(7 downto 0) <= X"FF";
    > end process;
    >
    > If n is locally static (i.e. a constant), then you *should*
    > be able to write
    >
    > D <= (n=> '1', 7 downto 0 => '1', others => '0');
    >
    >
    > kind regards
    >
    > Alan
    >
    > --
    > Alan Fitch
    > Consultant
    >
    > DOULOS - Developing Design Know-how
    > VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification *
    > Project Services
    >
    > Doulos Ltd. Church Hatch, 22 Market Place, Ringwood,
    > Hampshire, BH24 1AW, UK
    > Tel: +44 (0)1425 471223 mail:
    >
    > Fax: +44 (0)1425 471573 Web:
    > http://www.doulos.com
    >
    > The contents of this message may contain personal views
    > which are not the
    > views of Doulos Ltd., unless specifically stated.
    >
     
    Willem Oosthuizen, Jul 2, 2003
    #4
  5. Willem Oosthuizen

    Jon Guest

    Hi Willem,
    All you have to do is what Alan said execpt add 255 to D in places
    of directly assigning the lsbs to 255. Using the right packages you
    can do 2's complement signed or unsigned using std_logic_vector.

    jon


    "Willem Oosthuizen" <> wrote in message news:<bdudo2$bda$>...
    > I said:
    > D <= conv_std_logic_vector(2**n+16#ff#,D'length);
    >
    > Alan Said:
    > > process(n)
    > > begin
    > > D <= (others => '0'); -- all bits 0
    > > D(n) <= '1'); -- e.g. n = 0 => set bit 0, n = 1 =>
    > > set bit 1
    > > D(7 downto 0) <= X"FF";
    > > end process;

    >
    > This is not equivalent. What about the carry when n < 8 ?
    >
    > "Alan Fitch" <> wrote in message
    > news:bdu5fd$6h4$1$...
    > >
    > > "Jon" <> wrote in message
    > > news:...
    > > > "Willem Oosthuizen" <> wrote in message

    > news:<bdrp4d$i48$>...
    > > > > signal D is defined as std_logic_vector(51 downto 0)
    > > > >
    > > > > D <= conv_std_logic_vector(2**n+16#ff#,D'length); only

    > works correctly for
    > > > > integer n < 31. How can I make it work for integer n <

    > 52 ?
    > > > >
    > > > > Any suggestions? Why is there this 32 bit limit?
    > > >
    > > > Hi Willem,
    > > > VHDL defined the minimum supported range of an integer

    > to be -2^32
    > > > to (2^31)-1. Some simulators extended the range for

    > integers and you
    > > > would have to check to see if yours did.
    > > > One way not very efficient is to break up the number

    > into a sum of
    > > > integers each no greater than 2^32.
    > > >
    > > > jon

    > >
    > > I know this is very pedantic :) but the range is guaranteed
    > > to be
    > > (-2^32)+1 to (2^31)-1, i.e. the most negative number is not
    > > guaranteed by
    > > the standard to be included. Of course in practice is always
    > > is!
    > >
    > > Regarding the original question, you might be able to
    > > achieve something
    > > similar using shifts. It's not clear from your original code
    > > if n is a
    > > constant or a signal. I shall assume it's a signal.
    > >
    > > process(n)
    > > begin
    > > D <= (others => '0'); -- all bits 0
    > > D(n) <= '1'); -- e.g. n = 0 => set bit 0, n = 1 =>
    > > set bit 1
    > > D(7 downto 0) <= X"FF";
    > > end process;
    > >
    > > If n is locally static (i.e. a constant), then you *should*
    > > be able to write
    > >
    > > D <= (n=> '1', 7 downto 0 => '1', others => '0');
    > >
    > >
    > > kind regards
    > >
    > > Alan
    > >
    > > --
    > > Alan Fitch
    > > Consultant
    > >
    > > DOULOS - Developing Design Know-how
    > > VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification *
    > > Project Services
    > >
    > > Doulos Ltd. Church Hatch, 22 Market Place, Ringwood,
    > > Hampshire, BH24 1AW, UK
    > > Tel: +44 (0)1425 471223 mail:
    > >
    > > Fax: +44 (0)1425 471573 Web:
    > > http://www.doulos.com
    > >
    > > The contents of this message may contain personal views
    > > which are not the
    > > views of Doulos Ltd., unless specifically stated.
    > >
     
    Jon, Jul 3, 2003
    #5
  6. Willem Oosthuizen

    Alan Fitch Guest

    "Jon" <> wrote in message
    news:...
    > Hi Willem,
    > All you have to do is what Alan said execpt add 255 to D

    in places
    > of directly assigning the lsbs to 255. Using the right

    packages you
    > can do 2's complement signed or unsigned using

    std_logic_vector.
    >
    > jon
    >
    >
    > "Willem Oosthuizen" <> wrote in message

    news:<bdudo2$bda$>...
    > > I said:
    > > D <= conv_std_logic_vector(2**n+16#ff#,D'length);
    > >
    > > Alan Said:
    > > > process(n)
    > > > begin
    > > > D <= (others => '0'); -- all bits 0
    > > > D(n) <= '1'); -- e.g. n = 0 => set bit 0, n = 1

    =>
    > > > set bit 1
    > > > D(7 downto 0) <= X"FF";
    > > > end process;

    > >
    > > This is not equivalent. What about the carry when n < 8

    ?
    > >


    Sorry, brain failure - luckily Jon has answered it for me!

    I must work out how to get outlook express to wrap
    sensibly as well...

    regards

    Alan



    --
    Alan Fitch
    Consultant

    DOULOS - Developing Design Know-how
    VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification *
    Project Services

    Doulos Ltd. Church Hatch, 22 Market Place, Ringwood,
    Hampshire, BH24 1AW, UK
    Tel: +44 (0)1425 471223 mail:

    Fax: +44 (0)1425 471573 Web:
    http://www.doulos.com

    The contents of this message may contain personal views
    which are not the
    views of Doulos Ltd., unless specifically stated.
     
    Alan Fitch, Jul 3, 2003
    #6
    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. walala
    Replies:
    2
    Views:
    8,068
    Ralf Hildebrandt
    Sep 6, 2003
  2. Paul Boven
    Replies:
    1
    Views:
    1,017
    Ralf Hildebrandt
    Sep 25, 2005
  3. Peter Williams
    Replies:
    1
    Views:
    1,442
    Dylan Parry
    Jun 3, 2005
  4. Replies:
    4
    Views:
    20,516
    joris
    Apr 23, 2010
  5. Replies:
    5
    Views:
    527
    Colin Song
    Oct 4, 2007
Loading...

Share This Page