malikkhaled
Junior Member level 1
- Joined
- Jan 14, 2010
- Messages
- 19
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- sweden
- Activity points
- 1,447
i want to do x+y mod m,,using this algorithm
x1= x+y; x2= x1-m;
if x2>=0 then out = x2;
else out =x1;
here is the code...
//////////////////////////////////////
module adder_subtractor ( input [7:0]x, input [7:0]y,output [7:0] out);
parameter m=256;
wire [8:0] x1,x2,c;
assign x1[8:0]= (x[7:0]+y[7:0]);
assign x2[8:0]= (x1[7:0]-m);
or(c,x1[8],x2[8]);
if (c==1'b0)
assign out= x2[7:0];
else
assign out = x1[7:0];
endmodule
/// i have error like c is not a constant,,anyone help me to fix this problem any suggestion
x1= x+y; x2= x1-m;
if x2>=0 then out = x2;
else out =x1;
here is the code...
//////////////////////////////////////
module adder_subtractor ( input [7:0]x, input [7:0]y,output [7:0] out);
parameter m=256;
wire [8:0] x1,x2,c;
assign x1[8:0]= (x[7:0]+y[7:0]);
assign x2[8:0]= (x1[7:0]-m);
or(c,x1[8],x2[8]);
if (c==1'b0)
assign out= x2[7:0];
else
assign out = x1[7:0];
endmodule
/// i have error like c is not a constant,,anyone help me to fix this problem any suggestion