Comments (3)
Hi @ShraddhaDevaiya,
You'll need to make two changes to make this work:
-
Change from using rand_list_t to using randsz_list_t
-
Add a constraint on the size of the list
Randomizing a rand_list_t just randomizes the elements already in the list. In your case, there are no elements. Your example should work when written as follows:
import vsc
@vsc.randobj
class my_s(object):
def __init__(self):
super().__init__()
self.num_of_nested_loop = vsc.rand_bit_t(8)
self.loop_init_val = vsc.randsz_list_t(vsc.uint8_t())
@vsc.constraint
def ab_con(self):
self.num_of_nested_loop.inside(vsc.rangelist(1,2))
self.loop_init_val.size.inside(vsc.rangelist(1,2))
self.loop_init_val.size == self.num_of_nested_loop;
item = my_s()
for i in range(5):
item.randomize()
print("A = ",item.num_of_nested_loop,", B = ",item.loop_init_val)
Best Regards,
Matthew
from pyvsc.
Yeah it is working this way. Thanks for helping !
Regards,
Shraddha Devaiya.
from pyvsc.
Hi @mballance ,
One more issue I am facing in this case is like, it is iterating or randomizing every time with fix numbers. Like following is the code :
import vsc
@vsc.randobj
class my_s(object):
def __init__(self):
super().__init__()
self.num_of_nested_loop = vsc.rand_bit_t(8)
self.loop_init_val = vsc.randsz_list_t(vsc.uint8_t())
@vsc.constraint
def ab_con(self):
self.num_of_nested_loop.inside(vsc.rangelist(1,2))
self.loop_init_val.size.inside(vsc.rangelist(1,2))
self.loop_init_val.size == self.num_of_nested_loop
item = my_s()
for i in range(3):
item.randomize()
print("A = ",item.num_of_nested_loop,", B = ",item.loop_init_val)
So, for this we should get 3 prints , but every time it is giving an output like this for any value of range() :
A = 1 , B = [100]
A = 2 , B = [126, 210]
A = 1 , B = [184]
A = 1 , B = [204]
A = 2 , B = [7, 189]
A = 1 , B = [6]
A = 2 , B = [33, 71]
A = 1 , B = [219]
A = 2 , B = [61, 59]
A = 1 , B = [39]
A = 1 , B = [129]
A = 1 , B = [208]
A = 1 , B = [164]
Can you please help in this ?
Thanks & Regards,
Shraddha Devaiya.
from pyvsc.
Related Issues (20)
- vsc.model.solve_failure.SolveFailure: solve failure [randomly] in riscv-dv
- Adding riscv-dv PyFlow to the PyVSC regression list.
- Note:variable bounds model failed to converge in 100 iterations HOT 2
- Passing type of object rather object in isinstance(object,type) method in to_expr(t) function in vsc.types HOT 5
- rand_int8_t with negative maximum can not be randomized HOT 1
- Supporting inheritance in PyVSC HOT 2
- Performance impart using wilcard bins HOT 4
- Random distribution of 2-variable constraints not uniform HOT 5
- Sampling spams unhelpful messages HOT 1
- Dynamic constraints combined with 'soft' constraining HOT 1
- windows10 install pyboolector failed HOT 4
- Can't have a randsz_list_t of randobj HOT 1
- ModuleNotFoundError: No module named 'pyboolector' HOT 10
- I'm not able to install pyvsc package, it fails when handling the pyboolector module HOT 3
- Selecting a list element from a list of bit-vectors returns an int HOT 3
- Setting constraint_mode to False retains the previous range/bounds of the constraint HOT 1
- Cannot make constraint under if_then soft HOT 13
- Cannot use random value as list index in a constraint HOT 2
- PicklingError when trying to pickle a VSC randobj HOT 2
- What is the relation between pyvsc and portable stimulus (pss)? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyvsc.