rvvm 1.0.1 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0658be412bda5c88fecb1bb022492703865072a78aa90acfe2e055cade7dab0d'
4
- data.tar.gz: 8ff7f78d83a3af1c2e4c782be45cca46cb3a2a41cd7db86e91ee37ec991f599b
3
+ metadata.gz: 420096b77b4d823c6ad6a69509ffe6da56d4a63cf96152cd7d36a5ea41ab063a
4
+ data.tar.gz: 28b2c65e701d7f2bdfdb3b7bac2d0d7a9f62db9877d912d18eaa9a8e8d9aac78
5
5
  SHA512:
6
- metadata.gz: 8529ec4e33507e4a26327b96630db95b0782e9d5f344a62d194828601356b19dc0507f4f777b6bfe4b42198cc25ca7cca274ee994b607832d0f5eafea41b6c51
7
- data.tar.gz: 979591d920e12ae3e2bc0e112c887049177319c6d58aaef6b4b6b4343ac26029da797c834ccbce9ea892e67fb4018a508409ef88279cd81fd037e3d40fc530db
6
+ metadata.gz: b2cb584479a4fde2453c4d4830403db857d2dc197840dc44dd2b9b932881e111abea00fbad1ba52e7c2e01e4865b66911f12eef5110bdadb695a468df293aeb8
7
+ data.tar.gz: eea11a1a5f36f0a20d796dd87e165f7618b022c8062c81b0eb45122644a5291adcbd475973df785008bc3e43be866b3b78830bcb3c666636b17a03b138cde830
data/CHANGELOG.md CHANGED
@@ -153,3 +153,21 @@
153
153
  1. Missing gemspec dependencies
154
154
  2. Minor spinner rendering bugs
155
155
 
156
+ ## TBI:
157
+
158
+ 1. Elaboration and simulation custom waveform trace dump file
159
+ 2. Project template files regeneration/restoration to default
160
+ 3. Crayon module tests
161
+ 4. RBS definitions
162
+
163
+ ## [1.1.0] - 2024-09-18
164
+
165
+ ### Added:
166
+
167
+ 1. Crayon.command to execute shell commands with spinners
168
+ 2. Crayon module tests
169
+ 3. RBS definitions
170
+
171
+ ### Fixed:
172
+
173
+ 1. More Crayons rendering bugs
data/lib/rvvm/crayons.rb CHANGED
@@ -1,15 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "tty-spinner"
4
+ require "tty-command"
4
5
  require "rainbow/refinement"
5
6
 
6
7
  using Rainbow
7
8
 
8
- # Utility module providing spinners and stdout mesage formatting.
9
+ # Utility module providing an API to run shell commands
10
+ # with spinners and stdout mesage formatting.
9
11
  #
10
12
  # @example
11
13
  # require 'rvvm/crayons'
12
14
  #
15
+ # Crayons.init
16
+ #
17
+ # # Runn a shell command with a spinner
18
+ # Crayons.command("Running command...", "ls -aln")
19
+ #
20
+ # # Run custom code with a spinner
13
21
  # Crayons.spinner_start("New task...")
14
22
  #
15
23
  # # do stuff
@@ -29,6 +37,16 @@ module Crayons
29
37
  @thread = nil
30
38
  @thread_paused = false
31
39
  @spinner_running = false
40
+ @command = nil
41
+
42
+ # Initializes Crayons module.
43
+ #
44
+ # @return [void]
45
+ #
46
+ # @since 1.1.0
47
+ def self.init
48
+ @command = TTY::Command.new(printer: :null)
49
+ end
32
50
 
33
51
  # Returns spinner status.
34
52
  #
@@ -46,11 +64,14 @@ module Crayons
46
64
  # @since 1.0.0
47
65
  def self.spinner_start(message)
48
66
  print "\r\e[K"
49
- @spinner = TTY::Spinner.new("[:spinner] #{message}")
67
+ @spinner = TTY::Spinner.new("[:spinner] #{message}", interval: 5)
50
68
  @spinner_running = true
51
69
  @thread = Thread.new do
52
70
  @spinner.auto_spin
53
- sleep(0.1) while @thread_paused
71
+ while @thread_sleeping
72
+ print "\r\e[K"
73
+ sleep(0.1)
74
+ end
54
75
  end
55
76
  end
56
77
 
@@ -62,9 +83,10 @@ module Crayons
62
83
  def self.spinner_pause
63
84
  return unless @spinner_running
64
85
 
65
- sleep(0.1)
66
86
  print "\r\e[K"
67
87
  @thread_paused = true
