rvvm 0.9.2 → 0.9.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfe48fe0908436378978c1f713512eef964526caa955f0c20d6c63b866d5bcac
4
- data.tar.gz: 6d197fb0b236b3a8bde5c058db531593e551b97a6c8b71429c7aa302061d5d68
3
+ metadata.gz: 01a0976fb744924367077dfda5f613dbf6912032fbc61896c41aa647f606863e
4
+ data.tar.gz: 188c360b6cf73c1c4478c1cbb8d1f665daf6523a97b5c286a63ea0b3ab056fc2
5
5
  SHA512:
6
- metadata.gz: ec6fe8c155ffa528e13b0c443e8361b648fb5ab94e3230e6257fad0c10a16fa338e53cbda53b57b83186902fcb9aa03c486609e73a04fc4d8b51a5ab86542fa9
7
- data.tar.gz: bd555309f858e5bb274b03cdd929bbbbbac26042e634e9812a8f974c524d82a603cd735bfc9d4e01a2dd468d9245eab7534be4ce749833e84e7918929369bb8f
6
+ metadata.gz: ea4aaab4ac74410dcded24b69db2953ee51e2811539fec0e08891097231f4551ace3cb25fd7a68fe6a8afceeeddce9bed4ba277edddf453036d88ddea2e986ee
7
+ data.tar.gz: 67315687f47c4648af7db0b66530bfb3dae52affd5ee1ea97b7d1b16099ba1409e1fc4df805b4639dedebffd7afe43fdec91166c33f23c778928ca8585e49400
data/CHANGELOG.md CHANGED
@@ -47,16 +47,46 @@
47
47
 
48
48
  1. Test list parsing and batch simulation
49
49
  2. Unit tests
50
- 3. CLI log graphics
50
+ 3. CLI log graphic
51
51
 
52
52
  ## [0.9.1] - 2024-09-16
53
53
 
54
- ### Fixes
54
+ ### Fixes:
55
55
 
56
- 1. Fixed rvvm exacutable being excluded by gemspec
56
+ 1. Fixed `rvvm` exacutable being excluded by gemspec
57
57
 
58
58
  ## [0.9.2] - 2024-09-16
59
59
 
60
- ### Fixes
60
+ ### Fixes:
61
+
62
+ 1. `rvvm` executable still missing after 0.9.1 update
63
+
64
+ ### TBI:
65
+
66
+ 1. Test list parsing and batch simulation
67
+ 2. Tests
68
+ 3. CLI log graphic
69
+ 4. Project config load failure handling/error message when parsing invalid json
70
+ 5. Template file generation in pwd
71
+ 6. Elaboration and simulation custom waveform trace dump file
72
+
73
+ ## [0.9.3] - 2024-09-16
74
+
75
+ ### Added:
76
+
77
+ 1. Test list parsing and batch simulation
78
+ 2. Tests
79
+ 3. Updated gitlab pipeline
80
+ 4. `sandbox` script to play with during development
81
+ 5. Code documentation
82
+
83
+ ### Fixed:
84
+
85
+ 1. Hash key conversion to symbols when parsing config json
86
+
87
+ ### TBI:
61
88
 
62
- 1. rvvm executable still missing after 0.9.1 update
89
+ 1. CLI log graphic
90
+ 2. Project config load failure handling/error message when parsing invalid json
91
+ 3. Template file generation in pwd
92
+ 4. Elaboration and simulation custom waveform trace dump file
data/bin/sandbox ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # just a sandbox to play with ruby during development
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Module containing template hashes for rvvm.
3
4
  module Templates
4
5
  @templates = {}
5
6
 
@@ -49,7 +50,7 @@ module Templates
49
50
  "verbosity": "LOW",
50
51
  "defTest": " ",
51
52
  "batch": 0,
52
- "testList": " ",
53
+ "testlist": [" "],
53
54
  "args": " "
54
55
  }
55
56
  })
@@ -245,6 +246,11 @@ endpackage
245
246
  )
246
247
  }
247
248
 
249
+ # Loads template hashes.
250
+ #
251
+ # @return [Hash] template hashes
252
+ #
253
+ # @since 0.8.0
248
254
  def self.load
249
255
  @templates
250
256
  end
data/lib/rvvm/utils.rb CHANGED
@@ -1,12 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Utils module providing utilities and helper methods to rvvm.
4
+ #
5
+ # Mainly used to generate files and templates.
6
+ #
7
+ # @since 0.1.0
3
8
  module Utils
