def ab_c(self):
                vsc.solve_order(self.a, self.b)

                with vsc.if_then(self.a == 0):
                    self.b == 4
                with vsc.else_then:
                    self.b != 4
Esempio n. 2
0
 def illegal_opcode_c(self):
     vsc.solve_order(self.opcode, self.instr_bin)
     with vsc.if_then(self.exception == illegal_instr_type_e.kIllegalOpcode):
         self.opcode.not_inside(vsc.rangelist(self.legal_opcode))
         self.opcode[1:0] == 3
     with vsc.else_then():
         self.opcode.inside(vsc.rangelist(self.legal_opcode))
Esempio n. 3
0
 def has_func7_c(self):
     vsc.solve_order(self.opcode, self.func7)
     with vsc.if_then((self.opcode == 19) and (self.func3 == 1 or self.func3 == 5) or
                      (self.opcode == 51 or self.opcode == 59)):
         self.has_func7 == 1
     with vsc.else_then():
         self.has_func7 == 0
 def has_func3_c(self):
     vsc.solve_order(self.opcode, self.func7)
     with vsc.if_then(self.opcode == 55 or self.opcode == 111
                      or self.opcode == 23):
         self.has_func3 == 0
     with vsc.else_then():
         self.has_func3 == 1
            def ab_c(self):
                vsc.solve_order(self.b, self.c)
                vsc.solve_order(self.a, self.b)

                self.b < 30                
                self.a < 20
                with vsc.if_then(self.a == 0):
                    self.b < 10
 def addr_c(self):
     vsc.solve_order(self.data_page_id, self.max_load_store_offset)
     vsc.solve_order(self.max_load_store_offset, self.base)
     self.data_page_id < self.max_data_page_id
     with vsc.foreach(self.data_page, idx = True) as i:
         with vsc.if_then(i == self.data_page_id):
             self.max_load_store_offset == self.data_page[i].size_in_bytes
     self.base in vsc.rangelist(vsc.rng(0, self.max_load_store_offset - 1))
Esempio n. 7
0
            def reg_c(self):
                vsc.solve_order(self.num_of_regs, self.reg)
                self.reg.size == self.num_of_regs
                self.offset.size == self.num_of_regs

                with vsc.foreach(self.reg, idx=True) as i:
                    self.reg[i].not_inside(
                        vsc.rangelist(self.reserved_regs, reg_t.A))
                vsc.unique(self.reg)