88
+ sleep(0.1)
89
+ print "\r\e[K"
68
90
  end
69
91
 
70
92
  # Resumes spinner thread execution.
@@ -110,6 +132,22 @@ module Crayons
110
132
  spinner_resume if @spinner_running
111
133
  end
112
134
 
135
+ # Runs a shell command with a spinner.
136
+ #
137
+ # @param tag [String] spinner tag
138
+ # @param cmd [String] shell command to be run
139
+ #
140
+ # @return [void]
141
+ #
142
+ # @since 1.1.0
143
+ def self.command(tag, cmd)
144
+ spinner_start(tag)
145
+ out = @command.run!(cmd)
146
+ spinner_log("#{out.out}\n")
147
+ spinner_stop(nil, out.success?)
148
+ puts ""
149
+ end
150
+
113
151
  # Logs a green text message to stdout.
114
152
  #
115
153
  # @param message [String] message to print
data/lib/rvvm/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # Module holding current rvvm version.
4
4
  module Rvvm
5
5
  # Current rvvm module version.
6
- VERSION = "1.0.1"
6
+ VERSION = "1.1.0"
7
7
  end
data/lib/rvvm.rb CHANGED
@@ -55,6 +55,7 @@ module Rvvm
55
55
  OptionParser.new do |args|
56
56
  current_time = Time.now
57
57
  @formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
58
+ Crayons.init
58
59
 
59
60
  args.on("-h", "--help", "Shows this help") do
60
61
  puts "\nRVvM - Ruby Vivado Manager\n\n"
@@ -161,12 +162,14 @@ module Rvvm
161
162
  # @return [void]
162
163
  #
163
164
  # @since 0.8.0
164
- def self.execute(command)
165
+ def self.execute(tag, command)
165
166
  if @args[:debug]
166
- Crayons.spinner_log(command)
167
+ puts command
168
+ Crayons.spinner_start(tag)
167
169
  sleep(1)
170
+ Crayons.spinner_stop(nil, true)
168
171
  else
169
- system(command)
172
+ Crayons.command(tag, command)
170
173
  end
171
174
  end
172
175
 
@@ -247,7 +250,7 @@ module Rvvm
247
250
  system('git commit -am "Initial commit"')
248
251
  Crayons.spinner_resume
249
252
 
250
- Crayons.spinner_log("\n")
253
+ Crayons.spinner_log("")
251
254
  Crayons.spinner_stop("Done!", true)
252
255
  Crayons.log_pass("\nRVvM: New project generated. ^^\n\n")
253
256
 
@@ -289,6 +292,7 @@ module Rvvm
289
292
  puts ""
290
293
  rescue JSON::ParserError => e
291
294
  Crayons.log_error(" Invalid config json!\n\n#{e.message}")
295
+ puts""
292
296
  exit(1)
293
297
  end
294
298
 
@@ -307,18 +311,12 @@ module Rvvm
307
311
  #
308
312
  # @since 0.8.0
309
313
  def self.compile
310
- cmd_args = @config[:compilation][:args]
314
+ cmd_args = @config[:compilation][:args].strip
311
315
  logname = @args[:complog] || File.join([@config[:project][:logDir], @config[:compilation][:logDir], @config[:compilation][:log]])
312
316
  complist = @args[:compilelist] || @config[:compilation][:list]
313
317
 
314
- Crayons.spinner_start("Compiling HDL sources...")
315
-
316
318
  cmd = "xvlog -sv -f #{complist} -log #{logname} #{cmd_args}"
317
- Crayons.spinner_pause
318
- exit = execute(cmd)
319
- Crayons.spinner_resume
320
- Crayons.spinner_stop(nil, exit)
321
- puts ""
319
+ execute("Compiling HDL sources...", cmd)
322
320
  end
323
321
 
324
322
  # Compiles C/C++ sources into a shared library to use during
@@ -328,15 +326,11 @@ module Rvvm
328
326
  #
329
327
  # @Since 0.9.0
330
328
  def self.dpi_c
331
- cmd_args = @config[:dpi][:args]
329
+ cmd_args = @config[:dpi][:args].strip
332
330
  dpilist = @args[:dpilist] || @config[:dpi][:list]
333
331
 
334
- Crayons.spinner_start("Building DPI-C library...")
335
-
336
332
  cmd = "sxc -f #{dpilist} #{cmd_args}"
337
- exit = execute(cmd)
338
- Crayons.spinner_stop(nil, exit)
339
- puts ""
333
+ execute("Building DPI-C library...", cmd)
340
334
  end
341
335
 
342
336
  # Elaborates project into a testbench snapshot using xelab.