4
- def self.interpret(string, hash)
9
+ # Interpolates string.
10
+ #
11
+ # Replaces named keys `${example_key}` with provided values based on a hash.
12
+ #
13
+ # @param string [String] string to be interpolated
14
+ # @param hash [Hash] Hash to provide values to replace instead of the named keys
15
+ #
16
+ # @return [string] interpolated string
17
+ #
18
+ # @since 0.1.0
19
+ def self.interpolate(string, hash)
5
20
  string.gsub(/\$\{([^}]+)\}/) do |match|
6
21
  hash[Regexp.last_match(1).to_sym] || match
7
22
  end
8
23
  end
9
24
 
25
+ # Generates a file with a provided content.
26
+ #
27
+ # @param path [String] path of the file to be generated
28
+ # @param content [String] content of the file to be generated
29
+ #
30
+ # @return [void]
31
+ #
32
+ # @since 0.8.0
10
33
  def self.gen_file(path, content)
11
34
  File.open(path, "w") do |file|
12
35
  file.write(content)
@@ -15,16 +38,36 @@ module Utils
15
38
  puts "\nFailed to create a file!\nError #{e.message}"
16
39
  end
17
40
 
41
+ # Generates a file based on a template.
42
+ #
43
+ # @param template [Hash] hash with the template content
44
+ # @param name [String] name of the file to be generated
45
+ # @param config [Hash] template config hash for content interpolation
46
+ # @param path [String] path of the template file to be generated (excluding file name)
47
+ #
48
+ # @return [void]
49
+ #
50
+ # @since 0.8.0
18
51
  def self.gen_template(template, name = nil, config = nil, path = nil)
19
52
  temp_config = config || template[:config]
20
- content = interpret(template[:content], temp_config)
53
+ content = interpolate(template[:content], temp_config)
21
54
  filename = name || template[:file][:name]
22
55
  filepath = path || template[:file][:path]
23
56
 
24
- puts "Generating: #{filepath}/#{filename}"
57
+ puts " Generating: #{filepath}/#{filename}"
25
58
  gen_file("#{filepath}/#{filename}", content)
26
59
  end
27
60
 
61
+ # Recursively searches provided directory for a file.
62
+ #
63
+ # @param filename [String] name of the file to look for
64
+ # @param path [String] path to start search on
65
+ #
66
+ # @return [String] path of the first occurence of the file
67
+ # or
68
+ # @return [nil] if file not found
69
+ #
70
+ # @since 0.8.0
28
71
  def self.find_file_dir(filename, path)
29
72
  Dir.foreach(path) do |file|
30
73
  next if file == "."
@@ -42,6 +85,11 @@ module Utils
42
85
  nil
43
86
  end
44
87
 
88
+ # Extracts git username using git config system call.
89
+ #
90
+ # @return [String] git username
91
+ #
92
+ # @since 0.9.0
45
93
  def self.git_userame
46
94
  username = nil
47
95
  IO.popen("git config --get user.name") do |handle|
@@ -52,6 +100,15 @@ module Utils
52
100
  username
53
101
  end
54
102
 
103
+ # Checks if hash contains keys provided from an array.
104
+ #
105
+ # @param hash [Hash] hash to analyze
106
+ # @param arra [Array] array of keys to look for in the hash
107
+ #
108
+ # @return [Bolean] true if all provided keys from a hash return nil
109
+ # @return [Boolean] false if a provided key is found in the hash
110
+ #
111
+ # @since 0.9.0
55
112
  def self.all_nil?(hash, array)
56
113
  array.each do |key|
57
114
  return false if hash[key]
data/lib/rvvm/version.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Module holding current rvvm version.
3
4
  module Rvvm
4
- VERSION = "0.9.2"
5
+ # Current rvvm module version.
6
+ VERSION = "0.9.3"
5
7
  end
data/lib/rvvm.rb CHANGED
@@ -8,13 +8,28 @@ require "optparse"
8
8
  require "fileutils"
9
9
  require "json"
10
10
 
11
+ # Top level module of the rvvm cli meta tool.
12
+ #
13
+ # Handles argument parsing, project creation, template file
14
+ # generation and all interaction with Xilinx Vivado tools.
15
+ #
16
+ # Argument parsing runs on `require`, rest is run using run
17
+ #
18
+ # @example
19
+ # require "rvvm"
20
+ #
21
+ # Rvvm.run
22
+ #
23
+ # @since 0.1.0
11
24
  module Rvvm