Esempio n. 8
0
 def rs1_c(self):
     # TODO constraint size with num_of_rs1_reg
     vsc.solve_order(self.num_of_rs1_reg, self.rs1_reg)
     self.rs1_reg.size == 1  # self.num_of_rs1_reg
     self.offset.size == 1  # self.num_of_rs1_reg
     with vsc.foreach(self.rs1_reg, idx = True) as i:
         self.rs1_reg[i].not_inside(vsc.rangelist(cfg.reserved_regs,
                                                  self.reserved_rd, riscv_reg_t.ZERO))
     vsc.unique(self.rs1_reg)
 def reserved_compressed_instr_c(self):
     vsc.solve_order(self.exception, self.reserved_c)
     vsc.solve_order(self.exception, self.opcode)
     vsc.solve_order(self.reserved_c, self.instr_bin)
     vsc.solve_order(self.reserved_c, self.c_msb)
     vsc.solve_order(self.reserved_c, self.c_op)
     with vsc.if_then(self.xlen == 32):
         # c.addiw is RV64/RV128 only instruction, the encoding is used for C.JAL for RV32C
         self.reserved_c != reserved_c_instr_e.kReservedAddiw
     with vsc.if_then(self.exception ==
                      illegal_instr_type_e.kReservedCompressedInstr):
         with vsc.if_then(
                 self.reserved_c == reserved_c_instr_e.kIllegalCompressed):
             self.instr_bin[15:0] == 0
         with vsc.if_then(
                 self.reserved_c == reserved_c_instr_e.kReservedAddispn):
             ((self.instr_bin[15:0] == 0) and (self.c_op == 0))
         with vsc.if_then(
                 self.reserved_c == reserved_c_instr_e.kReservedAddiw):
             ((self.c_msb == 1) and (self.c_op == 1)
              and (self.instr_bin[11:7] == 0))
         with vsc.if_then(
                 self.reserved_c == reserved_c_instr_e.kReservedC0):
             ((self.instr_bin[15:10] == 39) and (self.instr_bin[6:5] == 2)
              and (self.c_op == 1))
         with vsc.if_then(
                 self.reserved_c == reserved_c_instr_e.kReservedC1):
             ((self.instr_bin[15:10] == 39) and (self.instr_bin[6:5] == 3)
              and (self.c_op == 1))
         with vsc.if_then(
                 self.reserved_c == reserved_c_instr_e.kReservedC2):
             ((self.c_msb == 4) and (self.c_op == 0))
         with vsc.if_then(
                 self.reserved_c == reserved_c_instr_e.kReservedAddi16sp):
             ((self.c_msb == 3) and (self.c_op == 1)
              and (self.instr_bin[11:7] == 2) and (not self.instr_bin[12])
              and (self.instr_bin[6:2] == 0))
         with vsc.if_then(
                 self.reserved_c == reserved_c_instr_e.kReservedLui):
             ((self.c_msb == 3) and (self.c_op == 1)
              and (not self.instr_bin[12]) and (self.instr_bin[6:2] == 0))
         with vsc.if_then(
                 self.reserved_c == reserved_c_instr_e.kReservedJr):
             self.instr_bin == 32770
         with vsc.if_then(
                 self.reserved_c == reserved_c_instr_e.kReservedLqsp):
             ((self.c_msb == 1) and (self.c_op == 2)
              and (self.instr_bin[11:7] == 0))
         with vsc.if_then(
                 self.reserved_c == reserved_c_instr_e.kReservedLwsp):
             ((self.c_msb == 2) and (self.c_op == 2)
              and (self.instr_bin[11:7] == 0))
         with vsc.if_then(
                 self.reserved_c == reserved_c_instr_e.kReservedLdsp):
             ((self.c_msb == 3) and (self.c_op == 2)
              and (self.instr_bin[11:7] == 0))
 def illegal_func3_c(self):
     vsc.solve_order(self.opcode, self.func3)
     with vsc.if_then(self.compressed == 0):
         with vsc.if_then(
                 self.exception == illegal_instr_type_e.kIllegalFunc3):
             with vsc.if_then(self.opcode == 103):
                 self.func3 != 0
             with vsc.if_then(self.opcode == 99):
                 self.func3.inside(vsc.rangelist(2, 3))
             with vsc.if_then(self.xlen == 32):
                 with vsc.if_then(self.opcode == 35):
                     self.func3 >= 3
                 with vsc.if_then(self.opcode == 3):
                     self.func3.inside(vsc.rangelist(3, 7))
             with vsc.else_then():
                 with vsc.if_then(self.opcode == 35):
                     self.func3 > 3
                 with vsc.if_then(self.opcode == 3):
                     self.func3 == 7
             with vsc.if_then(self.opcode == 15):
                 self.func3.not_inside(vsc.rangelist(0, 1))
             with vsc.if_then(self.opcode == 115):
                 self.func3 == 4
             with vsc.if_then(self.opcode == 27):
                 self.func3.not_inside(vsc.rangelist(0, 1, 5))
             with vsc.if_then(self.opcode == 59):
                 self.func3.inside(vsc.rangelist(2, 3))
             self.opcode.inside(
                 vsc.rangelist(103, 99, 3, 35, 15, 115, 27, 59))
         with vsc.else_then():
             with vsc.if_then(self.opcode == 103):
                 self.func3 == 0
             with vsc.if_then(self.opcode == 99):
                 self.func3.inside(vsc.rangelist(2, 3))
             with vsc.if_then(self.xlen == 32):
                 with vsc.if_then(self.opcode == 35):
                     self.func3 < 3
                 with vsc.if_then(self.opcode == 3):
                     self.func3.inside(vsc.rangelist(3, 7))
             with vsc.else_then():
                 with vsc.if_then(self.opcode == 35):
                     self.func3 <= 3
                 with vsc.if_then(self.opcode == 3):
                     self.func3 != 7
             with vsc.if_then(self.opcode == 15):
                 self.func3.inside(vsc.rangelist(0, 1))
             with vsc.if_then(self.opcode == 115):
                 self.func3 != 4
             with vsc.if_then(self.opcode == 27):
                 self.func3.inside(vsc.rangelist(0, 1, 5))
             with vsc.if_then(self.opcode == 59):
                 self.func3.not_inside(vsc.rangelist(2, 3))
Esempio n. 11
0
 def legal_loop_regs_c(self):
     self.num_of_nested_loop.inside(vsc.rangelist(1, 2))
     self.loop_limit_reg.size.inside(vsc.rangelist((1, 32)))
     self.loop_cnt_reg.size.inside(vsc.rangelist((1, 8)))
     vsc.solve_order(self.num_of_nested_loop, self.loop_cnt_reg)
     vsc.solve_order(self.num_of_nested_loop, self.loop_limit_reg)
     with vsc.foreach(self.loop_cnt_reg, idx=True) as i:
         self.loop_cnt_reg[i] != riscv_reg_t.ZERO
         with vsc.foreach(cfg.reserved_regs, idx=True) as j:
             self.loop_cnt_reg[i] != cfg.reserved_regs[j]
     with vsc.foreach(self.loop_limit_reg, idx=True) as i:
         with vsc.foreach(cfg.reserved_regs, idx=True) as j:
             self.loop_limit_reg[i] != cfg.reserved_regs[j]
     vsc.unique(self.loop_cnt_reg)
     vsc.unique(self.loop_limit_reg)
     self.loop_cnt_reg.size == self.num_of_nested_loop
     self.loop_limit_reg.size == self.num_of_nested_loop
