Search code examples
verilogfpgasystem-verilogvivado

Concatenated vector is truncated in synthesis


In attempting to concatenate a 32-bit floating point vector for a linear function shift register all goes well in behavioral simulation. However, in post-synthesis the "random_float" net has been truncated to 31 bits. It seems the "sign" is getting ignored. Any ideas?

logic       [7:0]   exponent_seed      =   8'b01100101;
logic       [22:0]  mantissa_seed      =   23'b01001011101011110010100;
logic       [31:0]  random_float       =   32'b00000000000000000000000000000000;
logic       [7:0]   exponent           =   exponent_seed;
logic       [22:0]  mantissa           =   mantissa_seed;
logic               sign               =   1'b0;  

wire                exponent_feedback  =   exponent[7] ^ exponent[5] ^ exponent[4] ^ exponent[3];

always @ (exponent or mantissa or sign)
    begin
        random_float <= {sign, exponent, mantissa};
    end

 always @ (posedge clk or posedge reset)
    begin
        if (reset)
            begin
                exponent        <= exponent_seed;
                mantissa        <= mantissa_seed;
            end
         else
            begin
                //use concatenation to shift and feed the vector.
                exponent <= {exponent[6:0], exponent_feedback};
                mantissa <= {mantissa[21:0], mantissa_feedback};
            end
    end        

PS i've only included what i believe to be the relevant code.


Solution

  • For posterity the following prevents synthesis from optimizing out constants:

    (*KEEP = "TRUE"*) logic       [31:0]  random_float       =   32'b00000000000000000000000000000000;