12
25
  class Error < StandardError; end
13
26
 
27
+ # Module instance variables to hold tempaltes and project config
14
28
  @templates = Templates.load
15
29
  @config_path = nil
16
30
  @config = nil
17
31
 
32
+ # Instance variables to hold parsed args and required arg symbol list
18
33
  @args = {}
19
34
  @required_args = %i[
20
35
  version
@@ -34,6 +49,8 @@ module Rvvm
34
49
  covreport
35
50
  ]
36
51
 
52
+ # Script argument parsing block.
53
+ # Runs on loading the module using require.
37
54
  OptionParser.new do |args|
38
55
  args.on("-h", "--help", "Shows this help") do
39
56
  puts "\nRVvM - Ruby Vivado Manager\n\n"
@@ -44,16 +61,11 @@ module Rvvm
44
61
  @current_time = Time.now
45
62
  @formatted_time = @current_time.strftime("%Y-%m-%d %H:%M:%S")
46
63
 
47
-
48
64
  req_args = String.new
49
65
  @required_args.each do |arg|
50
66
  req_args << "--#{arg} "
51
67
  end
52
68
  puts "\nRequired args (at least one): #{req_args}\n\n"
53
- # puts "\nRequired args (at least one):"
54
- # @required_args.each do |arg|
55
- # puts "\t--#{arg}"
56
- # end
57
69
  exit(0)
58
70
  end
59
71
  args.on("-v", "--version", "Displays RVvM gem version") do
@@ -66,7 +78,6 @@ module Rvvm
66
78
  args.on("--pkg NAME", "Creates a SystemVerilog package template (default path: <prj dir>/design/pkg)")
67
79
  args.on("--itf NAME", "Creates a SystemVerilog interface template (default path: <prj dir>/design/itf)")
68
80
  args.on("--svfile NAME", "Creates a generic SystemVerilog file template (default path: <prj dir>/design/src)")
69
- # args.on("--here", "Speciies pwd as a path when creating a file template")
70
81
  args.on("--path PATH", "Specifies a path relative to <prj dir> when creating a file template")
71
82
  args.on("-c", "--comp", "Compile SystemVerilog sources")
72
83
  args.on("-e", "--elab", "Elaborates project")
@@ -97,22 +108,31 @@ module Rvvm
97
108
  args.on("--debug", "Script debug")
98
109
  end.parse!(into: @args)
99
110
 
100
- def self.pass_config(config)
101
- @config = config
102
- end
103
-
111
+ # Simple argument check.
112
+ #
113
+ # @return [void]
114
+ #
115
+ # @since 0.8.0
104
116
  def self.check_args
105
117
  if @args[:all]
106
118
  @args[:comp] = 1
107
119
  @args[:elab] = 1
108
120
  @args[:run] = 1
109
121
  end
122
+
123
+ # Check if a required arg is provided
110
124
  if Utils.all_nil?(@args, @required_args)
111
125
  puts "\nNo required options provided!\nFor more info use -h or --help\n"
112
- exit
126
+ exit(1)
113
127
  end
114
128
  end
115
129
 
130
+ # Argument collision handling and additional settings for
131
+ # batch simulation and dpi compilation.
132
+ #
133
+ # @return [void]
134
+ #
135
+ # @since 0.8.0
116
136
  def self.handle_args
117
137
  @args[:dpi] = 1 if @args[:all] && @config[:dpi][:dpilib] == 1
118
138
 
@@ -127,6 +147,16 @@ module Rvvm
127
147
  end
128
148
  end
129
149
 
150
+ # Shell command with debug printout.
151
+ #
152
+ # If --debug arg provided instead of calling `system`
153
+ # prints the input command.
154
+ #
155
+ # @param command [String] command to be called/printed
156
+ #
157
+ # @return [void]
158
+ #
159
+ # @since 0.8.0
130
160
  def self.execute(command)
131
161
  if @args[:debug]
132
162
  puts command
@@ -135,6 +165,13 @@ module Rvvm
135
165
  end
136
166
  end
137
167
 
168
+ # Creates a new RVvM project template in pwd with a given name.
169
+ #
170
+ # @param name [String] project name
171
+ #
172
+ # @return [void]
173
+ #
174
+ # @since 0.8.0
138
175
  def self.create_new_project(name)
139
176
  puts "\nRVvM: Generating new project: #{name} ...\n"
140
177
 
@@ -187,15 +224,22 @@ module Rvvm
187
224
  temp_conf[:PRJNAME] = name.upcase
