Open kangshuo1 opened 5 months ago
I think you need to wrap up self.a as a list_t, which is non-random by default. Then you can append values to it and you'll end up with a list of constant non-random int_t.
import vsc
@vsc.randobj
class my_s(object):
def __init__(self) -> None:
self.a = vsc.list_t(vsc.int_t(8))
for i in range(10):
self.a.append(i)
self.b = vsc.rand_list_t(vsc.rand_int_t(8), 10)
@vsc.constraint
def ab_c1(self):
with vsc.foreach(self.b, idx=True) as i:
with vsc.if_then(i == 0):
self.b[i] == self.a[i]
with vsc.else_then:
self.b[i] == self.b[i-1] + self.a[i]
if __name__ == "__main__":
random1 = my_s()
random1.randomize(debug=False)
print(random1.a)
print(random1.b)
Hi! I encountered the problem of reporting keyerror in the for loop but i don't know why. Here is an exampel.
Output:
I found that this error does not occur when using vsc.foreach and vsc.if_then.
However, the list indices type of vsc.foreach does not support access to ordinary integer lists (self.a)
Do you have any good suggestions to solve this problem? Looking forward to your reply