Pyvsc: Systemverilog-Style Constraints, and Coverage in Python
Pyvsc: Systemverilog-Style Constraints, and Coverage in Python
Pyvsc: Systemverilog-Style Constraints, and Coverage in Python
Coverage in Python
M. Ballance
Milwaukie, OR, USA
matt.ballance@gmail.com
@vsc.constraint @vsc.constraint
def ab_c(self): def ab_c(self):
self.a < self.b self.a < self.b
@vsc.constraint
def ab_c(self): Feature SystemVerilog PyVSC
with vsc.if_then(self.a == 1): Algebraic constraints Y Y
self.b == 1 Integer fields Y Y
with vsc.else_if(self.a == 2): Enum fields Y Y
self.b == 2
with vsc.else_if(self.a == 3): Fixed-size arrays Y Y
self.b == 4 Variable-size arrays Y Y
with vsc.else_if(self.a == 4): dist constraint Y Y
self.b == 8
with vsc.else_if(self.a == 5):
soft constraint Y Y
self.b == 16 inside constraint Y Y
solve ordering Y Y
Figure 2 - If/else Constraints unique constraint Y Y
foreach constraint Y Y
The difference between Python statements and PyVSC
constraint_mode Y Y
constraints is most visible when control-flow constraints are
used, as shown in Figure 2. In these cases, Python statements rand_mode Y Y
cannot be used directly. It is necessary to use the PyVSC- if/else constraint Y Y
provided construct to capture the constraint intent. Figure 4 - Supported Constraint Statements
Just as with SystemVerilog, constraint blocks are considered C. Randomizing a Data Field
virtual, in that a same-named constraint in a sub-class overrides PyVSC randomziable classes have randomize and
the constraint in the super-class. randomize_with methods that are used for randomizing fields
within that class.
@vsc.randobj @vsc.covergroup
class my_base_s(object): class my_covergroup(object):