Comments (4)
Hi @ShraddhaDevaiya,
In order to use an expression in a constraint (eg in vsc.if_then), at least one element in the expression needs to be a vsc variable. Several of the variables in the class are non-vsc variables, so expressions evaluate to a constant when the constraint is constructed. The vast majority of the time, this behavior is undesirable in the context of constraints because the constraint is effectively eliminated.
The error message, unfortunately, is not very helpful. I'll look to see whether this can be improved.
Would it work to use vsc variables for has_rs1, has_rs2, format, etc? The constraints would be properly constructed in this case.
Best Regards,
Matthew
from pyvsc.
Yeah, I have tried that way, has_rs1, has_rs2, format as a vsc variables.
@vsc.randobj
class my_sub_s(object):
def __init__(self):
self.has_rs1 = vsc.uint8_t(1)
self.has_rs2 = vsc.uint8_t(1)
self.has_rd = vsc.uint8_t(1)
self.avail_regs = vsc.rand_list_t(vsc.uint8_t(0), 10)
self.reserved_rd = vsc.rand_list_t(vsc.uint8_t(0), 10)
self.reserved_regs = vsc.rand_list_t(vsc.uint8_t(0), 10)
self.rd = vsc.rand_uint8_t(0)
self.rs1 = vsc.rand_uint8_t(0)
self.rs2 = vsc.rand_uint8_t(0)
self.format = vsc.uint8_t(2)
obj = my_sub_s()
with obj.randomize_with() as it:
with vsc.if_then(obj.avail_regs.size > 0):
with vsc.if_then(obj.has_rs1):
obj.rs1.inside(vsc.rangelist(obj.avail_regs))
with vsc.if_then(obj.has_rs2):
obj.rs2.inside(vsc.rangelist(obj.avail_regs))
with vsc.if_then(obj.has_rd):
obj.rd.inside(vsc.rangelist(obj.avail_regs))
with vsc.foreach(obj.reserved_rd, idx = True) as i:
with vsc.if_then(obj.has_rd):
obj.rd != obj.reserved_rd[i]
with vsc.if_then(obj.format == 2):
obj.rs1 != obj.reserved_rd[i]
with vsc.foreach(obj.reserved_regs, idx = True) as i:
with vsc.if_then(obj.has_rd):
obj.rd != obj.reserved_regs[i]
with vsc.if_then(obj.format == 2):
obj.rs1 != obj.reserved_regs[i]
But then also it is giving an error like following:
Traceback (most recent call last):
File "9usecase.py", line 36, in <module>
obj.rs1 != obj.reserved_regs[i]
File "/home/adduser/.local/lib/python3.8/site-packages/vsc/rand_obj.py", line 186, in __exit__
Randomizer.do_randomize([model], [c])
File "/home/adduser/.local/lib/python3.8/site-packages/vsc/model/randomizer.py", line 694, in do_randomize
constraint_l.extend(ArrayConstraintBuilder.build(
File "/home/adduser/.local/lib/python3.8/site-packages/vsc/visitors/array_constraint_builder.py", line 45, in build
m.accept(builder)
File "/home/adduser/.local/lib/python3.8/site-packages/vsc/model/constraint_block_model.py",
line 42, in accept
v.visit_constraint_block(self)
File "/home/adduser/.local/lib/python3.8/site-packages/vsc/visitors/constraint_copy_builder.py", line 85, in visit_constraint_block
super().visit_constraint_block(c)
File "/home/adduser/.local/lib/python3.8/site-packages/vsc/model/model_visitor.py", line 102, in visit_constraint_block
self.visit_constraint_scope(c)
File "/home/adduser/.local/lib/python3.8/site-packages/vsc/visitors/constraint_override_visitor.py", line 26, in visit_constraint_scope
cc.accept(self)
File "/home/adduser/.local/lib/python3.8/site-packages/vsc/model/constraint_foreach_model.py", line 47, in accept
v.visit_constraint_foreach(self)
File "/home/adduser/.local/lib/python3.8/site-packages/vsc/visitors/array_constraint_builder.py", line 61, in visit_constraint_foreach
self.override_constraint(scope)
File "/home/adduser/.local/lib/python3.8/site-packages/vsc/visitors/constraint_override_visitor.py", line 37, in override_constraint
self.scope_s[-1].constraint_l[self.scope_i],
IndexError: list index out of range
What can I do for this ?
Thanks & Regards,
Shraddha Devaiya.
from pyvsc.
Hi @ShraddhaDevaiya,
Okay, thanks for confirming, and thanks for the testcase. I'm investigating now and will let you know what I find.
Best Regards,
Matthew
from pyvsc.
Hi @ShraddhaDevaiya,
The testcase was very helpful. It turns out there was an issue with nesting and combining if_then and foreach in certain ways. I've corrected the issue and your testcase (now part of the test suite) now passes. Release 0.2.6 contains the fix.
Thanks and Best Regards,
Matthew
from pyvsc.
Related Issues (20)
- PicklingError when trying to pickle a VSC randobj HOT 2
- What is the relation between pyvsc and portable stimulus (pss)? HOT 2
- how to print coverage model HOT 3
- pyvsc performance dominated by stack frame operations in inspect module HOT 1
- import error _boolector_add
- Enh: Support Default bin (How to write "default" in vsc.coverpoint ?)
- install error for latest version macos HOT 3
- support for function incur in constraint functions HOT 5
- constraint solver error HOT 1
- Installing pyvsc fails on pyboolector for python 3.11.5 on Linux (Arch) HOT 3
- Distributions have higher priority than soft constraints HOT 1
- I can't install pyvsc for pypy3.10! HOT 4
- not_inside constraint unexpectedly reducing output set significantly HOT 1
- Is there an example of pyvsc integrated with cocotb and SV RTL with a simulator? HOT 2
- Solve order of randsz_list_t size constraints within foreach incorrect [v0.8.8] HOT 5
- randsz_list_t: Placing the sum constraint before the size constraints can result in incorrect sums [v0.8.8]
- solve before is solve_order, but document marks it as not supported HOT 1
- Can't see vsc after installing pyvsc
- PyVSC to give exhaustive list of stimulus
- Set values on randobj and check if it satisfies the constraints 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.