rvvm 0.8.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 382560e4ccb96972c0588cb6e5bcfd1bc70e6270349ef8db3e156a86ae247507
4
+ data.tar.gz: 9a29c17cdf2496336b01767c9e9de74c451094fd4c8af361fc3f2d1c1a1c17a6
5
+ SHA512:
6
+ metadata.gz: 380692384df76a75b6099f1d395721162a10c30070fc2f678b07684379debe8e9f15d503ff2a0ff2a64fe116f395808378796313a2bebb806d6c6992d6dcf4f7
7
+ data.tar.gz: d15065c6eedba2aaf550d93f31f42e5717691a47355a0820b4366cfeb81034386641b771ca7e30a64e2c931843516d22ff2f8df25e628ecab82ce377d172c7c8
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
data/CHANGELOG.md ADDED
@@ -0,0 +1,27 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-09-16
4
+
5
+ - Initial release
6
+
7
+ ## [0.8.0] - 2024-09-16
8
+
9
+ ### Added:
10
+
11
+ 1. Template file generation api
12
+ 2. RVM project template generation
13
+ 3. Argument parsing
14
+ 4. RVvM project config loading and parsing
15
+ 5. Project SV source compilation
16
+ 6. Project elaboration
17
+ 7. UVM test simulation
18
+
19
+ ### TBI:
20
+ 1. Test list parsing and batch simulation
21
+ 2. Module/itf/pkg/generic sv template generation
22
+ 3. Pure SV/Vlog simulation
23
+ 4. Waveform inspection using Vivado GUI
24
+ 5. Functional coverage report generation
25
+ 6. Unit tests
26
+ 7. CLI log graphic
27
+
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Viktor Toth aka mrbya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # RVvM - Ruby Vivado Manager
2
+
3
+ RVvM is a Ruby based meta tool to manage, compile, elaborate and simulate SystemVerilog and UVM based projects using Xilinx Vivado xvlog, xelab, xrun and xsc tools.
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ ```bash
10
+ bundle add rvvm
11
+ ```
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ ```bash
16
+ gem install rvvm
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ TBA
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://gitlab.com/such-hdl-much-wow/rvvm. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://gitlab.com/such-hdl-much-wow/rvm/-/blob/master/CODE_OF_CONDUCT.md?ref_type=heads).
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
36
+
37
+ ## Code of Conduct
38
+
39
+ Everyone interacting in the Rvm project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/such-hdl-much-wow/rvm/-/blob/master/CODE_OF_CONDUCT.md?ref_type=heads).
40
+
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ # require "rubocop/rake_task"
9
+ #
10
+ # RuboCop::RakeTask.new
11
+ #
12
+ # task default: %i[test rubocop]
@@ -0,0 +1,251 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Templates
4
+ @templates = {}
5
+
6
+ @templates[:rvvmconf] = {
7
+ file: {
8
+ path: "./rvvm",
9
+ name: "rvvmconf.json"
10
+ },
11
+ conf: {
12
+ prjname: "RVvM",
13
+ prjpath: "~/rvvm/RVvM"
14
+ },
15
+ content: %({
16
+ "project": {
17
+ "name": "${prjname}",
18
+ "path": "${prjpath}",
19
+ "rvvmDir": "rvvm",
20
+ "logDir": "logs",
21
+ "company": " "
22
+ },
23
+
24
+ "compilation": {
25
+ "list": "${prjname}_compile_list.f",
26
+ "logDir": "comp",
27
+ "log": "comp.log",
28
+ "args": "-L uvm"
29
+ },
30
+
31
+ "dpi": {
32
+ "dpilib": 0,
33
+ "list": "dpi_compile_list.f",
34
+ "args": " "
35
+ },
36
+
37
+ "elaboration": {
38
+ "tbTop": "${prjname}_tb_top",
39
+ "tb": "${prjname}_tb",
40
+ "timescale": "1ns/1ps",
41
+ "logDir": "elab",
42
+ "log": "elab.log",
43
+ "args": " "
44
+ },
45
+
46
+ "simulation": {
47
+ "logDir": "sim",
48
+ "log": "${testname}.log",
49
+ "verbosity": "LOW",
50
+ "defTest": " ",
51
+ "batch": 0,
52
+ "testList": " ",
53
+ "args": " "
54
+ }
55
+ })
56
+ }
57
+
58
+ @templates[:compilelist] = {
59
+ file: {
60
+ path: "./rvvm",
61
+ name: "RVvM_compile_list.f"
62
+ },
63
+ conf: {
64
+ prjname: "RVvM"
65
+ },
66
+ content: %(-i ../design
67
+ -i ../design/src
68
+ -i ../verif/env
69
+ -i ../verif/env/agents
70
+ -i ../verif/env/top
71
+ -i ../verif/tb/src
72
+ -i ../verif/test
73
+ -i ../verif/test/seq
74
+ -i ../verif/test/src
75
+ ../verif/tb/src/${prjname}_tb_top.sv
76
+
77
+ )
78
+ }
79
+
80
+ @templates[:wfcfg] = {
81
+ file: {
82
+ path: "./rvvm",
83
+ name: "wfcfg.tcl"
84
+ },
85
+ conf: {},
86
+ content: %(log_wave -recursive *
87
+ run all
88
+ exit
89
+
90
+ )
91
+ }
92
+
93
+ @templates[:dpilist] = {
94
+ file: {
95
+ path: "./rvvm",
96
+ name: "dpi_compile_list.f"
97
+ },
98
+ conf: {},
99
+ content: %(#list of DPI-C sources
100
+ )
101
+ }
102
+
103
+ @templates[:tbtop] = {
104
+ file: {
105
+ path: "./verif/tb/src",
106
+ name: "RVvM_tb_top.sv"
107
+ },
108
+ conf: {
109
+ prjname: "RVvM",
110
+ PRJNAME: "RVvM"
111
+ },
112
+ content: %(`ifndef ${PRJNAME}_TB_TOP
113
+ `define ${PRJNAME}_TB_TOP
114
+
115
+ `include "uvm_macros.svh"
116
+
117
+ import uvm_pkg::*;
118
+
119
+ module ${prjname}_tb_top;
120
+
121
+ //testbench implementation
122
+
123
+ endmodule: ${prjname}_tb_top
124
+
125
+ `endif//${PRJNAME}_TB_TOP
126
+
127
+ )
128
+ }
129
+
130
+ @templates[:module] = {
131
+ file: {
132
+ path: "design/src"
133
+ },
134
+ conf: {
135
+ type: "module",
136
+ module: "best_rtl_module_ever",
137
+ date: "01/01/2024 00:00",
138
+ prjname: "RVvM",
139
+ company: " ",
140
+ username: "me"
141
+ },
142
+ content: %(//////////////////////////////////////////////////////////////////////////////////
143
+ // Company: ${company}
144
+ // Engineer: ${username}
145
+ //
146
+ // Create Date: ${date}
147
+ // Project Name: ${prjname}
148
+ // Module Name: ${module}
149
+ // Target Devices:
150
+ // Tool Versions:
151
+ // Description:
152
+ //
153
+ // Dependencies:
154
+ //
155
+ // Revision:
156
+ // Revision 0.01 - File Created
157
+ // Additional Comments:
158
+ //
159
+ //////////////////////////////////////////////////////////////////////////////////
160
+
161
+ ${type} ${module}(
162
+
163
+ );
164
+
165
+ end${type}
166
+ )
167
+ }
168
+
169
+ @templates[:package] = {
170
+ file: {
171
+ path: "design/pkg"
172
+ },
173
+ conf: {
174
+ package: "best_rtl_pkg",
175
+ PACKAGE: "BEST_RTL_PACKAGE",
176
+ date: "01/01/2024 00:00",
177
+ prjname: "RVvM",
178
+ company: " ",
179
+ username: "me"
180
+ },
181
+ content: %(//////////////////////////////////////////////////////////////////////////////////
182
+ // Company: ${company}
183
+ // Engineer: ${username}
184
+ //
185
+ // Create Date: ${date}
186
+ // Project Name: ${prjname}
187
+ // Package Name: ${package}
188
+ // Target Devices:
189
+ // Tool Versions:
190
+ // Description:
191
+ //
192
+ // Dependencies:
193
+ //
194
+ // Revision:
195
+ // Revision 0.01 - File Created
196
+ // Additional Comments:
197
+ //
198
+ //////////////////////////////////////////////////////////////////////////////////
199
+ `ifndef ${PACKAGE}
200
+ `define ${PACKAGE}
201
+
202
+ package ${package};
203
+
204
+ endpackage
205
+
206
+ `endif//${PACKAGE}
207
+ )
208
+ }
209
+
210
+ @templates[:svfile] = {
211
+ file: {
212
+ path: "design/src"
213
+ },
214
+ conf: {
215
+ NAME: "BEST_RTL_FILE",
216
+ date: "01/01/2024 00:00",
217
+ prjname: "RVvM",
218
+ company: " ",
219
+ username: "me"
220
+ },
221
+ content: %(//////////////////////////////////////////////////////////////////////////////////
222
+ // Company: ${company}
223
+ // Engineer: ${username}
224
+ //
225
+ // Create Date: ${date}
226
+ // Project Name: ${prjname}
227
+ // Package Name: ${package}
228
+ // Target Devices:
229
+ // Tool Versions:
230
+ // Description:
231
+ //
232
+ // Dependencies:
233
+ //
234
+ // Revision:
235
+ // Revision 0.01 - File Created
236
+ // Additional Comments:
237
+ //
238
+ //////////////////////////////////////////////////////////////////////////////////
239
+ `ifndef ${NAME}
240
+ `define ${NAME}
241
+
242
+
243
+
244
+ `endif//${NAME}
245
+ )
246
+ }
247
+
248
+ def self.load
249
+ @templates
250
+ end
251
+ end
data/lib/rvvm/utils.rb ADDED
@@ -0,0 +1,62 @@
1
+ # # frozen_string_literal: true
2
+
3
+ module Utils
4
+ def self.interpret(string, hash)
5
+ string.gsub(/\$\{([^}]+)\}/) do |match|
6
+ hash[Regexp.last_match(1).to_sym] || match
7
+ end
8
+ end
9
+
10
+ def self.gen_file(path, content)
11
+ File.open(path, "w") do |file|
12
+ file.write(content)
13
+ end
14
+ rescue StandardError => e
15
+ puts "\nFailed to create a file!\nError #{e.message}"
16
+ end
17
+
18
+ def self.gen_template(template, name = nil, config = nil, path = nil)
19
+ temp_config = config || template[:config]
20
+ content = interpret(template[:content], temp_config)
21
+ filename = name || template[:file][:name]
22
+ filepath = path || template[:file][:path]
23
+
24
+ puts "Generating: #{filepath}/#{filename}"
25
+ gen_file("#{filepath}/#{filename}", content)
26
+ end
27
+
28
+ def self.find_file_dir(filename, path)
29
+ Dir.foreach(path) do |file|
30
+ next if file == "."
31
+ next if file == ".."
32
+
33
+ full_path = File.join(path, file)
34
+
35
+ if File.directory?(full_path)
36
+ found = find_file_dir(filename, full_path)
37
+ return found if found
38
+ elsif file == filename
39
+ return path
40
+ end
41
+ end
42
+ nil
43
+ end
44
+
45
+ def self.git_userame
46
+ username = nil
47
+ IO.popen("git config --get user.name") do |handle|
48
+ username = handle.read
49
+ end
50
+
51
+ username.strip!
52
+ username
53
+ end
54
+
55
+ def self.all_nil?(hash, array)
56
+ array.each do |key|
57
+ return false if hash[key]
58
+ end
59
+
60
+ true
61
+ end
62
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rvvm
4
+ VERSION = "0.8.0"
5
+ end
data/lib/rvvm.rb ADDED
@@ -0,0 +1,291 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rvvm/version"
4
+ require_relative "rvvm/utils"
5
+ require_relative "rvvm/templates"
6
+
7
+ require "optparse"
8
+ require "fileutils"
9
+ require "json"
10
+
11
+ module Rvvm
12
+ class Error < StandardError; end
13
+
14
+ @templates = Templates.load
15
+ @config_path = nil
16
+ @config = nil
17
+
18
+ @args = {}
19
+ @required_args = %i[
20
+ new
21
+ module
22
+ pkg
23
+ itf
24
+ svfile
25
+ comp
26
+ elab
27
+ run
28
+ all
29
+ runsv
30
+ dpi
31
+ gui
32
+ gencov
33
+ covreport
34
+ ]
35
+
36
+ OptionParser.new do |args|
37
+ args.on("-h", "--help", "Shows this help") do
38
+ puts "\nRVvM - Ruby Vivado Manager\n\n"
39
+ puts "\tRVvM is a Ruby based tool to manage, compile, elaborate and simulate SystemVerilog and UVM based projects"
40
+ puts "\tusing Xilinx Vivado xvlog, xelab, xrun and xsc.\n\n"
41
+ puts args
42
+ # puts "\nRequired args (at least one):"
43
+ # @required_args.each do |arg|
44
+ # puts "\t--#{arg}"
45
+ # end
46
+ exit
47
+ end
48
+ args.on("-v", "--version", "Displays RVvM gem version") do
49
+ puts "RVvM version: #{VERSION}"
50
+ end
51
+
52
+ args.on("-n", "--new NAME", "Creates a new project wit the prowided name under pwd")
53
+ args.on("--module NAME", "Creates a SystemVerilog module template (default path: <prj dir>/design/src)")
54
+ args.on("--pkg NAME", "Creates a SystemVerilog package template (default path: <prj dir>/design/pkg)")
55
+ args.on("--itf NAME", "Creates a SystemVerilog interface template (default path: <prj dir>/design/itf)")
56
+ args.on("--svfile NAME", "Creates a generic SystemVerilog file template (default path: <prj dir>/design/src)")
57
+ args.on("--here", "Speciies pwd as a path when creating a file template")
58
+ args.on("--path PATH", "Specifies a path relative to <prj dir> when creating a file template")
59
+ args.on("-c", "--comp", "Compile SystemVerilog sources")
60
+ args.on("-e", "--elab", "Elaborates project")
61
+ args.on("-r", "--run", "Runs UVM simulation")
62
+ args.on("-a", "--all", "Runs --comp, (--dpi), --elab, --run")
63
+ args.on("--runsv", "Runs pure SystemVerilog/Verilog simulation (Ignores UVM related arguments and config options)")
64
+ args.on("-d", "--dpi", "Compiles C/C++ sources to a shared lib to link into an elaborated snaphost using DPI-C")
65
+ args.on("-u", "--gui", "Opens a dumped waveform in Xilinx Vivado GUI")
66
+ args.on("-g", "--gencov", "Generates a functional coverage report")
67
+ args.on("-p", "--covreport", "Opens the latest generated functional coverage report in Xilinx coverage dashboard")
68
+ args.on("--complog LOGNAME", "Specifies compilation log filename (overrides config)")
69
+ args.on("--complist LISTFILE", "Specifies compile list for compilation (overrides config)")
70
+ args.on("--elablog LOGNAME", "Specifies elaboration log filename (overrides config)")
71
+ args.on("--timescale TIMESCALE", "Specifies timescale for testbench snapshot to be elaborated (overrides config)")
72
+ args.on("--tbtop TOPMODULE", "Specifie testbench top module (overwrites config)")
73
+ args.on("--tb TBNAME", "Specifies tesbench snapshot to be elaborated (overwrites config)")
74
+ args.on("--simlog LOGNAME", "Specifies simulation log name (overwrites config)")
75
+ args.on("--test TESTNAME", "Specifies UVM test to be run by --run (overwrites config)")
76
+ args.on("-b", "--batch", "Run a batch of UVM tests from a test list (overwrites config)")
77
+ args.on("--testlist TESTLIST", "Specifies test list for a batch of test run (overwrites config)")
78
+ args.on("--verb VERBOSITY", "Specifies UVM verbosity <LOW, MEDIUM, HIGH, FULL, DEBUG> (overwrites config)")
79
+ args.on("--simtb TBNAME", "Specifies testbench snapshot for simulation (overwrites config)")
80
+ args.on("--dpilist LISTFILE", "Specifies source file list for DPI-C compilation (overwrites config)")
81
+ args.on("-w", "--wave", "Activates waveform trace dump for elaboration and simulation (overwrites config)")
82
+ args.on("--wavefile WAVEFILE", "Specifies waveform dump file to be openned in Vivado GUI")
83
+ args.on("--prjconf CONFIG", "Specifies RVvM project config file if not using the one provided in the project")
84
+ args.on("-l", "--dpilib", "Specifies a DPI-C shared library to be linked with a snapshot during elaboration")
85
+ args.on("--debug", "Script debug")
86
+ end.parse!(into: @args)
87
+
88
+ def self.pass_config(config)
89
+ @config = config
90
+ end
91
+
92
+ def self.check_args
93
+ if @args[:all]
94
+ @args[:comp] = 1
95
+ @args[:elab] = 1
96
+ @args[:run] = 1
97
+ end
98
+ if Utils.all_nil?(@args, @required_args)
99
+ puts "\nNo required options provided!\nFor more info use -h or --help\n"
100
+ exit
101
+ end
102
+ end
103
+
104
+ def self.handle_args
105
+ @args[:dpi] = 1 if @args[:all] && @config[:dpi][:dpilib] == 1
106
+
107
+ if @args[:batch] || @config[:simulation][:batch] == 1
108
+ if @args[:test]
109
+ puts "UVM test provided even though running in batch mode - option will be ignored..."
110
+ @args[:test] = nil
111
+ end
112
+ elsif @args[:testList]
113
+ puts "UVM test list provided without running in batch mode - option will be ignored..."
114
+ @args[:testlist] = nil
115
+ end
116
+ end
117
+
118
+ def self.execute(command)
119
+ if @args[:debug]
120
+ puts command
121
+ else
122
+ system(command)
123
+ end
124
+ end
125
+
126
+ def self.create_new_project(name)
127
+ puts "\nRVvM: Generating new project: #{name} ...\n"
128
+
129
+ FileUtils.mkdir(name)
130
+ Dir.chdir(name)
131
+
132
+ FileUtils.mkdir("rvvm")
133
+ FileUtils.chdir("rvvm")
134
+ FileUtils.mkdir("logs")
135
+ Dir.chdir("logs")
136
+ FileUtils.mkdir("comp")
137
+ FileUtils.mkdir("elab")
138
+ FileUtils.mkdir("sim")
139
+ FileUtils.mkdir("dpi")
140
+ Dir.chdir("../..")
141
+
142
+ temp_conf = @templates[:rvvmconf][:conf]
143
+ temp_conf[:prjname] = name
144
+ temp_conf[:prjpath] = Dir.pwd
145
+ Utils.gen_template(@templates[:rvvmconf], nil, temp_conf)
146
+
147
+ temp_conf = @templates[:compilelist][:conf]
148
+ temp_conf[:prjname] = name
149
+ Utils.gen_template(@templates[:compilelist], "#{name}_compile_list.f", temp_conf)
150
+
151
+ Utils.gen_template(@templates[:wfcfg])
152
+ Utils.gen_template(@templates[:dpilist])
153
+
154
+ FileUtils.mkdir("design")
155
+ Dir.chdir("design")
156
+ FileUtils.mkdir("pkg")
157
+ FileUtils.mkdir("itf")
158
+ FileUtils.mkdir("src")
159
+ Dir.chdir("..")
160
+
161
+ FileUtils.mkdir("verif")
162
+ Dir.chdir("verif")
163
+ FileUtils.mkdir("env")
164
+ FileUtils.mkdir("env/agents")
165
+ FileUtils.mkdir("env/top")
166
+ FileUtils.mkdir("tb")
167
+ FileUtils.mkdir("tb/src")
168
+ FileUtils.mkdir("test")
169
+ FileUtils.mkdir("test/seq")
170
+ FileUtils.mkdir("test/src")
171
+ Dir.chdir("..")
172
+
173
+ temp_conf = @templates[:tbtop][:conf]
174
+ temp_conf[:prjname] = name
175
+ temp_conf[:PRJNAME] = name.upcase
176
+ Utils.gen_template(@templates[:tbtop], "#{name}_tb_top.sv", temp_conf)
177
+
178
+ system("git init")
179
+ system("git add .")
180
+ system('git commit -am "Initial commit"')
181
+
182
+ puts "\nRVvM: New project generated. ^^"
183
+
184
+ exit(0)
185
+ end
186
+
187
+ def self.load_config
188
+ puts "\nRVvM: Loading RVvM project config..."
189
+
190
+ @config_path = Utils.find_file_dir("rvvmconf.json", ".")
191
+ json_file = File.read("#{@config_path}/rvvmconf.json") if @config_path
192
+
193
+ unless json_file
194
+ puts " Failed to load config file!\n"
195
+ puts " Make sure you are inside an RVvM project.\n\n"
196
+ exit(1)
197
+ end
198
+
199
+ @config = JSON.parse(json_file) if json_file
200
+ @config = @config.transform_values do |v|
201
+ v.transform_keys(&:to_sym)
202
+ end.transform_keys(&:to_sym)
203
+ end
204
+
205
+ def self.prj_top
206
+ Dir.chdir(@config_path)
207
+ end
208
+
209
+ def self.compile
210
+ cmd_args = @config[:compilation][:args]
211
+ logname = File.join(@config[:compilation][:logDir], @args[:complog] || @config[:compilation][:log])
212
+ complist = @args[:compilelist] || @config[:compilation][:list]
213
+
214
+ puts "\nRVvM: Compiling HDL sources..\n"
215
+
216
+ cmd = "xvlog -sv -f #{complist} -log #{logname} #{cmd_args}"
217
+ execute(cmd)
218
+ end
219
+
220
+ def self.dpi_c
221
+ cmd_args = @config[:dpi][:args]
222
+ dpilist = @args[:dpilist] || @config[:dpi][:list]
223
+
224
+ puts "\nRVvM: Building DPI-C library...\n"
225
+
226
+ cmd = "sxc -f #{dpilist} #{cmd_args}"
227
+ execute(cmd)
228
+ end
229
+
230
+ def self.elaborate
231
+ cmd_args = @config[:elaboration][:args]
232
+ cmd_args << " -sv_lib dpi" if @args[:dpi] || @args[:dpilib] || @config[:dpi][:dpilib] == 1
233
+ cmd_args << " -debug wave" if @args[:wave]
234
+ logname = File.join(@config[:elaboration][:logDir], @args[:elablog] || @config[:elaboration][:log])
235
+ tb_top = @args[:tbtop] || @config[:elaboration][:tbTop]
236
+ tb = @args[:tb] || @config[:elaboration][:tb]
237
+ timescale = @args[:timescale] || @config[:elaboration][:timescale]
238
+
239
+ puts "\nRVvM: Elaborating testbench:"
240
+ puts " TB TOP: \t#{tb_top}"
241
+ puts " SNAPSHOT:\t#{tb}\n"
242
+
243
+ cmd = "xelab #{tb_top} -relax -s #{tb} -timescale #{timescale} -log #{logname} #{cmd_args}"
244
+ execute(cmd)
245
+ end
246
+
247
+ def self.run_sim
248
+ cmd_args = @config[:simulation][:args]
249
+ if @args[:wave]
250
+ cmd_args << " --tclbatch wfcfg.tcl"
251
+ else
252
+ cmd_args << "-R"
253
+ end
254
+
255
+ test = @args[:test] || @config[:simulation][:defTest]
256
+ # TODO: parse test list
257
+ testlist = [test]
258
+
259
+ tb = @args[:simtb] || @args[:tb] || @config[:elaboration][:tb]
260
+
261
+ puts ""
262
+
263
+ testlist.each_with_index do |simtest, i|
264
+ puts "RVvM: Running test #{i + 1}/#{testlist.size}: #{simtest}"
265
+
266
+ logname = File.join(@config[:simulation][:logDir], @config[:simulation][:log])
267
+ logname = Utils.interpret(logname, { testname: simtest })
268
+
269
+ verb = "UVM_#{@args[:verb] || @config[:simulation][:verbosity]}"
270
+
271
+ cmd = "xsim #{tb} -log #{logname} -testplusarg \"UVM_VERBOSITY=#{verb}\" -testplusarg \"UVM_TESTNAME=#{simtest}\" #{cmd_args}"
272
+ execute(cmd)
273
+ end
274
+ end
275
+
276
+ def self.run
277
+ create_new_project(@args[:new]) if @args[:new]
278
+
279
+ check_args
280
+ load_config
281
+ handle_args
282
+
283
+ prj_top
284
+
285
+ compile if @args[:comp]
286
+ dpi_c if @args[:dpi]
287
+ elaborate if @args[:elab]
288
+ run_sim if @args[:run]
289
+ end
290
+ end
291
+
data/sig/rvvm.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Rvvm
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rvvm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.0
5
+ platform: ruby
6
+ authors:
7
+ - mrbya
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-09-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: RVvM is a Ruby based meta tool to manage/compile/elaborate and run simulations
14
+ on SystemVerilog and UVM based projects using Xilinx Vivado xvlog, xelab, xrun,
15
+ xsc tools
16
+ email:
17
+ - v.toth.svk2@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ".rubocop.yml"
23
+ - CHANGELOG.md
24
+ - CODE_OF_CONDUCT.md
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - lib/rvvm.rb
29
+ - lib/rvvm/templates.rb
30
+ - lib/rvvm/utils.rb
31
+ - lib/rvvm/version.rb
32
+ - sig/rvvm.rbs
33
+ homepage: https://gitlab.com/such-hdl-much-wow/rvvm.git
34
+ licenses:
35
+ - MIT
36
+ metadata:
37
+ homepage_uri: https://gitlab.com/such-hdl-much-wow/rvvm.git
38
+ source_code_uri: https://gitlab.com/such-hdl-much-wow/rvvm.git
39
+ changelog_uri: https://gitlab.com/such-hdl-much-wow/rvvm/-/blob/master/CHANGELOG.md?ref_type=heads
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 3.0.0
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.5.18
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: RVvM - Ruby Vivado Manager
59
+ test_files: []