diff --git a/doc/source/constraints.rst b/doc/source/constraints.rst index f196169..2e2cea9 100644 --- a/doc/source/constraints.rst +++ b/doc/source/constraints.rst @@ -81,7 +81,7 @@ condition without knowing the details of what that condition is. my_i = my_cls() - with my_i.randomize() + my_i.randomize() with my_i.randomize_with() as it: it.a_small() diff --git a/doc/source/features.rst b/doc/source/features.rst index 82aa415..474838e 100644 --- a/doc/source/features.rst +++ b/doc/source/features.rst @@ -38,8 +38,8 @@ scalar dynamic array Y Y N class fixed-size array Y Y Y class dynamic array Y Y N class (in)equality N N Y -array sum N Y Y -array size N Y Y +array sum Y Y Y +array size Y Y Y array reduction OR N Y N array reduction AND N Y N array reduction XOR N Y N @@ -50,7 +50,7 @@ default N N Y dynamic Y N Y inside (in) Y Y Y soft Y Y N -solve before N Y N +solve before Y Y N `unique` Y Y Y `foreach` Y Y Y `forall` N Y Y diff --git a/doc/source/introduction.rst b/doc/source/introduction.rst index 8d87c79..f7f997a 100644 --- a/doc/source/introduction.rst +++ b/doc/source/introduction.rst @@ -40,60 +40,58 @@ coverage, and inline randomization. .. code-block:: python3 + import vsc + @vsc.randobj class my_item_c(object): def __init__(self): self.a = vsc.rand_bit_t(8) self.b = vsc.rand_bit_t(8) - @vsc.constraint - def ab_c(self): - self.a != 0 - self.a <= self.b - self.b in vsc.rangelist(1,2,4,8) - - @vsc.covergroup - class my_cg(object): - - def __init__(self): - # Define the parameters accepted by the sample function - self.with_sample(dict( - it=my_item_c() - )) - - self.a_cp = vsc.coverpoint( self.it.a, bins=dict( - # Create 4 bins across the space 0..255 - a_bins = bin_array([4], [0,255]) - ) - self.b_cp = vsc.coverpoint(self.it.b, bins=dict( - # Create one bin for each value (1,2,4,8) - b_bins = bin_array([], 1, 2, 4, 8) - ) - self.ab_cross = vsc.cross([self.a_cp, self.b_cp]) - - # Create an instance of the covergroup - my_cg_i = my_cg() - - # Create an instance of the item class - my_item_i = my_item_c() - - # Randomize and sample coverage - for i in range(16): - my_item_i.randomize() - my_cg_i.sample(my_item_i) - - # Now, randomize keeping b in the range [1,2] - for i in range(16): - with my_item_i.randomize_with() as it: - it.b in vsc.rangelist(1,2) - my_cg_i.sample(my_item_i) - - print("Coverage: %f \%" % (my_cg_i.get_coverage())) - - - + @vsc.constraint + def ab_c(self): + self.a != 0 + self.a <= self.b + self.b in vsc.rangelist(1,2,4,8) + @vsc.covergroup + class my_cg(object): + def __init__(self): + # Define the parameters accepted by the sample function + self.with_sample(dict( + it = my_item_c() + )) + + self.a_cp = vsc.coverpoint(self.it.a, bins=dict( + # Create 4 bins across the space 0..255 + a_bins = vsc.bin_array([4], [0,255]) + )) + self.b_cp = vsc.coverpoint(self.it.b, bins=dict( + # Create one bin for each value (1,2,4,8) + b_bins = vsc.bin_array([], 1, 2, 4, 8) + )) + self.ab_cross = vsc.cross([self.a_cp, self.b_cp]) + + # Create an instance of the covergroup + my_cg_i = my_cg() + + # Create an instance of the item class + my_item_i = my_item_c() + + # Randomize and sample coverage + for i in range(16): + my_item_i.randomize() + my_cg_i.sample(my_item_i) + + # Now, randomize keeping b in the range [1,2] + for i in range(16): + with my_item_i.randomize_with() as it: + it.b in vsc.rangelist(1,2) + my_cg_i.sample(my_item_i) + + # Print report of type and instance coverage + vsc.report_coverage() Contributors diff --git a/doc/source/quickstart.rst b/doc/source/quickstart.rst index 934d4da..2311a1a 100644 --- a/doc/source/quickstart.rst +++ b/doc/source/quickstart.rst @@ -20,11 +20,20 @@ Installation from Source cd pyvsc pip install -e . - -Running a Simple Example + +A Simple Example ======================== +.. code-block:: python3 + + import vsc + a = vsc.rand_uint8_t() + b = vsc.rand_uint8_t() + for _ in range(10): + with vsc.randomize_with(a, b): + a < b + print(a.get_val(), b.get_val())