Release Notes
All releases are available from the GitHub Releases Page.
cocotb 2.0.0.dev0+fa3e92c (2024-10-10)
Features
Not using parentheses on
@cocotb.test
decorator is now supported. (#2731)The
Runner.build()
method now accepts aclean
argument to removebuild_dir
completely during build stage. (#3351)Python 3.12 is now supported. (#3409)
Added
cocotb.parametrize()
, a decorator that serves as an alternative toTestFactory
. (#3513)Added
cocotb.packages
, atypes.SimpleNamespace
which contains handles to SystemVerilog packages in a design. (#3536)Added
SIM_CMD_SUFFIX
to allow users to redirect simulator output or otherwise suffix the simulation command invocation. (#3561)The current Git revision will now be added to
cocotb.__version__
for alldev
versions. (#3568)The
cocotb.test()
decorator now accepts aname
argument to override the name of the test in theRegressionManager
. (#3578)Add support for
handle[sub_handle_name]
syntax toHierarchyObject
as a more readable alternative toHierarchyObject._id()
. (#3655)Added
range
,left
,direction
,right
, andlen()
support toHierarchyArrayObject
. (#3655)Added
_keys()
,_values()
, and_items()
to help users dynamically interact with the DUT object model. (#3655)Added
--trace
command line argument to Verilator simulation binaries for run-time trace generation. This new argument is passed to the binary when thewaves
argument toRunner.test()
isTrue
. (#3667)The
Runner.build()
andRunner.test()
methods now accept alog_file
argument to redirect stdout and stderr to the specified file. (#3668)The
results_xml
argument toRunner.test()
can now be an absolute path. (#3669)Added
--trace-file
command line argument to Verilator simulation binaries which specifies the trace file name. This can be passed to the binary by using thetest_args
argument toRunner.test()
. (#3683)Support comparing
LogicArray
withstr
,list
, andtuple
. (#3696)Support specifying arguments like in
TestFactory.add_option()
incocotb.parametrize()
. (#3717)Use parameter values in generated test names of
cocotb.parametrize()
, which should be clearer and allow the user to better group tests usingCOCOTB_TEST_FILTER
. (#3717)set()
was added to value-having simulation object handles as an alternative to thevalue
property that provides correct type checking information. (#3733)Setting a value with
ArrayObject.value
now accepts anySequence
-like type, such astuple
andlist
, as well asArray
. (#3733)Added
range
,left
,direction
, andright
properties toArrayObject
,LogicObject
, andStringObject
. (#3733)Added support for using
str
in assignment toLogicObject
s. (#3733)The
Runner.test()
method now accepts apre_cmd
argument to run given commands before the simulation starts. These are typically Tcl commands for simulators that support them. Only support for the Questa simulator has been implemented. (#3744)Introduced
cocotb.is_simulation
which isTrue
only when the cocotb library was loaded in a simulation. (#3779)The combine_results.py script now ships with the cocotb installation. (#3791)
Added
LogicArray.from_unsigned()
andLogicArray.from_signed()
to constructLogicArray
fromint
. (#3792)Added
LogicArray.to_unsigned()
andLogicArray.to_signed()
to convertLogicArray
intoint
. (#3792)The
sources
option was added toRunner.build()
to better support building mixed-language designs. (#3796)Enable use of VPI fallback in all simulators when attempting to access generate blocks directly via lookup. This enables better support for simulators that don’t support
vpiGenScopeArray
, allowing discovery of generate blocks without having to iterate over the parent handle. (#3817)Added
COCOTB_TEST_FILTER
which filters tests likeTESTCASE
, but is a regular expression to allow for more expressive test filtering. (#3841)Introduced
COCOTB_TRUST_INERTIAL_WRITES
to enable a mode where VPI/VHPI/FLI inertial writes are trusted to behave properly. Enabling this feature can lead to behavioral changes and noticable performance improvements. Some simulators do not handle writes properly, so use this option with caution. (#3873)Riviera-PRO now supports compilation into (multiple) VHDL libraries using
VHDL_SOURCES_
. (#3922)Added
cocotb.simulator.GpiClock
, a C++ clock generator implementation with higher performance due to less handshaking between Python and the GPI.Clock
uses it automatically when it would behave identically to the Python implementation. (#3983)Added
cocotb.sim_phase
to allow the user to determine what phase of a time step they are in. (#4022)Added
LogicArray.to_bytes()
andLogicArray.from_bytes()
for convertingLogicArray
to and frombytes
. (#4098)Array
can takeint
as the second positional argument orwidth
keyword argument as shorthand for passingRange(0, "to", width-1)
asrange
. (#4142)LogicArray
can takeint
as the second positional argument orwidth
keyword argument as shorthand for passingRange(width-1, "downto", 0)
asrange
. (#4142)Python 3.13 is now supported. (#4151)
Bugfixes
Xcelium 23.09.004 and newer can now be used to test designs with a VHDL toplevel. (#1076)
Fix a potential issue where pseudo-region lookup may find the wrong generate block if the name of one generate block starts with the name of another generate block. (#2255)
Fix incorrect cleanup of pending Tasks (queued by
cocotb.start_soon()
but not started yet) when a test ends. (#3354)Support
waves
argument toRunner.build()
for Verilator. (#3681)The
test_args
argument toRunner.test()
is now passed to the Verilator simulation binary when running the simulation, which was previously missing. (#3682)
Deprecations and Removals
Removed unmaintained WaveDrom support. Users (if any) are encouraged to include the code in their own codebase, or create a cocotb extension for it. (#2066)
cocotb.handle.NonConstantObject
was removed, useValueObjectBase
instead. (#2720)Iteration of and querying length and range of
IntegerObject
,EnumObject
, andRealObject
have been removed. (#2720)The deprecated
cocotb.fork
function was removed. (#3425)Support for generator-based coroutines, which used the
cocotb.coroutine
decorator andyield
syntax, has been removed. To update to the new syntax, remove all uses of the decorator and convert the function to a coroutine function using theasync
andawait
syntax. (#3509)Removed
cocotb.types.Bit
. (#3549)The
prefix
andpostfix
arguments toTestFactory.generate_tests()
are deprecated in favor of the more flexiblename
argument. (#3578)Methods
get_definition_name()
andget_definition_file()
ofcocotb.handle.SimHandleBase
were removed in favor of_def_name()
and_def_file()
, respectively. (#3609)cocotb.binary.BinaryValue
,cocotb.binary.BinaryRepresentation
, and thecocotb.binary
module have been removed in favor ofLogicArray
. See the guide for a tutorial on upgrading toLogicArray
. (#3634)Deprecated
MODULE
,TOPLEVEL
,TESTCASE
,COVERAGE
,COVERAGE_RCFILE
,PLUSARGS
, andRANDOM_SEED
, that are respectively replaced withCOCOTB_TEST_MODULES
,COCOTB_TOPLEVEL
,COCOTB_TESTCASE
,COCOTB_USER_COVERAGE
,COCOTB_COVERAGE_RCFILE
,COCOTB_PLUSARGS
andCOCOTB_RANDOM_SEED
to avoid issues with simulators overwriting cocotb environment variables. (#3644)HierarchyObject._id()
is now deprecated. Usehandle["sub_handle_name"]
syntax instead. (#3655)Removed
cocotb.logging.SimLog
, uselogging.getLogger()
instead. (#3673)cocotb.types.concat
was removed. UseArray(itertools.chain(a, b))
instead. (#3705)TestFactory
is now deprecated. Usecocotb.parametrize
instead. (#3717)cocotb.handle.ModifiableObject
was removed along with its non-functionaldrivers()
andloads()
methods. (#3733)cocotb.RANDOM_SEED
was made private. (#3779)cocotb.LANGUAGE
was removed, useos.environ["TOPLEVEL_LANG"]
if you need that information. (#3779)Removed
cocotb.argc
. Uselen(cocotb.argv)
instead. (#3779)LogicArray.integer
has been deprecated. UseLogicArray.to_unsigned()
instead. (#3792)Constructing a
LogicArray
from anint
is deprecated. UseLogicArray.from_unsigned()
andLogicArray.from_signed()
instead. (#3792)LogicArray.signed_integer
has been deprecated. UseLogicArray.to_signed()
instead. (#3792)LogicArray.binstr
has been deprecated. Usestr(logic_array)
instead. (#3792)Deprecated the
verilog_sources
andvhdl_sources
parameters toRunner.build()
. Use the language-agnosticsources
parameter instead. (#3836)Made
cocotb.triggers.Trigger.primed
,cocotb.triggers.GPITrigger.cbhdl
, andcocotb.triggers.Timer.sim_steps
private. (#3851)Removed
cocotb.triggers.PythonTrigger
. (#3851)cocotb.result.TestComplete
was removed. (#3864)cocotb.result.ExternalException
was removed. (#3864)cocotb.triggers.Join.retval
was removed. (#3931)Support for passing
0
as the time argument toTimer
has been removed. If a rounding operation causes the value to become0
, we change it to 1 simulation time step. (#3937)cocotb.result.SimFailure
has been removed. It’s replaced with the _expect_sim_failure argument tococotb.test()
. Users are not intended to use this functionality. (#3938)LogicArray.buff
has been deprecated. UseLogicArray.to_unsigned()
in combination withint.to_bytes()
instead. For example:v.to_unsigned().to_bytes(ceil(len(v) / 8), byteorder="big")
. (#3944)The outcome parameter to
NullTrigger
was removed. There is no alternative. (#3969)Removed the
cycles
argument toClock.start()
. Usekill()
on the clock task instead, or implement manually. (#3983)cocotb.utils.want_color_output()
,cocotb.utils.remove_traceback_frames
,cocotb.utils.walk_coro_stack
, andcocotb.utils.extract_coro_stack
were removed. (#4023)The undocumented
cocotb.triggers._TriggerException
, thrown when a trigger failed to register, was removed.RuntimeError
is thrown in its place. (#4024)Removed the undocumented data attribute on
Event
and on the correspondingEvent.set()
. (#4079)Task.join()
was deprecated, use theTask
being joined directly wherevertask.join()
was previously used. (#4084)Join
was deprecated, use theTask
being joined directly whereverJoin(task)
was previously used. (#4084)When constructing a
LogicArray
from aint
, the range argument is now required. (#4093)Constructing a
LogicArray
from anint
now only accepts integer literals (unsigned). UseLogicArray.from_signed()
to convert negative integers intoLogicArray
s using two’s complement representation. (#4093)The module
cocotb.decorators
was removed. All functionality is now available directly in thecocotb
namespace (e.g.cocotb.decorators.test
is nowcocotb.test()
). (#4129)Removed
Task.has_started()
. (#4149)The
RTL_LIBRARY
andTOPLEVEL_LIBRARY
Makefile variables were merged intoTOPLEVEL_LIBRARY
. Update all uses ofRTL_LIBRARY
. (#4189)
Changes
cocotb.handle.ConstantObject
was removed. Constant value objects are now returned as their correspondingsimulator value object
subtype (e.g. integers in VHDL and Verilog are nowIntegerObject
s). You can check if the value object is constant using theis_const()
method. (#2720)All casts on
simulator value objects
have been deprecated. If you want to get the value from a simulator value object, use thevalue()
property; then cast the value. (#2720)All
simulator objects
when cast to astr
now return therepr
of the object and not thepath
. (#2720)Testing equality of
simulator value object
subtypes no longer does a value equality, but an identity equality. All simulator objects can now be used in hashable collections likedict
andset
. (#2720)std_(u)logic_vector
andstd_(u)logic
signals and constants in VHDL, andlogic
and packed arrays oflogic
signals and parameters in Verilog are nowLogicObject
s. (#2720)cocotb-bus can no longer be installed at the same time as cocotb using pip install cocotb[bus]. Use pip install cocotb-bus instead. (#3436)
cocotb.resume()
andcocotb.bridge()
are now implemented as decorator functions and not types. All attributes, e.g.log
, are no longer available. (#3461)For Aldec simulators, the -dbg and -O2 options are no longer passed by default, as they reduce simulation speed. Pass these options in
COMPILE_ARGS
andSIM_ARGS
if you need them for increased observability. (#3490)Use of the
TESTCASE
variable has been changed so that each element ofTESTCASE
will now select all tests with a matching name across allMODULE
s instead of just the first one found. (#3578)The
cocotb.test()
decorator now returns the decorated object instead of aTest
object. (#3578)The
RegressionManager
uses a new mechanism to discover tests. Typical uses of thecocotb.test()
decorator andTestFactory
should be unaffected, but atypical uses may not. (#3578)Getting a value with
LogicObject.value
now returns aLogicArray
. (#3634)cocotb.handle.RegionObject
was renamed toHierarchyObjectBase
. (#3655)The module
cocotb.xunit_reporter
was made private. (#3672)The module
cocotb.outcomes
was made private. (#3672)The module
cocotb.log
was renamed tococotb.logging
to prevent clashing withcocotb.log
. (#3673)Moved
cocotb.config
tococotb_tools.config
andcocotb.runner
tococotb_tools.runner
to improve startup speed. (#3731)Getting a value with
ArrayObject.value
now returns anArray
with the appropriateRange
set instead of alist
. This will change how the object is indexed to match the range of the simulation object, instead of0
tolen(handle)-1
like before. (#3733)Renamed
cocotb.handle.NonHierarchyIndexableObject
toArrayObject
. (#3733)Renamed
cocotb.handle.NonHierarchyObject
toValueObjectBase
. (#3733)Improved VHPI implementation of
cocotb.simulator.get_root_handle()
. Thename
parameter is now used for handle lookup only as the last fallback, after checking it against the name of thevhpiRootInst
object and its associatedentity
object. Handle lookup by name now always includes the:
prefix so that it matches theFullName
of the instantiated object, and will not match objects in the library information model. (#3774)When constructing a
LogicArray
, if the given value cannot fit in the given range, anOverflowError
is now thrown, instead of aValueError
. (#3792)The
cocotb.scheduler
module andcocotb.scheduler
object have been made private. (#3806)The base class for Python runners has been renamed from
Simulator
toRunner
. (#4025)Moved
SimTimeoutError
fromcocotb.result
tococotb.triggers
. (#4039)cocotb.external
andcocotb.function
have been renamed tococotb.bridge()
andcocotb.resume()
to better reflect their intended use case. (#4054)Updated
ValueObjectBase.setimmediatevalue()
to useGPI_NO_DELAY
to set values, so values are actually set immediately and can be read back immediately. (#4068)Writes performed following an
await
onReadWrite
will be applied immediately (but inertially) and not scheduled for the nextReadWrite
. (#4115)Attempting to await on either the
ReadWrite
orReadOnly
trigger while in the ReadOnly phase now raises aRuntimeError
. (#4208)
cocotb 1.9.1 (2024-08-29)
Bugfixes
Improve the Verilator Makefile to pass on
--trace
at runtime as well. (#4088)Pass
EXTRA_ARGS
in the Verilator Makefile to both the compilation and the simulation step.
Changes
Support setuptools 72.2.0
cocotb 1.9.0 (2024-07-14)
Features
Not using parentheses on
@cocotb.test
decorator is now supported. (#2731)The
cocotb.runner.Simulator.build()
method now accepts aclean
argument to removebuild_dir
completely during build stage. (#3351)Added
SIM_CMD_SUFFIX
to allow users to redirect simulator output or otherwise suffix the simulation command invocation. (#3561)Added
--trace
command line argument to Verilator simulation binaries for run-time trace generation. This new argument is passed to the binary when thewaves
argument tococotb.runner.Simulator.test()
isTrue
. (#3667)The
cocotb.runner.Simulator.build()
andcocotb.runner.Simulator.test()
methods now accept alog_file
argument to redirect stdout and stderr to the specified file. (#3668)The
results_xml
argument tococotb.runner.Simulator.test()
can now be an absolute path. (#3669)Added
--trace-file
command line argument to Verilator simulation binaries which specifies the trace file name. This can be passed to the binary by using thetest_args
argument tococotb.runner.Simulator.test()
. (#3683)The
cocotb.runner.Simulator.test()
method now accepts apre_cmd
argument to run given commands before the simulation starts. These are typically Tcl commands for simulators that support them. Only support for the Questa simulator has been implemented. (#3744)The
sources
option was added tococotb.runner.Simulator.build()
to better support building mixed-language designs. (#3796)Enable use of VPI fallback in all simulators when attempting to access generate blocks directly via lookup. This enables better support for simulators that don’t support
vpiGenScopeArray
, allowing discovery of generate blocks without having to iterate over the parent handle. (#3817)Added support for comparing
BinaryValue
withLogic
,LogicArray
, andstr
. (#3845)Riviera-PRO now supports compilation into (multiple) VHDL libraries using
VHDL_SOURCES_
. (#3922)
Bugfixes
Xcelium 23.09.004 and newer can now be used to test designs with a VHDL toplevel. (#1076)
Fixed a potential issue where pseudo-region lookup may find the wrong generate block if the name of one generate block starts with the name of another generate block. (#2255)
Support
waves
argument tococotb.runner.Simulator.build()
for Verilator. (#3681)The
test_args
argument tococotb.runner.Simulator.test()
is now passed to the Verilator simulation binary when running the simulation, which was previously missing. (#3682)
Deprecations and Removals
Join.retval
is deprecated. UseTask.result()
to get the result of a joined Task. (#3871)Passing the outcome argument to
NullTrigger
- which allowed the user to inject arbitrary outcomes when the trigger wasawait
ed - is deprecated. There is no alternative. (#3871)
Changes
For Aldec simulators, the -dbg and -O2 options are no longer passed by default, as they reduce simulation speed. Pass these options in
COMPILE_ARGS
andSIM_ARGS
if you need them for increased observability. (#3490)await
ing aJoin
trigger will yield the Join trigger and not the result of the task in the 2.0 release. (#3871)Lock.locked
is now a method rather than an attribute to mirrorasyncio.Lock.locked()
. (#3871)
cocotb 1.8.0 (2023-06-15)
Features
cocotb.types.LogicArray
now supports a default value construction if arange
is given. (#3031)Add support for
fraction.Fraction
anddecimal.Decimal
to theperiod
argument ofcocotb.clock.Clock
. (#3045)This release adds the Python Test Runner, an experimental replacement for the traditional Makefile-based build and run flow. (#3103)
Incisive now supports compilation into a named VHDL library
lib
usingVHDL_SOURCES_<lib>
. (#3261)Cocotb can now correctly drive Verilator when its new
--timing
flag is used. (#3316)Creating an FST waveform dump in Icarus Verilog can now be done by setting the
WAVES
environment variable. Icarus-specific Verilog code is no longer required. (#3324)
Bugfixes
Fixed Verilator not writing coverage files in some cases. (#1478)
The
Regression Manager
now correctly handles exceptions raised in tests when the exceptions inherit from BaseException. (#3196)Fix a performance regression when using Questa with FLI introduced in cocotb 1.7.0. (#3229)
Adds support for packed union in SystemVerilog when using Cadence Xcelium. (#3239)
Fixed
RecursionError
caused by certain corner cases in the scheduler. (#3267)Fixed cleanup in scheduler which caused sporadic warning messages and bugs in some corner cases. (#3270)
Fix “use after free” bug in VHPI implementation causing Riviera to fail to discover some simulation objects. (#3307)
Changes
Removed
level
arg from_sim_event
function in thePYGPI_ENTRY_POINT
interface. This function can only indicate a request to shutdown from the simulator or GPI. (#3066)Moved
cocotb.task.Task
and friends tococotb.task
module to alleviate internal cyclic import dependency. Users should update imports of theTask
to import from the top-levelcocotb
namespace. (#3067)Added support for
VERILOG_INCLUDE_DIRS
in the Makefiles. (#3189)Changed platform support: Added Red Hat Enterprise Linux 9 (RHEL) and compatible clones, added macOS 13 x86_64 (Ventura on Intel), removed Ubuntu 18.04 (end-of-life). Note that Python wheels compatible with Ubuntu 18.04 remain available for the time being. Even though the cocotb project does not provide pre-compiled binaries for unsupported platforms users can typically compile cocotb themselves, as done automatically when running
pip install
.
cocotb 1.7.2 (2022-11-15)
Changes
Python 3.11 is now supported.
find_libpython
, a library to find (as the name indicates) libpython, is now a dependency of cocotb. Its latest version resolves an issue for users on RedHat Enterprise Linux (RHEL) 8 and Python 3.8, where the correct Python library would not be detected. (#3097)
Bugfixes
Fixed a segmentation fault in Aldec Riviera-PRO that prevented mixed-language simulation from running. (#3078)
cocotb 1.7.1 (2022-09-17)
Bugfixes
cocotb 1.7.0 (2022-09-06)
Features
Removed the need for ModelSim or Questa being installed when building cocotb. Similar to the approach taken with VPI and VHPI, cocotb now includes all C header files to build the FLI interface. This improvement was done in close collaboration with Siemens EDA, who changed the license of the relevant source code file. (#2948)
With Questa 2022.3 VHPI support is now fully working and no longer experimental. cocotb still defaults to using the FLI interface for VHDL toplevels with Questa. Users can choose VHPI instead by setting the
VHDL_GPI_INTERFACE
environment variable tovhpi
before running cocotb. (#2803)cocotb tests are now more reproducible. (#2721)
Force
,Freeze
, andRelease
are now supported when using the FLI, Questa’s traditional method to access VHDL. (#2775)cocotb binaries now statically link libstdc++ on Linux, which prevents library load errors even if the simulator ships its own libstdc++. (#3002)
Bugfixes
Fixed write scheduling to apply writes oldest to newest. (#2792)
Fixed Riviera makefile error for mixed-language simulation when VHDL is the top-level. This bug prevented the VPI library from loading correctly, and was a regression in 1.5.0. (#2912)
Fixed FLI issue where unprimed triggers were still firing. (#3010)
Deprecations and Removals
cocotb.fork()
has been deprecated in favor ofcocotb.start_soon()
orcocotb.start()
. (#2663)
Changes
Passing coroutines to
with_timeout()
is now supported. (#2494)Made
Task
interface more likeasyncio.Task
’s. (#2876)When code coverage is enabled with
COVERAGE
and a configuration file is specified withCOVERAGE_RCFILE
, default coverage configuration is not applied to avoid overriding the user-defined configuration. (#3014)
cocotb 1.6.2 (2022-02-07)
Bugfixes
Fix regression in
TestFactory
when using generator-based test coroutines. (#2839)
Changes
Change how
PYTHONHOME
is populated to work with broken mingw environments. (#2739)
cocotb 1.6.1 (2021-12-07)
Bugfixes
Fix regression in
TestFactory
wrt unique test names. (#2781)
cocotb 1.6.0 (2021-10-20)
Features
Support a custom entry point from C to Python with
PYGPI_ENTRY_POINT
. (#1225)Added
Logic
andcocotb.types.Bit
modeling datatypes. (#2059)ModelSim and Questa now support compilation into a named VHDL library
lib
usingVHDL_SOURCES_<lib>
. (#2465)Added the
LogicArray
modeling datatype. (#2514)Xcelium now supports compilation into a named VHDL library
lib
usingVHDL_SOURCES_<lib>
. (#2614)Add the
SIM_CMD_PREFIX
to supported Makefile variables, allowing users to pass environment variables and other command prefixes to simulators. (#2615)To support VHDL libraries in ModelSim/Questa/Xcelium,
VHDL_LIB_ORDER
has been added to specify a library compilation order. (#2635)cocotb.fork()
,cocotb.start()
,cocotb.start_soon()
, andcocotb.create_task()
now accept any object that implements thecollections.abc.Coroutine
protocol. (#2647)TestFactory
andcocotb.test
now accept anycollections.abc.Callable
object which returns acollections.abc.Coroutine
as a test function. (#2647)Added
cocotb.start()
andcocotb.start_soon()
scheduling functions. (#2660)Add
cocotb.create_task()
API for creating a Task from a Coroutine without scheduling. (#2665)Support rounding modes in
get_sim_steps()
. (#2684)Support passing
'step'
as a time unit incocotb.utils.get_sim_time()
. (#2691)
Bugfixes
VHDL signals that are zero bits in width now read as the integer
0
, instead of raising an exception. (#2294)Correctly parse plusargs with
=
s in the value. (#2483)COCOTB_RESULTS_FILE
now properly communicates with theRegression Manager
to allow overloading the result filename. (#2487)Fixed several scheduling issues related to the use of
cocotb.start_soon()
. (#2504)Verilator and Icarus now support running without specifying a
TOPLEVEL
. (#2547)Fixed discovery of signals inside SystemVerilog interfaces. (#2683)
Improved Documentation
The Models of Analog Circuits example has been added, showing how to use Python models for analog circuits together with a digital part. (#2438)
Deprecations and Removals
Setting values on indexed handles using the
handle[i] = value
syntax is deprecated. Instead use thehandle[i].value = value
syntax. (#2490)Setting values on handles using the
dut.handle = value
syntax is deprecated. Instead use thehandle.value = value
syntax. (#2490)Setting values on handles using the
signal <= newval
syntax is deprecated. Instead, use thesignal.value = newval
syntax. (#2681)cocotb.utils.hexdump
is deprecated; usescapy.utils.hexdump()
instead. (#2691)cocotb.utils.hexdiffs
is deprecated; usescapy.utils.hexdiff()
instead. (#2691)Passing
None
tococotb.utils.get_sim_time()
is deprecated; use'step'
as the time unit instead. (#2691)The
stdout
andstderr
attributes oncocotb.result.TestComplete
and subclasses are deprecated. (#2692)TestFailure
is deprecated, use anassert
statement instead. (#2692)
Changes
Assigning out-of-range Python integers to signals will now raise an
OverflowError
. (#2316)cocotb now requires Python 3.6+. (#2422)
Selecting tests using
TESTCASE
will now search for the first occurrence of a test of that name in order of modules listed inMODULE
s, and not just the first module in that list. (#2434)The environment variable
COCOTB_LOG_LEVEL
now supportsTRACE
value, which is used for verbose low-level logging that was previously inDEBUG
logs. (#2502)Improves formatting on test-related logging outputs. (#2564)
Shorter log lines (configurable with
COCOTB_REDUCED_LOG_FMT
) are now the default. For wider log output, similar to previous cocotb releases, set theCOCOTB_REDUCED_LOG_FMT
environment variable to0
. (#2564)
cocotb 1.5.2 (2021-05-03)
Bugfixes
cocotb 1.5.1 (2021-03-20)
Bugfixes
Prevent pytest assertion rewriting (#2028) from capturing stdin, which causes problems with IPython support. (#1649) (#2462)
Add dependency on cocotb_bus to prevent breaking users that were previously using the bus and testbenching objects. (#2477)
Add back functionality to
cocotb.binary.BinaryValue
that allows the user to changebinaryRepresentation
after object creation. (#2480)
cocotb 1.5.0 (2021-03-11)
Features
Support for building with Microsoft Visual C++ has been added. See Installation for more details. (#1798)
Makefiles now automatically deduce
TOPLEVEL_LANG
based on the value ofVERILOG_SOURCES
andVHDL_SOURCES
. Makefiles also detect incorrect usage ofTOPLEVEL_LANG
for simulators that only support one language. (#1982)cocotb.fork()
will now raise a descriptiveTypeError
if a coroutine function is passed into them. (#2006)Added
cocotb.scheduler.start_soon()
which schedules a coroutine to start after the current coroutine yields control. This behavior is distinct fromcocotb.fork()
which schedules the given coroutine immediately. (#2023)If
pytest
is installed, its assertion-rewriting framework will be used to produce more informative tracebacks from theassert
statement. (#2028)The handle to
TOPLEVEL
, typically seen as the first argument to a cocotb test function, is now available globally ascocotb.top
. (#2134)The
units
argument toTimer
,Clock
andget_sim_steps()
, and thetimeout_unit
argument towith_timeout()
andcocotb.test
now accepts'step'
to mean the simulator time step. This used to be expressed usingNone
, which is now deprecated. (#2171)TestFactory.add_option()
now supports groups of options when a full Cartesian product is not desired. (#2175)Added asyncio-style queues,
Queue
,PriorityQueue
, andLifoQueue
. (#2297)Support for the SystemVerilog type
bit
has been added. (#2322)Added the
--lib-dir
,--lib-name
and--lib-name-path
options to thecocotb-config
command to make cocotb integration into existing flows easier. (#2387)Support for using Questa’s VHPI has been added. Use
VHDL_GPI_INTERFACE
to select between using the FLI or VHPI when dealing with VHDL simulations. Note that VHPI support in Questa is still experimental at this time. (#2408)
Bugfixes
Assigning Python integers to signals greater than 32 bits wide will now work correctly for negative values. (#913)
Fix GHDL’s library search path, allowing libraries other than work to be used in simulation. (#2038)
Tests skipped by default (created with skip=True) can again be run manually by setting the
TESTCASE
variable. (#2045)In Icarus Verilog, generate blocks are now accessible directly via lookup without having to iterate over parent handle. (#2079, #2143)
# Example pseudo-region dut.genblk1 #<class 'cocotb.handle.HierarchyArrayObject'>
Fixed an issue with VHPI on Mac OS and Linux where negative integers were returned as large positive values. (#2129)
Improved Documentation
The Mixed-signal (analog/digital) example has been added, showing how to use HDL helper modules in cocotb testbenches that exercise two mixed-signal (i.e. analog and digital) designs. (#1051)
New example Matrix Multiplier. (#1502)
A Reference Card showing the most used features of cocotb has been added. (#2321)
A chapter Extending existing build flows has been added. (#2340)
Deprecations and Removals
The contents of
cocotb.generators
have been deprecated. (#2047)The outdated “Sorter” example has been removed from the documentation. (#2049)
Passing
bool
values toexpect_error
option ofcocotb.test
is deprecated. Pass a specificException
or a tuple of Exceptions instead. (#2117)The system task overloads for
$info
,$warn
,$error
and$fatal
in Verilog and mixed language testbenches have been removed. (#2133)TestError
has been deprecated, use Built-in Exceptions. (#2177)The undocumented class
cocotb.xunit_reporter.File
has been removed. (#2200)Deprecated
cocotb.hook
andCOCOTB_HOOKS
. See the documentation forcocotb.hook
for suggestions on alternatives. (#2201)Deprecate
cocotb.utils.pack
andcocotb.utils.unpack
and the use ofctypes.Structure
in signal assignments. (#2203)The outdated “ping” example has been removed from the documentation and repository. (#2232)
Using the undocumented custom format
dict
object in signal assignments has been deprecated. (#2240)The access modes of many interfaces in the cocotb core libraries were re-evaluated. Some interfaces that were previously public are now private and vice versa. Accessing the methods through their old name will create a
DeprecationWarning
. In the future, the deprecated names will be removed. (#2278)The bus and testbenching components in cocotb have been officially moved to the cocotb-bus package. This includes
Bus
,Scoreboard
, everything incocotb_bus.drivers
, and everything incocotb_bus.monitors
. Documentation will remain in the main cocotb repository for now. Old names will continue to exist, but their use will cause aDeprecationWarning
, and will be removed in the future. (#2289)
Changes
Assigning negative Python integers to handles does an implicit two’s compliment conversion. (#913)
Updated
Driver
,Monitor
, and all their subclasses to use theasync
/await
syntax instead of theyield
syntax. (#2022)The package build process is now fully PEP 517 compliant. (#2091)
Improved support and performance for Verilator (version 4.106 or later now required). (#2105)
Changed how libraries are specified in
GPI_EXTRA
to allow specifying libraries with paths, and names that don’t start with “lib”. (#2341)
Cocotb 1.4.0 (2020-07-08)
Features
Lock
can now be used inasync with
statements. (#1031)Add support for distinguishing between
net
(vpiNet
) andreg
(vpiReg
) type when using the VPI interface. (#1107)Support for dropping into
pdb
upon failure, via the newCOCOTB_PDB_ON_EXCEPTION
environment variable. (#1180)Simulators run through a Tcl script (Aldec Riviera Pro and Mentor simulators) now support a new
RUN_ARGS
Makefile variable, which is passed to the first invocation of the tool during runtime. (#1244)Cocotb now supports the following example of forking a non-decorated async coroutine.
async def example(): for i in range(10): await cocotb.triggers.Timer(10, "ns") cocotb.fork(example())
Issue (#1255)
The cocotb log configuration is now less intrusive, and only configures the root logger instance,
logging.getLogger()
, as part ofcocotb.logging.default_config()
(#1266).As such, it is now possible to override the default cocotb logging behavior with something like:
# remove the cocotb log handler and formatting root = logging.getLogger() for h in root.handlers[:]: root.remove_handler(h) h.close() # add your own logging.basicConfig()
Support for
vpiRealNet
. (#1282)The colored output can now be disabled by the
NO_COLOR
environment variable. (#1309)Cocotb now supports deposit/force/release/freeze actions on simulator handles, exposing functionality similar to the respective Verilog/VHDL assignments.
from cocotb.handle import Deposit, Force, Release, Freeze dut.q <= 1 # A regular value deposit dut.q <= Deposit(1) # The same, higher verbosity dut.q <= Force(1) # Force value of q to 1 dut.q <= Release() # Release q from a Force dut.q <= Freeze() # Freeze the current value of q
Issue (#1403)
Custom logging handlers can now access the simulator time using
logging.LogRecord.created_sim_time
, provided theSimTimeContextFilter
filter added bydefault_config()
is not removed from the logger instance. (#1411)Questa now supports
PLUSARGS
. This requires thattcl.h
be present on the system. This is likely included in your installation of Questa, otherwise, specifyCFLAGS=-I/path/to/tcl/includedir
. (#1424)The name of the entry point symbol for libraries in
GPI_EXTRA
can now be customized. The delimiter between each library in the list has changed from:
to,
. (#1457)New methods for setting the value of a
cocotb.handle.NonHierarchyIndexableObject
(HDL arrays). (#1507)# Now supported dut.some_array <= [0xAA, 0xBB, 0xCC] dut.some_array.value = [0xAA, 0xBB, 0xCC] # For simulators that support n-dimensional arrays dut.some_2d_array <= [[0xAA, 0xBB], [0xCC, 0xDD]] dut.some_2d_array.value = [[0xAA, 0xBB], [0xCC, 0xDD]]
Added support for Aldec’s Active-HDL simulator. (#1601)
Including
Makefile.inc
from user makefiles is now a no-op and deprecated. Lines likeinclude $(shell cocotb-config --makefiles)/Makefile.inc
can be removed from user makefiles without loss in functionality. (#1629)Support for using
await
inside an embedded IPython terminal, usingcocotb.ipython_support
. (#1649)Added
is_set()
, so users may check if anEvent
has fired. (#1723)The
cocotb.simulator.is_running()
function was added so a user of cocotb could determine if they are running within a simulator. (#1843)
Bugfixes
Tests which fail at initialization, for instance due to no
yield
being present, are no longer silently ignored. (#1253)Tests that were not run because predecessors threw
cocotb.result.SimFailure
, and caused the simulator to exit, are now recorded with an outcome ofcocotb.result.SimFailure
. Previously, these tests were ignored. (#1279)Makefiles now correctly fail if the simulation crashes before a
results.xml
file can be written. (#1314)Logging of non-string messages with colored log output is now working. (#1410)
Getting and setting the value of a
cocotb.handle.NonHierarchyIndexableObject
now iterates through the correct range of the simulation object, so arrays that do not start/end at index 0 are supported. (#1507)The
XGMII
monitor no longer crashes on Python 3, and now assembles packets asbytes
instead ofstr
. TheXGMII
driver has expectedbytes
since cocotb 1.2.0. (#1545)signal <= value_of_wrong_type
no longer breaks the scheduler, and throws an error immediately. (#1661)Scheduling behavior is now consistent before and after the first
await
of aGPITrigger
. (#1705)Iterating over
for generate
statements using VHPI has been fixed. This bug caused some simulators to crash, and was a regression in version 1.3. (#1882)The
XGMII
driver no longer emits a corrupted word on the first transfer. (#1905)
Improved Documentation
If a makefile uses cocotb’s
Makefile.sim
,make help
now lists the supported targets and variables. (#1318)A new section Rotating Log Files has been added. (#1400)
The documentation at http://docs.cocotb.org/ has been restructured, making it easier to find relevant information. (#1482)
Deprecations and Removals
cocotb.utils.reject_remaining_kwargs
is deprecated, as it is no longer needed now that we only support Python 3.5 and newer. (#1339)The value of
cocotb.handle.StringObject
s is now of typebytes
, instead ofstr
with an implied ASCII encoding scheme. (#1381)ReturnValue
is now deprecated. Use areturn
statement instead; this works in all supported versions of Python. (#1489)The makefile variable
VERILATOR_TRACE
that was not supported for all simulators has been deprecated. Using it prints a deprecation warning and points to the documentation section Simulator Support explaining how to get the same effect by other means. (#1495)cocotb.binary.BinaryValue.get_hex_buff
produced nonsense and has been removed. (#1511)Passing
str
instances tococotb.utils.hexdump
andcocotb.utils.hexdiffs
is deprecated.bytes
objects should be passed instead. (#1519)Makefile.pylib
, which provided helpers for building C extension modules for Python, has been removed. Users of thePYTHON_LIBDIR
andPYTHON_INCLUDEDIR
variables will now have to compute these values themselves. See theendian_swapper
example for how to do this. (#1632)Makefile and documentation for the NVC simulator which has never worked have been removed. (#1693)
Changes
Cocotb no longer supports Python 2, at least Python 3.5 is now required. Users of Python 2.7 can still use cocotb 1.3, but are heavily encouraged to update. It is recommended to use the latest release of Python 3 for improved performance over older Python 3 versions. (#767)
Mentor Questa, Aldec Riviera-PRO and GHDL are now started in the directory containing the Makefile and also save
results.xml
there, bringing them in line with the behavior used by other simulators. (#1598) (#1599) (#1063)Tests are now evaluated in order of their appearance in the
MODULE
environment variable, their stage, and the order of invocation of thecocotb.test
decorator within a module. (#1380)All libraries are compiled during installation to the
cocotb/libs
directory. The interface librarieslibcocotbvpi
andlibcocotbvhpi
have been renamed to have a_simulator_name
postfix. Thesimulator
module has moved tococotb.simulator
. TheLD_LIBRARY_PATH
environment variable no longer needs to be set by the makefiles, as the libraries now discover each other viaRPATH
settings. (#1425)cocotb.handle.NonHierarchyIndexableObject.value
is now a list in left-to-right range order of the underlying simulation object. Previously the list was always ordered low-to-high. (#1507)Various binary representations have changed type from
str
tobytes
. These include:cocotb.binary.BinaryValue.buff
, which as a consequence meanscocotb.binary.BinaryValue.assign
, no longer accepts malformed10xz
-stylestr
s (which were treated as binary).The objects produced by
cocotb.generators.byte
, which means that single bytes are represented byint
instead of 1-characterstr
s.The packets produced by the
AvalonSTPkts
.
Code working with these objects may find it needs to switch from creating
str
objects like"this"
tobytes
objects likeb"this"
. This change is a consequence of the move to Python 3. (#1514)There’s no longer any need to set the
PYTHON_BIN
makefile variable, the Python executable automatically matches the one cocotb was installed into. (#1574)The
SIM
setting for Aldec Riviera-PRO has changed fromaldec
toriviera
. (#1691)Certain methods on the
cocotb.simulator
Python module now throw aRuntimeError
when no simulator is present, making it safe to usecocotb
without a simulator present. (#1843)Invalid values of the environment variable
COCOTB_LOG_LEVEL
are no longer ignored. They now raise an exception with instructions how to fix the problem. (#1898)
cocotb 1.3.2
Released on 08 July 2020
Notable changes and bug fixes
Iterating over
for generate
statements using VHPI has been fixed. This bug caused some simulators to crash, and was a regression in version 1.3.1. (#1882)
cocotb 1.3.1
Released on 15 March 2020
Notable changes and bug fixes
The Makefiles for the Aldec Riviera and Cadence Incisive simulators have been fixed to use the correct name of the VHPI library (
libcocotbvhpi
). This bug prevented VHDL designs from being simulated, and was a regression in 1.3.0. (#1472)
cocotb 1.3.0
Released on 08 January 2020
This will likely be the last release to support Python 2.7.
New features
Initial support for the Verilator simulator (version 4.020 and above). The integration of Verilator into cocotb is not yet as fast or as powerful as it is for other simulators. Please use the latest version of Verilator, and report bugs if you experience problems.
New makefile variables
COCOTB_HDL_TIMEUNIT
andCOCOTB_HDL_TIMEPRECISION
for setting the default time unit and precision that should be assumed for simulation when not specified by modules in the design. (#1113)New
timeout_time
andtimeout_unit
arguments tococotb.test()
, for adding test timeouts. (#1119)with_timeout()
, for a shorthand for waiting for a trigger with a timeout. (#1119)The
expect_error
argument tococotb.test()
now accepts a specific exception type. (#1116)New environment variable
COCOTB_RESULTS_FILE
, to allow configuration of the xUnit XML output filename. (#1053)A new
bus_separator
argument tococotb.drivers.BusDriver
. (#1160)A new
start_high
argument tococotb.clock.Clock.start()
. (#1036)A new
cocotb.__version__
constant, which contains the version number of the running cocotb. (#1196)
Notable changes and bug fixes
DeprecationWarning
s are now shown in the output by default.Tracebacks are now preserved correctly for exceptions in Python 2. The tracebacks in all Python versions are now a little shorter.
cocotb.bridge()
andcocotb.resume()
now work more reliably and with fewer race conditions.A failing
assert
will be considered a test failure. Previously, it was considered a test error.drivers()
andloads()
now also work correctly in Python 3.7 onwards.Timer
can now be used withdecimal.Decimal
instances, allowing constructs likeTimer(Decimal("1e-9"), units="sec")
as an alternate spelling forTimer(100, units="us")
. (#1114)Many (editorial) documentation improvements.
Deprecations
cocotb.result.raise_error
andcocotb.result.create_error
are deprecated in favor of using Python exceptions directly.TestError
can still be used if the same exception type is desired. (#1109)The
AvalonSTPktsWithChannel
type is deprecated. Use thereport_channel
argument toAvalonSTPkts
instead.The
colour
attribute of log objects likecocotb.log
orsome_coro.log
is deprecated. Usecocotb.utils.want_color_output
instead. (#1231)
Other news
cocotb is now packaged for Fedora Linux and available as python-cocotb. (Fedora bug #1747574) (thanks Ben Rosser)
cocotb 1.2.0
Released on 24 July 2019
New features
cocotb is now built as Python package and installable through pip. (#517, #799, #800, #803, #805)
Support for
async
functions and generators was added (Python 3 only). Please have a look at Coroutines and Tasks for an example how to use this new feature.VHDL block statements can be traversed. (#850)
Support for Python 3.7 was added.
Notable changes and bug fixes
The heart of cocotb, its scheduler, is now even more robust. Many small bugs, inconsistencies and unreliable behavior have been ironed out.
Exceptions are now correctly propagated between coroutines, giving users the “natural” behavior they’d expect with exceptions. (#633)
The
setimmediatevalue()
function now works for values larger than 32 bit. (#768)The documentation was cleaned up, improved and extended in various places, making it more consistent and complete.
Tab completion in newer versions of IPython is fixed. (#825)
Python 2.6 is officially not supported any more. cocotb supports Python 2.7 and Python 3.5+.
The cocotb GitHub project moved from
potentialventures/cocotb
tococotb/cocotb
. Redirects for old URLs are in place.
Deprecations
The bits argument to
cocotb.binary.BinaryValue
, which is now called n_bits.The logger attribute of log objects like
cocotb.log
orsome_coro.log
, which is now just an alias forself
.The
cocotb.utils.get_python_integer_types
function, which was intended to be private.
Known issues
Depending on your simulation, cocotb 1.2 might be roughly 20 percent slower than cocotb 1.1. Much of the work in this release cycle went into fixing correctness bugs in the scheduler, sometimes at the cost of performance. We are continuing to investigate this in issue #961. Independent of the cocotb version, we recommend using the latest Python 3 version, which is shown to be significantly faster than previous Python 3 versions, and slightly faster than Python 2.7.
Please have a look at the issue tracker for more outstanding issues and contribution opportunities.
cocotb 1.1
Released on 24 January 2019.
This release is the result of four years of work with too many bug fixes, improvements and refactorings to name them all.
cocotb 1.0
Released on 15 February 2015.
New features
FLI support for ModelSim
Mixed Language, Verilog and VHDL
Windows
300% performance improvement with VHPI interface
WaveDrom support for wave diagrams.
cocotb 0.4
Released on 25 February 2014.
New features
Issue #101: Implement Lock primitive to support mutex
Issue #105: Compatibility with Aldec Riviera-Pro
Issue #109: Combine multiple
results.xml
into a single results fileIssue #111: XGMII drivers and monitors added
Issue #113: Add operators to
BinaryValue
classIssue #116: Native VHDL support by implementing VHPI layer
Issue #117: Added AXI4-Lite Master BFM
Bugs fixed
New examples
Issue #106: TUN/TAP example using ping
cocotb 0.3
Released on 27 September 2013.
This contains a raft of fixes and feature enhancements.
cocotb 0.2
Released on 19 July 2013.
New features
Release 0.2 supports more simulators and increases robustness over 0.1.
A centralized installation is now supported (see documentation) with supporting libraries build when the simulation is run for the first time.
cocotb 0.1
Released on 9 July 2013.
The first release of cocotb.
Allows installation and running against Icarus, VCS, Aldec simulators.