Guest
Hi,
I'm trying to code a variable shift of signed values in Verilog - and
simulate with icarus's iverilog.
I find that this works as I expect:
Give these variables,
wire signed [5:0] GAIN //amount to shift by
wire signed [23:0] iir //the signed value to be shifted
wire signed [23:0] iir_shift //the result of the shift
assign iir_shift = iir >>> 2;
iir_shift is correctly sign extended (MSBs filled with 1's if it's
negative, filled with 0's if its positive)
assign iir_shift = iir >>> GAIN;
iir_shift is not correctly sign extended - the MSBs are filled with '0'
when iir is a negative number.
Am I doing something wrong? Why this discrepancy? How to fix it?
Could it be a bug in icarus's program? Thanks for your time. Russell
I'm trying to code a variable shift of signed values in Verilog - and
simulate with icarus's iverilog.
I find that this works as I expect:
Give these variables,
wire signed [5:0] GAIN //amount to shift by
wire signed [23:0] iir //the signed value to be shifted
wire signed [23:0] iir_shift //the result of the shift
assign iir_shift = iir >>> 2;
iir_shift is correctly sign extended (MSBs filled with 1's if it's
negative, filled with 0's if its positive)
assign iir_shift = iir >>> GAIN;
iir_shift is not correctly sign extended - the MSBs are filled with '0'
when iir is a negative number.
Am I doing something wrong? Why this discrepancy? How to fix it?
Could it be a bug in icarus's program? Thanks for your time. Russell