doubt in VHDL

V

Viswan

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
 
R

Ralfe Cookson

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.
 
V

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
 
T

Tuukka Toivonen

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top