You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
All the individual blocks are working perfectly now. Thank you for your consideration. I further tried stacking multiple features together. In the example below, there are nested foreach loops which gives an "'expr' object has no attribute '_int_field_info'" syntactical error.
I request you to look into this aspect.
Thank you
import vsc
from vsc import *
import random
# random.seed(3)
level_list = [('level_'+str(level), auto()) for level in range(3)]
level_e = Enum('level', dict(level_list))
@vsc.randobj
class Parent:
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)
@vsc.constraint
def enum_inter_class(self):
with vsc.foreach(self.c1, idx=True) as i:
with vsc.foreach(self.c1[i].a, idx=True) as j:
with vsc.if_then(self.c1[i].a[0].enum_test == level_e.level_0):
self.c2[i].x[0].value == 0
with vsc.else_if(self.c1[i].a[0].enum_test == level_e.level_1):
self.c2[i].x[0].value == 1
with vsc.else_then:
self.c2[i].x[0].value == 2
@vsc.randobj
class Field():
def __init__(self, name, def_value):
self.name = name
self.enum_test = vsc.rand_enum_t(level_e)
self.value = vsc.rand_uint8_t(def_value)
@vsc.randobj
class Child1:
def __init__(self):
self.a = vsc.rand_list_t(vsc.attr(Field('a', 10)))
for i in range(5):
self.a.append(vsc.attr(Field('a', 10)))
self.b = vsc.rand_list_t(vsc.attr(Field('b', 10)))
for i in range(5):
self.b.append(vsc.attr(Field('b', 10)))
#self.enum_test = vsc.rand_enum_t(level_e)
@vsc.constraint
def test_c(self):
self.a[0].value < self.a[1].value
@vsc.randobj
class Child2:
def __init__(self):
self.x = vsc.rand_list_t(vsc.attr(Field('x', 10)))
for i in range(5):
self.x.append(vsc.attr(Field('x', 10)))
self.y = vsc.rand_list_t(vsc.attr(Field('y', 10)))
for i in range(5):
self.y.append(vsc.attr(Field('y', 10)))
@vsc.constraint
def test_c(self):
self.x[0].value < self.x[1].value
inst=Parent()
inst.randomize()
for i in range(10):
inst.randomize()
print(inst.c1[0].a[0].enum_test)
print(inst.c2[0].x[0].value)
print()
print(inst.c1[1].a[0].enum_test)
print(inst.c2[1].x[0].value)
#print(inst.val)
print()
The text was updated successfully, but these errors were encountered:
Hello,
All the individual blocks are working perfectly now. Thank you for your consideration. I further tried stacking multiple features together. In the example below, there are nested foreach loops which gives an "'expr' object has no attribute '_int_field_info'" syntactical error.
I request you to look into this aspect.
Thank you
The text was updated successfully, but these errors were encountered: