Toffee Package API
Submodules
toffee.agent module
- class toffee.agent.Agent(bundle)[源代码]
基类:
objectProvides an agent for operation on the DUT.
- all_driver_method()[源代码]
Yields all driver method in the agent.
- 返回:
A generator that yields all driver method in the agent.
- all_monitor_method()[源代码]
Yields all monitor methods in the agent.
- 返回:
A generator that yields all monitor method in the agent.
toffee.asynchronous module
- class toffee.asynchronous.Event[源代码]
基类:
EventChange the function in the Event to meet the asynchronous requirements.
- class toffee.asynchronous.Queue[源代码]
基类:
QueueChange the function in the Queue to meet the asynchronous requirements.
- toffee.asynchronous.create_task(coro, *, name=None, context=None)[源代码]
Schedule the execution of a coroutine object in a spawn task.
Return a Task object.
- async toffee.asynchronous.gather(*coros)[源代码]
Gather multiple coroutines and run them at the same time.
- async toffee.asynchronous.main_coro(test, env_handle=None)[源代码]
Wrapper for a coroutine to meet the rules for toffee.
- 参数:
test -- The test to be run, it can be a coroutine or a function.
env_handle -- A handle to create the environment. make sure the env is created before the test starts. if the env_handle is provided, the test will be called with the env_handle's return value. when the env_handle is set, make sure the test is a function and has the same number of arguments as the env_handle's return.
- 返回:
The result of the coroutine (or function).
- toffee.asynchronous.run(test, env_handle=None, dut=None)[源代码]
Start the asynchronous event loop and run the coroutine.
- 参数:
test -- The test to be run, it can be a coroutine or a function.
env_handle -- A handle to create the environment. make sure the env is created before the test starts. if the env_handle is provided, the test will be called with the env_handle's return value. when the env_handle is set, make sure the test is a function and has the same number of arguments as the env_handle's return.
dut -- The DUT object.
- 返回:
The result of the coroutine (or function).
toffee.bundle module
- class toffee.bundle.Bundle[源代码]
基类:
MObjectA bundle is a collection of signals in a DUT.
- all_signals(level_string='')[源代码]
Yield all signals of the bundle.
- 返回:
A generator of signal names and signals.
- all_signals_rule()[源代码]
Get all signals rules in the bundle.
- 返回:
A dictionary of all signals rules in the bundle.
- as_dict(multilevel=True)[源代码]
Collect all signals values into a dictionary.
- 参数:
multilevel -- When multilevel is true, the subbundle signal values are put into a secondary dictionary. Otherwise, the dictionary returned will have only one level, with the sub-bundles separated by dots in keys.
- 返回:
A dictionary of all signals values in the bundle.
- assign(item, multilevel=True, level_string='')[源代码]
Assign all signals values.
- 参数:
item -- item can be a dict or an object with a __bundle_assign__ method defined. When item is a dictionary, if "*" is in the dictionary, the value of "*" will be assigned to all signals that are not in the dictionary. Otherwise assign will call the __bundle_assign__ function in item to complete the assignment to the bundle
multilevel -- When multilevel is true, the subbundle signal values are taken from a secondary dictionary. Otherwise, the dictionary should have only one level, with the sub-bundles separated by dots in keys.
- bind(dut, unconnected_signal_access=True)[源代码]
Bind the dut's signal to this bundle. it will overwrites the previous bind.
- 参数:
dut -- The dut to bind the bundle to.
unconnected_signal_access -- Whether unconnected signals could be accessed.
- 返回:
The bundle itself.
- detect_connectivity(signal_name)[源代码]
Detect wether a signal name could be connected to this bundle.
- 参数:
bundle -- The bundle to connect.
signal_name -- The name of the signal to connect.
- 返回:
True if the signal name could be connected to the bundle, False otherwise.
- static detect_multiple_connections(dut)[源代码]
Detect signals that are connected to multiple bundles.
- 参数:
dut -- The dut to detect.
- 返回:
A list of signals that are connected to multiple bundles.
- detect_specific_connectivity(signal_name, specific_signal)[源代码]
Detects whether a signal name can be connected to a specific signal in the bundle
- 参数:
signal_name -- The name of the signal to connect.
specific_signal -- The specific signal in this bundle to connect to, format such as "subbundle1.subbundle2.siganlA"
- static detect_unconnected_signals(dut)[源代码]
Detect signals that are not connected to any bundle.
- 参数:
dut -- The dut to detect.
- 返回:
A list of unconnected signals
- static dut_all_signals(dut)[源代码]
Yield all signals of the dut.
- 参数:
dut -- The dut to get signals from.
- 返回:
A generator of dictionaries containing the name, original name, and signal of the signal.
- classmethod from_dict(dict={})[源代码]
Create a bundle from a dictionary. The keys of the dictionary are the names of the signals in the bundle, and the values are the names of the signals in DUT.
- 参数:
dict -- The dictionary to guide bundle connections
- 返回:
A new bundle.
- classmethod from_prefix(prefix='', dut=None)[源代码]
Create a bundle from a prefix.
- 参数:
prefix -- The prefix to match the signals.
- 返回:
A new bundle.
- classmethod from_regex(regex='')[源代码]
Create a bundle from a regex. The signals captured in the regex will be used for matching. If there are multiple capture groups, they are concatenated into a string to match.
- 参数:
regex -- The regex to match the signals.
- 返回:
A new bundle.
- classmethod from_xport(xport)[源代码]
Create a bundle from an XPort.
- 参数:
xport -- The XPort to create the bundle from.
- 返回:
A new bundle.
- make_requset_response_for(dut)[源代码]
Make a request response for the dut.
- 参数:
dut -- The dut to make the request response for.
- static new_class_from_list(signal_list)[源代码]
Create a new bundle class with a list of signals quickly.
>>> myBundle = Bundle.new_class_from_list(["a", "b", "c"]).from_prefix("io_")
- 参数:
signal_list -- A list of signals.
- 返回:
A new bundle class.
- static new_class_from_xport(xport)[源代码]
Create a new bundle class with an XPort quickly.
- 参数:
xport -- The XPort to create the bundle from.
- 返回:
A new bundle class.
- process_requests(request: Dict | List[Dict] | None)[源代码]
Process the requests.
- 参数:
request -- The request to process.
- randomize_all(value_range=None, exclude_signals=[], random_func=<bound method Random.randint of <random.Random object>>)[源代码]
Randomize all signals values in the bundle.
- 参数:
value_range -- The range of the random values, eg. (0, 100), both values are inclusive. If None, the range of random values will be the range of each signal value.
exclude_signals -- A list of signals to exclude from randomization, sub-bundle names are separated by dots.
random_func -- The random function to use, default is random.randint.
- set_all(value)[源代码]
Set all signals values to a value, including sub-bundles.
- 参数:
value -- The value to set.
- 返回:
The bundle itself.
- set_dict(dict={})[源代码]
Set the bundle to bind from a dictionary.
- 参数:
dict -- The dictionary to guide bundle connections
- 返回:
The bundle itself.
- set_name(name)[源代码]
Set the name of the bundle.
- 参数:
name -- The name of the bundle.
- 返回:
The bundle itself.
- set_prefix(prefix='')[源代码]
Set the bundle to bind from prefix.
- 参数:
prefix -- The prefix to match the signals.
- 返回:
The bundle itself.
- set_regex(regex='')[源代码]
Set the bundle to bind from regex.
- 参数:
regex -- The regex to match the signals.
- 返回:
The bundle itself.
- set_write_mode(write_mode: WriteMode)[源代码]
Set the write mode of the bundle. it will change the write mode of all signals in the bundle.
- 参数:
write_mode -- The write mode to set.
- 返回:
The bundle itself.
- set_write_mode_as_imme()[源代码]
Set the write mode of the bundle to immediate.
- 返回:
The bundle itself.
- signals = []
- class toffee.bundle.BundleList(bundle, format: str, limit: int, rule=None)[源代码]
基类:
object- classmethod from_bundlelist(old_bundle_list: BundleList)[源代码]
- class toffee.bundle.DummySignal[源代码]
基类:
objectA dummy signal class that does nothing. It will return None when accessed, and do nothing when set.
- class toffee.bundle.SignalList(format: str, limit: int, rule=None)[源代码]
基类:
object- classmethod from_signallist(old_signal_list: SignalList)[源代码]
toffee.debug module
toffee.delay module
toffee.env module
- class toffee.env.Env[源代码]
基类:
MObjectEnv is used to wrap the entire verification environment and provides reference model synchronization
- all_agent_names()[源代码]
Yields all agent names in the env.
- 返回:
A generator that yields all agent names in the env.
toffee.executor module
toffee.funcov module
- class toffee.funcov.CovEq(value)[源代码]
基类:
CovConditionCovEq class, check if the target is equal to the value
- class toffee.funcov.CovGe(value)[源代码]
基类:
CovConditionCovGe class, check if the target is greater or equal to the value
- class toffee.funcov.CovGroup(name: str = '', disable_sample_when_point_hinted=True)[源代码]
基类:
objectfunctional coverage group
- add_cover_point(target: object, bins: dict | CovCondition | Callable[[object, object], bool], name: str = '', once=None, dynamic_bin=False)
Add a watch point to the group @param target: the object to be watched, need to have a value attribute. eg target.value is available @param bins: a dict of CovCondition objects, a single CovCondition object or a Callable object (its params is call(target) -> bool). @param name: the name of the point
- add_watch_point(target: object, bins: dict | CovCondition | Callable[[object, object], bool], name: str = '', once=None, dynamic_bin=False)[源代码]
Add a watch point to the group @param target: the object to be watched, need to have a value attribute. eg target.value is available @param bins: a dict of CovCondition objects, a single CovCondition object or a Callable object (its params is call(target) -> bool). @param name: the name of the point
- is_point_covered(key: str) bool[源代码]
check if the point with key is covered @param key: the key of the point
- mark_function(name: str, func: Callable | str | list, bin_name: str | list = '*', raise_error=True)[源代码]
Mark one or more functions for a point
- Description:
By this reverse marking, record the relationship between checkpoints and target coverage functions to facilitate the management and analysis of checkpoints and test cases.
- 参数:
name (str) -- checkpoint name
func (Union[Callable,str, list]) -- function or function list to be marked
bin_name (Union[str, list]) -- bin name, support wildcard and regex. Default to '*' all bins.
- 返回:
this covgroup object
- 返回类型:
- class toffee.funcov.CovGt(value)[源代码]
基类:
CovConditionCovGt class, check if the target is greater than the value
- class toffee.funcov.CovIn(value)[源代码]
基类:
CovConditionCovIn class, check if the target is in the value
- class toffee.funcov.CovIsInRange(low, high)[源代码]
基类:
CovConditionCovIsInRange class, check if the target is in the range
- class toffee.funcov.CovLe(value)[源代码]
基类:
CovConditionCovLe class, check if the target is less or equal to the value
- class toffee.funcov.CovLt(value)[源代码]
基类:
CovConditionCovLt class, check if the target is less than the value
- class toffee.funcov.CovNe(value)[源代码]
基类:
CovConditionCovNe class, check if the target is not equal to the value
- class toffee.funcov.CovNotIn(value)[源代码]
基类:
CovConditionCovNotIn class, check if the target is not in the value
- toffee.funcov.IsInRange
CovIsInRange的别名
toffee.logger module
- toffee.logger.critical(msg, *args, **kwargs)[源代码]
Log 'msg % args' with severity 'CRITICAL'.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.critical("Houston, we have a %s", "major disaster", exc_info=True)
- toffee.logger.debug(msg, *args, **kwargs)[源代码]
Log 'msg % args' with severity 'DEBUG'.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.debug("Houston, we have a %s", "thorny problem", exc_info=True)
- toffee.logger.error(msg, *args, **kwargs)[源代码]
Log 'msg % args' with severity 'ERROR'.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.error("Houston, we have a %s", "major problem", exc_info=True)
- toffee.logger.exception(msg, *args, exc_info=True, **kwargs)[源代码]
Convenience method for logging an ERROR with exception information.
- toffee.logger.info(msg, *args, **kwargs)[源代码]
Log 'msg % args' with severity 'INFO'.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.info("Houston, we have a %s", "notable problem", exc_info=True)
- toffee.logger.log(level, msg, *args, **kwargs)[源代码]
Log 'msg % args' with the integer severity 'level'.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.log(level, "We have a %s", "mysterious problem", exc_info=True)
- toffee.logger.setup_logging(log_level=30, format='%(name)s_%(levelname)s @%(filename)s:%(lineno)d%(log_id)s:\t%(message)s', console_display=True, log_file=None)[源代码]
Setup the logging configuration for Toffee
- 参数:
log_level -- The log level for the logger
format -- The format of the log message
console_display -- Whether to display logs on the console
log_file -- The log file name to write logs, if None, logs are not written to a file
toffee.model module
- class toffee.model.AgentPort(agent_name: str = '', maxsize: int = 4, *, agents: list = [], methods: list = [])[源代码]
基类:
Port
- class toffee.model.DriverPort(driver_path: str = '', *, agent_name: str = '', driver_name: str = '', maxsize: int = 4)[源代码]
基类:
PortThe DriverPort is used to match driver_method in the agent and obtain call arguments.
- class toffee.model.Model[源代码]
基类:
ComponentThe Model is used to provide a reference model for the DUT.
- clear_matched()[源代码]
Clear the matched status of all driver ports, monitor ports, driver hooks, and agent hooks.
- class toffee.model.MonitorPort(monitor_path: str = '', *, agent_name: str = '', monitor_name: str = '', maxsize: int = 4)[源代码]
基类:
PortThe MonitorPort is used to match the monitor_method in the agent, and obtain the results.
- toffee.model.agent_hook(agent_name: str = '', *, agents: list = [], methods: list = [], priority: int = 99, sche_order: str = 'model_first')[源代码]
Decorator for agent hook.
- 参数:
agent_name -- The name of the agent to be hooked. If it is empty, the name of the function will be used.
agents -- The list of agents to be hooked.
methods -- The list of paths of the methods to be hooked.
priority -- The priority of the agent hook which should be an integer between 0 and 99. The smaller the number, the higher the priority. It will determine the order of calls within the same cycle. The default priority of agent hook is 99.
sche_order -- The order in which the hook is called relative to the dut. If it is "model_first", it will be called before the corresponding agent_method runs, and vice versa after it runs.
- toffee.model.driver_hook(driver_path: str = '', *, agent_name: str = '', driver_name: str = '', priority=99, sche_order='model_first')[源代码]
Decorator for driver hook.
- 参数:
driver_path -- The path of the driver.
agent_name -- The name of the agent to be hooked.
driver_name -- The name of the driver to be hooked.
priority -- The priority of the driver hook which should be an integer between 0 and 99. The smaller the number, the higher the priority. It will determine the order of calls within the same cycle. The default priority of driver hook is 99.
sche_order -- The order in which the hook is called relative to the dut. If it is "model_first", it will be called before the corresponding driver_method runs, and vice versa after it runs.
- toffee.model.monitor_hook(monitor_path: str = '', *, agent_name: str = '', monitor_name: str = '', priority: int = 0)[源代码]
Decorator for monitor hook.
- 参数:
monitor_path -- The path of the monitor.
agent_name -- The name of the agent to be hooked.
monitor_name -- The name of the monitor to be hooked.
priority -- The priority of the monitor hook which should be an integer between 0 and 99. The smaller the number, the higher the priority. It will use the same priority as driver_hook, determining the order of calls within the same cycle. The default priority of monitor hook is -1, which means the monitor hook will be executed before driver hook.
toffee.triggers module
- async toffee.triggers.AllValid(*pins, delay=1)[源代码]
Wait for all the pins to be valid.
- 参数:
pins -- The pins to be checked.
delay -- The minimum number of clock cycles to pass before checking.
- async toffee.triggers.Change(pin)[源代码]
Wait for the pin value to change.
- 参数:
pin -- The pin to be checked.
- async toffee.triggers.ClockCycles(item, ncycles=1)[源代码]
Wait for the specified number of clock cycles.
- 参数:
item -- The item to be waited for. It can be a dut, a bundle, or an xpin.
ncycles -- The number of clock cycles to be waited for.
- async toffee.triggers.Condition(item, func, delay=1)[源代码]
Wait for the specified condition to be true.
- 参数:
item -- The item to be waited for. It can be a dut, a bundle, or an xpin.
func -- The condition function to be checked, it should accept a single argument 'item' and return a boolean.
delay -- The minimum number of clock cycles to pass before checking.
- async toffee.triggers.FallingEdge(pin)[源代码]
Wait for the pin to have a falling edge. Specifically, the function returns when the pin has a value of non-0 in the previous cycle and a value of 0 in the current cycle.
- 参数:
pin -- The pin to be checked.
Subpackages
Module contents
- class toffee.Agent(bundle)[源代码]
基类:
objectProvides an agent for operation on the DUT.
- all_driver_method()[源代码]
Yields all driver method in the agent.
- 返回:
A generator that yields all driver method in the agent.
- all_monitor_method()[源代码]
Yields all monitor methods in the agent.
- 返回:
A generator that yields all monitor method in the agent.
- class toffee.AgentPort(agent_name: str = '', maxsize: int = 4, *, agents: list = [], methods: list = [])[源代码]
基类:
Port
- async toffee.AllValid(*pins, delay=1)[源代码]
Wait for all the pins to be valid.
- 参数:
pins -- The pins to be checked.
delay -- The minimum number of clock cycles to pass before checking.
- class toffee.Bundle[源代码]
基类:
MObjectA bundle is a collection of signals in a DUT.
- all_signals(level_string='')[源代码]
Yield all signals of the bundle.
- 返回:
A generator of signal names and signals.
- all_signals_rule()[源代码]
Get all signals rules in the bundle.
- 返回:
A dictionary of all signals rules in the bundle.
- as_dict(multilevel=True)[源代码]
Collect all signals values into a dictionary.
- 参数:
multilevel -- When multilevel is true, the subbundle signal values are put into a secondary dictionary. Otherwise, the dictionary returned will have only one level, with the sub-bundles separated by dots in keys.
- 返回:
A dictionary of all signals values in the bundle.
- assign(item, multilevel=True, level_string='')[源代码]
Assign all signals values.
- 参数:
item -- item can be a dict or an object with a __bundle_assign__ method defined. When item is a dictionary, if "*" is in the dictionary, the value of "*" will be assigned to all signals that are not in the dictionary. Otherwise assign will call the __bundle_assign__ function in item to complete the assignment to the bundle
multilevel -- When multilevel is true, the subbundle signal values are taken from a secondary dictionary. Otherwise, the dictionary should have only one level, with the sub-bundles separated by dots in keys.
- bind(dut, unconnected_signal_access=True)[源代码]
Bind the dut's signal to this bundle. it will overwrites the previous bind.
- 参数:
dut -- The dut to bind the bundle to.
unconnected_signal_access -- Whether unconnected signals could be accessed.
- 返回:
The bundle itself.
- detect_connectivity(signal_name)[源代码]
Detect wether a signal name could be connected to this bundle.
- 参数:
bundle -- The bundle to connect.
signal_name -- The name of the signal to connect.
- 返回:
True if the signal name could be connected to the bundle, False otherwise.
- static detect_multiple_connections(dut)[源代码]
Detect signals that are connected to multiple bundles.
- 参数:
dut -- The dut to detect.
- 返回:
A list of signals that are connected to multiple bundles.
- detect_specific_connectivity(signal_name, specific_signal)[源代码]
Detects whether a signal name can be connected to a specific signal in the bundle
- 参数:
signal_name -- The name of the signal to connect.
specific_signal -- The specific signal in this bundle to connect to, format such as "subbundle1.subbundle2.siganlA"
- static detect_unconnected_signals(dut)[源代码]
Detect signals that are not connected to any bundle.
- 参数:
dut -- The dut to detect.
- 返回:
A list of unconnected signals
- static dut_all_signals(dut)[源代码]
Yield all signals of the dut.
- 参数:
dut -- The dut to get signals from.
- 返回:
A generator of dictionaries containing the name, original name, and signal of the signal.
- classmethod from_dict(dict={})[源代码]
Create a bundle from a dictionary. The keys of the dictionary are the names of the signals in the bundle, and the values are the names of the signals in DUT.
- 参数:
dict -- The dictionary to guide bundle connections
- 返回:
A new bundle.
- classmethod from_prefix(prefix='', dut=None)[源代码]
Create a bundle from a prefix.
- 参数:
prefix -- The prefix to match the signals.
- 返回:
A new bundle.
- classmethod from_regex(regex='')[源代码]
Create a bundle from a regex. The signals captured in the regex will be used for matching. If there are multiple capture groups, they are concatenated into a string to match.
- 参数:
regex -- The regex to match the signals.
- 返回:
A new bundle.
- classmethod from_xport(xport)[源代码]
Create a bundle from an XPort.
- 参数:
xport -- The XPort to create the bundle from.
- 返回:
A new bundle.
- make_requset_response_for(dut)[源代码]
Make a request response for the dut.
- 参数:
dut -- The dut to make the request response for.
- static new_class_from_list(signal_list)[源代码]
Create a new bundle class with a list of signals quickly.
>>> myBundle = Bundle.new_class_from_list(["a", "b", "c"]).from_prefix("io_")
- 参数:
signal_list -- A list of signals.
- 返回:
A new bundle class.
- static new_class_from_xport(xport)[源代码]
Create a new bundle class with an XPort quickly.
- 参数:
xport -- The XPort to create the bundle from.
- 返回:
A new bundle class.
- process_requests(request: Dict | List[Dict] | None)[源代码]
Process the requests.
- 参数:
request -- The request to process.
- randomize_all(value_range=None, exclude_signals=[], random_func=<bound method Random.randint of <random.Random object>>)[源代码]
Randomize all signals values in the bundle.
- 参数:
value_range -- The range of the random values, eg. (0, 100), both values are inclusive. If None, the range of random values will be the range of each signal value.
exclude_signals -- A list of signals to exclude from randomization, sub-bundle names are separated by dots.
random_func -- The random function to use, default is random.randint.
- set_all(value)[源代码]
Set all signals values to a value, including sub-bundles.
- 参数:
value -- The value to set.
- 返回:
The bundle itself.
- set_dict(dict={})[源代码]
Set the bundle to bind from a dictionary.
- 参数:
dict -- The dictionary to guide bundle connections
- 返回:
The bundle itself.
- set_name(name)[源代码]
Set the name of the bundle.
- 参数:
name -- The name of the bundle.
- 返回:
The bundle itself.
- set_prefix(prefix='')[源代码]
Set the bundle to bind from prefix.
- 参数:
prefix -- The prefix to match the signals.
- 返回:
The bundle itself.
- set_regex(regex='')[源代码]
Set the bundle to bind from regex.
- 参数:
regex -- The regex to match the signals.
- 返回:
The bundle itself.
- set_write_mode(write_mode: WriteMode)[源代码]
Set the write mode of the bundle. it will change the write mode of all signals in the bundle.
- 参数:
write_mode -- The write mode to set.
- 返回:
The bundle itself.
- set_write_mode_as_imme()[源代码]
Set the write mode of the bundle to immediate.
- 返回:
The bundle itself.
- signals = []
- class toffee.BundleList(bundle, format: str, limit: int, rule=None)[源代码]
基类:
object- classmethod from_bundlelist(old_bundle_list: BundleList)[源代码]
- async toffee.ClockCycles(item, ncycles=1)[源代码]
Wait for the specified number of clock cycles.
- 参数:
item -- The item to be waited for. It can be a dut, a bundle, or an xpin.
ncycles -- The number of clock cycles to be waited for.
- async toffee.Condition(item, func, delay=1)[源代码]
Wait for the specified condition to be true.
- 参数:
item -- The item to be waited for. It can be a dut, a bundle, or an xpin.
func -- The condition function to be checked, it should accept a single argument 'item' and return a boolean.
delay -- The minimum number of clock cycles to pass before checking.
- class toffee.CovEq(value)[源代码]
基类:
CovConditionCovEq class, check if the target is equal to the value
- class toffee.CovGe(value)[源代码]
基类:
CovConditionCovGe class, check if the target is greater or equal to the value
- class toffee.CovGroup(name: str = '', disable_sample_when_point_hinted=True)[源代码]
基类:
objectfunctional coverage group
- add_cover_point(target: object, bins: dict | CovCondition | Callable[[object, object], bool], name: str = '', once=None, dynamic_bin=False)
Add a watch point to the group @param target: the object to be watched, need to have a value attribute. eg target.value is available @param bins: a dict of CovCondition objects, a single CovCondition object or a Callable object (its params is call(target) -> bool). @param name: the name of the point
- add_watch_point(target: object, bins: dict | CovCondition | Callable[[object, object], bool], name: str = '', once=None, dynamic_bin=False)[源代码]
Add a watch point to the group @param target: the object to be watched, need to have a value attribute. eg target.value is available @param bins: a dict of CovCondition objects, a single CovCondition object or a Callable object (its params is call(target) -> bool). @param name: the name of the point
- is_point_covered(key: str) bool[源代码]
check if the point with key is covered @param key: the key of the point
- mark_function(name: str, func: Callable | str | list, bin_name: str | list = '*', raise_error=True)[源代码]
Mark one or more functions for a point
- Description:
By this reverse marking, record the relationship between checkpoints and target coverage functions to facilitate the management and analysis of checkpoints and test cases.
- 参数:
name (str) -- checkpoint name
func (Union[Callable,str, list]) -- function or function list to be marked
bin_name (Union[str, list]) -- bin name, support wildcard and regex. Default to '*' all bins.
- 返回:
this covgroup object
- 返回类型:
- class toffee.CovGt(value)[源代码]
基类:
CovConditionCovGt class, check if the target is greater than the value
- class toffee.CovIn(value)[源代码]
基类:
CovConditionCovIn class, check if the target is in the value
- class toffee.CovIsInRange(low, high)[源代码]
基类:
CovConditionCovIsInRange class, check if the target is in the range
- class toffee.CovLe(value)[源代码]
基类:
CovConditionCovLe class, check if the target is less or equal to the value
- class toffee.CovLt(value)[源代码]
基类:
CovConditionCovLt class, check if the target is less than the value
- class toffee.CovNe(value)[源代码]
基类:
CovConditionCovNe class, check if the target is not equal to the value
- class toffee.CovNotIn(value)[源代码]
基类:
CovConditionCovNotIn class, check if the target is not in the value
- class toffee.Delayer(signal, delay)[源代码]
基类:
MObjectA Delayer class is used to delay the signal value.
- property value
Get the value of the signal after the delay.
- class toffee.DriverPort(driver_path: str = '', *, agent_name: str = '', driver_name: str = '', maxsize: int = 4)[源代码]
基类:
PortThe DriverPort is used to match driver_method in the agent and obtain call arguments.
- class toffee.DummySignal[源代码]
基类:
objectA dummy signal class that does nothing. It will return None when accessed, and do nothing when set.
- class toffee.Env[源代码]
基类:
MObjectEnv is used to wrap the entire verification environment and provides reference model synchronization
- all_agent_names()[源代码]
Yields all agent names in the env.
- 返回:
A generator that yields all agent names in the env.
- class toffee.Event[源代码]
基类:
EventChange the function in the Event to meet the asynchronous requirements.
- class toffee.Executor(exit='all')[源代码]
基类:
MObjectThe executor class is used to manage the execution of multiple coroutines.
- async toffee.FallingEdge(pin)[源代码]
Wait for the pin to have a falling edge. Specifically, the function returns when the pin has a value of non-0 in the previous cycle and a value of 0 in the current cycle.
- 参数:
pin -- The pin to be checked.
- toffee.IsInRange
CovIsInRange的别名
- class toffee.Model[源代码]
基类:
ComponentThe Model is used to provide a reference model for the DUT.
- clear_matched()[源代码]
Clear the matched status of all driver ports, monitor ports, driver hooks, and agent hooks.
- class toffee.MonitorPort(monitor_path: str = '', *, agent_name: str = '', monitor_name: str = '', maxsize: int = 4)[源代码]
基类:
PortThe MonitorPort is used to match the monitor_method in the agent, and obtain the results.
- class toffee.Queue[源代码]
基类:
QueueChange the function in the Queue to meet the asynchronous requirements.
- async toffee.RisingEdge(pin)[源代码]
Wait for the pin to have a rising edge. Specifically, the function returns when the pin has a value of 0 in the previous cycle and a value of non-0 in the current cycle.
- 参数:
pin -- The pin to be checked.
- class toffee.SignalList(format: str, limit: int, rule=None)[源代码]
基类:
object- classmethod from_signallist(old_signal_list: SignalList)[源代码]
- class toffee.TwoBitsCounter(init_value=2)[源代码]
基类:
objectTwo bit saturation counter 00 <-> 01 <-> 10 <-> 11
00: Strongly not taken 01: Weakly not taken 10: Weakly taken 11: Strongly taken
- async toffee.Value(pin, value: int, delay=1)[源代码]
Wait for the pin to have the specified value.
- 参数:
pin -- The pin to be checked.
value -- The value to be checked.
delay -- The minimum number of clock cycles to pass before checking.
- class toffee.WriteMode(*values)[源代码]
基类:
EnumThe write mode of a bundle.
- Fall = 2
- Imme = 0
- Rise = 1
- toffee.agent_hook(agent_name: str = '', *, agents: list = [], methods: list = [], priority: int = 99, sche_order: str = 'model_first')[源代码]
Decorator for agent hook.
- 参数:
agent_name -- The name of the agent to be hooked. If it is empty, the name of the function will be used.
agents -- The list of agents to be hooked.
methods -- The list of paths of the methods to be hooked.
priority -- The priority of the agent hook which should be an integer between 0 and 99. The smaller the number, the higher the priority. It will determine the order of calls within the same cycle. The default priority of agent hook is 99.
sche_order -- The order in which the hook is called relative to the dut. If it is "model_first", it will be called before the corresponding agent_method runs, and vice versa after it runs.
- toffee.create_task(coro, *, name=None, context=None)[源代码]
Schedule the execution of a coroutine object in a spawn task.
Return a Task object.
- toffee.critical(msg, *args, **kwargs)[源代码]
Log 'msg % args' with severity 'CRITICAL'.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.critical("Houston, we have a %s", "major disaster", exc_info=True)
- toffee.driver_hook(driver_path: str = '', *, agent_name: str = '', driver_name: str = '', priority=99, sche_order='model_first')[源代码]
Decorator for driver hook.
- 参数:
driver_path -- The path of the driver.
agent_name -- The name of the agent to be hooked.
driver_name -- The name of the driver to be hooked.
priority -- The priority of the driver hook which should be an integer between 0 and 99. The smaller the number, the higher the priority. It will determine the order of calls within the same cycle. The default priority of driver hook is 99.
sche_order -- The order in which the hook is called relative to the dut. If it is "model_first", it will be called before the corresponding driver_method runs, and vice versa after it runs.
- toffee.error(msg, *args, **kwargs)[源代码]
Log 'msg % args' with severity 'ERROR'.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.error("Houston, we have a %s", "major problem", exc_info=True)
- toffee.exception(msg, *args, exc_info=True, **kwargs)[源代码]
Convenience method for logging an ERROR with exception information.
- toffee.info(msg, *args, **kwargs)[源代码]
Log 'msg % args' with severity 'INFO'.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.info("Houston, we have a %s", "notable problem", exc_info=True)
- toffee.log(level, msg, *args, **kwargs)[源代码]
Log 'msg % args' with the integer severity 'level'.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.log(level, "We have a %s", "mysterious problem", exc_info=True)
- async toffee.main_coro(test, env_handle=None)[源代码]
Wrapper for a coroutine to meet the rules for toffee.
- 参数:
test -- The test to be run, it can be a coroutine or a function.
env_handle -- A handle to create the environment. make sure the env is created before the test starts. if the env_handle is provided, the test will be called with the env_handle's return value. when the env_handle is set, make sure the test is a function and has the same number of arguments as the env_handle's return.
- 返回:
The result of the coroutine (or function).
- toffee.monitor_hook(monitor_path: str = '', *, agent_name: str = '', monitor_name: str = '', priority: int = 0)[源代码]
Decorator for monitor hook.
- 参数:
monitor_path -- The path of the monitor.
agent_name -- The name of the agent to be hooked.
monitor_name -- The name of the monitor to be hooked.
priority -- The priority of the monitor hook which should be an integer between 0 and 99. The smaller the number, the higher the priority. It will use the same priority as driver_hook, determining the order of calls within the same cycle. The default priority of monitor hook is -1, which means the monitor hook will be executed before driver hook.
- toffee.run(test, env_handle=None, dut=None)[源代码]
Start the asynchronous event loop and run the coroutine.
- 参数:
test -- The test to be run, it can be a coroutine or a function.
env_handle -- A handle to create the environment. make sure the env is created before the test starts. if the env_handle is provided, the test will be called with the env_handle's return value. when the env_handle is set, make sure the test is a function and has the same number of arguments as the env_handle's return.
dut -- The DUT object.
- 返回:
The result of the coroutine (or function).
- toffee.setup_logging(log_level=30, format='%(name)s_%(levelname)s @%(filename)s:%(lineno)d%(log_id)s:\t%(message)s', console_display=True, log_file=None)[源代码]
Setup the logging configuration for Toffee
- 参数:
log_level -- The log level for the logger
format -- The format of the log message
console_display -- Whether to display logs on the console
log_file -- The log file name to write logs, if None, logs are not written to a file