@@ -348,19 +342,14 @@ module Rvvm
348
342
  cmd_args = @config[:elaboration][:args]
349
343
  cmd_args << " -sv_lib dpi" if @args[:dpi] || @args[:dpilib] || @config[:dpi][:dpilib] == 1
350
344
  cmd_args << " -debug wave" if @args[:wave]
345
+ cmd_args.strip!
351
346
  logname = @args[:elablog] || File.join([@config[:project][:logDir], @config[:elaboration][:logDir], @config[:elaboration][:log]])
352
347
  tb_top = @args[:tbtop] || @config[:elaboration][:tbTop]
353
348
  tb = @args[:tb] || @config[:elaboration][:tb]
354
349
  timescale = @args[:timescale] || @config[:elaboration][:timescale]
355
350
 
356
- Crayons.spinner_start("Elaborating testbench: #{tb}...")
357
-
358
351
  cmd = "xelab #{tb_top} -relax -s #{tb} -timescale #{timescale} -log #{logname} #{cmd_args}"
359
- Crayons.spinner_pause
360
- exit = execute(cmd)
361
- Crayons.spinner_resume
362
- Crayons.spinner_stop(nil, exit)
363
- puts ""
352
+ execute("Elaborating testbench #{tb}...", cmd)
364
353
  end
365
354
 
366
355
  # Runs UVM test simulation on an elaborated testbench snapshot using xrun.
@@ -373,8 +362,9 @@ module Rvvm
373
362
  if @args[:wave]
374
363
  cmd_args << " --tclbatch wfcfg.tcl"
375
364
  else
376
- cmd_args << "-R"
365
+ cmd_args << " -R"
377
366
  end
367
+ cmd_args.strip!
378
368
 
379
369
  # Run simulaton on an array of tests.
380
370
  # If in not running in batch mode testlist is an array with a single test
@@ -386,8 +376,6 @@ module Rvvm
386
376
 
387
377
  testlist.each_with_index do |simtest, i|
388
378
  simtest.strip!
389
- puts "" if i.positive?
390
- Crayons.spinner_start("Running test #{i + 1}/#{testlist.size}: #{simtest}...")
391
379
 
392
380
  logname = File.join([@config[:project][:logDir], @config[:simulation][:logDir], @config[:simulation][:log]])
393
381
  logname = Utils.interpolate(logname, { testname: simtest })
@@ -395,13 +383,8 @@ module Rvvm
395
383
  verb = "UVM_#{@args[:verb] || @config[:simulation][:verbosity]}"
396
384
 
397
385
  cmd = "xsim #{tb} -log #{logname} -testplusarg \"UVM_VERBOSITY=#{verb}\" -testplusarg \"UVM_TESTNAME=#{simtest}\" #{cmd_args}"
398
- Crayons.spinner_pause
399
- exit = execute(cmd)
400
- Crayons.spinner_resume
401
- Crayons.spinner_stop(nil, exit)
386
+ execute("Running UVM test #{i + 1}/#{testlist.size}: #{simtest}...", cmd)
402
387
  end
403
-
404
- puts ""
405
388
  end
406
389
 
407
390
  # Runs a pure SystemVerilog/Verilog simulation using xrun.
@@ -410,17 +393,13 @@ module Rvvm
410
393
  #
411
394
  # @since 0.9.0
412
395
  def self.run_sv
413
- cmd_args = @config[:simulation][:args]
396
+ cmd_args = @config[:simulation][:args].strip!
414
397
  tb = @args[:simtb] || @args[:tb] || @config[:elaboration][:tb]
415
398
 
416
- Crayons.spinner_start("Running pure SV/V simulation...")
417
399
  logname = @args[:simlog] || File.join([@config[:project][:logDir], @config[:simulation][:logDir], "svsim.log"])
418
400
 
419
401
  cmd = "xsim #{tb} -log #{logname} #{cmd_args}"
420
- Crayons.spinner_pause
421
- exit = execute(cmd)
422
- Crayons.spinner_resume
423
- Crayons.spinner_stop(nil, exit)
402
+ execute("Running pure SV/V simulation...", cmd)
424
403
  end
425
404
 
426
405
  # Opens last generated waveform trace dump to inspect in Vivado GUI.
@@ -432,7 +411,7 @@ module Rvvm
432
411
  dump = @args[:wavefile] || "#{@config[:elaboration][:tb]}.wdb"
433
412
 
434
413
  cmd = "xsim --gui #{dump}"
435
- execute(cmd)
414
+ execute("Running Vivado GUI...", cmd)
436
415
 
