Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - multiplier

 
Thread Tools Search this Thread
Old 08-19-2006, 02:59 PM   #1
Default multiplier


Hello.
I need to write a multiplier in VHDL which multiplies two 32 bit registers,
assuming that the result is never bigger than 32 bits.

we used the following code:

ENTITY mult_rg IS
PORT (
d_in1: IN STD_LOGIC_VECTOR (31 DOWNTO 0);
d_in2: IN STD_LOGIC_VECTOR (31 DOWNTO 0);
d_out: OUT STD_LOGIC_VECTOR (31 DOWNTO 0)
);
END mult_rg;

ARCHITECTURE rtl OF mult_rg IS
SIGNAL a_int, b_int: SIGNED (31 downto 0);
SIGNAL pdt_int: SIGNED (31 downto 0);

BEGIN
a_int <= SIGNED (d_in1);
b_int <= SIGNED (d_in2);
pdt_int <= a_int * b_int;
d_out <= STD_LOGIC_VECTOR(pdt_int);
END rtl;

but I got the following error messege:

Length of expected is 32; length of actual is 64.

What should I do?
thanx.


Scofield
Scofield is offline   Reply With Quote
Old 08-19-2006, 06:57 PM   #2
Jerrie85
Junior Member
 
Join Date: Aug 2006
Posts: 7
Default
when you multiply two 32 bit numbers, the resultant is always 2 * 32 bits long at max 64 bits long ...

u can test this out by doing (2^32 - 1)(2^32-1) = (2^64 - 2^33 - 2)

i multiplied the two largest 32 bit numbers possible..and as u can see, the resultant is a 64 bit number

hence, change your d_out to (63 downto 0)...that'll fix it


Jerrie85
Jerrie85 is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Clock Multiplier (3.5 times) mreddy.a Hardware 0 09-16-2007 11:13 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46