making a code more simple

R

rekz

Guest
Is there a way so I can directly assign Result to take only the 32 LSB
of the resulting Reg1 * Reg2 without having to utilize the mul reg?
As this gives a warning when synthesizing

input signed[31:0] Reg1;
input signed[31:0] Reg2;
output[31:0] Result;

reg signed[31:0] Result;
reg[63:0] mul;

mul = Reg1 * Reg2;
Result = mul[31:0];
 
On Apr 22, 11:44 am, rekz <aditya15...@gmail.com> wrote:
Is there a way so I can directly assign Result to take only the 32 LSB
of the resulting Reg1 * Reg2 without having to utilize the mul reg?
As this gives a warning when synthesizing

input signed[31:0] Reg1;
input signed[31:0] Reg2;
output[31:0] Result;

reg signed[31:0] Result;
reg[63:0] mul;

mul = Reg1 * Reg2;
Result = mul[31:0];
How about:

Result = (Reg1 * Reg2) & 32'hffffffff;

But are you sure you want the LSbits? If you instead want the MSbits,
perhaps:

Result = (Reg1 * Reg2) >>> 31;

But you should double-check for proper alignment of the signed
multiply result compared to your expectation.
 
On Apr 22, 3:30 pm, John_H <newsgr...@johnhandwork.com> wrote:
On Apr 22, 11:44 am, rekz <aditya15...@gmail.com> wrote:

Is there a way so I can directly assign Result to take only the 32 LSB
of the resulting Reg1 * Reg2 without having to utilize the mul reg?
As this gives a warning when synthesizing

input signed[31:0] Reg1;
input signed[31:0] Reg2;
output[31:0] Result;

reg signed[31:0] Result;
reg[63:0] mul;

mul = Reg1 * Reg2;
Result = mul[31:0];

How about:

Result = (Reg1 * Reg2) & 32'hffffffff;

But are you sure you want the LSbits?  If you instead want the MSbits,
perhaps:

Result = (Reg1 * Reg2) >>> 31;

But you should double-check for proper alignment of the signed
multiply result compared to your expectation.
If I just do:

Result = (Reg1 * Reg2)

would that give me the 32 bits of the resulting multiplication?
 
On Apr 22, 7:45 pm, rekz <aditya15...@gmail.com> wrote:
On Apr 22, 3:30 pm, John_H <newsgr...@johnhandwork.com> wrote:



On Apr 22, 11:44 am, rekz <aditya15...@gmail.com> wrote:

Is there a way so I can directly assign Result to take only the 32 LSB
of the resulting Reg1 * Reg2 without having to utilize the mul reg?
As this gives a warning when synthesizing

input signed[31:0] Reg1;
input signed[31:0] Reg2;
output[31:0] Result;

reg signed[31:0] Result;
reg[63:0] mul;

mul = Reg1 * Reg2;
Result = mul[31:0];

How about:

Result = (Reg1 * Reg2) & 32'hffffffff;

But are you sure you want the LSbits?  If you instead want the MSbits,
perhaps:

Result = (Reg1 * Reg2) >>> 31;

But you should double-check for proper alignment of the signed
multiply result compared to your expectation.

If I just do:

Result = (Reg1 * Reg2)

would that give me the 32 bits of the resulting multiplication?
That would just give you the least-significant 32 bits of your
multiplication. If that's what you want, you're golden.
 

Welcome to EDABoard.com

Sponsor

Back
Top