Esempio n. 12
0
 def instr_bit_assignment_c(self):
     vsc.solve_order(self.opcode, self.instr_bin)
     vsc.solve_order(self.func3, self.instr_bin)
     vsc.solve_order(self.func7, self.instr_bin)
     vsc.solve_order(self.c_msb, self.instr_bin)
     # vsc.solve_order(self.c_op, self.instr_bin)
     with vsc.if_then(self.compressed == 1):
         self.instr_bin[1:0] == self.c_op
         self.instr_bin[15:13] == self.c_msb
     with vsc.else_then():
         self.instr_bin[6:0] == self.opcode
         with vsc.if_then(self.has_func7 == 1):
             self.instr_bin[31:25] == self.func7
         with vsc.if_then(self.has_func3 == 1):
             self.instr_bin[14:12] == self.func3
Esempio n. 13
0
 def reasonable_c(self):
     vsc.solve_order(self.num_amo, self.num_mixed_instr)
     self.num_amo in vsc.rangelist(vsc.rng(1, 10))
     self.num_mixed_instr in vsc.rangelist(vsc.rng(0, self.num_amo))
Esempio n. 14
0
 def loop_c(self):
     vsc.solve_order(self.num_of_nested_loop, self.loop_cnt_reg)
     vsc.solve_order(self.num_of_nested_loop, self.loop_limit_reg)
     self.loop_cnt_reg.size == self.num_of_nested_loop
     self.loop_limit_reg.size == self.num_of_nested_loop
Esempio n. 15
0
 def legal_loop_regs_c(self):
     vsc.solve_order(self.num_of_nested_loop, self.loop_init_val)
     vsc.solve_order(self.num_of_nested_loop, self.loop_step_val)
     vsc.solve_order(self.num_of_nested_loop, self.loop_limit_val)
     vsc.solve_order(self.loop_limit_val, self.loop_limit_reg)
     vsc.solve_order(self.branch_type, self.loop_init_val)
     vsc.solve_order(self.branch_type, self.loop_step_val)
     vsc.solve_order(self.branch_type, self.loop_limit_val)
     self.num_of_instr_in_loop.inside(vsc.rangelist((1, 25)))
     self.num_of_nested_loop.inside(vsc.rangelist(1, 2))
     self.loop_init_val.size == self.num_of_nested_loop
     self.loop_step_val.size == self.num_of_nested_loop
     self.loop_limit_val.size == self.num_of_nested_loop
     self.loop_init_val.size == self.num_of_nested_loop
     self.branch_type.size == self.num_of_nested_loop
     self.loop_step_val.size == self.num_of_nested_loop
     self.loop_limit_val.size == self.num_of_nested_loop
     self.branch_type.size == self.num_of_nested_loop
Esempio n. 16
0
 def num_of_rs1_reg_c(self):
     vsc.solve_order(self.num_amo, self.num_of_rs1_reg)
     self.num_of_rs1_reg in vsc.rangelist(vsc.rng(1, self.num_amo))
     self.num_of_rs1_reg < 5
Esempio n. 17
0
 def init_val_c(self):
     # TODO
     vsc.solve_order(self.init_val_type, self.init_val)
     self.init_val_type.size == 10  # self.num_of_avail_regs
     self.init_val.size == 10  # self.num_of_avail_regs
     self.num_of_instr in vsc.rangelist(vsc.rng(15, 30))
Esempio n. 18
0
 def ab_c(self):
     vsc.solve_order(1, self.b)
     with vsc.if_then(self.a == 0):
         self.b < 10
Esempio n. 19
0
 def my_const(self):
     vsc.solve_order(self.b, self.a)
     self.a.size == self.s
Esempio n. 20
0
 def __init__(self):
     self.a = vsc.rand_uint8_t()
     self.b = vsc.rand_uint8_t()
     vsc.solve_order(self.a, self.b)
