API Reference

Domain-Specific Language API

Data and Constraints

vsc.attrs.attr(t)[source]

Wraps a recognized datatype as a non-rand field

vsc.attrs.rand_attr(t)[source]

Wraps a VSC datatype, or recognized datatype, as a rand field

class vsc.constraints.constraint_t(c)[source]
constraint_mode(en)[source]
set_model(m)[source]
elab()[source]
class vsc.constraints.dynamic_constraint_t(c)[source]
set_model(m)[source]
class call_closure(c, *args, **kwargs)[source]
vsc.constraints.dynamic_constraint(c)[source]
vsc.constraints.constraint(c)[source]
class vsc.constraints.weight(val, w)[source]
vsc.constraints.dist(lhs, weights)[source]

Applies distribution weights to the specified field

class vsc.constraints.if_then(e)[source]
class vsc.constraints.else_if(e)[source]
class vsc.constraints.else_then_c[source]
class vsc.constraints.implies(e)[source]
vsc.constraints.soft(e)[source]
vsc.constraints.unique(*args)[source]
class vsc.constraints.forall(target_type)[source]
class vsc.constraints.foreach(l, it=None, idx=None)[source]
class idx_term_c(index)[source]
to_expr()[source]
class it_term_c(em)[source]
to_expr()[source]
vsc.constraints.solve_order(before, after)[source]
vsc.rand_obj.randobj(*args, **kwargs)[source]
vsc.rand_obj.generator(T)[source]

Mark a class as a generator

vsc.types.unsigned(v, w=-1)[source]
vsc.types.signed(v, w=-1)[source]
class vsc.types.expr(em)[source]
bin_expr(op, rhs)[source]
inside(rhs)[source]
outside(rhs)[source]
not_inside(rhs)[source]
class vsc.types.dynamic_constraint_proxy(em)[source]
class vsc.types.expr_subscript(em)[source]
class vsc.types.rng(low, high)[source]
class vsc.types.rangelist(*args)[source]
clear()[source]
extend(ranges)[source]
append(a)[source]
vsc.types.to_expr(t)[source]
class vsc.types.field_info(is_composite=False)[source]

Model-specific information about the field

set_is_rand(is_rand)[source]
class vsc.types.type_base(width, is_signed, i=0)[source]

Base type for all primitive-type fields that participate in constraints

get_model()[source]
build_field_model(name)[source]
to_expr()[source]
property rand_mode
property val
get_val()[source]
set_val(val)[source]
bin_expr(op, rhs)[source]
inside(rhs)[source]
outside(rhs)[source]
not_inside(rhs)[source]
clone()[source]
class vsc.types.type_bool(i=False)[source]

Base class for boolean fields

build_field_model(name)[source]
get_val()[source]

Gets the field value

set_val(val)[source]

Sets the field value

class vsc.types.type_enum(t, i=None)[source]

Base class for enumerated-type fields

build_field_model(name)[source]
get_val()[source]

Returns the enum id

set_val(val)[source]

Sets the enum id

class vsc.types.enum_t(t, i=None)[source]

Creates a non-random enumerated-type attribute

class vsc.types.rand_enum_t(t, i=None)[source]

Creates a random enumerated-type attribute

class vsc.types.bit_t(w=1, i=0)[source]

Creates an unsigned arbitrary-width attribute

class vsc.types.bool_t(i=False)[source]

Creates a boolean field

class vsc.types.uint8_t(i=0)[source]

Creates an unsigned 8-bit attribute

class vsc.types.uint16_t(i=0)[source]

Creates an unsigned 16-bit attribute

class vsc.types.uint32_t(i=0)[source]

Creates an unsigned 32-bit attribute

class vsc.types.uint64_t(i=0)[source]

Creates an unsigned 64-bit attribute

class vsc.types.rand_bit_t(w=1, i=0)[source]

Creates a random unsigned arbitrary-width attribute

class vsc.types.rand_uint8_t(i=0)[source]

Creates a random unsigned 8-bit attribute

class vsc.types.rand_uint16_t(i=0)[source]

Creates a random unsigned 16-bit attribute

class vsc.types.rand_uint32_t(i=0)[source]

Creates a random unsigned 32-bit attribute

class vsc.types.rand_uint64_t(i=0)[source]

