VeriSnip 0.0.2__tar.gz
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.
- verisnip-0.0.2/LICENSE +201 -0
- verisnip-0.0.2/PKG-INFO +195 -0
- verisnip-0.0.2/README.md +180 -0
- verisnip-0.0.2/pyproject.toml +27 -0
- verisnip-0.0.2/setup.cfg +4 -0
- verisnip-0.0.2/src/VeriSnip/__init__.py +0 -0
- verisnip-0.0.2/src/VeriSnip/vs_build.py +668 -0
- verisnip-0.0.2/src/VeriSnip/vs_colours.py +31 -0
- verisnip-0.0.2/src/VeriSnip.egg-info/PKG-INFO +195 -0
- verisnip-0.0.2/src/VeriSnip.egg-info/SOURCES.txt +11 -0
- verisnip-0.0.2/src/VeriSnip.egg-info/dependency_links.txt +1 -0
- verisnip-0.0.2/src/VeriSnip.egg-info/entry_points.txt +2 -0
- verisnip-0.0.2/src/VeriSnip.egg-info/top_level.txt +1 -0
verisnip-0.0.2/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2024 Pedro Antunes
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
verisnip-0.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: VeriSnip
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: A small example package
|
|
5
|
+
Author-email: Pedro Nuno de Melo Antunes <pedronmantunes@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/LogicoreDesign/VT-Tool.git
|
|
8
|
+
Project-URL: Issues, https://github.com/LogicoreDesign/VT-Tool/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
## VeriSnip-Overview
|
|
17
|
+
|
|
18
|
+
VeriSnip (VS) is a project designed to bring the power of Verilog scripting to the open‑source hardware community. This tool simplifies the generation of Verilog modules or snippets by seamlessly integrating with other programs. The generated files can be easily included in any Verilog project. The motivation behind this work is so that creating hardware modules is a process of creating a template file written in Verilog and letting your programs/scripts generate the hardware. These scripts are included in your Verilog template file using Verilog snippets.
|
|
19
|
+
|
|
20
|
+
With VeriSnip, the process of calling programs or scripts responsible for generating Verilog files is streamlined. After file generation, VeriSnip neatly organizes all Hardware Description Languages (HDL) and TestBench files under the build directory.
|
|
21
|
+
|
|
22
|
+
Learn more about how VeriSnip works [here](#how-to-use-verisnip).
|
|
23
|
+
|
|
24
|
+
### Index
|
|
25
|
+
|
|
26
|
+
1. [How to use VeriSnip (*vs\_build.py*)](#how-to-use-verisnip)
|
|
27
|
+
2. [*vs\_colours.py*](#vtcolors)
|
|
28
|
+
3. [MyLibrary](#mylibrary)
|
|
29
|
+
4. [Opening Issues](#opening-an-issue)
|
|
30
|
+
5. [Contributing](#contributing)
|
|
31
|
+
6. [Development Environment](#development-environment)
|
|
32
|
+
7. [Credits](#credits)
|
|
33
|
+
|
|
34
|
+
## How to use VeriSnip (aka, *vs\_build*)
|
|
35
|
+
|
|
36
|
+
The ***vs\_build*** script serves as the cornerstone of the VeriSnip tool‑chain, encompassing core functions essential for project compilation. This script orchestrates the creation of the build directory, housing Verilog modules and headers crucial for the project's hardware implementation.
|
|
37
|
+
The code residing under the `./build` directory represents the compiled output ready for simulation and FPGA synthesis.
|
|
38
|
+
|
|
39
|
+
### Run *vs\_build.py*
|
|
40
|
+
|
|
41
|
+
***vs\_build*** must receive at least one argument.
|
|
42
|
+
To show the help page:
|
|
43
|
+
|
|
44
|
+
> Usage: python *vs\_build*.py --help
|
|
45
|
+
|
|
46
|
+
Create a build directory containing all the compiled hardware:
|
|
47
|
+
|
|
48
|
+
> Usage: python *vs\_build*.py \<main\_module> --TestBench \<testbench\_name> --Boards \<board\_modules>
|
|
49
|
+
> \<main\_module> -> This is the name of the main RTL design.
|
|
50
|
+
> \--TestBench \<testbench\_name> (optional) -> by default *vs\_build* looks for a TestBench file with the name \<main\_module>\_tb.
|
|
51
|
+
> \--Boards \<board\_modules> (optional) -> by default *vs\_build* looks for NO board RTL design top module. Multiple boards can be passed in a single argument (example, "Board1 Board2 Board3").
|
|
52
|
+
> \--quiet (optional) -> suppresses INFO prints.
|
|
53
|
+
> \--debug (optional) -> enables DEBUG prints.
|
|
54
|
+
|
|
55
|
+
Clean the contents generated by *vs\_build*:
|
|
56
|
+
|
|
57
|
+
> Usage: python *vs\_build*.py --clean all
|
|
58
|
+
> all (optional) -> By default "--clean" only removes the "build" directory, with "all" it also removes the "hardware/generated" directory.
|
|
59
|
+
|
|
60
|
+
Example of calling ***vs\_build***:
|
|
61
|
+
`python3 ./*vs_build* top_module --TestBench top_module_tb --Boards "top_module_ecp5"`
|
|
62
|
+
or
|
|
63
|
+
`./*vs_build* --help`
|
|
64
|
+
|
|
65
|
+
### Using Verilog Snippets (.vs)
|
|
66
|
+
|
|
67
|
+
To enable VeriSnip to search for or generate a Verilog Snippet, users only need to include the corresponding ".vs" file in their Verilog modules. For example:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
module example (
|
|
71
|
+
`include "example_ios.vs" // Argument passed to the program/script that generates example_ios.vs
|
|
72
|
+
);
|
|
73
|
+
`include "example_contents.vs" /*
|
|
74
|
+
Argument passed to the program/script that generates example_contents.vs
|
|
75
|
+
*/
|
|
76
|
+
endmodule
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
In the above example, VeriSnip scans for a program or script resembling the Verilog Snippet name (without the file extension). Snippet files must adhere to the snake\_case naming convention, which VeriSnip uses to identify the program/script generating the Snippet file. For instance, the `include "example_ios.vs"` statement corresponds to a program/script named either "example\_ios.*" or "example.*", where \* represents any supported file extension. Similarly, `include "example_contents.vs"` corresponds to "example\_contents.*" or "example.*".
|
|
80
|
+
|
|
81
|
+
For another example, refer to the [MyReg module](MyLibrary/modules/MyReg.v). You can run `python3 *vs_build* myreg` to execute a small build with VeriSnip.
|
|
82
|
+
|
|
83
|
+
**Note:** Avoid including a file in the first line of the file, as this is not supported. Instead, use the file's beginning to provide a brief introduction about its contents.
|
|
84
|
+
|
|
85
|
+
### Creating a Compatible Program/Script for Verilog Snippet Generation
|
|
86
|
+
|
|
87
|
+
Users have the flexibility to create custom programs or scripts for generating ".vs" files or Verilog modules, or they can utilize existing ones. It's crucial to note that all scripts responsible for generating Verilog code, whether modules or ".vs" files, are independent of "*vs\_build*." "*vs\_build*" exclusively calls these scripts without importing them into the project.
|
|
88
|
+
|
|
89
|
+
**Supported File Extensions and Corresponding Languages:**
|
|
90
|
+
Currently, VeriSnip supports programs and scripts with the following file extensions:
|
|
91
|
+
|
|
92
|
+
* ".py" for Python
|
|
93
|
+
* ".sh" for Bash
|
|
94
|
+
* ".lua" for Lua
|
|
95
|
+
* ".scala" for Scala
|
|
96
|
+
* ".rb" for Ruby
|
|
97
|
+
* ".pl" for Perl
|
|
98
|
+
* ".vt" for Verilog Template (a custom extension)
|
|
99
|
+
|
|
100
|
+
The Verilog Template extension (".vt") is specific to VeriSnip. If you compile a program that generates a Verilog module or snippet, you can use the ".vt" extension to enable VeriSnip to locate it.
|
|
101
|
+
|
|
102
|
+
When *vs\_build* calls another program ([see example here](*vs_build*.py#L238)), it passes a variable number of arguments. Nevertheless, it always follows the same order. Therefore, take into consideration the following arguments and their order when developing your program or script:
|
|
103
|
+
|
|
104
|
+
* Path to the program or script being called
|
|
105
|
+
* Difference between the ".vs" filename and the program/script name. It corresponds to the suffix of the program/script name
|
|
106
|
+
* Comment written after the "\`include"
|
|
107
|
+
* File where the include is being called from, therefore the file where the "\`include" is written
|
|
108
|
+
* *vs\_build* received arguments (excluding its own name)
|
|
109
|
+
|
|
110
|
+
### Code structure
|
|
111
|
+
|
|
112
|
+
***vs\_build*** code is distinctly divided into three stages.
|
|
113
|
+
|
|
114
|
+
* in **1st stage** the function `find_vs_scripts_and_verilog()` finds all existing verilog modules, headers, snippets and scripts under the current directory.
|
|
115
|
+
* the **2nd stage** is where it finds the verilog modules and snippets needed by the core. If a verilog module or a snippet does not exist it will try to generate them. The generated snippets should be stored under the `./rtl/generated` directory. The function called for this stage is `verilog_fetch()`.
|
|
116
|
+
* during the **3rd stage** all verilog snippet files included are substituted for its content. Those files are then stored under the `./build` directory.
|
|
117
|
+
|
|
118
|
+
#### **2nd stage** - details
|
|
119
|
+
|
|
120
|
+
* When calling scripts to generate ".vs" priority is always given to scripts with the full name of the file. If there is no script corresponding to the ".vs" name look for a script that corresponds only to the initial part of the name. Example:
|
|
121
|
+
|
|
122
|
+
* in `include "io_modules.vs"` look for `VTio.py` or `io.py` if `io_modules.py` does not exist.
|
|
123
|
+
* When calling scripts that generate modules the script should have the name of the module.
|
|
124
|
+
* "*vs\_build*" only calls the scripts if they are newer than the files already existent.
|
|
125
|
+
* When there are two or more scripts with the same name a warning should be printed and the script with the closest directory path should be used.
|
|
126
|
+
* All files and scripts should only be looked for from the base directory of the project, unless specified otherwise in a custom script.
|
|
127
|
+
|
|
128
|
+
#### **3rd stage** - details
|
|
129
|
+
|
|
130
|
+
* all files which are generated should have a copy in the "aux" directory
|
|
131
|
+
* "*vs\_build*" substitutes the ".vs" and copies the modules needed to the build directory, after finding or generating all modules and ".vs" files.
|
|
132
|
+
|
|
133
|
+
## *vs\_colours*
|
|
134
|
+
|
|
135
|
+
This script defines the colors that should be used when printing error, warning or successful messages.
|
|
136
|
+
It defines the `print_coloured()` function and some variables that allow to modify the text printed to the console.
|
|
137
|
+
|
|
138
|
+
## MyLibrary
|
|
139
|
+
|
|
140
|
+
The "MyLibrary" directory contains hardware Verilog modules, snippets and scripts that might be commonly reused.
|
|
141
|
+
|
|
142
|
+
### Scripts
|
|
143
|
+
|
|
144
|
+
This section of the README contains information about the scripts present under the `./library/scripts` directory.
|
|
145
|
+
Read more about each script in the [README.md on the scripts directory](https://github.com/PedroAntunes178/VT-Tool/tree/main/MyLibrary/scripts/README.md).
|
|
146
|
+
|
|
147
|
+
## Opening an Issue
|
|
148
|
+
|
|
149
|
+
Welcome to our issue reporting system! We appreciate your contribution to the project by reporting any issues you encounter. Your feedback helps us make this project even better.
|
|
150
|
+
|
|
151
|
+
### How to Open an Issue
|
|
152
|
+
|
|
153
|
+
When opening an issue, please follow this format:
|
|
154
|
+
|
|
155
|
+
> **Issue Title**: A concise and descriptive title for the issue.
|
|
156
|
+
|
|
157
|
+
> Hello **Tag the developers you think might be able to help**,
|
|
158
|
+
>
|
|
159
|
+
> ## Issue Description:
|
|
160
|
+
>
|
|
161
|
+
> Provide a detailed description of the issue you encountered. Include information about your environment, steps to reproduce the issue, and any error messages. The more details you provide, the easier it is for us to understand and address the problem.
|
|
162
|
+
>
|
|
163
|
+
> ## Solution Reference (Optional):
|
|
164
|
+
>
|
|
165
|
+
> If you have a solution in mind, you're welcome to present it and provide a detailed explanation of why you believe it will work. If possible, include references to supporting pages or documentation that back your proposed solution. This can help us better understand your perspective and expedite the resolution process.
|
|
166
|
+
>
|
|
167
|
+
> ## Suggested Changes (Optional):
|
|
168
|
+
>
|
|
169
|
+
> If you have ideas for changes that might solve the issue, propose them here. Be clear and concise in your suggestions.
|
|
170
|
+
>
|
|
171
|
+
> ## Additional Question (Optional):
|
|
172
|
+
>
|
|
173
|
+
> If you have questions directly or indirectly related to the issue, feel free to ask them in this section.
|
|
174
|
+
|
|
175
|
+
Tag developers by using `@username` to get their attention.
|
|
176
|
+
|
|
177
|
+
We appreciate your help in improving this project!
|
|
178
|
+
|
|
179
|
+
## Contributing
|
|
180
|
+
|
|
181
|
+
All contributions to this project are warmly welcomed.
|
|
182
|
+
|
|
183
|
+
Contributions in the form of automatically generated Verilog scripts should be placed within the hardware/scripts directory. Additionally, contributors are required to create a corresponding section in the README when adding a script. This section should detail the generated core and provide instructions on the script's usage. It is important that the section structure aligns with the structures of other script sections.
|
|
184
|
+
|
|
185
|
+
## Development Environment
|
|
186
|
+
|
|
187
|
+
To utilize *vs\_build*, all that's necessary is Python3 and support for the scripting languages in which your scripts are written.
|
|
188
|
+
|
|
189
|
+
## Credits
|
|
190
|
+
|
|
191
|
+
This project idea came to me while I was working at IObundle. IObundle was developing a similar open-source tool called python-setup. The two projects are fundamentally different. Therefore I decided to create this project from 0 instead of contributing the ideas and tools directly to IObundle's python-setup.
|
|
192
|
+
|
|
193
|
+
Where the two projects are similar is both are being developed to generate automatic verilog.
|
|
194
|
+
|
|
195
|
+
Where they mainly differ is on the way the verilog is generated. The IObundle python-setup project aims to generate all the verilog core using a python framework. VeriSnip aims to substitute the .vs files present on the verilog code, generating the .vs code as needed. There may also exist scripts that generate .v modules.
|
verisnip-0.0.2/README.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
## VeriSnip-Overview
|
|
2
|
+
|
|
3
|
+
VeriSnip (VS) is a project designed to bring the power of Verilog scripting to the open‑source hardware community. This tool simplifies the generation of Verilog modules or snippets by seamlessly integrating with other programs. The generated files can be easily included in any Verilog project. The motivation behind this work is so that creating hardware modules is a process of creating a template file written in Verilog and letting your programs/scripts generate the hardware. These scripts are included in your Verilog template file using Verilog snippets.
|
|
4
|
+
|
|
5
|
+
With VeriSnip, the process of calling programs or scripts responsible for generating Verilog files is streamlined. After file generation, VeriSnip neatly organizes all Hardware Description Languages (HDL) and TestBench files under the build directory.
|
|
6
|
+
|
|
7
|
+
Learn more about how VeriSnip works [here](#how-to-use-verisnip).
|
|
8
|
+
|
|
9
|
+
### Index
|
|
10
|
+
|
|
11
|
+
1. [How to use VeriSnip (*vs\_build.py*)](#how-to-use-verisnip)
|
|
12
|
+
2. [*vs\_colours.py*](#vtcolors)
|
|
13
|
+
3. [MyLibrary](#mylibrary)
|
|
14
|
+
4. [Opening Issues](#opening-an-issue)
|
|
15
|
+
5. [Contributing](#contributing)
|
|
16
|
+
6. [Development Environment](#development-environment)
|
|
17
|
+
7. [Credits](#credits)
|
|
18
|
+
|
|
19
|
+
## How to use VeriSnip (aka, *vs\_build*)
|
|
20
|
+
|
|
21
|
+
The ***vs\_build*** script serves as the cornerstone of the VeriSnip tool‑chain, encompassing core functions essential for project compilation. This script orchestrates the creation of the build directory, housing Verilog modules and headers crucial for the project's hardware implementation.
|
|
22
|
+
The code residing under the `./build` directory represents the compiled output ready for simulation and FPGA synthesis.
|
|
23
|
+
|
|
24
|
+
### Run *vs\_build.py*
|
|
25
|
+
|
|
26
|
+
***vs\_build*** must receive at least one argument.
|
|
27
|
+
To show the help page:
|
|
28
|
+
|
|
29
|
+
> Usage: python *vs\_build*.py --help
|
|
30
|
+
|
|
31
|
+
Create a build directory containing all the compiled hardware:
|
|
32
|
+
|
|
33
|
+
> Usage: python *vs\_build*.py \<main\_module> --TestBench \<testbench\_name> --Boards \<board\_modules>
|
|
34
|
+
> \<main\_module> -> This is the name of the main RTL design.
|
|
35
|
+
> \--TestBench \<testbench\_name> (optional) -> by default *vs\_build* looks for a TestBench file with the name \<main\_module>\_tb.
|
|
36
|
+
> \--Boards \<board\_modules> (optional) -> by default *vs\_build* looks for NO board RTL design top module. Multiple boards can be passed in a single argument (example, "Board1 Board2 Board3").
|
|
37
|
+
> \--quiet (optional) -> suppresses INFO prints.
|
|
38
|
+
> \--debug (optional) -> enables DEBUG prints.
|
|
39
|
+
|
|
40
|
+
Clean the contents generated by *vs\_build*:
|
|
41
|
+
|
|
42
|
+
> Usage: python *vs\_build*.py --clean all
|
|
43
|
+
> all (optional) -> By default "--clean" only removes the "build" directory, with "all" it also removes the "hardware/generated" directory.
|
|
44
|
+
|
|
45
|
+
Example of calling ***vs\_build***:
|
|
46
|
+
`python3 ./*vs_build* top_module --TestBench top_module_tb --Boards "top_module_ecp5"`
|
|
47
|
+
or
|
|
48
|
+
`./*vs_build* --help`
|
|
49
|
+
|
|
50
|
+
### Using Verilog Snippets (.vs)
|
|
51
|
+
|
|
52
|
+
To enable VeriSnip to search for or generate a Verilog Snippet, users only need to include the corresponding ".vs" file in their Verilog modules. For example:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
module example (
|
|
56
|
+
`include "example_ios.vs" // Argument passed to the program/script that generates example_ios.vs
|
|
57
|
+
);
|
|
58
|
+
`include "example_contents.vs" /*
|
|
59
|
+
Argument passed to the program/script that generates example_contents.vs
|
|
60
|
+
*/
|
|
61
|
+
endmodule
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
In the above example, VeriSnip scans for a program or script resembling the Verilog Snippet name (without the file extension). Snippet files must adhere to the snake\_case naming convention, which VeriSnip uses to identify the program/script generating the Snippet file. For instance, the `include "example_ios.vs"` statement corresponds to a program/script named either "example\_ios.*" or "example.*", where \* represents any supported file extension. Similarly, `include "example_contents.vs"` corresponds to "example\_contents.*" or "example.*".
|
|
65
|
+
|
|
66
|
+
For another example, refer to the [MyReg module](MyLibrary/modules/MyReg.v). You can run `python3 *vs_build* myreg` to execute a small build with VeriSnip.
|
|
67
|
+
|
|
68
|
+
**Note:** Avoid including a file in the first line of the file, as this is not supported. Instead, use the file's beginning to provide a brief introduction about its contents.
|
|
69
|
+
|
|
70
|
+
### Creating a Compatible Program/Script for Verilog Snippet Generation
|
|
71
|
+
|
|
72
|
+
Users have the flexibility to create custom programs or scripts for generating ".vs" files or Verilog modules, or they can utilize existing ones. It's crucial to note that all scripts responsible for generating Verilog code, whether modules or ".vs" files, are independent of "*vs\_build*." "*vs\_build*" exclusively calls these scripts without importing them into the project.
|
|
73
|
+
|
|
74
|
+
**Supported File Extensions and Corresponding Languages:**
|
|
75
|
+
Currently, VeriSnip supports programs and scripts with the following file extensions:
|
|
76
|
+
|
|
77
|
+
* ".py" for Python
|
|
78
|
+
* ".sh" for Bash
|
|
79
|
+
* ".lua" for Lua
|
|
80
|
+
* ".scala" for Scala
|
|
81
|
+
* ".rb" for Ruby
|
|
82
|
+
* ".pl" for Perl
|
|
83
|
+
* ".vt" for Verilog Template (a custom extension)
|
|
84
|
+
|
|
85
|
+
The Verilog Template extension (".vt") is specific to VeriSnip. If you compile a program that generates a Verilog module or snippet, you can use the ".vt" extension to enable VeriSnip to locate it.
|
|
86
|
+
|
|
87
|
+
When *vs\_build* calls another program ([see example here](*vs_build*.py#L238)), it passes a variable number of arguments. Nevertheless, it always follows the same order. Therefore, take into consideration the following arguments and their order when developing your program or script:
|
|
88
|
+
|
|
89
|
+
* Path to the program or script being called
|
|
90
|
+
* Difference between the ".vs" filename and the program/script name. It corresponds to the suffix of the program/script name
|
|
91
|
+
* Comment written after the "\`include"
|
|
92
|
+
* File where the include is being called from, therefore the file where the "\`include" is written
|
|
93
|
+
* *vs\_build* received arguments (excluding its own name)
|
|
94
|
+
|
|
95
|
+
### Code structure
|
|
96
|
+
|
|
97
|
+
***vs\_build*** code is distinctly divided into three stages.
|
|
98
|
+
|
|
99
|
+
* in **1st stage** the function `find_vs_scripts_and_verilog()` finds all existing verilog modules, headers, snippets and scripts under the current directory.
|
|
100
|
+
* the **2nd stage** is where it finds the verilog modules and snippets needed by the core. If a verilog module or a snippet does not exist it will try to generate them. The generated snippets should be stored under the `./rtl/generated` directory. The function called for this stage is `verilog_fetch()`.
|
|
101
|
+
* during the **3rd stage** all verilog snippet files included are substituted for its content. Those files are then stored under the `./build` directory.
|
|
102
|
+
|
|
103
|
+
#### **2nd stage** - details
|
|
104
|
+
|
|
105
|
+
* When calling scripts to generate ".vs" priority is always given to scripts with the full name of the file. If there is no script corresponding to the ".vs" name look for a script that corresponds only to the initial part of the name. Example:
|
|
106
|
+
|
|
107
|
+
* in `include "io_modules.vs"` look for `VTio.py` or `io.py` if `io_modules.py` does not exist.
|
|
108
|
+
* When calling scripts that generate modules the script should have the name of the module.
|
|
109
|
+
* "*vs\_build*" only calls the scripts if they are newer than the files already existent.
|
|
110
|
+
* When there are two or more scripts with the same name a warning should be printed and the script with the closest directory path should be used.
|
|
111
|
+
* All files and scripts should only be looked for from the base directory of the project, unless specified otherwise in a custom script.
|
|
112
|
+
|
|
113
|
+
#### **3rd stage** - details
|
|
114
|
+
|
|
115
|
+
* all files which are generated should have a copy in the "aux" directory
|
|
116
|
+
* "*vs\_build*" substitutes the ".vs" and copies the modules needed to the build directory, after finding or generating all modules and ".vs" files.
|
|
117
|
+
|
|
118
|
+
## *vs\_colours*
|
|
119
|
+
|
|
120
|
+
This script defines the colors that should be used when printing error, warning or successful messages.
|
|
121
|
+
It defines the `print_coloured()` function and some variables that allow to modify the text printed to the console.
|
|
122
|
+
|
|
123
|
+
## MyLibrary
|
|
124
|
+
|
|
125
|
+
The "MyLibrary" directory contains hardware Verilog modules, snippets and scripts that might be commonly reused.
|
|
126
|
+
|
|
127
|
+
### Scripts
|
|
128
|
+
|
|
129
|
+
This section of the README contains information about the scripts present under the `./library/scripts` directory.
|
|
130
|
+
Read more about each script in the [README.md on the scripts directory](https://github.com/PedroAntunes178/VT-Tool/tree/main/MyLibrary/scripts/README.md).
|
|
131
|
+
|
|
132
|
+
## Opening an Issue
|
|
133
|
+
|
|
134
|
+
Welcome to our issue reporting system! We appreciate your contribution to the project by reporting any issues you encounter. Your feedback helps us make this project even better.
|
|
135
|
+
|
|
136
|
+
### How to Open an Issue
|
|
137
|
+
|
|
138
|
+
When opening an issue, please follow this format:
|
|
139
|
+
|
|
140
|
+
> **Issue Title**: A concise and descriptive title for the issue.
|
|
141
|
+
|
|
142
|
+
> Hello **Tag the developers you think might be able to help**,
|
|
143
|
+
>
|
|
144
|
+
> ## Issue Description:
|
|
145
|
+
>
|
|
146
|
+
> Provide a detailed description of the issue you encountered. Include information about your environment, steps to reproduce the issue, and any error messages. The more details you provide, the easier it is for us to understand and address the problem.
|
|
147
|
+
>
|
|
148
|
+
> ## Solution Reference (Optional):
|
|
149
|
+
>
|
|
150
|
+
> If you have a solution in mind, you're welcome to present it and provide a detailed explanation of why you believe it will work. If possible, include references to supporting pages or documentation that back your proposed solution. This can help us better understand your perspective and expedite the resolution process.
|
|
151
|
+
>
|
|
152
|
+
> ## Suggested Changes (Optional):
|
|
153
|
+
>
|
|
154
|
+
> If you have ideas for changes that might solve the issue, propose them here. Be clear and concise in your suggestions.
|
|
155
|
+
>
|
|
156
|
+
> ## Additional Question (Optional):
|
|
157
|
+
>
|
|
158
|
+
> If you have questions directly or indirectly related to the issue, feel free to ask them in this section.
|
|
159
|
+
|
|
160
|
+
Tag developers by using `@username` to get their attention.
|
|
161
|
+
|
|
162
|
+
We appreciate your help in improving this project!
|
|
163
|
+
|
|
164
|
+
## Contributing
|
|
165
|
+
|
|
166
|
+
All contributions to this project are warmly welcomed.
|
|
167
|
+
|
|
168
|
+
Contributions in the form of automatically generated Verilog scripts should be placed within the hardware/scripts directory. Additionally, contributors are required to create a corresponding section in the README when adding a script. This section should detail the generated core and provide instructions on the script's usage. It is important that the section structure aligns with the structures of other script sections.
|
|
169
|
+
|
|
170
|
+
## Development Environment
|
|
171
|
+
|
|
172
|
+
To utilize *vs\_build*, all that's necessary is Python3 and support for the scripting languages in which your scripts are written.
|
|
173
|
+
|
|
174
|
+
## Credits
|
|
175
|
+
|
|
176
|
+
This project idea came to me while I was working at IObundle. IObundle was developing a similar open-source tool called python-setup. The two projects are fundamentally different. Therefore I decided to create this project from 0 instead of contributing the ideas and tools directly to IObundle's python-setup.
|
|
177
|
+
|
|
178
|
+
Where the two projects are similar is both are being developed to generate automatic verilog.
|
|
179
|
+
|
|
180
|
+
Where they mainly differ is on the way the verilog is generated. The IObundle python-setup project aims to generate all the verilog core using a python framework. VeriSnip aims to substitute the .vs files present on the verilog code, generating the .vs code as needed. There may also exist scripts that generate .v modules.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "VeriSnip"
|
|
7
|
+
version = "0.0.2"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="Pedro Nuno de Melo Antunes", email="pedronmantunes@gmail.com" },
|
|
10
|
+
]
|
|
11
|
+
description = "A small example package"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.9"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
]
|
|
18
|
+
license = "Apache-2.0"
|
|
19
|
+
license-files = ["LICENSE"]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://github.com/LogicoreDesign/VT-Tool.git"
|
|
24
|
+
Issues = "https://github.com/LogicoreDesign/VT-Tool/issues"
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
vs_build = "VeriSnip.vs_build:main"
|
verisnip-0.0.2/setup.cfg
ADDED
|
File without changes
|