Hi,
I am trying to understand some Verilog source code, but I am confused
about the following
1 | reg [29-PSR-1: 0] kp_reg ;
|
2 | wire [ 29-1: 0] kp_mult ;
|
3 |
|
4 | always @(posedge clk_i) begin
|
5 | if (rstn_i == 1'b0) begin
|
6 | kp_reg <= {29-PSR{1'b0}};
|
7 | end
|
8 | else begin
|
9 | kp_reg <= kp_mult[29-1:PSR] ;
|
10 | end
|
11 | end
|
12 |
|
13 | assign kp_mult = $signed(error) * $signed(set_kp_i);
|
where PSR is a paramter equal = 12.
So, kp_mult keeps the value of the product. But then it is truncated and
only MSB are assigned to kp_reg. I am wondering what this is happened?
My guess is that it is related to the fixed-point arithmetics and PSR
defines the position of the binary point but I am not sure.