![]() |
|
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
(Viswan) wrote in message news:<. com>...
> 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 |
|
|
|
#3 |
|
Posts: n/a
|
(Ralfe Cookson) wrote in message news:<. com>...
> (Viswan) wrote in message news:<. com>... > > 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 |
|
|
|
#4 |
|
Posts: n/a
|
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 |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VHDL 12 bit BCD counter | dv09 | Hardware | 0 | 10-07-2009 05:57 PM |
| How to execute an external software from VHDL? And how to interface VHDL with JAVA? | becool_nikks | Software | 0 | 03-06-2009 07:08 PM |
| Help on auto conversion from Matlab to vhdl on filter design | hardheart | Hardware | 0 | 12-07-2007 09:19 AM |
| ARRAY(n DOWNTO 0) OF STD_LOGIC_VECTOR(m DOWNTO 0) - VHDL | freitass | Hardware | 0 | 11-01-2007 03:44 PM |
| doubt in vhdl | sreeram | Hardware | 0 | 09-17-2007 10:25 AM |