Continue to Site

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.

Signed multiplier in Verilog

Status
Not open for further replies.

pbernardi

Full Member level 3
Joined
Nov 21, 2013
Messages
151
Helped
30
Reputation
60
Reaction score
31
Trophy points
1,308
Activity points
2,903
Hello All,

I would like to make a signed multiplied on Verilog, using an Spartan-6.

Spartan-6 has the DSP48A1 multiplier, that is able to make a pre-sum, and a post-sum. Meaning I can write the following code:

Code:
wire [15:0] A, B, C, D;

wire [31:0] MUL = ((A + B) * C) + D;

And the ISE will synthesize a DSP48A1 multiplier.

According the UG389, however, they say that the pre and post operator can be positive or negative; however, I cannot think a way to describe it. What I want is, with two more wires (S1 and S2), make the following:

Code:
wire [15:0] A, B, C, D;
wire S1, S2;

wire [31:0] MUL = ((A +- B) * C) +- D;

where S1 and S2 will indicate if the operators are negative or positive. DSP48A1 support this natively, so no additional hardware should be synthesized.

Any ideas?
 

Did you ever consider using the the Verilog signed type?
 

Yes, but how would I change the signal on each operation?

for example, if I do:
Code:
wire [15:0] A, C;
wire signed [15:0] B, D;

wire [31:0] MUL = ((A + B) * C) + D;

B or D can be signed, but I cannot make a true subtraction; I can only set B or D negative. There is a difference, because my application is clocked and I would like to make the operation in a single clock. If I have to negate B or D and then multiply, I lose one clock pulse.
 

You mean, you want to model the specific DSP48 functionality in Verilog (because you need it in your application for some reason).

I see two options:
- ISE does recognize an additional signed +/-1 factor as description of the respective function
- you need to instantiate a low level DSP48 primitive
 
Yes, exactly. Tell me more about first option, please.

you mean, if I define:

Code:
wire signed S1;

ISE understand this as a +/-1 signal?
 
Last edited:

The smallest +/- 1 factor is a two bit signed variable. More easily, a mux could represent the sign switching.

I'm not using Xilinx tools so I can't check the suggestions. I also have no feeling about ISE's intelligency in infering hardware from HDL.

Every inference rule has to be implemented by compiler developers explicitely. It can be primarly expected for portable HDL constructs, less likely for vendor specific features like the discussed DSP OPMODE input.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top