Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

multiplication without using * operator in verilog

Status
Not open for further replies.

senthilos

Newbie level 6
Joined
Feb 25, 2010
Messages
12
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Raleigh, NC, USA
Activity points
1,360
Hi,

I got an interview question yesterday on multiplying a 10 bit number with a constant. Ex: a[9:0] * 24. The interviewer was expecting a answer without using the straightforward * operator. Can anyone throw me more light on how to do this multiplication without using * operator?

Thanks
Senthil
 

Syswip

Advanced Member level 4
Joined
Nov 11, 2009
Messages
119
Helped
12
Reputation
24
Reaction score
4
Trophy points
1,298
Activity points
1,859
1. sum = 0;
for(int i = 0; i < 24; i++) sum += a;

2. a * 24 = a * (8 + 16) = a* 8 + a * 16 = (a << 3) + (a << 4);

3. Design mult circuit using ANDs and XORs.

Bests,
Tiksan
 

amraldo

Advanced Member level 4
Joined
Aug 29, 2004
Messages
1,185
Helped
145
Reputation
290
Reaction score
40
Trophy points
1,328
Location
Egypt
Activity points
5,880
Analyzing the multiplicand into additions of multiples of 2 numbers.
Shifting and summing would be fine.
For example X * 3 is the same as X << 1 + X
--
Amr Ali
 

rca

Advanced Member level 4
Joined
May 20, 2010
Messages
1,485
Helped
355
Reputation
710
Reaction score
328
Trophy points
1,363
Location
Marin
Activity points
8,522
the first question is why not using a "*" with a constant? The synthesis tools are enought intelligent to simplify the combinaison.

The 2 proposition of Syswip-Tiksan seems to be the more efficient.
 

senthilos

Newbie level 6
Joined
Feb 25, 2010
Messages
12
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Raleigh, NC, USA
Activity points
1,360
Syswip and amraldo,

Your solutions seem quite different. Thanks!
What do you mean by design circuit using ANDs and XORs? You mean to draw the entire multiplier circuit using logic gates?
 

Syswip

Advanced Member level 4
Joined
Nov 11, 2009
Messages
119
Helped
12
Reputation
24
Reaction score
4
Trophy points
1,298
Activity points
1,859
the first question is why not using a "*" with a constant? The synthesis tools are enought intelligent to simplify the combination.

Because it is only for interview. :D

What do you mean by design circuit using ANDs and XORs? You mean to draw the entire multiplier circuit using logic gates?

Yes I mean to design entire multiplier circuit using logic gates.
You can use school book method.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top