Re: Examples of issues with std_logic_arith

Discussion in 'VHDL' started by Jacko, Mar 27, 2009.

  1. Jacko

    Jacko Guest

    On 26 Mar, 10:17, Sean Durkin <> wrote:
    > Hi *,
    >
    > I know the whole numeric_std vs. std_logic_arith issue has been covered
    > several times before here, but please bear with me for a second :)


    The critical point to get is that std_logic_vector is a string type!
    so expect it to behave as such sometimes, including having a greater
    than 32 bit length.

    numeric standard_does a string->number->string with number being
    limited to 32 bits. std_logic_artih does not do this conversion, an
    all things remain as strings with a limited character subset.

    If you go for more than addition and subtraction, then things get less
    supported in logic arith. If you understand your logic, then this is
    no problem to write your own boole multiplier etc.

    With numeric std, full arithmetic is generally supported to 32 bit
    resolution with reduction of stuck at 1 or 0 inputs. You can't easily
    write a 64 bit cpu in numeric std.

    cheers jacko
    Jacko, Mar 27, 2009
    #1
    1. Advertising

  2. Jacko

    Guest

    On Mar 27, 10:45 am, Jacko <> wrote:


    >
    > With numeric std, full arithmetic is generally supported to 32 bit
    > resolution with reduction of stuck at 1 or 0 inputs. You can't easily
    > write a 64 bit cpu in numeric std.
    >
    > cheers jacko


    I just looked at the source for numeric_std and how it implements
    addition, subtraction, multiplication, and division. As far as my
    quick perusal reveals, everything is coded at the bit level and has no
    constraints other than the LENGTH of the unsigned/signed numbers have
    to be integers, so it looks like it could support (roughly) numbers up
    to 2^31 bits in length. Can you give a more precise description of
    where you ran into this issue - I'm curious to know if I mis-read the
    code?

    - Kenn
    , Mar 27, 2009
    #2
    1. Advertising

  3. Jacko

    Tricky Guest


    >
    > numeric standard_does a string->number->string with number being
    > limited to 32 bits. std_logic_artih does not do this conversion, an
    > all things remain as strings with a limited character subset.
    >


    Tell that to my 36 bit unsigned mutliplier results!
    Tricky, Mar 27, 2009
    #3
  4. Jacko

    Jacko Guest

    On 27 Mar, 15:01, wrote:
    > On Mar 27, 10:45 am, Jacko <> wrote:
    >
    >
    >
    > > With numeric std, full arithmetic is generally supported to 32 bit
    > > resolution with reduction of stuck at 1 or 0 inputs. You can't easily
    > > write a 64 bit cpu in numeric std.

    >
    > > cheers jacko

    >
    > I just looked at the source for numeric_std and how it implements
    > addition, subtraction, multiplication, and division. As far as my
    > quick perusal reveals, everything is coded at the bit level and has no
    > constraints other than the LENGTH of the unsigned/signed numbers have
    > to be integers, so it looks like it could support (roughly) numbers up
    > to 2^31 bits in length.  Can you give a more precise description of
    > where you ran into this issue - I'm curious to know if I mis-read the
    > code?
    >
    >  - Kenn


    I didn't run into an issue, I've used std_logic_arith always, I have
    never needed the higher coverage of division ops, or needed to convert
    between integers and std_logic.

    I only use + and - and I always make sure that the result size is
    assigned to a correctly sized std_logic_vector. I think the limits
    come by using type integer to store calculation results, which I never
    do. I never use any library feature to perform sign extension, and
    prefer a more explicit '&' concat style of coding.

    The reason for my preference for std_logic_arith is that I constrains
    me to not get too flashy with large sythesis designs. Case in point
    '/' can expand to a large amount of logic etc.

    signal1 <= unsigned(signal2)+1 -- is about as complex as my use is of
    the libraries. as a synchronous counter.

    The adder in the ALU of http://nibz.googlecode.com is implemented in
    descrete logic to reduce produced area. i.e. the whole CPU fits in
    less space than the multiplexed 4 way standard library version of the
    ALU processor. Granted it is faster in the 4 way multiplexed library
    version, but this is due to non optimal use of fast carry routing.
    (technology specific).

    I find I can not rely on library code reducing to minimal area.

    cheers jacko
    Jacko, Mar 28, 2009
    #4
  5. Jacko

    Andy Guest

    On Mar 27, 10:34 am, Alan Fitch <> wrote:
    > Alan Fitch wrote:
    > > Jacko wrote:
    > >> On 26 Mar, 10:17, Sean Durkin <> wrote:
    > >>> Hi *,

    >
    > >>> I know the whole numeric_std vs. std_logic_arith issue has been covered
    > >>> several times before here, but please bear with me for a second :)

    >
    > >> The critical point to get is that std_logic_vector is a string type!
    > >> so expect it to behave as such sometimes, including having a greater
    > >> than 32 bit length.

    >
    > >> numeric standard_does a string->number->string with number being
    > >> limited to 32 bits. std_logic_artih does not do this conversion, an
    > >> all things remain as strings with a limited character subset.

    >
    > >> If you go for more than addition and subtraction, then things get less
    > >> supported in logic arith. If you understand your logic, then this is
    > >> no problem to write your own boole multiplier etc.

    >
    > >> With numeric std, full arithmetic is generally supported to 32 bit
    > >> resolution with reduction of stuck at 1 or 0 inputs. You can't easily
    > >> write a 64 bit cpu in numeric std.

    >
    > >> cheers jacko

    >
    > > That's almost completely wrong in every respect.

    >
    > > regards
    > > Alan

    >
    > Sorry I was a bit quick there - perhaps I should be more specific
    >
    > 1. std_logic_vector is not "a string type" it is an unconstrained array
    > of std_logic
    >
    > 2. numeric std uses types signed and unsigned which are also
    > unconstrained arrays of std_logic
    >
    > 3. numeric std does *not* do a "string -> number -> string" conversion.
    > All functions and operators (except to_integer, to_signed, to_unsigned)
    > are written to work on signed and unsigned (which are arbitrary width up
    > to the range of NATURAL)
    >
    > The exceptions are the conversions to and from integer which must
    > produce a result limited to the range of integer - but then so is
    > conv_integer in std_logic_arith
    >
    > 4. I agree that the coverage of arithmetic operations is not as good in
    > std_logic_arith as it is in numeric_std.
    >
    > 5. Numeric std *can* easily write a 64 bit cpu,
    >
    > regards
    > Alan
    >
    > --
    > Alan Fitch
    > Senior Consultant
    >
    > Doulos – Developing Design Know-how
    > VHDL * Verilog * SystemVerilog * SystemC * PSL * Perl * Tcl/Tk * Project
    > Services
    >
    > Doulos Ltd. Church Hatch, 22 Marketing Place, Ringwood, Hampshire, BH24
    > 1AW, UK
    > Tel:  + 44 (0)1425 471223               Email:
    > Fax:  +44 (0)1425 471573                http://www.doulos.com
    >
    > ------------------------------------------------------------------------
    >
    > This message may contain personal views which are not the views of
    > Doulos, unless specifically stated.- Hide quoted text -
    >
    > - Show quoted text -


    I'm not that familiar with std_logic_arith. I've avoided it whenever
    possible, and never seen any code that got beyond the basics with it.

    What arithmetic operations does SLA/SLS/SLU support that numeric_std
    does not?

    I am aware that many moons ago, Synopsys did not support
    numeric_std.signed/unsigned and div/mod by integral powers of 2 for
    synthesis, but they would simulate it.

    Andy
    Andy, Mar 30, 2009
    #5
  6. Andy wrote:

    > I'm not that familiar with std_logic_arith. I've avoided it whenever
    > possible, and never seen any code that got beyond the basics with it.


    Save here.
    The package is often declared, but rarely used.
    Commenting the unused USE clause can eliminate some sim warnings.

    > What arithmetic operations does SLA/SLS/SLU support that numeric_std
    > does not?


    None.
    That is the old Mentor version by the way.
    Synopsys has different names for those operators.

    -- Mike Treseler
    Mike Treseler, Mar 30, 2009
    #6
  7. Mike Treseler wrote:

    > Save here.

    Same
    > The package is often declared, but rarely used.
    > Commenting the unused USE clause can eliminate some sim warnings.
    >
    >> What arithmetic operations does SLA/SLS/SLU support that numeric_std
    >> does not?

    >
    > None.
    > That is the old Mentor version by the way.
    > Synopsys has different names for those operators.
    >
    > -- Mike Treseler
    Mike Treseler, Mar 30, 2009
    #7
    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. Mark McDougall
    Replies:
    1
    Views:
    426
    Mark McDougall
    Mar 27, 2009
  2. Martin Thompson
    Replies:
    0
    Views:
    531
    Martin Thompson
    Mar 27, 2009
  3. Tricky
    Replies:
    0
    Views:
    408
    Tricky
    Mar 27, 2009
  4. Sean Durkin
    Replies:
    0
    Views:
    422
    Sean Durkin
    Mar 27, 2009
  5. Mike Treseler
    Replies:
    0
    Views:
    432
    Mike Treseler
    Mar 27, 2009
Loading...

Share This Page