437
416
  exit(0)
438
417
  end
@@ -443,13 +422,8 @@ module Rvvm
443
422
  #
444
423
  # @since 0.9.0
445
424
  def self.coverage
446
- Crayons.spinner_start("Generating UVM functional coverage report...")
447
-
448
425
  cmd = "xcrg -report_format html -dir xsim.covdb"
449
- Crayons.spinner_pause
450
- exit = execute(cmd)
451
- Crayons.spinner_resume
452
- Crayons.spinner_stop(nil, exit)
426
+ execute("Generating UVM test functional coverage report...", cmd)
453
427
  end
454
428
 
455
429
  # Opens last generated functional coverage report in a HTML dashboard.
@@ -459,7 +433,7 @@ module Rvvm
459
433
  # @since 0.9.0
460
434
  def self.cov_report
461
435
  Dir.chdir("xcrg_func_cov_report")
462
- execute("./dashboard.html")
436
+ execute("Opening coverage dashboard...", "./dashboard.html")
463
437
 
464
438
  exit(0)
465
439
  end
@@ -491,7 +465,6 @@ module Rvvm
491
465
  end
492
466
  conf[:username] = Utils.git_userame || " "
493
467
 
494
- puts ""
495
468
  Crayons.spinner_start("Generating SV #{type} template...")
496
469
  Utils.gen_template(@templates[:module], "#{name}.sv", conf, path)
497
470
  Crayons.spinner_stop(nil, true)
@@ -524,7 +497,6 @@ module Rvvm
524
497
  path = File.join([@config[:project][:path], @args[:path] || @templates[:module][:file][:path]])
525
498
  end
526
499
 
527
- puts ""
528
500
  Crayons.spinner_start("Generating SV pkg template...")
529
501
  Utils.gen_template(@templates[:package], "#{name}.sv", conf, path)
530
502
  Crayons.spinner_stop(nil, true)
@@ -556,7 +528,6 @@ module Rvvm
556
528
  path = File.join([@config[:project][:path], @args[:path] || @templates[:module][:file][:path]])
557
529
  end
558
530
 
559
- puts ""
560
531
  Crayons.spinner_start("Generating generic SV file template...")
561
532
  Utils.gen_template(@templates[:svfile], "#{name}.sv", conf, path)
562
533
  Crayons.spinner_stop(nil, true)
@@ -0,0 +1,17 @@
1
+ module Crayons
2
+
3
+ def self.spinner_running?: () -> Boolean
4
+
5
+ def self.spinner_start: (String) -> void
6
+
7
+ def self.spinner_stop: (String, Boolean) -> void
8
+
9
+ def self.spinner_log: (String) -> void
10
+
11
+ def self.command: (String, String) -> void
12
+
13
+ def self.log_pass: (String) -> void
14
+
15
+ def self.log_error: (String) -> void
16
+
17
+ end
@@ -0,0 +1,15 @@
1
+ module Utils
2
+
3
+ def self.interpolate: (String, Hash) -> String
4
+
5
+ def self.gen_file: (String, String) -> void
6
+
7
+ def self.gen_template: (Hash, String, Hash, String) -> void
8
+
9
+ def self.find_file_dir: (String, String) -> String
10
+
11
+ def self.git_username: () -> String
12
+
13
+ def self.all_nil? (Hash, Array) -> Boolean
14
+
15
+ end
data/sig/rvvm.rbs CHANGED
@@ -1,4 +1,13 @@
1
1
  module Rvvm
2
2
  VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
3
+
4
+ def self.execute: (String, String) -> void
5
+
6
+ def self.create_new_project: (String) -> void
7
+
8
+ def self.create_module: (String, String) -> void
9
+
10
+ def self.create_pkg: (String) -> void
11
+
12
+ def self.create_svfile: (String) -> void
4
13
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rvvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mrbya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-17 00:00:00.000000000 Z
11
+ date: 2024-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: minitest
14
+ name: rainbow
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.16'
19
+ version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '5.16'
26
+ version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rainbow
28
+ name: tty-command
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.1'
33
+ version: 0.10.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.1'
40
+ version: 0.10.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: tty-spinner
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -76,6 +76,8 @@ files:
76
76
  - lib/rvvm/utils.rb
77
77
  - lib/rvvm/version.rb
78
78
  - sig/rvvm.rbs
79
+ - sig/rvvm/crayons.rbs
80
+ - sig/rvvm/utils.rbs
79
81
  homepage: https://gitlab.com/such-hdl-much-wow/rvvm.git
80
82
  licenses:
81
83
  - MIT