Creates a random unsigned 64-bit attribute

class vsc.types.int_t(w=32, i=0)[source]

Creates a signed arbitrary-width attribute

class vsc.types.int8_t(i=0)[source]

Creates a signed 8-bit attribute

class vsc.types.int16_t(i=0)[source]

Creates a signed 16-bit attribute

class vsc.types.int32_t(i=0)[source]

Creates a signed 32-bit attribute

class vsc.types.int64_t(i=0)[source]

Creates a signed 64-bit attribute

class vsc.types.rand_int_t(w=32, i=0)[source]

Creates a random signed arbitrary-width attribute

class vsc.types.rand_int8_t(i=0)[source]

Creates a random signed 8-bit attribute

class vsc.types.rand_int16_t(i=0)[source]

Creates a random signed 16-bit attribute

class vsc.types.rand_int32_t(i=0)[source]

Creates a random signed 32-bit attribute

class vsc.types.rand_int64_t(i=0)[source]

Creates a random signed 64-bit attribute

class vsc.types.list_t(t, sz=0, is_rand=False, is_randsz=False, init=None)[source]
get_model()[source]
build_field_model(name)[source]
property size
property sum
property product
append(v)[source]
extend(v)[source]
clear()[source]
to_expr()[source]
class vsc.types.rand_list_t(t, sz=0)[source]

List of random elements with a non-random size

class vsc.types.randsz_list_t(t)[source]

List of random elements with a random size

Data and Constraints

vsc.coverage.covergroup(T)[source]

Covergroup decorator marks as class as being a covergroup

class vsc.coverage.bin(*args)[source]

Specifies a single coverage bin

build_cov_model(parent, name, exclude_bins: RangelistModel)[source]
class vsc.coverage.bin_array(nbins, *args)[source]

Specifies an array of bins

args may be one of two formats - Single list of tuples or lists of values or ranges (eg [[1], [2,4], [8]]) - Arguments comprising values and ranges (eg 1, [2,4], 8)

build_cov_model(parent, name, exclude_bins: RangelistModel)[source]
class vsc.coverage.wildcard_bin(*args)[source]

Specifies a single wildcard coverage bin

build_cov_model(parent, name, excluded_bins)[source]
class vsc.coverage.wildcard_bin_array(nbins, *args)[source]

Specifies an array of bins using wildcard specifications

args may be one of two formats - Single list of wildcard strings (eg “0x82x”) - Single list of value/mask tuples (eg [(0x820,0xFF0)]) - Single string - Single tuple

build_cov_model(parent, name, excluded_bins)[source]
class vsc.coverage.binsof(cp)[source]
intersect(rng)[source]
class vsc.coverage.coverpoint(target, cp_t=None, iff=None, bins=None, ignore_bins=None, illegal_bins=None, options=None, type_options=None, name=None)[source]
get_coverage()[source]
get_inst_coverage()[source]
build_cov_model(parent, name)[source]
get_model()[source]
get_val(cp_m)[source]
set_val(val)[source]
class vsc.coverage.cross(target_l, bins=None, options=None, name=None, iff=None)[source]
build_cov_model(parent, name)[source]
get_coverage()[source]

Model API

Data and constraints

class vsc.model.field_composite_model.FieldCompositeModel(name, is_rand=False, rand_if=None)[source]
finalize()[source]
property is_declared_rand
set_used_rand(is_rand, level=0)[source]
build(builder)[source]
add_field(f) FieldModel[source]
get_field(idx)[source]
set_field(idx, f)[source]
find_field(name)[source]
add_constraint(c)[source]
get_constraint(name)[source]
add_dynamic_constraint(c)[source]
get_constraints(constraint_l)[source]
get_fields(field_l)[source]
pre_randomize()[source]

Called during the randomization process to propagate pre_randomize event

post_randomize()[source]

Called during the randomization process to propagate post_randomize event

accept(v)[source]
dispose()[source]
class vsc.model.constraint_block_model.ConstraintBlockModel(name, constraints=None)[source]

Information about a top-level constraint block described by the user

set_constraint_enabled(en)[source]
accept(v)[source]
clone(deep=False) ConstraintModel[source]
class vsc.model.constraint_expr_model.ConstraintExprModel(e)[source]
build(btor, soft=False)[source]
accept(visitor)[source]
clone(deep=False) ConstraintModel[source]
class vsc.model.constraint_if_else_model.ConstraintIfElseModel(cond: ExprModel, true_c: Optional[ConstraintScopeModel] = None, false_c: Optional[ConstraintScopeModel] = None)[source]
build(btor, soft=False)[source]
accept(visitor)[source]
clone(deep=False) ConstraintModel[source]
class vsc.model.constraint_implies_model.ConstraintImpliesModel(cond, constraints=None)[source]
build(btor, soft=False)[source]
get_nodes(node_l)[source]
accept(visitor)[source]
clone(deep=False) ConstraintModel[source]
class vsc.model.constraint_model.ConstraintModel[source]

Base class for all constraint models

dispose()[source]
build(btor, soft=False) BoolectorNode[source]
get_nodes(node_l)[source]
static and_nodelist(node_l, btor)[source]

Creates a boolean AND across a list of expression nodes

accept(visitor)[source]
clone(deep=False) ConstraintModel[source]
class vsc.model.constraint_scope_model.ConstraintScopeModel(constraints=None)[source]
addConstraint(c) ConstraintModel[source]
build(btor, soft=False)[source]
get_nodes(node_l)[source]
accept(visitor)[source]
clone(deep=False) ConstraintModel[source]
class vsc.model.constraint_unique_model.ConstraintUniqueModel(unique_l)[source]
build(btor, soft=False)[source]
get_nodes(node_l)[source]
accept(visitor)[source]
clone(deep=False) ConstraintModel[source]

Coverage

class vsc.model.covergroup_model.CovergroupModel(name: str, options=None)[source]
finalize()[source]
sample()[source]
add_coverpoint(cp)[source]
get_coverage()[source]
coverage_ev(cp, bin_idx)[source]
get_inst_coverage()[source]
accept(v)[source]
dump(ind='')[source]
equals(oth: CovergroupModel) bool[source]
clone() CovergroupModel[source]
class vsc.model.covergroup_registry.CovergroupRegistry[source]
accept(v)[source]
static inst()[source]
class vsc.model.coverpoint_bin_array_model.CoverpointBinArrayModel(name, low, high)[source]
finalize(bin_idx_base: int) int[source]

Accepts the bin index where this bin starts ; returns number of bins

get_bin_expr(idx)[source]

Builds expressions to represent a single bin

get_bin_name(bin_idx)[source]
sample()[source]
dump(ind='')[source]
get_bin_range(bin_idx)[source]
get_n_bins()[source]
hit_idx()[source]
accept(v)[source]
equals(oth)[source]
clone() CoverpointBinArrayModel[source]
class vsc.model.coverpoint_bin_collection_model.CoverpointBinCollectionModel(name)[source]
DEBUG_EN = False
finalize(bin_idx_base: int) int[source]

Accepts the bin index where this bin starts ; returns number of bins

get_bin_expr(idx)[source]

Builds expressions to represent the values in this bin

get_bin_name(idx)[source]
add_bin(bin_m) CoverpointBinModelBase[source]
get_coverage()[source]
sample()[source]
get_bin_range(idx)[source]
dump(ind='')[source]
get_hits(idx)[source]
get_n_bins()[source]
hit_idx()[source]
set_bin_type(bin_type)[source]
accept(v)[source]
equals(oth) bool[source]
clone() CoverpointBinCollectionModel[source]
static mk_collection(name: str, rangelist: RangelistModel, n_bins) CoverpointBinCollectionModel[source]

Creates a bin collection by partitioning a rangelist

class vsc.model.coverpoint_bin_enum_model.CoverpointBinEnumModel(name, val)[source]
finalize(bin_idx_base: int) int[source]

Accepts the bin index where this bin starts ; returns number of bins

get_bin_name(bin_idx)[source]
sample()[source]
accept(v)[source]
equals(oth) bool[source]
clone() CoverpointBinEnumModel[source]
class vsc.model.coverpoint_bin_model_base.CoverpointBinModelBase(name)[source]
finalize(bin_idx_base: int) int[source]

Accepts the bin index where this bin starts ; returns number of bins

