Skip to content

[BUG] Top rounding is incorrect when length rounding causes exp to increase. #24

@joncapltd

Description

@joncapltd

Is there an existing CVA6 bug for this?

  • I have searched the existing bug issues

Bug Description

--- a/cva6_cheri_pkg.sv
+++ b/cva6_cheri_pkg.sv
@@ -832,12 +832,17 @@ package cva6_cheri_pkg;
addrwe2_t lmsk_m_bits = ~(-1 << (exp + 3 + CAP_M_WIDTH - 4)) & ~lmsk_exp_bits;
//addrwe2_t lmsk_m_less_1_bits = ~(-1 << (exp + 3 + CAP_M_WIDTH - 3)) & ~lmsk_exp_bits;
addrwe2_t lmsk_m_less_1_bits = (-1 << (exp + 4)) & lmsk_m_bits;

  •    // Creates mask to check all bits bellow msb(l) = exp + CAP_MW_WIDTH + 1;
    
  •    // in case length_over increases exp.
    
  •    addrwe2_t lmsk_exp_bits_over = ~(-1 << (exp + 4));
       // Check if any of the lsb of len, base and top were lost, i.e., [Einitial+2:0]
       // are all non-zero
       bool_t lost_lsb_len = (new_len & lmsk_exp_bits) != 0 && int_e;
       bool_t lost_lsb_base = (new_base & lmsk_exp_bits) != 0 && int_e;
       bool_t lost_lsb_top = (new_top & lmsk_exp_bits) != 0 && int_e;
       bool_t is_exact = !(lost_lsb_base || lost_lsb_top);
    
  •    // Check lsb of Top for length_over case
    
  •    bool_t lost_lsb_top_over = (new_top & lmsk_exp_bits_over) != 0 && int_e;
       // Check if all mantissa bits above the Einitial+3 are all ones (i.e., length is max)
       bool_t is_len_max = (new_len & (lmsk_m_bits)) == (lmsk_m_bits);
       bool_t is_len_max_less_one = (new_len & (lmsk_m_bits)) == (lmsk_m_less_1_bits);
    

@@ -860,7 +865,7 @@ package cva6_cheri_pkg;
// C = , we need to increase the E
exp = exp + 1;
// Sum one to T if there was a overflow and we lost the 3 lsb bits of T

  •        ret.cap.bounds.top_bits = lost_lsb_top ? new_top_bits_over + 14'b00000000001000
    
  •        ret.cap.bounds.top_bits = lost_lsb_top_over ? new_top_bits_over + 14'b00000000001000
                                                 : new_top_bits_over;
           ret.cap.bounds.base_bits = new_base_bits_over;
       end else begin
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions