doubt in VHDL

Discussion in 'VHDL' started by Viswan, Aug 3, 2004.

  1. Viswan

    Viswan Guest

    hi,
    I have question regarding multiplication in VHDL. I have many
    multiplications to be done in an application and I have only one
    multiplier in my hardware. And in many of the multiplications I am
    going to do, I will have either multiplicand or multiplier or both as
    some constant values. Now my question is how can I load these
    constants as the input to the multiplier? Do I have to use some
    separate registers to hold these constants through out or can I just
    use some internal signals and assign them these constant values and
    use those? Once synthesized, will there be any problem if I use the
    internal signals to hold the constant values?

    And also any suggestion to deal with these multiplication with
    constants is greatly appreciated.

    Thanks
    Viswan
     
    Viswan, Aug 3, 2004
    #1
    1. Advertising

  2. (Viswan) wrote in message news:<>...
    > hi,
    > I have question regarding multiplication in VHDL. I have many
    > multiplications to be done in an application and I have only one
    > multiplier in my hardware. And in many of the multiplications I am
    > going to do, I will have either multiplicand or multiplier or both as
    > some constant values. Now my question is how can I load these
    > constants as the input to the multiplier? Do I have to use some
    > separate registers to hold these constants through out or can I just
    > use some internal signals and assign them these constant values and
    > use those? Once synthesized, will there be any problem if I use the
    > internal signals to hold the constant values?
    >
    > And also any suggestion to deal with these multiplication with
    > constants is greatly appreciated.
    >
    > Thanks
    > Viswan


    Your question is not very clear.

    If you are multiplying A * C where A is a variable but C is a constant
    (i.e. known before hand),then you do not need to tie up your
    multiplier for this. You can use adders to do the multiplication
    provided you shift the bits of A appropriately at the adder inputs to
    do the power of 2 multiplications. For example if C = 11, then the
    product in terms of power of 2 sums is 8A + 2A + A. Multiply by 8 =
    shift left 3 bits. Multiply by 2 = shift left 1 bit.

    So your adder's input bit triplets would be:

    1A 2A 8A
    -----------------
    A(0) + 0 + 0
    A(1) + A(0) + 0
    A(2) + A(1) + 0
    A(3) + A(2) + A(0)
    A(4) + A(3) + A(1)
    ..
    ..
    ..
    etc.

    If you are multiplying two constants C1 * C2, just do the
    multiplication in advance and hard code the product into your VHDL
    code. No need for any multipliers or adders.

    If you are multiplying two variables, i.e. neither is a constant, then
    you should use the multiplier. If you are saying that you have several
    sources for the variables and only one multiplier to multiply them,
    then you need some muxes on the inputs to the multiplier to select
    which operands to use and a state machine to control the select lines
    of the muxes and where to store the products. You can also use this
    for the constants if time is not a constraint.
     
    Ralfe Cookson, Aug 4, 2004
    #2
    1. Advertising

  3. Viswan

    Viswan Guest

    (Ralfe Cookson) wrote in message news:<>...
    > (Viswan) wrote in message news:<>...
    > > hi,
    > > I have question regarding multiplication in VHDL. I have many
    > > multiplications to be done in an application and I have only one
    > > multiplier in my hardware. And in many of the multiplications I am
    > > going to do, I will have either multiplicand or multiplier or both as
    > > some constant values. Now my question is how can I load these
    > > constants as the input to the multiplier? Do I have to use some
    > > separate registers to hold these constants through out or can I just
    > > use some internal signals and assign them these constant values and
    > > use those? Once synthesized, will there be any problem if I use the
    > > internal signals to hold the constant values?
    > >
    > > And also any suggestion to deal with these multiplication with
    > > constants is greatly appreciated.
    > >
    > > Thanks
    > > Viswan

    >
    > Your question is not very clear.
    >
    > If you are multiplying A * C where A is a variable but C is a constant
    > (i.e. known before hand),then you do not need to tie up your
    > multiplier for this. You can use adders to do the multiplication
    > provided you shift the bits of A appropriately at the adder inputs to
    > do the power of 2 multiplications. For example if C = 11, then the
    > product in terms of power of 2 sums is 8A + 2A + A. Multiply by 8 =
    > shift left 3 bits. Multiply by 2 = shift left 1 bit.
    >
    > So your adder's input bit triplets would be:
    >
    > 1A 2A 8A
    > -----------------
    > A(0) + 0 + 0
    > A(1) + A(0) + 0
    > A(2) + A(1) + 0
    > A(3) + A(2) + A(0)
    > A(4) + A(3) + A(1)
    > .
    > .
    > .
    > etc.
    >
    > If you are multiplying two constants C1 * C2, just do the
    > multiplication in advance and hard code the product into your VHDL
    > code. No need for any multipliers or adders.
    >
    > If you are multiplying two variables, i.e. neither is a constant, then
    > you should use the multiplier. If you are saying that you have several
    > sources for the variables and only one multiplier to multiply them,
    > then you need some muxes on the inputs to the multiplier to select
    > which operands to use and a state machine to control the select lines
    > of the muxes and where to store the products. You can also use this
    > for the constants if time is not a constraint.



    hi,

    Thanks a lot for this help. It helped me a bit. But what I was
    trying to ask also is, suppose I have some constants to be used in the
    operations. For example I have this X * 1.7895 ( here I am using
    fixed point reals), and also I want to use multiplier only for this
    purpose. While coding in VHDL can I just represent this value of
    1.7895 as some 'signal' and assign this constant value to that signal
    as follows:
    signal exvalue : std_logic_vector (15 downto 0);
    exvalue <= "0001.........1";
    Regards
    Viswan
     
    Viswan, Aug 23, 2004
    #3
  4. In article <>, Viswan wrote:
    > purpose. While coding in VHDL can I just represent this value of
    > 1.7895 as some 'signal' and assign this constant value to that signal
    > as follows:
    > signal exvalue : std_logic_vector (15 downto 0);
    > exvalue <= "0001.........1";


    Yes, you can. No synthesizer should have problems with that.

    Or you could use "when" to select correct constant:

    m <= "101010101" when STATE=CONST1 else "101111101";

    or a "process" statement with case...end case.
     
    Tuukka Toivonen, Aug 24, 2004
    #4
    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. Bob Nelson

    doubt about doubt

    Bob Nelson, Jul 28, 2006, in forum: C Programming
    Replies:
    11
    Views:
    659
  2. afd
    Replies:
    1
    Views:
    8,550
    Colin Paul Gloster
    Mar 23, 2007
  3. Replies:
    0
    Views:
    592
  4. Peter Otten
    Replies:
    2
    Views:
    138
    Cousin Stanley
    Aug 10, 2013
  5. Terry Reedy
    Replies:
    0
    Views:
    135
    Terry Reedy
    Aug 10, 2013
Loading...

Share This Page