get_bin_expr(idx)[source]
get_bin_name(bin_idx)[source]
sample()[source]
get_n_bins()[source]
hit_idx()[source]
set_bin_type(bin_type)[source]
equals(oth)[source]
class vsc.model.coverpoint_bin_single_bag_model.CoverpointBinSingleBagModel(name, binspec: Optional[RangelistModel] = None)[source]

Coverpoint single bin that is triggered on a set of values or value ranges

finalize(bin_idx_base: int) int[source]

Accepts the bin index where this bin starts ; returns number of bins

get_bin_expr(bin_idx)[source]

Builds expressions to represent the values in this bin

get_bin_name(bin_idx)[source]
sample()[source]
dump(ind='')[source]
accept(v)[source]
equals(oth) bool[source]
clone() CoverpointBinSingleBagModel[source]
class vsc.model.coverpoint_bin_single_range_model.CoverpointBinSingleRangeModel(name, target_val_low: int, target_val_high: int)[source]
finalize(bin_idx_base: int) int[source]

Accepts the bin index where this bin starts ; returns number of bins

get_bin_expr(bin_idx)[source]

Builds expressions to represent the values in this bin

get_bin_name(bin_idx)[source]
sample()[source]
accept(v)[source]
equals(oth) bool[source]
clone() CoverpointBinSingleRangeModel[source]
class vsc.model.coverpoint_bin_single_val_model.CoverpointBinSingleValModel(name, target_val: int)[source]
finalize(bin_idx_base: int) int[source]

Accepts the bin index where this bin starts ; returns number of bins

get_bin_expr(bin_idx)[source]

Builds expressions to represent the values in this bin

get_bin_name(bin_idx)[source]
sample()[source]
get_bin_range(idx)[source]
accept(v)[source]
equals(oth) bool[source]
clone() CoverpointBinSingleValModel[source]
class vsc.model.coverpoint_cross_model.CoverpointCrossModel(name, options, iff=None)[source]
set_target_value_cache(iff)[source]
reset()[source]
coverpoints()[source]
get_coverage()[source]
get_n_bins()[source]
get_bin_expr(bin_idx: int) ExprModel[source]
select_unhit_bin(r: RandIF) int[source]
get_bin_hits(bin_idx)[source]
get_bin_name(bin_idx) str[source]
add_coverpoint(cp_m)[source]
finalize()[source]
accept(v)[source]
sample()[source]
dump(ind='')[source]
equals(oth: CoverpointCrossModel) bool[source]
clone(coverpoint_m) CoverpointCrossModel[source]
class vsc.model.coverpoint_model.CoverpointModel(target: ExprModel, name: str, options, iff: Optional[ExprModel] = None)[source]
set_target_value_cache(val, iff=True)[source]
reset()[source]
add_bin_model(bin_m)[source]
add_ignore_bin_model(bin_m)[source]
add_illegal_bin_model(bin_m)[source]
finalize()[source]
get_bin_expr(bin_idx)[source]
get_coverage() float[source]
get_inst_coverage()[source]
sample()[source]
select_unhit_bin(r: RandIF) int[source]
get_bin_range(bin_idx) RangelistModel[source]
coverage_ev(bin_idx, bin_type)[source]

Called by a bin to signal that an uncovered bin has been covered

get_val()[source]
accept(v)[source]
dump(ind='')[source]
get_n_bins()[source]
get_n_ignore_bins()[source]
get_n_illegal_bins()[source]
get_n_hit_bins()[source]
get_bin_hits(bin_idx)[source]
get_ignore_bin_hits(bin_idx)[source]
get_illegal_bin_hits(bin_idx)[source]
get_bin_name(bin_idx) str[source]
get_ignore_bin_name(bin_idx) str[source]
get_illegal_bin_name(bin_idx) str[source]
get_hit_bins(bin_l)[source]
equals(oth: CoverpointModel) bool[source]
clone() CoverpointModel[source]

Expressions

class vsc.model.rangelist_model.RangelistModel(rl: Optional[List[List[int]]] = None)[source]
add_value(v)[source]
add_range(low, high)[source]
compact()[source]
intersect(other)[source]

Intersects another list or ranges with this one, trimming values that overlap

equals(oth) bool[source]
toString()[source]
clone()[source]
accept(v)[source]