piel.tools.cocotb#
Submodules#
Attributes#
Functions#
|
Checks if a Cocotb testbench exists in the specified design directory. |
|
Configures a Cocotb simulation by generating a Makefile in the specified directory. |
|
Runs the Cocotb simulation by executing the Makefile in the specified design directory. |
Returns a list of all simulation output files in the specified design directory. |
|
|
Reads simulation files from a specified file into a Pandas dataframe. |
|
Plots simulation files using Bokeh for interactive visualization. |
Package Contents#
- check_cocotb_testbench_exists(design_directory: str | pathlib.Path) bool[source]#
Checks if a Cocotb testbench exists in the specified design directory.
- Parameters:
design_directory (str | pathlib.Path) – The directory where the design files are located.
- Returns:
True if a Cocotb testbench exists, False otherwise.
- Return type:
bool
Examples
>>> check_cocotb_testbench_exists("/path/to/design") True
- configure_cocotb_simulation(design_directory: str | pathlib.Path, simulator: piel.types.digital.HDLSimulator, top_level_language: piel.types.digital.HDLTopLevelLanguage, top_level_verilog_module: str, test_python_module: str, design_sources_list: list | None = None) pathlib.Path[source]#
Configures a Cocotb simulation by generating a Makefile in the specified directory.
This function creates a Makefile required to run Cocotb simulations. It includes paths to design source files and sets up the simulator and language options.
- Parameters:
design_directory (str | pathlib.Path) – The directory where the design files are located.
simulator (Literal["icarus", "verilator"]) – The simulator to use for the simulation.
top_level_language (Literal["verilog", "vhdl"]) – The top-level HDL language used in the design.
top_level_verilog_module (str) – The top-level Verilog module name.
test_python_module (str) – The Python test module name for Cocotb.
design_sources_list (list | None, optional) – A list of design source file paths. Defaults to None.
- Returns:
The path to the generated Makefile.
- Return type:
pathlib.Path
Examples
>>> configure_cocotb_simulation("/path/to/design", "icarus", "verilog", "top_module", "test_module") PosixPath('/path/to/design/tb/Makefile')
- delete_simulation_output_files#
- run_cocotb_simulation(design_directory: str, raise_error: bool = False) subprocess.CompletedProcess[source]#
Runs the Cocotb simulation by executing the Makefile in the specified design directory.
- Parameters:
design_directory (str) – The directory where the design files are located.
- Returns:
The completed process object containing the result of the simulation run.
- Return type:
subprocess.CompletedProcess
Examples
>>> run_cocotb_simulation("/path/to/design")
- get_simulation_output_files#
- get_simulation_output_files_from_design(design_directory: piel.types.PathTypes, extension: str = 'csv') list[source]#
Returns a list of all simulation output files in the specified design directory.
- Parameters:
design_directory (PathTypes) – The path to the design directory.
extension (str, optional) – The file extension to filter by. Defaults to “csv”.
- Returns:
A list of paths to the simulation output files in the design directory.
- Return type:
list
Examples
>>> get_simulation_output_files_from_design("/path/to/design") [PosixPath('/path/to/design/tb/out/output1.csv'), PosixPath('/path/to/design/tb/out/output2.csv')]
- read_simulation_data(file_path: piel.types.PathTypes, *args, **kwargs) pandas.DataFrame[source]#
Reads simulation files from a specified file into a Pandas dataframe.
- Parameters:
file_path (PathTypes) – The path to the simulation files file.
- Returns:
The simulation files as a Pandas dataframe.
- Return type:
pd.DataFrame
Examples
>>> read_simulation_data("/path/to/simulation/output.csv") # Returns a dataframe with the contents of the CSV file.
- simple_plot_simulation_data(simulation_data: pandas.DataFrame)[source]#
Plots simulation files using Bokeh for interactive visualization.
- Parameters:
simulation_data (pd.DataFrame) – The simulation files to plot, containing columns ‘t’ for time and ‘x’ for signal values.
- Returns:
Displays an interactive plot.
- Return type:
None
Examples
>>> files = pd.DataFrame({"t": [0, 1, 2, 3], "x": [0, 1, 0, 1]}) >>> simple_plot_simulation_data(files) # Displays an interactive Bokeh plot.