Пример #1
0
     def __init__(self):
         super().__init__()
         # Not used in a constraint
         self.nc_one = vsc.rand_uint16_t()
         self.nc_two = vsc.rand_uint16_t()
 
         # Used in a constraint
         self.con_one = vsc.rand_uint16_t()
         self.con_two = vsc.rand_uint16_t()
Пример #2
0
 def __init__(self):
     self.chksz = vsc.rand_uint8_t()
     self.totsz = vsc.rand_uint16_t()
     self.inc_src = vsc.rand_bit_t(i=1)
     self.inc_dst = vsc.rand_bit_t(i=1)
     self.src_addr = 0
     self.dst_addr = 0
Пример #3
0
 def __init__(self, cfg):
     self.cfg = cfg
     self.max_data_page_id = vsc.int32_t()
     self.load_store_shared_memory = False
     self.kernel_mode = False
     self.data_page = vsc.list_t(region_c())
     self.data_page_id = vsc.rand_uint16_t()
     self.max_load_store_offset = vsc.rand_uint32_t()
Пример #4
0
            def __init__(self):
                self.id = 0
                self.c1 = vsc.rand_list_t(vsc.attr(Child1()))
                for i in range(10):
                    self.c1.append(vsc.attr(Child1()))

                self.c2 = vsc.rand_list_t(vsc.attr(Child2()))
                for i in range(10):
                    self.c2.append(vsc.attr(Child2()))

                self.val = vsc.rand_uint16_t(5)
Пример #5
0
    def test_distweight(self):
        PCID = vsc.rand_uint16_t()
        
        hist1 = [0]*65536
        hist2 = [0]*65536

        items = 10000
        for i in range(items):
#            vsc.randomize(PCID)
            with vsc.randomize_with(PCID, debug=0):
#                PCID.inside(vsc.rng(1,65534))
                vsc.dist(PCID, [
                    vsc.weight(0, 1),
                    vsc.weight(vsc.rng(1,65534), 900),
                    vsc.weight(65535, 1)
                    ])
#            print("PCID: " + str(PCID.get_val()))
            hist1[PCID.get_val()] += 1 
            hist2[random.randint(1,65534)] += 1

        hist1_hit = 0
        hist2_hit = 0
        for e in hist1[1:65534]:
            if e != 0:
                hist1_hit += 1
        for e in hist2[1:65534]:
            if e != 0:
                hist2_hit += 1

        print("Items: %d hist1=%f hist2=%f" % (items, hist1_hit/65534, hist2_hit/65534))

        # Only check deeper if full random actually hit more than weighted
        if hist1_hit > hist2_hit:
            # Fail if plain randomization hit 15% more than weighted
            hist1_15p = int(hist1_hit * 0.15)
            self.assertLessEqual((hist1_hit-hist2_hit), hist1_15p)
Пример #6
0
 def __init__(self):
     self.available = vsc.rangelist((0, 19), (30, 49))
     self.selectedList = vsc.rand_list_t(vsc.rand_uint16_t(), 5)
Пример #7
0
 def __init__(self):
     self.a = vsc.rand_uint32_t()
     self.b = vsc.rand_uint16_t()
Пример #8
0
    def test_standalone_setpart(self):
        a = vsc.rand_uint16_t()

        a[15:8] = 1
        
        self.assertEqual(a.val, (1 << 8))
Пример #9
0
    def test_standalone_setbit(self):
        a = vsc.rand_uint16_t()

        a[15] = 1
        
        self.assertEqual(a.val, (1 << 15))
Пример #10
0
    def test_standalone_getpart(self):
        a = vsc.rand_uint16_t()

        a.val = (25 << 8)
        
        self.assertEqual(a[15:8], 25)
Пример #11
0
    def test_standalone_getbit(self):
        a = vsc.rand_uint16_t()

        a.val = (1 << 15)
        
        self.assertEqual(a[15], 1)
Пример #12
0
 def __init__(self):
     super().__init__()
     self.c = vsc.rand_uint16_t()