這是我編寫的簡單代碼。從'outt'我得到了122116.但是如果我將'outt'寬度更改爲33位([32:0]),那麼代碼似乎工作並給出正確答案-140028。這種行爲的原因是什麼?如何正確確定寄存器位寬?
`timescale 1ns/1ps
module valu_parser(clk,outt);
input clk;
reg signed [31:0] r_1;
reg signed [31:0] r_2;
output reg signed [31:0] outt;
initial begin
r_1 = -47938;
r_2 = -150096;
end
always @ (posedge clk) begin
outt <= ((r_1 + r_2)* 11585 + 8192)>>>14;
end
endmodule
非常感謝您的回答! – RONEY