fvutils / pyvsc

Python packages providing a library for Verification Stimulus and Coverage
https://fvutils.github.io/pyvsc
Apache License 2.0
113 stars 26 forks source link

Issue with assignment of list of enum types #33

Closed aneels3 closed 4 years ago

aneels3 commented 4 years ago

Hi @mballance I was trying to implement an example for the randomization process like this

import vsc
from enum import Enum, auto 

class Numbers(Enum):
     Zero = 0
     One = auto()
     Two = auto()
     Three = auto()

class more_numbers(Enum):
     Eight = 8
     Nine  = auto()

@vsc.randobj
class parent_0:
    def __init__(self):
        self.count = vsc.rand_enum_t(Numbers)

@vsc.randobj
class parent_1():
    def __init__(self):
        self.list_count = vsc.randsz_list_t(vsc.enum_t(Numbers))

@vsc.randobj
class child_0(parent_0):
    def __init__(self):
        super().__init__()
        self.name = vsc.rand_enum_t(more_numbers)

@vsc.randobj
class child_1(parent_1):
    def __init__(self):
        super().__init__()
        self.child_0_ins = []
        self.length = vsc.uint8_t(10)
    def pre_randomize(self):
        #self.list_count = [None] * self.length
        pass

    def post_randomize(self):
        self.child_0_ins = [None] * 4
        for i in range(3):
           print=("PS: list_count", self.list_count)
           self.child_0_ins[i] = child_0()
           self.child_0_ins[i].count = self.list_count[i]

    @vsc.constraint
    def list_count_size(self):
        self.list_count.size == 10

child_1_ins = child_1()
child_1_ins.randomize()
print("List_Count ", child_1_ins.list_count)

After experimenting with every possibility, I am getting an attribute error as image

I am trying to call the randomize() with the child_1 class instance to update the count variable of parent_0 class with a parent_1 list_count element. I might be missing something here. Can you help me with this issue?

mballance commented 4 years ago

Hi @aneels3, Good catch on this. I actually ran into this issue with another issue report as well. This should be resolved in the 0.1.5 release.

Best Regards, Matthew

aneels3 commented 4 years ago

Thanks for the support @mballance It's working fine now!