The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Apr 26th, 2024, 12:29pm
Pages: 1
Send Topic Print
Need some help with this code (Read 2714 times)
wandola
Junior Member
**
Offline



Posts: 24

Need some help with this code
Nov 19th, 2015, 7:18pm
 
I am trying to write some code for a digital circuit.

module Processor(count,residue,out)
input [7:0] count;
input [4:0] residue;
output [12:0] out;

wire [12:0] mem, tmp1,tmp2,tmp3;

reg [4:0] coeff = 5'b10110;

assign tmp1 = count*coeff;
assign tmp2 = tmp1 + residue;
if (tmp1>mem)
  assign tmp3 = tmp2-mem;
else
 assign tmp3 = tmp+coef - mem;

assign mem = tmp2;
assign out = tmp3;

endmodule

I am using cadence nc-verilog for the design. the error msg says
if(tmp3 > mem): illegal operand for constant expression

can anybody help with this? really confused... Or, how shall I manage this?
Back to top
 
 
View Profile   IP Logged
Torq
New Member
*
Offline



Posts: 6

Re: Need some help with this code
Reply #1 - Nov 23rd, 2015, 5:41am
 
Hi, wandola!

It seems, you sould use a multiplexer instead of if/else construction:

assign tmp3 = (tmp1>mem) ? tmp2-mem : (tmp+coef - mem);
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.