skyworld_cy
Junior Member level 3
Hi,
I wrote a piece of code to test signed calculation. The code doesn't work as what I expected, I can't find the souce of bug. Can anybody give me some help? thanks.
here is the code:
I assign sign_a to -1. Since -1<0, I expect result_a would be assigned to 0. but after simulation, the result_a is assigned to -1, which confused. Can anybody give me some guide? thnaks.
I wrote a piece of code to test signed calculation. The code doesn't work as what I expected, I can't find the souce of bug. Can anybody give me some help? thanks.
here is the code:
Code:
wire signed [8:0] sign_a;
wire signed [9:0] constant_a;
wire signed [8:0] result_a;
assign constant_a = 10'd511;
assign sign_a = -9'd1;
assign result_a = (sign_a > constant_a) ? constant_a
: (sign_a < 10'd0) ? 9'd0
: sign_a;
I assign sign_a to -1. Since -1<0, I expect result_a would be assigned to 0. but after simulation, the result_a is assigned to -1, which confused. Can anybody give me some guide? thnaks.