Hi Guys,
I have run into a problem that I was not expecting, I need to calculate the remainder after division (modulo) of a number preferebly in combinational logic or a single clock cycle, and I need it to behave in the same fashion as matlab does (as you would expect).
So i essentially need to calculate: x = mod(y, 6434);
I did this in verilog as follows
reg signed [15:0] y; wire signed [14:0] x;
assign x = y % 6434;
However this does not do what I am after. I assumed that % would perform a modulo operation however, when my input is y = -6310, x = -6310. This seems to be doing some kind of singed mod.. I would be expecting 124 as the answer as matlab produced.
Can you give me any clues as to where I am going wrong??
Regards,
Paul Solomon