Esempio n. 21
0
 def loop_c(self):
     vsc.solve_order(self.num_of_nested_loop, self.loop_init_val)
     vsc.solve_order(self.num_of_nested_loop, self.loop_step_val)
     vsc.solve_order(self.num_of_nested_loop, self.loop_limit_val)
     vsc.solve_order(self.loop_limit_val, self.loop_limit_reg)
     vsc.solve_order(self.branch_type, self.loop_init_val)
     vsc.solve_order(self.branch_type, self.loop_step_val)
     vsc.solve_order(self.branch_type, self.loop_limit_val)
     self.num_of_instr_in_loop.inside(vsc.rangelist((1, 25)))
     self.num_of_nested_loop.inside(vsc.rangelist(1, 2))
     self.loop_init_val.size.inside(vsc.rangelist(1, 2))
     self.loop_step_val.size.inside(vsc.rangelist(1, 2))
     self.loop_limit_val.size.inside(vsc.rangelist(1, 2))
     self.branch_type.size.inside(vsc.rangelist(1, 2))
     self.loop_init_val.size == self.num_of_nested_loop
     self.branch_type.size == self.num_of_nested_loop
     self.loop_step_val.size == self.num_of_nested_loop
     self.loop_limit_val.size == self.num_of_nested_loop
     self.branch_type.size == self.num_of_nested_loop
     with vsc.foreach(self.branch_type, idx=True) as i:
         with vsc.if_then(cfg.disable_compressed_instr == 0):
             self.branch_type[i].inside(
                 vsc.rangelist(
                     riscv_instr_name_t.C_BNEZ, riscv_instr_name_t.C_BEQZ,
                     riscv_instr_name_t.BEQ, riscv_instr_name_t.BNE,
                     riscv_instr_name_t.BLTU, riscv_instr_name_t.BLT,
                     riscv_instr_name_t.BGEU, riscv_instr_name_t.BGE))
         with vsc.else_then():
             self.branch_type[i].inside(
                 vsc.rangelist(riscv_instr_name_t.BEQ,
                               riscv_instr_name_t.BNE,
                               riscv_instr_name_t.BLTU,
                               riscv_instr_name_t.BLT,
                               riscv_instr_name_t.BGEU,
                               riscv_instr_name_t.BGE))
     with vsc.foreach(self.loop_init_val, idx=True) as i:
         with vsc.if_then(self.branch_type[i].inside(
                 vsc.rangelist(riscv_instr_name_t.C_BNEZ,
                               riscv_instr_name_t.C_BEQZ))):
             self.loop_limit_val[i] == 0
             self.loop_limit_reg[i] == riscv_reg_t.ZERO
             self.loop_cnt_reg[i].inside(vsc.rangelist(compressed_gpr))
         with vsc.else_then:
             self.loop_limit_val[i].inside(vsc.rangelist((-20, 20)))
             self.loop_limit_reg[i] != riscv_reg_t.ZERO
         with vsc.if_then(self.branch_type[i].inside(
                 vsc.rangelist(riscv_instr_name_t.C_BNEZ,
                               riscv_instr_name_t.C_BEQZ,
                               riscv_instr_name_t.BEQ,
                               riscv_instr_name_t.BNE))):
             self.loop_limit_val[i] != self.loop_init_val[i]
             ((self.loop_limit_val[i] - self.loop_init_val[i]) %
              self.loop_step_val[i]) == 0
         with vsc.else_if(self.branch_type[i] == riscv_instr_name_t.BGE):
             self.loop_step_val[i] < 0
         with vsc.else_if(self.branch_type[i].inside(
                 vsc.rangelist(riscv_instr_name_t.BGEU))):
             self.loop_step_val[i] < 0
             self.loop_init_val[i] > 0
             # Avoid count to negative
             (self.loop_step_val[i] + self.loop_limit_val[i]) > 0
         with vsc.else_if(self.branch_type[i] == riscv_instr_name_t.BLT):
             self.loop_step_val[i] > 0
         with vsc.else_if(self.branch_type[i] == riscv_instr_name_t.BLTU):
             self.loop_step_val[i] > 0
             self.loop_limit_val[i] > 0
         self.loop_init_val[i].inside(vsc.rangelist((-10, 10)))
         self.loop_step_val[i].inside(vsc.rangelist((-10, 10)))
         with vsc.if_then(self.loop_init_val[i] < self.loop_limit_val[i]):
             self.loop_step_val[i] > 0
         with vsc.else_then:
             self.loop_step_val[i] < 0
Esempio n. 22
0
 def ab_c(self):
     with vsc.if_then(self.a < self.b):
         self.b == 10
         vsc.solve_order(self.a, self.b)                
Esempio n. 23
0
 def a_c1(self):
     vsc.solve_order(self.a, self.value)
     vsc.solve_order(self.b, self.value)
Esempio n. 24
0
 def ab_c(self):
     vsc.solve_order(self.a, self.b)
     self.a < self.b
     with vsc.if_then(self.a == 0):
         self.b < 10
Esempio n. 25
0
 def sp_rnd_order_c(self):
     vsc.solve_order(self.use_sp_as_rs1, self.rs1_reg)