- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am new to the forum, but not VHDL. I am a student at RIT and have taken classes and am very familiar with the language. The questions I have are more of what should my hardware multiplier and divider include?
I am designing an 32-bit arithmetic logic unit that can add, subtract, multiply and divide twos compliment signed numbers and one that does unsigned (two separate units). This is part of a larger system that includes a status word. I do know that for an adder/subtractor there is an overflow and carry bit for a status register. What do you need for a multiplier and divider, or better yet, what is typically found? I know there are conditions specified by the IEEE for floating point.Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- I am new to the forum, but not VHDL. I am a student at RIT and have taken classes and am very familiar with the language. The questions I have are more of what should my hardware multiplier and divider include? I am designing an 32-bit arithmetic logic unit that can add, subtract, multiply and divide twos compliment signed numbers and one that does unsigned (two separate units). This is part of a larger system that includes a status word. I do know that for an adder/subtractor there is an overflow and carry bit for a status register. What do you need for a multiplier and divider, or better yet, what is typically found? I know there are conditions specified by the IEEE for floating point. --- Quote End --- Hi, it is not necessary to develop your own divider or multiplier. Have a look to the Quartus build-in Megawizard. I'm pretty sure you will find most of the things you need. Kind regards GPK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did look at the megawizard but the divider and multiplier do not have carry, overflow, etc outputs you can specify, only the adder.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
building a multiplier is as simple as writing:
output <= a * b; a divider has to be pipelined to run at any useful speed, but if you dont mind a slow clock rate, you can write: output <= a / b; I dont know why you are looking for carry on multiplier and divider, they have no meaning.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The alu output is 32 bits. The multiplier, if it is to have no overflow would require 64 bits. The inputs are 32 bits as well. The wizard has no overflow, even if the output is restricted to 32 bits.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thats no problem. Embedded multipliers allow inputs up to 36 bits, with 72 bit output.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The output of the ALU goes to a 32 bit bus. The wizard has no overflow, even if the output is restricted to 32 bits. So if you multiply FFFFFFFF * FFFFFFFF what happens?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I agree, that depending on the multiplier/divider usage, overflow detection and/or handling (saturation logic) may be reasonable. But it's not provided by the Altera MegaFunctions, you have to add the feature by writing behavioral code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suppose could make an overflow like this (syntax not guaranteed):
product <= a * b; -- product is 64 bits. overflow <= NOT product(63 downto 32) AND x"0"; --No overflow when zeros.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- I suppose could make an overflow like this (syntax not guaranteed): product <= a * b; -- product is 64 bits. overflow <= NOT product(63 downto 32) AND x"0"; --No overflow when zeros. --- Quote End --- overflow will always be zero. A and 0 = 0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yeah, careless mistake I'm half asleep here in the us. figure it out tomorrow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What megawizard are you looking at to create a multiplier btw? my one allows inputs up to 256 bits, no overflow problems.
Also, you can just write behavioural VHDL and it will use the correct number of embedded multipliers. 32bit * 32bit doesnt need an overflow.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The LPM_Mult is what I looked at. If you are multiplying two 32 bit numbers, and the output is restricted to 32 bits, all numbers that have bits above the 32 bit limit will require an overflow detection. For example if you multiply FFFFFFFF * FFFFFFFF, the result will be FFFFFFFE00000001, which exceeds the limit and will not fit on a 32 bit output bus.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dont use the LPM mult
Use behavioural code. What FPGA are you targetting?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cyclone II
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For me, Quartus 10, The megawizard lets me create an LPM_MULT for a cyclone two that has 2x 256bit inputs and 512 bit output. So no need for any overflow.
Basically, 32 bit multiply is trivial in even the most basic of FPGAs. overflow is never needed.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And if you understand VHDL, why are you using the megawizard anyway for multiply. What wrong with the * function?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I agree that you need no overflow when the output is twice the width of the inputs. That is not the case with me. I do not have a 64 bit output bus, only a 32. Are you misunderstanding something?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In that case, all you need for a single overflow but is to or the top 32 bits of the output of the multuplier (because you connect the least significant 32 bits of the multiplier to your output) for your unsigned ALU.
for the signed, the output becomes and overflow/underflow. first check is to see if the top 32 bit are all 1 or all 0. If this fails, there is an overflow (in the case of MSB = '1') or underflow (MSB = '0'). Then you compare MSB with bit 31. MSB = '1' and bit31 = '0' means underflow, MSB = '0' and bit31 = '1' mean overflow. You can of course combine all this for a single bit "error".- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How are divide by zero conditions handled in the MegaWizard divider, the LPM_DIVIDER?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page