188
225
  Utils.gen_template(@templates[:tbtop], "#{name}_tb_top.sv", temp_conf)
189
226
 
227
+ puts " "
190
228
  system("git init")
191
229
  system("git add .")
192
230
  system('git commit -am "Initial commit"')
193
231
 
194
- puts "\nRVvM: New project generated. ^^"
232
+ puts "\nRVvM: New project generated. ^^\n\n"
195
233
 
196
234
  exit(0)
197
235
  end
198
236
 
237
+ # Loads and parses rvvmconf.json config file from
238
+ # an RVvM project rvvm directory.
239
+ #
240
+ # @return [void]
241
+ #
242
+ # @since 0.8.0
199
243
  def self.load_config
200
244
  puts "\nRVvM: Loading RVvM project config..."
201
245
 
@@ -210,14 +254,26 @@ module Rvvm
210
254
 
211
255
  @config = JSON.parse(json_file) if json_file
212
256
  @config = @config.transform_values do |v|
213
- v.transform_keys(&:to_sym)
257
+ v.is_a?(Hash) ? v.transform_keys(&:to_sym) : v
214
258
  end.transform_keys(&:to_sym)
215
- end
216
259
 
260
+ puts @config[:simulation][:testlist]
261
+ end
262
+
263
+ # Navigates to project top (rvvm directory of the RVvM project).
264
+ #
265
+ # @return [void]
266
+ #
267
+ # @since 0.8.0
217
268
  def self.prj_top
218
269
  Dir.chdir(@config_path)
219
270
  end
220
-
271
+
272
+ # Compiles project SystemVerilog sources using xvlog.
273
+ #
274
+ # @return [void]
275
+ #
276
+ # @since 0.8.0
221
277
  def self.compile
222
278
  cmd_args = @config[:compilation][:args]
223
279
  logname = @args[:complog] || File.join([@config[:project][:logDir], @config[:compilation][:logDir], @config[:compilation][:log]])
@@ -228,7 +284,13 @@ module Rvvm
228
284
  cmd = "xvlog -sv -f #{complist} -log #{logname} #{cmd_args}"
229
285
  execute(cmd)
230
286
  end
231
-
287
+
288
+ # Compiles C/C++ sources into a shared library to use during
289
+ # elaboration and simulation using DPI-C.
290
+ #
291
+ # @return [void]
292
+ #
293
+ # @Since 0.9.0
232
294
  def self.dpi_c
233
295
  cmd_args = @config[:dpi][:args]
234
296
  dpilist = @args[:dpilist] || @config[:dpi][:list]
@@ -238,7 +300,12 @@ module Rvvm
238
300
  cmd = "sxc -f #{dpilist} #{cmd_args}"
239
301
  execute(cmd)
240
302
  end
241
-
303
+
304
+ # Elaborates project into a testbench snapshot using xelab.
305
+ #
306
+ # @return [void]
307
+ #
308
+ # @since 0.8.0
242
309
  def self.elaborate
243
310
  cmd_args = @config[:elaboration][:args]
244
311
  cmd_args << " -sv_lib dpi" if @args[:dpi] || @args[:dpilib] || @config[:dpi][:dpilib] == 1
@@ -255,7 +322,12 @@ module Rvvm
255
322
  cmd = "xelab #{tb_top} -relax -s #{tb} -timescale #{timescale} -log #{logname} #{cmd_args}"
256
323
  execute(cmd)
257
324
  end
258
-
325
+
326
+ # Runs UVM test simulation on an elaborated testbench snapshot using xrun.
327
+ #
328
+ # @return [void]
329
+ #
330
+ # @since 0.8.0
259
331
  def self.run_sim
260
332
  cmd_args = @config[:simulation][:args]
261
333
  if @args[:wave]
@@ -263,10 +335,12 @@ module Rvvm
263
335
  else
264
336
  cmd_args << "-R"
265
337
  end
266
-
338
+
339
+ # Run simulaton on an array of tests.
340
+ # If in not running in batch mode testlist is an array with a single test
267
341
  test = @args[:test] || @config[:simulation][:defTest]
268
- # TODO: parse test list
269
342
  testlist = [test]
343
+ testlist = @args[:testlist] || @config[:simulation][:testlist] if @args[:batch] || @config[:simulation][:batch] == 1
270
344
 
271
345
  tb = @args[:simtb] || @args[:tb] || @config[:elaboration][:tb]
272
346
 
