【发布时间】:2015-01-22 15:51:57
【问题描述】:
我想同时使用选择器和算术移位。 但是这段代码执行失败,结果只是逻辑移位。
module multiplier(x1, x2, x1x2);
input [15:0] x1, x2;
output [15:0] x1x2;
assign x1x2 =
x2[13]? ($signed(x1)>>>4'd1) : 16'b0000000000000000;
endmodule
在没有选择器的情况下,算术移位成功完成。
module multiplier(x1, x2, x1x2);
input [15:0] x1, x2;
output [15:0] x1x2;
assign x1x2 = $signed(x1)>>>4'd1;
endmodule
如何同时使用选择器和算术移位?
【问题讨论】:
-
可能与文字 16'b0 是无符号的事实有关;如果你把它变成一个有符号的文字,它会起作用吗? (16'sb0)
标签: math verilog bit-shift shift