Help -- how to do multiplication in Verilog

624 views
Skip to first unread message

MD ZAKIR HUSSAIN

unread,
Jan 24, 2016, 6:52:47 AM1/24/16
to EDA Playground

Dear all,

I know the discussions going here are about EDA Playground related, since majority are working with HDLs, I am posting my Question here.

My question :

y= A x 0.7071 ( A is multiplied with 0.7071)

How do I implement it in Verilog HDL ? Of course without using Verilog multiplier construct * (asterisk)

----
I have attached a doc file for reference wherein the above said is carried out , but unfortunately I did not understand any out of that !!!
code.docx

Kushaagra Goyal

unread,
Jan 24, 2016, 7:10:39 AM1/24/16
to EDA Playground
Designing a hardware for multiplying with a fixed value is easy. (you need to multiply with 0.7071 always)
 Follow the following steps:
1.) First of all choose a format in which you wish to represent your data. (See Q format) 
2.) Find the bit representation for 0.7071 in the Q format chosen above.
3.) Carry out the multiplication of any general number A with 0.7071 (by hand in bit format). With this you can see what each output pin will look like combinatorially.
4.) I mean to say that you can find each output pin as a combinatiorial of input pins(A1 A2 A3 ..).   the combinationational required will be very less and it can be implemented efficiently.


Alternative option

1.)  you can always try splitting the multiplication into few shift and add operations.
For example : Multiplying A with 101 is equivalent to (A + (A <<2))
2.) You can split multiplication by 0.7071 into shift and add operations after representing 0.7071 in appropriate format (Either fixed point or floating point arthmetic)

I hope it is clear.



 

MD ZAKIR HUSSAIN

unread,
Jan 24, 2016, 7:34:35 AM1/24/16
to EDA Playground
Thank you so much for your prompt reply , yes to the maximum extent it is clear,  I will try in case of doubts I will get back to seek assistance. Thank you so much.

EDA Playground

unread,
Jan 25, 2016, 2:29:23 AM1/25/16
to EDA Playground

Hello again Kushaagra,

Thank you for replying to this. It would be nice to see an EDA Playground community developing - it's usually just me that answers the questions!

I guess I might add that one could implement your first suggestion as a ROM. I would call it a "constant multiplier".

Matthew

MD ZAKIR HUSSAIN

unread,
Jan 25, 2016, 2:41:29 AM1/25/16
to EDA Playground
Could you please brief or suggest any source to refer  , how to do using ROM. (Question is Y=A multiplied with 0.7071)

Kushaagra Goyal

unread,
Jan 25, 2016, 5:31:30 AM1/25/16
to EDA Playground

ROM can be basically used to store the intermediate results. It has a benefit of being configurable, as the constant can be changed and the values changed in the ROM can be reconfigured.
 
       For Example : Multiply X with a 8 bit constant number A. 
                              you can store 16 values in ROM -- A*0000, A*0001, A*0010 and so on.
                              So for any 8 bit X , you need to do just one addition:  (X[7:4]*A  << 4) + (X[3:0]*A)
                              The bracket values can be accesed from ROM directly. Rom is basically a lookup table.
 

 
Reply all
Reply to author
Forward
0 new messages