@@ -276,7 +350,7 @@ module Rvvm
276
350
  puts "RVvM: Running test #{i + 1}/#{testlist.size}: #{simtest}"
277
351
 
278
352
  logname = File.join([@config[:project][:logDir], @config[:simulation][:logDir], @config[:simulation][:log]])
279
- logname = Utils.interpret(logname, { testname: simtest })
353
+ logname = Utils.interpolate(logname, { testname: simtest })
280
354
 
281
355
  verb = "UVM_#{@args[:verb] || @config[:simulation][:verbosity]}"
282
356
 
@@ -285,6 +359,11 @@ module Rvvm
285
359
  end
286
360
  end
287
361
 
362
+ # Runs a pure SystemVerilog/Verilog simulation using xrun.
363
+ #
364
+ # @return [void]
365
+ #
366
+ # @since 0.9.0
288
367
  def self.run_sv
289
368
  cmd_args = @config[:simulation][:args]
290
369
  tb = @args[:simtb] || @args[:tb] || @config[:elaboration][:tb]
@@ -295,24 +374,47 @@ module Rvvm
295
374
  cmd = "xsim #{tb} -log #{logname} #{cmd_args}"
296
375
  execute(cmd)
297
376
  end
298
-
377
+
378
+ # Opens last generated waveform trace dump to inspect in Vivado GUI.
379
+ #
380
+ # @return [void]
381
+ #
382
+ # @since 0.9.0
299
383
  def self.gui
300
384
  dump = @args[:wavefile] || "#{@config[:elaboration][:tb]}.wdb"
301
385
 
302
386
  cmd = "xsim --gui #{dump}"
303
387
  execute(cmd)
304
388
  end
305
-
389
+
390
+ # Generates UVM test functional coverage report using xcrg.
391
+ #
392
+ # @return [void]
393
+ #
394
+ # @since 0.9.0
306
395
  def self.coverage
307
396
  cmd = "xcrg -report_format html -dir xsim.covdb"
308
397
  execute(cmd)
309
398
  end
310
-
399
+
400
+ # Opens last generated functional coverage report in a HTML dashboard.
401
+ #
402
+ # @return [void]
403
+ #
404
+ # @since 0.9.0
311
405
  def self.cov_report
312
406
  Dir.chdir("xcrg_func_cov_report")
313
407
  execute("./dashboard.html")
314
408
  end
315
-
409
+
410
+ # Generates a SystemVerilog module/interface template.
411
+ #
412
+ # @param type [String] specifies modudle/itf
413
+ # @param name [String] specifies module/itf name
414
+ #
415
+ # @return [void]
416
+ #
417
+ # @since 0.9.0
316
418
  def self.create_module(type, name)
317
419
  conf = @templates[:module][:conf]
318
420
  conf[:module] = name
@@ -329,7 +431,14 @@ module Rvvm
329
431
 
330
432
  exit(0)
331
433
  end
332
-
434
+
435
+ # Generates a SystemVerilog package template.
436
+ #
437
+ # @param name [String] specifies package name
438
+ #
439
+ # @return [void]
440
+ #
441
+ # @since 0.9.0
333
442
  def self.create_pkg(name)
334
443
  conf = @templates[:package][:conf]
335
444
  conf[:package] = name
@@ -345,7 +454,14 @@ module Rvvm
345
454
 
346
455
  exit(0)
347
456
  end
348
-
457
+
458
+ # Generates a generic SystemVerilog template file.
459
+ #
460
+ # @param name [String] specifies template name
461
+ #
462
+ # @return [void]
463
+ #
464
+ # @since 0.9.0
349
465
  def self.create_svfile(name)
350
466
  conf = @templates[:svfile][:conf]
351
467
  conf[:NAME] = name.upcase
@@ -360,7 +476,12 @@ module Rvvm
360
476
 
361
477
  exit(0)
362
478
  end
363
-
479
+
480
+ # Runs rvvm calling its methods based on provided script args.
481
+ #
482
+ # @return [void]
483
+ #
484
+ # @since 0.8.0
364
485
  def self.run
365
486
  create_new_project(@args[:new]) if @args[:new]
366
487
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rvvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - mrbya
@@ -26,6 +26,7 @@ files:
26
26
  - LICENSE.txt
27
27
  - README.md
28
28
  - Rakefile
29
+ - bin/sandbox
29
30
  - exe/rvvm
30
31
  - lib/rvvm.rb
31
32
  - lib/rvvm/templates.rb