opencos-eda 0.3.10__py3-none-any.whl → 0.3.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opencos/commands/deps_help.py +63 -113
- opencos/commands/export.py +7 -2
- opencos/commands/multi.py +3 -3
- opencos/commands/sim.py +14 -15
- opencos/commands/synth.py +1 -2
- opencos/commands/upload.py +192 -4
- opencos/commands/waves.py +8 -8
- opencos/deps/deps_commands.py +6 -6
- opencos/deps/deps_processor.py +129 -50
- opencos/docs/Architecture.md +45 -0
- opencos/docs/ConnectingApps.md +29 -0
- opencos/docs/DEPS.md +199 -0
- opencos/docs/Debug.md +77 -0
- opencos/docs/DirectoryStructure.md +22 -0
- opencos/docs/Installation.md +117 -0
- opencos/docs/OcVivadoTcl.md +63 -0
- opencos/docs/OpenQuestions.md +7 -0
- opencos/docs/README.md +13 -0
- opencos/docs/RtlCodingStyle.md +54 -0
- opencos/docs/eda.md +147 -0
- opencos/docs/oc_cli.md +135 -0
- opencos/eda.py +132 -35
- opencos/eda_base.py +173 -47
- opencos/eda_config.py +56 -17
- opencos/eda_config_defaults.yml +21 -4
- opencos/files.py +26 -1
- opencos/tools/cocotb.py +5 -5
- opencos/tools/invio.py +2 -2
- opencos/tools/invio_yosys.py +2 -1
- opencos/tools/iverilog.py +3 -3
- opencos/tools/quartus.py +113 -115
- opencos/tools/questa_common.py +2 -2
- opencos/tools/riviera.py +3 -3
- opencos/tools/slang.py +11 -7
- opencos/tools/slang_yosys.py +1 -0
- opencos/tools/surelog.py +4 -3
- opencos/tools/verilator.py +4 -4
- opencos/tools/vivado.py +307 -176
- opencos/tools/yosys.py +4 -4
- opencos/util.py +6 -3
- opencos/utils/dict_helpers.py +31 -0
- opencos/utils/markup_helpers.py +2 -2
- opencos/utils/subprocess_helpers.py +3 -3
- opencos/utils/vscode_helper.py +2 -2
- opencos/utils/vsim_helper.py +16 -5
- {opencos_eda-0.3.10.dist-info → opencos_eda-0.3.11.dist-info}/METADATA +1 -1
- opencos_eda-0.3.11.dist-info/RECORD +94 -0
- opencos_eda-0.3.10.dist-info/RECORD +0 -81
- {opencos_eda-0.3.10.dist-info → opencos_eda-0.3.11.dist-info}/WHEEL +0 -0
- {opencos_eda-0.3.10.dist-info → opencos_eda-0.3.11.dist-info}/entry_points.txt +0 -0
- {opencos_eda-0.3.10.dist-info → opencos_eda-0.3.11.dist-info}/licenses/LICENSE +0 -0
- {opencos_eda-0.3.10.dist-info → opencos_eda-0.3.11.dist-info}/licenses/LICENSE.spdx +0 -0
- {opencos_eda-0.3.10.dist-info → opencos_eda-0.3.11.dist-info}/top_level.txt +0 -0
opencos/docs/Debug.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
CogniX has a few things that should help debug.
|
|
4
|
+
|
|
5
|
+
1) Direct connection to COS control layer. This is like "root" on Linux, being able to direct access the I/O (read buttons, override LEDs, fans, PLLs...). Via this path, we can also fake the user interactions (emulate a button press, see what userspace is driving to LEDs, etc), which is great for testing the user space itself. It's also useful for outward facing debug, i.e. ensuring COS is properly connected to the board (without needing userspace at all).
|
|
6
|
+
|
|
7
|
+
2) Debug Macros: Virtual Input/Output, Integrated Logic Analyzer, etc.
|
|
8
|
+
|
|
9
|
+
* Virtual Input/Output will be mapped to the appropriate target-specific feature, generally a GUI connecting to the target via JTAG.
|
|
10
|
+
|
|
11
|
+
Remind the user that generally this requires an IP to be built for the appropriate parameter sizes. The board/vendor will have certain sizes prebuilt.
|
|
12
|
+
|
|
13
|
+
32 inputs, 32 outputs : the only size required to be universally supported (CogniX itself uses this).
|
|
14
|
+
|
|
15
|
+
# ─── Example: Virtual Input/Output
|
|
16
|
+
|
|
17
|
+
logic [27:0] clockSignalDivide;
|
|
18
|
+
always_ff @(posedge clockSignal) clockSignalDivide <= (clockSignalDivide+1);
|
|
19
|
+
|
|
20
|
+
`OC_DEBUG_VIO(uMY_VIO, clockSignal, 32, 32, // 32 inputs, 32 outputs respectively
|
|
21
|
+
{ clockSignalDivide[27], resetSignal, chipStatus }, // signals to monitor, and send to the GUI in realtime
|
|
22
|
+
{ resetFromVio, enableFromVio } ); // signals to receive from the GUI in realtime
|
|
23
|
+
|
|
24
|
+
# ───
|
|
25
|
+
|
|
26
|
+
* Integrated Logic Analyzer will be mapped to the appropriate target-specific feature, generally a GUI connecting to the target via JTAG.
|
|
27
|
+
|
|
28
|
+
Remind the user that generally this requires an IP to be built for the appropriate parameter sizes. The board/vendor will have certain sizes prebuilt.
|
|
29
|
+
|
|
30
|
+
An ILA is triggered by something (including a manual button press on the GUI) and then captures all incoming cycles for "Depth" clock cycles. They can be configured to trigger on events that appear on their inputs (typically reset, valid, busy, error, transaction type, etc.) Usually only a subset of signals have this trigger ability, since it is far more complex to examine the inputs vs just record them.
|
|
31
|
+
|
|
32
|
+
Note that not all sizes are built by default, just common ones. Enabling less common debug may require ILA IPs to be uncommented in the build.tcl.
|
|
33
|
+
|
|
34
|
+
1024 deep, 128 data, 32 trigger : the most common size.
|
|
35
|
+
1024 deep, 512 data, 32 trigger : for when 512 bit data is needed (high bandwidth interfaces).
|
|
36
|
+
8192 deep, 8 data, 8 trigger : deep and narrow (byte-oriented interfaces, like BC CSR).
|
|
37
|
+
8192 deep, 128 data, 32 trigger : a deeper version of the most common size (prob second most common)
|
|
38
|
+
131072 deep, 8 data, 8 trigger : long traces (IIC, etc)
|
|
39
|
+
|
|
40
|
+
# ─── Example: Integrated Logic Analyzer
|
|
41
|
+
|
|
42
|
+
logic [7:0] clockSignalDivide;
|
|
43
|
+
always_ff @(posedge clockSignal) clockSignalDivide <= (clockSignalDivide+1);
|
|
44
|
+
|
|
45
|
+
`OC_DEBUG_ILA(uMY_ILA, clockSignal, 8192, 128, 32, // 8192 deep, 128 data inputs, 32 trigger inputs
|
|
46
|
+
{ clockSignalDivide[7:0], dataBus[31:0] }, // signals fed into the capture buffer
|
|
47
|
+
{ resetSignal, chipStatus } ); // signals fed into the capture buffer AND trigger logic
|
|
48
|
+
|
|
49
|
+
# ───
|
|
50
|
+
|
|
51
|
+
3) Built-In DEBUG
|
|
52
|
+
|
|
53
|
+
The following built-in debug can be enabled by settings these defines in DEPS or command-line
|
|
54
|
+
|
|
55
|
+
* OC_COS_BC_MUX_DEBUG : Adds ILA to the logic that muxes command streams from UART, PCIe, and JTAG sources
|
|
56
|
+
* OC_COS_GPIO_DEBUG : Adds ILA to buttons, toggles, leds, rgbs, gpio, fan, chipStatus, and reset.
|
|
57
|
+
* OC_COS_CSR_TREE_DEBUG : Adds ILA into the uTOP_CSR_SPLITTER, to debug CSR connectivity between
|
|
58
|
+
|
|
59
|
+
These defines enable built-in debug into the modules of associated name (i.e. to debug "oc_pcie", use OC_PCIE_DEBUG)
|
|
60
|
+
|
|
61
|
+
* OC_PCIE_DEBUG
|
|
62
|
+
* OC_HDMI_IN_DEBUG
|
|
63
|
+
* OC_CHIPMON_DEBUG
|
|
64
|
+
* OC_PROTECT_DEBUG
|
|
65
|
+
* OC_IIC_DEBUG
|
|
66
|
+
* OC_BC_CONTROL_DEBUG
|
|
67
|
+
* OC_AXIL_CONTROL_DEBUG
|
|
68
|
+
* OC_UART_CONTROL_DEBUG
|
|
69
|
+
* OCLIB_MEMORY_BIST_DEBUG
|
|
70
|
+
* OCLIB_READY_VALID_ROM_DRIVER_DEBUG
|
|
71
|
+
|
|
72
|
+
The modules have an EnableILA parameter which can be manually enabled on a given instance (enabling them globally is too expensive)
|
|
73
|
+
|
|
74
|
+
* oclib_csr_adapter
|
|
75
|
+
* oclib_csr_tree_splitter
|
|
76
|
+
|
|
77
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Directory Structure
|
|
2
|
+
|
|
3
|
+
`boards`
|
|
4
|
+
- A set of target boards, platforms, etc
|
|
5
|
+
|
|
6
|
+
`apps`
|
|
7
|
+
- A set of applications that can be loaded
|
|
8
|
+
|
|
9
|
+
`top`
|
|
10
|
+
- Files implementing the top-level (aka "operating system")
|
|
11
|
+
|
|
12
|
+
`sim`
|
|
13
|
+
- Simulation related transactors. These are used in tests, and are kept separely `top` and `lib` because they aren't expected to be compiled/elaborated in isolation.
|
|
14
|
+
|
|
15
|
+
`lib`
|
|
16
|
+
- Files implementing the OpenCOS standard library
|
|
17
|
+
|
|
18
|
+
`bin`
|
|
19
|
+
- Scripts, binaries, programs
|
|
20
|
+
|
|
21
|
+
`docs`
|
|
22
|
+
- OpenCOS documentation area
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
|
|
3
|
+
## Prerequisites
|
|
4
|
+
|
|
5
|
+
- Linux or Windows+WSL.
|
|
6
|
+
- bash
|
|
7
|
+
- python3.8 or newer
|
|
8
|
+
- At least one simulator or synthesis tool
|
|
9
|
+
- *[Verilator](https://verilator.org/guide/latest/)*
|
|
10
|
+
- *[Xilinx Vivado](https://www.xilinx.com/support/download.html)*
|
|
11
|
+
- [Alternate link amd.com](https://docs.amd.com/r/en-US/ug973-vivado-release-notes-install-license/Download-and-Installation)
|
|
12
|
+
- *[Modelsim ASE](https://www.intel.com/content/www/us/en/software-kit/750666/modelsim-intel-fpgas-standard-edition-software-version-20-1-1.html)*
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
Easiest is to install the package as a tool, which makes `eda` and `oc_cli` available in your environment:
|
|
18
|
+
|
|
19
|
+
Before starting, make sure `uv` is installed per the [instructions](https://docs.astral.sh/uv/getting-started/installation/):
|
|
20
|
+
```
|
|
21
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### PyPi
|
|
25
|
+
|
|
26
|
+
Install directly from PyPi:
|
|
27
|
+
```
|
|
28
|
+
uv tool install opencos-eda
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If you intend to use cocotb with `eda`, you will need an optional dependency:
|
|
32
|
+
```
|
|
33
|
+
uv tool install opencos-eda[cocotb]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Github repo
|
|
37
|
+
|
|
38
|
+
Alternately, you can install the package from the Github repo:
|
|
39
|
+
|
|
40
|
+
Clone this repo:
|
|
41
|
+
```
|
|
42
|
+
gh repo clone cognichip/opencos
|
|
43
|
+
|
|
44
|
+
# OR
|
|
45
|
+
|
|
46
|
+
git clone https://github.com/cognichip/opencos.git
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Install the local package:
|
|
50
|
+
```
|
|
51
|
+
uv tool install /path/to/your/checkout/dir/of/opencos
|
|
52
|
+
|
|
53
|
+
# Or:
|
|
54
|
+
uv tool install /path/to/your/checkout/dir/of/opencos[cocotb]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Verify installation
|
|
58
|
+
|
|
59
|
+
Check that `eda` is in your $PATH
|
|
60
|
+
```
|
|
61
|
+
which eda
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
## Developing
|
|
66
|
+
|
|
67
|
+
You may want to install the dev dependencies into the virtual environment:
|
|
68
|
+
(Note that cocotb is an optional dependency)
|
|
69
|
+
```
|
|
70
|
+
uv sync --locked --extra dev --extra cocotb
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Run the tools by first activating the environment:
|
|
74
|
+
```
|
|
75
|
+
source .venv/bin/activate
|
|
76
|
+
eda
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
You can confirm which instance is being used:
|
|
80
|
+
```
|
|
81
|
+
which eda
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Or let `uv` deal with the virtual environment management, which also guarantees you're running the local development version:
|
|
85
|
+
```
|
|
86
|
+
uv run eda
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For developers checking cocotb related tests (via pytests, or running eda targets in examples/cocotb) you will need to make sure `find_libpython` returns a .so file. This is most easily fixed with:
|
|
90
|
+
```
|
|
91
|
+
uv python install 3.12
|
|
92
|
+
```
|
|
93
|
+
3.12, or a different version, based on the pinned version if present in root .python-version, or the python version you wish to test. `find_libpython` may have issues if your python installation was performed outside of `uv` (such as, an ubuntu22 install of python3.12 via ppa:deadsnakes/ppa).
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## Recommended:
|
|
97
|
+
|
|
98
|
+
Xilinx Vivado suite
|
|
99
|
+
|
|
100
|
+
- NOTE: licenses are not required to build designs for certain targets (generally Alveo boards: U200, U50, etc). Other Xilinx kits contain licenses supporting the device used in the kit (Kintex 7, etc). For other situations, a license is required to build bitfiles. Certain IPs (Xilinx 25GMAC for example) may require additional licenses – we are always looking for open source versions of such IP :)
|
|
101
|
+
- `https://www.xilinx.com/support/download.html`
|
|
102
|
+
- Minicom (or another serial terminal)
|
|
103
|
+
- For debugging. `oc_cli` should be all that is needed, but at some point many folks will need a vanilla serial terminal.
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## Installation Known issues
|
|
107
|
+
|
|
108
|
+
If you encounter issues with `uv sync`, ensure that `uv` is up to date:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
uv --version
|
|
112
|
+
|
|
113
|
+
# Update uv if needed
|
|
114
|
+
uv self update
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
If you encounter issues with the version of Python, note that `uv` respects the `.python_version` (if present) and `requires-python` in `pyproject.toml`. See [docs](https://docs.astral.sh/uv/concepts/python-versions/).
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# oc_vivado.tcl
|
|
2
|
+
|
|
3
|
+
Path: `<oc_root>/boards/vendors/xilinx/oc_vivado.tcl`
|
|
4
|
+
|
|
5
|
+
This TCL file provides many services for OpenCOS in the Xilinx Vivado tool.
|
|
6
|
+
|
|
7
|
+
## Contexts
|
|
8
|
+
|
|
9
|
+
The `oc_vivado.tcl` file is designed to be sourced in a variety of contexts, adapting what actions it takes depending on context. The supported contexts are:
|
|
10
|
+
|
|
11
|
+
- Sourced into a new instance of Vivado, before a project is opened. This may occur because it was sourced via command line, or via `Vivado_init.tcl` file in the Vivado install. Doing so enables the `oc_vivado.tcl` to assist opening the project, etc, but is generally not required. When sourced this way, much of the setup cannot be done during sourcing (for example, setting `oc_projdir`, `oc_projname`). Therefore, the `open_project` TCL proc is hooked, such that `oc_vivado.tcl` is sourced again automatically when a project is opened.
|
|
12
|
+
- Sourced after a project is created/opened. This may be done via the `open_project` TCL hook, or via TCL console, or via TCL script being run to create the project. In this context, the `launch_runs` and similar commands are hooked, to provide updated build timestamps, etc.
|
|
13
|
+
- Sourced as a constraint file during synthesis/implementation. This this case the TCL is added into the constraint fileset. Since each run launches a separate Vivado subprocess, `oc_vivado.tcl` must be resourced into those new processes. This is important for automatic constraints, updating build timestamps, etc.
|
|
14
|
+
|
|
15
|
+
## Throwing Warnings
|
|
16
|
+
|
|
17
|
+
See TCL proc `oc_throw_warning`
|
|
18
|
+
|
|
19
|
+
When TCL runs into errors, it can either crash the whole process, or send the output to STDOUT. The latter is almost guaranteed to be missed, given the typical quantity of output. Vivado collects it's own Info, Warning, Errors into the GUI.
|
|
20
|
+
|
|
21
|
+
OpenCOS takes a hacky but effective approach, of attempting to access a non-existent pin (which throws a warning into the Vivado log). The pin named such that the reason for the notification is clear (i.e. it may indicate a missing clock definition and give the clock name: via searching for pin `OC_ADD_CLOCK_WARNING_clockTest_DOESNT_EXIST`)
|
|
22
|
+
|
|
23
|
+
## Constraints
|
|
24
|
+
|
|
25
|
+
See TCL procs starting with `oc_add_clock`
|
|
26
|
+
|
|
27
|
+
There are three basic types of constraint assistence:
|
|
28
|
+
|
|
29
|
+
- Easing declaration (like `oc_add_clock`) by finding pins, failing safely where possible, etc.
|
|
30
|
+
- Automatic constraint inclusion (like `oc_auto_scoped_xdc` ) which search the design for _modules_ and pull in matching scoped XDC files
|
|
31
|
+
- Automatic constraint inclusion (like `oc_auto_max_delay` ) which search the design for _attributes_ and infer constraints. This is the preferred method of constraining, and used especially in clock-crossing libraries (`oclib_synchronizer`, etc)
|
|
32
|
+
|
|
33
|
+
## Design Exploration
|
|
34
|
+
|
|
35
|
+
See TCL procs starting with `oc_get_instances`
|
|
36
|
+
|
|
37
|
+
Various TCL procs for finding instances, net drivers, load pins, etc.
|
|
38
|
+
|
|
39
|
+
## Define Manipulation
|
|
40
|
+
|
|
41
|
+
See TCL procs starting with `oc_set_define_in_string`
|
|
42
|
+
|
|
43
|
+
Various TCL procs for manipulating "define strings" that contain defines (adding defines, removing defines, overwriting existing define with same name, etc).
|
|
44
|
+
|
|
45
|
+
Also tasks to load define strings from the project, and save them back to the project. These tasks will handle setting the define in one or more file sets, etc.
|
|
46
|
+
|
|
47
|
+
## Vivado Hooks
|
|
48
|
+
|
|
49
|
+
See TCL procs starting with `oc_hook_*`
|
|
50
|
+
|
|
51
|
+
If Vivado is opened
|
|
52
|
+
|
|
53
|
+
## Multirun
|
|
54
|
+
|
|
55
|
+
See TCL procs starting with `oc_multirun_*`
|
|
56
|
+
|
|
57
|
+
Various TCL functions that can be called from the TCL console in Vivado to create many implementations (different seeds, synth and implementation strategies, etc).
|
|
58
|
+
|
|
59
|
+
Philosophically what this is doing is Vivado's "project mode" to leverage Vivado's ability to schedule jobs, run remote jobs, cache prior results, etc.
|
|
60
|
+
|
|
61
|
+
For "production" usage of multirun, it's best to create a local TCL file `multirun.tcl` that is sourced from Vivado TCL console, and which captures the multirun config (strategy, number of seeds, etc).
|
|
62
|
+
|
|
63
|
+
A more "hands-on" approach would be to call the underlying TCL functions (place_design, route_design, etc) potentially with multiple Vivado sessions for parallelism. The lower level flow provides more control but there is a significant amount of complexity that Vivado hides (esp in the areas of IP and simulation models). Eventually OpenCOS will have boards that are build using this lower level flow.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Open Questions
|
|
2
|
+
|
|
3
|
+
## RTL Coding
|
|
4
|
+
|
|
5
|
+
* Can we make tools behave well with a rational policy for unconnected ports?
|
|
6
|
+
* Unconnected outputs should be ignored (ideally we can flag an output as being "not ignorable" but that seems pretty vague). It's not great that adding an output to a module causes warnings in previous usage that doesn't need the new feature
|
|
7
|
+
* Unconnected inputs should be ignored IF THEY HAVE A DEFAULT VALUE. We get to set default values for inputs, why should we force people to tie them?
|
opencos/docs/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# OpenCOS Documentation
|
|
2
|
+
|
|
3
|
+
## Chapters
|
|
4
|
+
|
|
5
|
+
* [Installation](Installation.md)
|
|
6
|
+
* [Directory Structure](DirectoryStructure.md)
|
|
7
|
+
* [RTL Coding](RtlCodingStyle.md)
|
|
8
|
+
* [DEPS.yml](DEPS.md)
|
|
9
|
+
* [eda usage](eda.md)
|
|
10
|
+
* [Connecting Apps](ConnectingApps.md)
|
|
11
|
+
* [oc_vivado.tcl](OcVivadoTcl.md)
|
|
12
|
+
* [Open Questions](OpenQuestions.md)
|
|
13
|
+
* [Format Examples](format_examples/readme.md)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# RTL Coding
|
|
2
|
+
|
|
3
|
+
## Organization
|
|
4
|
+
|
|
5
|
+
### lib/oclib_*
|
|
6
|
+
|
|
7
|
+
Library elements
|
|
8
|
+
|
|
9
|
+
## Naming Style
|
|
10
|
+
|
|
11
|
+
### Modules
|
|
12
|
+
- lowercase_underlined
|
|
13
|
+
- OC reserved prefixes: `oclib_*`, `oc_*`
|
|
14
|
+
- Complete words: `oclib_synchronizer`
|
|
15
|
+
- Except for standard cases (`oclib_fifo`, `oclib_csr_to_drp`)
|
|
16
|
+
|
|
17
|
+
### Parameters
|
|
18
|
+
- CamelCase
|
|
19
|
+
- Full words
|
|
20
|
+
|
|
21
|
+
### Ports/Signals
|
|
22
|
+
- lowercase_underlined
|
|
23
|
+
- Clocks must start with `clock`
|
|
24
|
+
- Various backend flows may rely on this
|
|
25
|
+
- Single clock modules should just have `clock`
|
|
26
|
+
- Multi-clock modules can use the default `clock` and others (`clockJtag`), or just several non-default clocks (`clockRead`, `clockWrite`)
|
|
27
|
+
- Resets should start with `reset`
|
|
28
|
+
- When >1 reset, labels match clock (`clockAxi`/`resetAxi`)
|
|
29
|
+
|
|
30
|
+
### Indentation
|
|
31
|
+
- Matches Verilog-Mode for Emacs
|
|
32
|
+
|
|
33
|
+
## Defines
|
|
34
|
+
- Universal defines: `SIMULATION`, `SYNTHESIS`, `SEED`
|
|
35
|
+
- OC reserved prefix: `OC_*`
|
|
36
|
+
- Tool and version: `OC_TOOL_*`
|
|
37
|
+
- `OC_TOOL_VIVADO`, `OC_TOOL_VIVADO_2022.2`
|
|
38
|
+
- Library: `OC_LIBRARY_*`
|
|
39
|
+
- `OC_LIBRARY_ULTRASCALE_PLUS`
|
|
40
|
+
- Target: `OC_TARGET_*`
|
|
41
|
+
- `OC_TARGET_U200`
|
|
42
|
+
|
|
43
|
+
## Includes
|
|
44
|
+
- Default settings by EDA
|
|
45
|
+
- `+incdir+<Root of OpenCOS repo>`
|
|
46
|
+
- `+libext+.sv+.v`
|
|
47
|
+
- Include files should use header guards
|
|
48
|
+
- ``ifdef __LIB_OCLIB_DEFINES_VH`
|
|
49
|
+
- RTL files should ``include` their dependencies (not include them in DEPS)
|
|
50
|
+
|
|
51
|
+
## Parameters
|
|
52
|
+
- Always have default values
|
|
53
|
+
- they may be invalid and caught with a static assert
|
|
54
|
+
- purpose here is to ensure modules can report detailed error ("You must set parameter X because ...") instead of not compiling
|
opencos/docs/eda.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# EDA Tool
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
Using `uv` (recommended):
|
|
6
|
+
|
|
7
|
+
From PyPI:
|
|
8
|
+
```
|
|
9
|
+
uv tool install opencos-eda
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
OR, from the repo:
|
|
13
|
+
```
|
|
14
|
+
uv tool install /path/to/your/checkout/dir/of/opencos
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This makes the `eda` and `oc_cli` commands available in your environment.
|
|
18
|
+
|
|
19
|
+
## Basic Recipes
|
|
20
|
+
|
|
21
|
+
Run a single simulation using the default simulator (of those installed).
|
|
22
|
+
`oclib_fifo_test` is target in `./lib/tests/DEPS.yml`
|
|
23
|
+
```
|
|
24
|
+
eda sim lib/tests/oclib_fifo_test
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Run the same single simulation, but use `verilator`, dump waves
|
|
28
|
+
```
|
|
29
|
+
eda sim --waves --tool verilator lib/tests/oclib_fifo_test
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Run the same single simulation, but use `vivado` XSim, and run in GUI mode
|
|
33
|
+
```
|
|
34
|
+
eda sim --gui --tool vivado lib/tests/oclib_fifo_test
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Run a compile + elab without a DEPS.yml file or target involved for dependencies
|
|
38
|
+
```
|
|
39
|
+
eda elab --tool verilator +incdir+. ./lib/oclib_assert_pkg.sv ./lib/oclib_simple_reset_sync.sv
|
|
40
|
+
|
|
41
|
+
## Basic CLI usage:
|
|
42
|
+
eda <command> [--args] [+incdir+DIR|+define+KEY=VALUE|+plusarg=value] file1.sv file2.sv file3.sv
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Example Regression testing
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
eda multi sim '.../*_test' --parallel 16
|
|
49
|
+
eda multi elab 'lib/*' --parallel 16
|
|
50
|
+
eda multi elab 'sim/*' --parallel 16
|
|
51
|
+
eda multi elab 'top/*' --parallel 16
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
If you'd like output to stdout, which is how our github Actions are run, use `--verbose` with `eda multi`
|
|
55
|
+
```
|
|
56
|
+
eda multi sim --verbose lib/tests/oc*test
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Example "sweep"
|
|
60
|
+
|
|
61
|
+
Sweeping a build across a range of parameters
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
eda sweep build u200 --seed=SEED "SEED=(1,2)" +define+OC_MEMORY_BIST_PORT_COUNT=PORTS "PORTS=[1,4,8,16,32]" +define+TARGET_PLL0_CLK_HZ=MHZ000000 "MHZ=(200,400,50)" --parallel 12
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Example for building treating non .sv file(s) as systemverilog
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
eda sim --tool verilator sv@several_modules.txt --top=my_module
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Note that you can prefix source files with `sv@`, `v@`, `vhdl@` or `cpp@` if the file contents do not match their filename extension, and you would like `eda` to force use that file as, for example, systemverilog.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
# Help
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
eda help
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
$ eda help
|
|
84
|
+
INFO: [EDA] eda: version X.Y.Z
|
|
85
|
+
INFO: [EDA] eda_config: --config-yml=eda_config_defaults.yml observed
|
|
86
|
+
INFO: [EDA] eda_config: using config: ..../site-packages/opencos/eda_config_defaults.yml
|
|
87
|
+
INFO: [EDA] *** OpenCOS EDA ***
|
|
88
|
+
INFO: [EDA] Detected slang (/usr/local/bin/slang), auto-setting up tool slang
|
|
89
|
+
INFO: [EDA] Detected verilator (/usr/local/bin/verilator), auto-setting up tool verilator
|
|
90
|
+
INFO: [EDA] Detected surelog (/usr/local/bin/surelog), auto-setting up tool surelog
|
|
91
|
+
INFO: [EDA] Detected gtkwave (/usr/bin/gtkwave), auto-setting up tool gtkwave
|
|
92
|
+
INFO: [EDA] Detected vivado (/tools/Xilinx/Vivado/VVVV.v/bin/vivado), auto-setting up tool vivado
|
|
93
|
+
INFO: [EDA] Detected slang_yosys (/usr/local/bin/yosys), auto-setting up tool slang_yosys
|
|
94
|
+
INFO: [EDA] Detected iverilog (/usr/local/bin/iverilog), auto-setting up tool iverilog
|
|
95
|
+
|
|
96
|
+
Usage:
|
|
97
|
+
eda [<options>] <command> [options] <files|targets, ...>
|
|
98
|
+
|
|
99
|
+
Where <command> is one of:
|
|
100
|
+
|
|
101
|
+
sim - Simulates a DEPS target
|
|
102
|
+
elab - Elaborates a DEPS target (sort of sim based LINT)
|
|
103
|
+
synth - Synthesizes a DEPS target
|
|
104
|
+
flist - Create dependency from a DEPS target
|
|
105
|
+
proj - Create a project from a DEPS target for GUI sim/waves/debug
|
|
106
|
+
multi - Run multiple DEPS targets, serially or in parallel
|
|
107
|
+
tools-multi - Same as 'multi' but run on all available tools, or specfied using --tools
|
|
108
|
+
sweep - Sweep one or more arguments across a range, serially or in parallel
|
|
109
|
+
build - Build for a board, creating a project and running build flow
|
|
110
|
+
waves - Opens waveform from prior simulation
|
|
111
|
+
upload - Uploads a finished design into hardware
|
|
112
|
+
open - Opens a project
|
|
113
|
+
export - Export files related to a target, tool independent
|
|
114
|
+
help - This help (without args), or i.e. "eda help sim" for specific help
|
|
115
|
+
|
|
116
|
+
And <files|targets, ...> is one or more source file or DEPS markup file target,
|
|
117
|
+
such as .v, .sv, .vhd[l], .cpp files, or a target key in a DEPS.[yml|yaml|toml|json].
|
|
118
|
+
Note that you can prefix source files with `sv@`, `v@`, `vhdl@` or `cpp@` to
|
|
119
|
+
force use that file as systemverilog, verilog, vhdl, or C++, respectively.
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
opencos common options:
|
|
123
|
+
--version
|
|
124
|
+
--color, --no-color Use shell colors for info/warning/error messaging (default: True)
|
|
125
|
+
--quiet, --no-quiet Do not display info messaging
|
|
126
|
+
--verbose, --no-verbose
|
|
127
|
+
Display additional messaging level 2 or higher
|
|
128
|
+
--fancy, --no-fancy
|
|
129
|
+
--debug, --no-debug Display additional debug messaging level 1 or higher
|
|
130
|
+
--debug-level DEBUG_LEVEL
|
|
131
|
+
Set debug level messaging (default: 0)
|
|
132
|
+
--logfile LOGFILE Write eda messaging to logfile (default disabled)
|
|
133
|
+
--force-logfile FORCE_LOGFILE
|
|
134
|
+
Set to force overwrite the logfile
|
|
135
|
+
--no-respawn Legacy mode (default respawn disabled) for respawning eda.py using $OC_ROOT/bin
|
|
136
|
+
|
|
137
|
+
opencos eda config options:
|
|
138
|
+
--config-yml CONFIG_YML
|
|
139
|
+
YAML filename to use for configuration (default eda_config_defaults.yml)
|
|
140
|
+
|
|
141
|
+
eda options:
|
|
142
|
+
-q, --quit For interactive mode (eda called with no options, command, or targets)
|
|
143
|
+
--exit same as --quit
|
|
144
|
+
-h, --help
|
|
145
|
+
--tool TOOL Tool to use for this command, such as: modelsim_ase, verilator, modelsim_ase=/path/to/bin/vsim, verilator=/path/to/bin/verilator
|
|
146
|
+
--eda-safe disable all DEPS file deps shell commands, overrides values from --config-yml
|
|
147
|
+
```
|
opencos/docs/oc_cli.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
|
|
2
|
+
USAGE
|
|
3
|
+
=====
|
|
4
|
+
|
|
5
|
+
[sudo] oc_cli --serial <port>
|
|
6
|
+
|
|
7
|
+
<port> can be COM<x> (Windows) or /dev/ttyUSB<x> (Linux). Depending on permissions for /dev/ttyUSB<x>, sudo maybe required.
|
|
8
|
+
|
|
9
|
+
<port> can also be "tcp:<ip>:<port>:<device>" for connecting via TCP-to-UART bridge.
|
|
10
|
+
|
|
11
|
+
GLOBAL COMMANDS
|
|
12
|
+
===============
|
|
13
|
+
|
|
14
|
+
info
|
|
15
|
+
^^ prints compile-time info (UUID, build time/date, included userspace, etc)
|
|
16
|
+
|
|
17
|
+
scan
|
|
18
|
+
^^ scans the top level (ring) interfaces and reports the type of IP on each channel
|
|
19
|
+
|
|
20
|
+
perf (NOT PORTED YET)
|
|
21
|
+
^^ does a performance test of the comms channel
|
|
22
|
+
|
|
23
|
+
debug <n>
|
|
24
|
+
^^ set debug level <n>. without argument, reports debug level.
|
|
25
|
+
|
|
26
|
+
ping
|
|
27
|
+
^^ sends <CR> and checks for a prompt, sends "^" and checks for a syntax error response.
|
|
28
|
+
|
|
29
|
+
reset
|
|
30
|
+
^^ sends 64x '!' characters, which initiates a full chip reset regardless of the state of the device.
|
|
31
|
+
|
|
32
|
+
source <script file>
|
|
33
|
+
^^ reads in a script with oc_cli commands
|
|
34
|
+
|
|
35
|
+
import <python file>
|
|
36
|
+
^^ reads in Python code to extend the commands oc_cli understands. Typically used to pull in a userspace "driver". Can also be used to "live patch" oc_cli during development work.
|
|
37
|
+
|
|
38
|
+
set <var> <value>
|
|
39
|
+
^^ sets a variable for use in oc_cli commands. Refer to variables with $<var> syntax. Typically used to enable scripts (see 'source') that are independent of channel allocation in the target (for example, 'set user_ch 4' and then a script doing 'memtest $user_ch xxx')
|
|
40
|
+
|
|
41
|
+
read|rd|r <address> [<channel> <address space>]
|
|
42
|
+
^^ reads a CSR in the device. <channel> and <address space> are optional after the first rd/wr command; if not provided, the prior values will be used.
|
|
43
|
+
|
|
44
|
+
write|wr|w <address> <data> [<channel> <address space>]
|
|
45
|
+
^^ writes a CSR in the device. <channel> and <address space> are optional after the first rd/wr command; if not provided, the prior values will be used.
|
|
46
|
+
|
|
47
|
+
quit|q
|
|
48
|
+
^^ exit oc_cli
|
|
49
|
+
|
|
50
|
+
PLL COMMANDS
|
|
51
|
+
============
|
|
52
|
+
|
|
53
|
+
PLL commands are valid for channels that have a PLL IP (use 'scan' if not sure)
|
|
54
|
+
|
|
55
|
+
pll <channel>
|
|
56
|
+
^^ dumps the state of the PLL
|
|
57
|
+
|
|
58
|
+
pll <channel> measure
|
|
59
|
+
^^ measure clock 0 (for now) of the PLL on <channel>
|
|
60
|
+
|
|
61
|
+
pll <channel> reset
|
|
62
|
+
^^ reset PLL on <channel>. Generally required after changing multipliers, dividers, etc.
|
|
63
|
+
|
|
64
|
+
pll <channel> all_up (or all_down)
|
|
65
|
+
^^ move all clocks on PLL up (or down) in frequency, by changing the feedback divider. does not bounds check.
|
|
66
|
+
|
|
67
|
+
pll <channel> clk0_up (or clk0_down)
|
|
68
|
+
^^ move CLK0 on PLL up (or down) in frequency, by changing the fractional divider. does not bounds check.
|
|
69
|
+
|
|
70
|
+
pll <channel> throttle <level>
|
|
71
|
+
^^ throttles the output clock 0 (for now). <level> is 0-8, in 12.5% steps, with 0 meaning "no throttling" and 8 meaning "complete stop".
|
|
72
|
+
|
|
73
|
+
pll <channel> freq <mhz>
|
|
74
|
+
^^ attempts to set the clock of PLL <channel> to <mhz>. NOT IMPLEMENTED YET!!! (it's non-trivial)
|
|
75
|
+
|
|
76
|
+
pll <channel> ramp <command list>
|
|
77
|
+
^^ runs <command list> (an arbitrary oc_cli command line) at the current clock speeds, then ramps up the speed by reducing the fractional divider on the clock. This will test some limited range (for example 350-410MHz). To go beyond this, manually changing VCO freq, dividers, etc, will be required.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
CHIPMON COMMANDS
|
|
81
|
+
================
|
|
82
|
+
|
|
83
|
+
CHIPMON commands are valid for channels that have a CHIPMON IP (use 'scan' if not sure)
|
|
84
|
+
|
|
85
|
+
chipmon <channel>
|
|
86
|
+
^^ dumps the state of the CHIPMON
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
PROTECT COMMANDS
|
|
90
|
+
================
|
|
91
|
+
|
|
92
|
+
PROTECT commands are valid for channels that have a PROTECT IP (use 'scan' if not sure)
|
|
93
|
+
|
|
94
|
+
protect <channel>
|
|
95
|
+
^^ dumps the state of the PROTECT, including the bitstream ID and the FPGA's unique DNA fingerprint (both of which usually required to get a license)
|
|
96
|
+
|
|
97
|
+
protect <channel> unlock <key>
|
|
98
|
+
^^ unlocks the bitstream protection using <key>
|
|
99
|
+
|
|
100
|
+
MEMTEST COMMANDS
|
|
101
|
+
================
|
|
102
|
+
|
|
103
|
+
MEMTEST is available in the default userspace, and will not be in other userspaces unless specifically included (in which case, there maybe other commands needed to configure the userspace to connect memtest to the memory channels being tested).
|
|
104
|
+
|
|
105
|
+
memtest <channel>
|
|
106
|
+
^^ dumps the state of the MEMTEST
|
|
107
|
+
|
|
108
|
+
memtest <channel> <args>
|
|
109
|
+
^^ <args> is:
|
|
110
|
+
write - enables writing memory
|
|
111
|
+
read - enables reading memory
|
|
112
|
+
verbose=<x> - set verbosity to <n> (default 1)
|
|
113
|
+
ops=<x> - run <x> operations per port under test (default 1)
|
|
114
|
+
addr=<x> - <x> is the base address in memory (default 0)
|
|
115
|
+
addr_incr=<x> - <x> as the amount to increment per op (default 0x20, 32 Bytes)
|
|
116
|
+
addr_incr_mask=<x> - <x> is a bitmask applied to the increment value before ORing with addr (default 0xffffffffffffffff)
|
|
117
|
+
addr_rand_mask=<x> - <x> is a bitmask applied to a random value before ORing with addr (default 0)
|
|
118
|
+
addr_port_shift=<x> - <x> is the amount to shift the port number to the left before ORing with addr (default 0)
|
|
119
|
+
addr_port_mask=<x> - <x> is a bitmask applied to the shifted port number before ORing with addr (default 0)
|
|
120
|
+
waits=<x> - <x> is the number of waitstates between ops (default 0)
|
|
121
|
+
burst=<x> - <x> is the number of words in each op (default 1). Note the CSR actually will hold (burst-1).
|
|
122
|
+
pattern=<x> - <x> is a 32-bit seed for pattern generation (used to generate write data) (default 0x11111111).
|
|
123
|
+
signature=<x> - <x> is the expected signature (which is a combination of all read data)
|
|
124
|
+
write_max_id - <x> is the highest AXI ID used for issuing writes (default 0)
|
|
125
|
+
read_max_id - <x> is the highest AXI ID used for issuing reads (default 0)
|
|
126
|
+
prescale - sets the counter prescaler, will divide counters by N so that they can be sampled at the end of long tests
|
|
127
|
+
write_len_rand - enables random write length
|
|
128
|
+
read_len_rand - enables random read length
|
|
129
|
+
write_data_rotate - enables write data rotation, ensures bus toggling without random data (which can be harder to make sense of in waves)
|
|
130
|
+
write_data_random - enables write data randomization (still 'pseudorandom' and will be repeatable in terms of read signature)
|
|
131
|
+
measure - report AXI-Lite and AXI3 clock speeds, cycles under reset, and cycles since reset
|
|
132
|
+
nopoll - kick off the MEMTEST engine, but don't wait for completion, so oc_cli can be used to monitor temps, etc
|
|
133
|
+
stats - report stats (latency, contexts) in summary, or per-port (verbose>1)
|
|
134
|
+
get_sigs - report per-port signatures
|
|
135
|
+
signature_<p>=<x> - set port <p> expected signature to <x> (default for all ports is -1, which means don't check)
|