opencos-eda 0.3.9__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 +89 -120
- opencos/commands/export.py +7 -2
- opencos/commands/multi.py +3 -3
- opencos/commands/sim.py +14 -16
- 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_file.py +82 -79
- 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 +175 -41
- opencos/eda_base.py +180 -50
- opencos/eda_config.py +62 -16
- opencos/eda_config_defaults.yml +21 -4
- opencos/eda_deps_bash_completion.bash +37 -15
- 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 +3 -4
- 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 +5 -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/str_helpers.py +7 -0
- opencos/utils/subprocess_helpers.py +3 -3
- opencos/utils/vscode_helper.py +2 -2
- opencos/utils/vsim_helper.py +58 -22
- {opencos_eda-0.3.9.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.9.dist-info → opencos_eda-0.3.11.dist-info}/entry_points.txt +1 -0
- opencos/tests/__init__.py +0 -0
- opencos/tests/custom_config.yml +0 -13
- opencos/tests/deps_files/command_order/DEPS.yml +0 -44
- opencos/tests/deps_files/error_msgs/DEPS.yml +0 -55
- opencos/tests/deps_files/iverilog_test/DEPS.yml +0 -4
- opencos/tests/deps_files/no_deps_here/DEPS.yml +0 -0
- opencos/tests/deps_files/non_sv_reqs/DEPS.yml +0 -50
- opencos/tests/deps_files/tags_with_tools/DEPS.yml +0 -54
- opencos/tests/deps_files/test_err_fatal/DEPS.yml +0 -4
- opencos/tests/helpers.py +0 -354
- opencos/tests/test_build.py +0 -12
- opencos/tests/test_deps_helpers.py +0 -207
- opencos/tests/test_deps_schema.py +0 -30
- opencos/tests/test_eda.py +0 -921
- opencos/tests/test_eda_elab.py +0 -110
- opencos/tests/test_eda_synth.py +0 -150
- opencos/tests/test_oc_cli.py +0 -25
- opencos/tests/test_tools.py +0 -404
- opencos_eda-0.3.9.dist-info/RECORD +0 -99
- {opencos_eda-0.3.9.dist-info → opencos_eda-0.3.11.dist-info}/WHEEL +0 -0
- {opencos_eda-0.3.9.dist-info → opencos_eda-0.3.11.dist-info}/licenses/LICENSE +0 -0
- {opencos_eda-0.3.9.dist-info → opencos_eda-0.3.11.dist-info}/licenses/LICENSE.spdx +0 -0
- {opencos_eda-0.3.9.dist-info → opencos_eda-0.3.11.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
Looking at it roughly bottom up.
|
|
4
|
+
|
|
5
|
+
## oc_user.sv
|
|
6
|
+
|
|
7
|
+
A "userspace" app is loaded, via pointing a build to a DEPS target that pulls in an oc_user.sv.
|
|
8
|
+
|
|
9
|
+
There is an associated oc_user.vh which contains:
|
|
10
|
+
- `defines which configure the internals of the user-space app, and can be whatever is required by the application. They don't need OC_* prefixes, etc
|
|
11
|
+
- `defines which configure the interface to the operating system, and are defined by OpenCOS. These OC_USER_* defines configure the ports of oc_user and it's instantiation in oc_cos.
|
|
12
|
+
|
|
13
|
+
Userspace apps which "ship" with OpenCOS are in the <oc>/user directory, but they can be located anywhere (TBD: document how that is done)
|
|
14
|
+
|
|
15
|
+
TODO: define a userspace testbench. The OC_COS and above levels are implemented behaviorally for flexible testing at the userspace API level.
|
|
16
|
+
|
|
17
|
+
## oc_cos.sv
|
|
18
|
+
|
|
19
|
+
The "operating system", which instantiates the userspace app, as well as a collection of top level modules. It is stores in <oc>/top
|
|
20
|
+
|
|
21
|
+
oc_cos configures itself via two sets of defines:
|
|
22
|
+
- OC_COS_* defines which enable services from the operating system. For example the userspace could request that ethernet bridging is enabled between 4 external and 4 userspace ports, instead of direct connection. The board may setup features such as fan and LED controls. Meanwhile the integrator may enable things like bitstream licensing.
|
|
23
|
+
- OC_BOARD_* defines which are set by the board target DEPS, and configure the ports of oc_cos. The goal is for OC_BOARD defines to setup the defaults for the parameters of oc_cos, not for them to be used repeatedly internally. Some things cannot be done that way (for example setting module names).
|
|
24
|
+
|
|
25
|
+
Testing is performed via <oc>/top/tests/oc_cos_*test targets, which should aim to instantiate as much as possible, while testing the subset that the testbench knows how to test. Practically speaking, the kinds of tests run at this level should consider not duplicating the tests that operate at the next stage up (board level).
|
|
26
|
+
|
|
27
|
+
TODO: do we require board target to use DEPS? what if they just want to have defines in a file, how do we ensure it's read before oc_cos (we could add a way for oc_cos to pull in a header file)
|
|
28
|
+
|
|
29
|
+
## oc_chip_top.sv
|
|
30
|
+
|
|
31
|
+
This is the typical (but not mandatory) name of the top level for a given target. This is stored in a <oc>/boards/<board> directory.
|
|
32
|
+
|
|
33
|
+
The concept of oc_chip_top is like a "board support package" for an operating system, the thin shim that connects the shared code with the unique target. It likely instantiates I/O buffers, maybe connects some pins that are unique to the board (things to do with bringup sequence, custom thermal solutions, etc). Basically, anything that OC_COS cannot handle, needs to be put up here.
|
|
34
|
+
|
|
35
|
+
It's entirely optional for oc_chip_top to configure oc_cos via parameter. oc_cos will setup it's ports based on OC_BOARD defines, and overriding the parameters so they don't match the defaults could result in inconsistent state if the design looks at the OC_BOARD defines again. oc_chip_top
|
|
36
|
+
|
|
37
|
+
TODO: work on the naming. it's called a target, a board, oc_chip_top, etc, and it's confusing.
|
|
38
|
+
|
|
39
|
+
## oc_chip_harness.sv
|
|
40
|
+
|
|
41
|
+
The purpose of oc_chip_harness is to "reverse" the transformation between oc_cos ports (ledOut[1:0], pciRxP[15:0], etc) and oc_chip_top ports (LED_GREEN, LED_RED, PCI_RXP_15, PCI_RXP_14, etc). It terminates any custom interface coming out of oc_chip_top in a way that makes sense. Upwards, it shows ports that look like oc_cos. In this way, oc_cos tests (including those that test userspace apps) can be run on oc_chip_top (i.e. including all board customizations).
|
|
42
|
+
|
|
43
|
+
The upward facing ports need to match the upward facing oc_cos ports. This can be done "with care", or can be done by examining OC_BOARD_* defines and setting up params and ports to match.
|
|
44
|
+
|
|
45
|
+
oc_chip_harness does not accept params, and oc_cos_test runs in a mode where it doesn't push params. Instead it is expected that OC_BOARD_* defines from the board DEPS will configure oc_cos (definitely) and oc_chip_top/oc_chip_harness (optionally).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Connecting Apps
|
|
2
|
+
|
|
3
|
+
The API between oc_top and oc_user is perhaps the area where OpenCOS diverges the most from the OS/Userspace parallel in the software world.
|
|
4
|
+
|
|
5
|
+
Similarities:
|
|
6
|
+
- In both cases, we desire to give a stable API to our userspace apps. Existing APIs should not change.
|
|
7
|
+
- As new APIs are made available, they shouldn't break existing applications.
|
|
8
|
+
Differences:
|
|
9
|
+
- The OS can add new APIs and expose them to userspace, without significant cost, and without changes to userspace. In hardware, connectivity between OS and userspace is in the form of physical wires that must be connected.
|
|
10
|
+
|
|
11
|
+
Furthermore, module ports (and connections to instance ports) cannot be made dependent on parameters. Either all ports are always there, or they must be made conditional on `defines.
|
|
12
|
+
|
|
13
|
+
We desire to not burden userspace with unnecessary complexity. For example, if it does not require networking, it shouldn't have to declare network ports.
|
|
14
|
+
|
|
15
|
+
We desire that the userspace can be flexible. For example, if it is a memory tester, it would be nice if it could scale the number, width, and type of interfaces (for example, connecting to four 512-bit AXI-3 interfaces, or thirty-two 256-bit AXI-4 interfaces).
|
|
16
|
+
|
|
17
|
+
We desire that the top level (`oc_top`) only contains logic required to meet user-space requests. We don't "build everything in" and then just connect what we need.
|
|
18
|
+
|
|
19
|
+
The following methodology is used:
|
|
20
|
+
|
|
21
|
+
- Userspace declares via a header (`oc_user_defines.vh`) what types of interfaces it can connect to.
|
|
22
|
+
- This includes a class (local memory), an interface type (AXI-4), a width (512-bit), and a count (4)
|
|
23
|
+
- This file is not expected to be edited by the integrator. But it may note defines that can be set in `oc_board_defines.vh` to configure functionality within the userspace app.
|
|
24
|
+
- The board comes with a header file that (`oc_board_defines.vh`) that the integrator edits to constrain which external interfaces are connected. This file will also set the defines which activate `oc_top` ports connecting out to the chip interfaces. It can also hint to `oc_top` about internal features to enable, when they can't be inferred just from the interfaces (for example, a define could enable Ethernet switching functionality between external network interfaces and userspace)
|
|
25
|
+
- The board-specific `oc_chip_top` will take the `oc_board_defines.vh` and drive parameters into `oc_top`
|
|
26
|
+
- do we need this?
|
|
27
|
+
- `oc_top` will read `oc_board_defines.vh` to enable ports out to chip interfaces.
|
|
28
|
+
- `oc_top` will read `oc_user_defines.vh` to know what interfaces must be connected to userspace.
|
|
29
|
+
- `oc_top` will infer what internal functions are needed based on board and user defines.
|
opencos/docs/DEPS.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# DEPS.yml schema:
|
|
2
|
+
|
|
3
|
+
(Note this information, DEPS.md, is also available via: eda deps-help --verbose)
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
DEFAULTS: # <table> defaults applied to ALL targets in this file, local targets ** override ** the defaults.
|
|
7
|
+
|
|
8
|
+
METADATA: # <table> unstructured data, any UPPERCASE first level key is not considered a target.
|
|
9
|
+
|
|
10
|
+
target-spec:
|
|
11
|
+
|
|
12
|
+
args: # <array or | separated str>
|
|
13
|
+
- --waves
|
|
14
|
+
- --sim_plusargs="+info=500"
|
|
15
|
+
|
|
16
|
+
defines: # <table>
|
|
17
|
+
SOME_DEFINE: value
|
|
18
|
+
SOME_DEFINE_NO_VALUE: # we just leave this blank, or use nil (yaml's None)
|
|
19
|
+
|
|
20
|
+
plusargs: # <table>
|
|
21
|
+
variable0: value
|
|
22
|
+
variable1: # blank for no value, or use nil (yaml's None)
|
|
23
|
+
|
|
24
|
+
parameters: # <table>
|
|
25
|
+
SomeParameter: value
|
|
26
|
+
SOME_OTHER_PARAMETER: value
|
|
27
|
+
|
|
28
|
+
incdirs: # <array>
|
|
29
|
+
- some/relative/path
|
|
30
|
+
|
|
31
|
+
top: # <string>
|
|
32
|
+
|
|
33
|
+
deps: # <array or | space separated string>
|
|
34
|
+
- some_relative_target # <string> aka, a target
|
|
35
|
+
- some_file.sv # <string> aka, a file
|
|
36
|
+
- sv@some_file.txt # <string> aka, ext@file where we'd like a file not ending in .sv to be
|
|
37
|
+
# treated as a .sv file for tools.
|
|
38
|
+
# Supported for sv@, v@, vhdl@, cpp@, sdc@, f@, py@, makefile@
|
|
39
|
+
- commands: # <table> with key 'commands' for a <array>: support for built-in commands
|
|
40
|
+
# Note this cannot be confused for other targets or files.
|
|
41
|
+
- shell: # <string>
|
|
42
|
+
var-subst-args: # <bool> default false. If true, substitute vars in commands, such as {fpga}
|
|
43
|
+
# substituted from eda arg --fpga=SomeFpga, such that {fpga} becomes SomeFpga
|
|
44
|
+
var-subst-os-env: #<bool> default false. If true, substitute vars in commands using os.environ vars,
|
|
45
|
+
# such as $FPGA could get substituted by env value for it.
|
|
46
|
+
tee: # <string> optional filename, otherwise shell commands write to {target-spec}__shell_0.log
|
|
47
|
+
run-from-work-dir: #<bool> default true. If false, runs from the directory of this DEPS file.
|
|
48
|
+
filepath-subst-target-dir: #<bool> default true. If false, disables shell file path
|
|
49
|
+
# substituion on this target's directory (this DEPS file dir).
|
|
50
|
+
dirpath-subst-target-dir: #<bool> default false. If true, enables shell directory path
|
|
51
|
+
# substituion on this target's directory (this DEPS file dir).
|
|
52
|
+
run-after-tool: # <bool> default false. Set to true to run after any EDA tools, or
|
|
53
|
+
# any command handlers have completed.
|
|
54
|
+
- shell: echo "Hello World!"
|
|
55
|
+
- work-dir-add-sources: # <array or | space separated string>, this is how to add generated files
|
|
56
|
+
# to compile order list.
|
|
57
|
+
- peakrdl: # <string> ## peakrdl command to generate CSRs
|
|
58
|
+
|
|
59
|
+
reqs: # <array or | space separated string>
|
|
60
|
+
- some_file.mem # <string> aka, a non-source file required for this target.
|
|
61
|
+
# This file is checked for existence prior to invoking the tool involved, for example,
|
|
62
|
+
# in a simulation this would be done prior to a compile step.
|
|
63
|
+
|
|
64
|
+
multi:
|
|
65
|
+
ignore-this-target: # <array of tables> eda commands to be ignored in `eda multi <command>` for this target only
|
|
66
|
+
# this is checked in the matching multi targets list, and is not inherited through dependencies.
|
|
67
|
+
- commands: synth # space separated strings
|
|
68
|
+
tools: vivado # space separated strings
|
|
69
|
+
|
|
70
|
+
- commands: sim # omit tools, ignores 'sim' commands for all tools, for this target only, when this target
|
|
71
|
+
# is in the target list called by `eda multi`.
|
|
72
|
+
|
|
73
|
+
- tools: vivado # omit commands, ignores all commands if tool is vivado, for this target only, when this target
|
|
74
|
+
# is in the target list called by `eda multi`.
|
|
75
|
+
|
|
76
|
+
args: # <array> additional args added to all multi commands of this target.
|
|
77
|
+
# Note that all args are POSIX with dashes, --sim-plusargs=value, etc.
|
|
78
|
+
|
|
79
|
+
<eda-command>: # key is one of sim, flist, build, synth, etc.
|
|
80
|
+
# can be used instead of 'tags' to support different args or deps.
|
|
81
|
+
args: # <array or | space separated string>
|
|
82
|
+
defines: ## <table>
|
|
83
|
+
plusargs: ## <table>
|
|
84
|
+
parameters: ## <table>
|
|
85
|
+
incdirs: ## <array>
|
|
86
|
+
|
|
87
|
+
tags: # <table> this is the currently support tags features in a target.
|
|
88
|
+
<tag-name>: # <string> key for table, can be anything, name is not used.
|
|
89
|
+
with-tools: <array or | space separated string>
|
|
90
|
+
# If using one of these tools, apply these values.
|
|
91
|
+
# entries can be in the form: vivado, or vivado:2024.1
|
|
92
|
+
with-commands: <array or | space separated string>
|
|
93
|
+
# apply if this was the `eda` command, such as: sim
|
|
94
|
+
with-args: # <table> (optional) arg key/value pairs to match for this tag.
|
|
95
|
+
# this would be an alternative to running eda with --tags=value
|
|
96
|
+
# The existence of an argument with correct value would enable a tag.
|
|
97
|
+
# And example would be:
|
|
98
|
+
# with-args:
|
|
99
|
+
# waves: true
|
|
100
|
+
args: <array or | space separated string> # args to be applied if this target is used, with a matching
|
|
101
|
+
# tool in 'with-tools'.
|
|
102
|
+
deps: <array or | space separated string, applied with tag>
|
|
103
|
+
defines: <table, applied with tag>
|
|
104
|
+
plusargs: <table, applied with tag>
|
|
105
|
+
parameters: <table, applied with tag>
|
|
106
|
+
incdirs: <array, applied with tag>
|
|
107
|
+
replace-config-tools: <table> # spec matching eda_config_defaults.yml::tools.<tool> (replace merge strategy)
|
|
108
|
+
additive-config-tools: <table> # spec matching eda_config_defaults.yml::tools.<tool> (additive merge strategy)
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Examples
|
|
113
|
+
|
|
114
|
+
### Target with tag-mode:
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
target-foo-with-tags:
|
|
118
|
+
deps: some_file1.sv some_file2.sv
|
|
119
|
+
tags:
|
|
120
|
+
|
|
121
|
+
# This can be invoked with eda --tool=vivado --gui
|
|
122
|
+
xilinx_mode:
|
|
123
|
+
with-args:
|
|
124
|
+
gui: true
|
|
125
|
+
with-tools: vivado
|
|
126
|
+
deps: <some_deps_for_this_fpga>
|
|
127
|
+
defines:
|
|
128
|
+
XILINX_GUI_MODE: 1
|
|
129
|
+
|
|
130
|
+
defaults:
|
|
131
|
+
deps: some_dummy_dep_not_fpga
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
### Simple Target, with deps as an explicit list
|
|
137
|
+
|
|
138
|
+
This is the basic, common format for a target. target - deps - (array of files or other relative targets). The file order is compile order, top to bottom.
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
some-target:
|
|
142
|
+
deps:
|
|
143
|
+
- ../foo/some_prev_target
|
|
144
|
+
- some_other_target
|
|
145
|
+
- some_file.sv
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Simple Target, with deps as a string with \n separators
|
|
149
|
+
|
|
150
|
+
This is more terse variant ` deps: |` followed by a string of targets and source files.
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
some-target2:
|
|
154
|
+
deps: |
|
|
155
|
+
../bar/some_prev_target2
|
|
156
|
+
some_file2.sv
|
|
157
|
+
some_other_target2
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Simple Target, non-table (strings)
|
|
161
|
+
|
|
162
|
+
The most terse variant for a target is a array or \n separated string, not a table, with no `deps` key, then it is assumed that all entries are other targets or sources.
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
some-target3: |
|
|
166
|
+
../bar/some_prev_target3
|
|
167
|
+
some_file3.sv
|
|
168
|
+
some_other_target3
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
You could also explicitly make a list without a `deps` key:
|
|
172
|
+
```
|
|
173
|
+
## target entry is an explicit list
|
|
174
|
+
some-target4:
|
|
175
|
+
- ../bar/some_prev_target4
|
|
176
|
+
- some_file4.sv
|
|
177
|
+
- some_other_target4
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
You can also have space separated in a string:
|
|
181
|
+
```
|
|
182
|
+
some-target5: ../bar/some_prev_target5 some_file5.sv
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Defines with relative path
|
|
186
|
+
|
|
187
|
+
Defines with file path information relative to a DEPS.yml file are supported with special words `%PWD%` as a replacement for ./ in defines only. This is necessary because we do not do path substituion on defines.
|
|
188
|
+
|
|
189
|
+
Example:
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
my_define_target:
|
|
193
|
+
deps:
|
|
194
|
+
- my_dut.sv
|
|
195
|
+
- my_testbench.sv
|
|
196
|
+
defines:
|
|
197
|
+
SOME_FILE: >
|
|
198
|
+
"%PWD%/my_pcap.pcap"
|
|
199
|
+
```
|
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
|