Promote coverage_db to a true singleton object with various query and reporting methods. Arguments include filtering by bin or transaction name, amount of detail, etc. Also a custom accessor to get and inspect a particular CoverItem. This could allow feedback to CRV to achieve faster functional coverage during runtime.
coverage_db = cocotb.coverage.get_coverage_database()
coverage_db.report_covered(**kwargs)
coverage_db.report_uncovered(**kwargs)
coverage_db.get_coverage_for_item(item_name)
# etc.
CRV
A standardized method to build random lists, such as for packet payloads. Would take parameters for min/max len() and min/max values that applies to all values in the list. I realize the underlying constraint.py doesn't support this. Maybe just implement using random module and generate during pre_randomize() or post_randomize()? Other constraints could then use len(txn.payload) in the constraint solver.
I hacked together something like this in my base transaction class:
from random import choice
from cocotb.crv import Randomized
class MyRandomized(Randomized):
def __init__(self):
super().__init__()
self._rand_lists = {}
def add_rand_list(self, name, lengths, values, pre_randomize=True):
self._rand_lists[name] = (lengths, values, pre_randomize)
setattr(self, name, [])
def build_rand_lists(self, pre_randomize):
for name, (lengths, values, pr) in self._rand_lists.items():
if pre_randomize == pr:
setattr(self, name, [choice(values) for x in range(choice(lengths))])
def pre_randomize(self):
self.build_rand_lists(pre_randomize=True)
def post_randomize(self):
self.build_rand_lists(pre_randomize=False)
A small bit of style advice. Use CamelCase for class names but all_lower_case() for methods. E.g., addRand() --> add_rand()
Most of the suggested enhancements have been added. Regarding building random dataset options, I don't see a need to do this, as there are different ways, depending on particular requirements.
I do have a little bit feedback.
Coverage
CRV
len()
and min/max values that applies to all values in the list. I realize the underlying constraint.py doesn't support this. Maybe just implement using random module and generate duringpre_randomize()
orpost_randomize()
? Other constraints could then use len(txn.payload) in the constraint solver.I hacked together something like this in my base transaction class:
addRand()
-->add_rand()
Keep up the good work!
Originally posted by @jrpetrus in https://github.com/potentialventures/cocotb/pull/490#issuecomment-358652919