HDLRuby 2.4.28 → 2.6.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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/HDLRuby/drivers/xcd.rb +79 -0
  3. data/lib/HDLRuby/drivers/xcd/dummy.xcd +4 -0
  4. data/lib/HDLRuby/hdr_samples/adder.rb +1 -1
  5. data/lib/HDLRuby/hdr_samples/adder_bench.rb +1 -1
  6. data/lib/HDLRuby/hdr_samples/adder_gen.rb +1 -1
  7. data/lib/HDLRuby/hdr_samples/constant_in_function.rb +27 -0
  8. data/lib/HDLRuby/hdr_samples/dff_properties.rb +19 -0
  9. data/lib/HDLRuby/hdr_samples/dff_unit.rb +54 -0
  10. data/lib/HDLRuby/hdr_samples/huge_rom.rb +25 -0
  11. data/lib/HDLRuby/hdr_samples/logic_bench.rb +21 -0
  12. data/lib/HDLRuby/hdr_samples/mei8_bench.rb +1 -1
  13. data/lib/HDLRuby/hdr_samples/music.rb +79 -0
  14. data/lib/HDLRuby/hdr_samples/named_sub.rb +42 -0
  15. data/lib/HDLRuby/hdr_samples/rom.rb +16 -0
  16. data/lib/HDLRuby/hdr_samples/with_function_generator.rb +25 -0
  17. data/lib/HDLRuby/hdrcc.rb +165 -26
  18. data/lib/HDLRuby/hruby_decorator.rb +250 -0
  19. data/lib/HDLRuby/hruby_high.rb +468 -91
  20. data/lib/HDLRuby/hruby_low.rb +913 -45
  21. data/lib/HDLRuby/hruby_low2c.rb +189 -168
  22. data/lib/HDLRuby/hruby_low2hdr.rb +738 -0
  23. data/lib/HDLRuby/hruby_low2high.rb +331 -549
  24. data/lib/HDLRuby/hruby_low2vhd.rb +39 -2
  25. data/lib/HDLRuby/hruby_low_bool2select.rb +29 -0
  26. data/lib/HDLRuby/hruby_low_casts_without_expression.rb +27 -0
  27. data/lib/HDLRuby/hruby_low_fix_types.rb +25 -0
  28. data/lib/HDLRuby/hruby_low_mutable.rb +70 -0
  29. data/lib/HDLRuby/hruby_low_resolve.rb +28 -0
  30. data/lib/HDLRuby/hruby_low_without_connection.rb +6 -3
  31. data/lib/HDLRuby/hruby_low_without_namespace.rb +7 -4
  32. data/lib/HDLRuby/hruby_low_without_select.rb +13 -0
  33. data/lib/HDLRuby/hruby_tools.rb +11 -1
  34. data/lib/HDLRuby/hruby_verilog.rb +1577 -1709
  35. data/lib/HDLRuby/sim/hruby_sim.h +29 -3
  36. data/lib/HDLRuby/sim/hruby_sim_calc.c +63 -6
  37. data/lib/HDLRuby/sim/hruby_sim_core.c +24 -9
  38. data/lib/HDLRuby/sim/hruby_sim_vcd.c +5 -1
  39. data/lib/HDLRuby/sim/hruby_sim_vizualize.c +22 -6
  40. data/lib/HDLRuby/std/fixpoint.rb +9 -0
  41. data/lib/HDLRuby/std/function_generator.rb +139 -0
  42. data/lib/HDLRuby/std/hruby_unit.rb +75 -0
  43. data/lib/HDLRuby/template_expander.rb +61 -0
  44. data/lib/HDLRuby/version.rb +1 -1
  45. metadata +20 -5
@@ -0,0 +1,75 @@
1
+ require "HDLRuby/hruby_high"
2
+
3
+
4
+
5
+ ##
6
+ # Library for building unit test systems.
7
+ #
8
+ ########################################################################
9
+ module HDLRuby::Unit
10
+
11
+ ## The HDLRuby unit test error class.
12
+ class UnitError < ::StandardError
13
+ end
14
+
15
+ # The set of the unit systems by name.
16
+ @@unit_systems = {}
17
+
18
+
19
+ # Declares system +name+ for unit testing.
20
+ # The system is built by executing +ruby_block+.
21
+ #
22
+ # NOTE: the name of the system is not registered within the HDLRuby
23
+ # namespace since it is not meant to be used directly.
24
+ def self.system(name,&ruby_block)
25
+ # Ensure name is a symbol.
26
+ name = name.to_s.to_sym unless name.is_a?(Symbol)
27
+ # Check if the name is already used or not.
28
+ if @@unit_systems.key?(name) then
29
+ raise UnitError, "Unit test system #{name} already declared."
30
+ end
31
+ # @@unit_systems[name] = HDLRuby::High.system(&ruby_block)
32
+ @@unit_systems[name] = ruby_block
33
+ end
34
+
35
+
36
+ # Create a system named +test_name+ executing the unit tests given from
37
+ # +names+.
38
+ def self.test(test_name = :test, *names)
39
+ # If there is no name given, use all the test systems.
40
+ names = @@unit_systems.each_key if names.empty?
41
+ # Declare the system.
42
+ HDLRuby::High.system test_name do
43
+
44
+ # The timed block that contains the bench execurtion code.
45
+ @@tester = timed {}
46
+
47
+ # Generate the test code for each selected test units.
48
+ names.each do |name|
49
+ name = name.to_s.to_sym unless name.is_a?(Symbol)
50
+ unless @@unit_systems.key?(name) then
51
+ raise UnitError, "Unit test #{name} does not exist."
52
+ end
53
+ sub(name) do
54
+ @@myself = self
55
+ instance_exec do
56
+ # Define the test command that insert code of
57
+ # the current test unit to the tester timed block.
58
+ def test(&ruby_block)
59
+ @@tester.block.open do
60
+ # Here the signals are to be taken from
61
+ # the test unit and not the timed block.
62
+ set_this(@@myself)
63
+ ruby_block.call
64
+ # Go back to the default current this.
65
+ set_this
66
+ end
67
+ end
68
+ end
69
+ # Process the test unit.
70
+ instance_exec(&@@unit_systems[name])
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,61 @@
1
+ require 'strscan'
2
+
3
+ ##
4
+ # Tool for expanding template files.
5
+ #
6
+ # Used for generating files like confugaration file for given HW target
7
+ #
8
+ ########################################################################
9
+
10
+
11
+ class TemplateExpander
12
+
13
+ ## Describes an expansion rule.
14
+ Rule = Struct.new(:match,:action)
15
+
16
+ # Creates a new template expander with potential list of +rules+.
17
+ def initialize(rules= [])
18
+ # Setup the rules.
19
+ @rules = rules.map do |match,action|
20
+ # Ensures action is a proc.
21
+ action = proc { |str| action.to_s } unless action.is_a?(Proc)
22
+ # Create the rule.
23
+ Rule.new(Regexp.new(match), action)
24
+ end
25
+ # The skip regexp is empty, it has to be built with finalize.
26
+ @skip = nil
27
+ end
28
+
29
+ # Adds a +rule+.
30
+ def add_rule(*rule)
31
+ @rules << Rule.new(Regexp.new(rule[0]), rule[1])
32
+ end
33
+
34
+ # Finalize the expander by building the default rule.
35
+ def finalize
36
+ # @skip = Regexp.union(*@rules.map { |rule| rule.match })
37
+ @skip = /(?=#{Regexp.union(*@rules.map { |rule| rule.match }).source})|\z/
38
+ end
39
+
40
+ # Apply the expander to +str+ and put the result in +res+.
41
+ def expand(str,res = "")
42
+ # Ensure the default rule is properly set up.
43
+ self.finalize
44
+ # Scan the string with each rule.
45
+ scanner = StringScanner.new(str)
46
+ until scanner.eos? do
47
+ @rules.find do |rule|
48
+ scanned = scanner.scan(rule.match)
49
+ if scanned then
50
+ res << rule.action.call(scanned)
51
+ else
52
+ false
53
+ end
54
+ end
55
+ res << scanner.scan_until(@skip)
56
+ end
57
+ return res
58
+ end
59
+
60
+
61
+ end
@@ -1,3 +1,3 @@
1
1
  module HDLRuby
2
- VERSION = "2.4.28"
2
+ VERSION = "2.6.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: HDLRuby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.28
4
+ version: 2.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lovic Gauthier
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-10 00:00:00.000000000 Z
11
+ date: 2021-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,8 @@ files:
66
66
  - lib/HDLRuby/alcc.rb
67
67
  - lib/HDLRuby/backend/hruby_allocator.rb
68
68
  - lib/HDLRuby/backend/hruby_c_allocator.rb
69
+ - lib/HDLRuby/drivers/xcd.rb
70
+ - lib/HDLRuby/drivers/xcd/dummy.xcd
69
71
  - lib/HDLRuby/hdr_samples/WithMultiChannelExpVerilog/with_multi_channels_hs_32.v
70
72
  - lib/HDLRuby/hdr_samples/WithMultiChannelExpVerilog/with_multi_channels_qu_213.v
71
73
  - lib/HDLRuby/hdr_samples/WithMultiChannelExpVerilog/with_multi_channels_qu_222.v
@@ -81,13 +83,18 @@ files:
81
83
  - lib/HDLRuby/hdr_samples/alu.rb
82
84
  - lib/HDLRuby/hdr_samples/bstr_bench.rb
83
85
  - lib/HDLRuby/hdr_samples/calculator.rb
86
+ - lib/HDLRuby/hdr_samples/constant_in_function.rb
84
87
  - lib/HDLRuby/hdr_samples/counter_bench.rb
85
88
  - lib/HDLRuby/hdr_samples/dff.rb
86
89
  - lib/HDLRuby/hdr_samples/dff_bench.rb
87
90
  - lib/HDLRuby/hdr_samples/dff_counter.rb
91
+ - lib/HDLRuby/hdr_samples/dff_properties.rb
92
+ - lib/HDLRuby/hdr_samples/dff_unit.rb
93
+ - lib/HDLRuby/hdr_samples/huge_rom.rb
88
94
  - lib/HDLRuby/hdr_samples/include.rb
89
95
  - lib/HDLRuby/hdr_samples/instance_open.rb
90
96
  - lib/HDLRuby/hdr_samples/linear_test.rb
97
+ - lib/HDLRuby/hdr_samples/logic_bench.rb
91
98
  - lib/HDLRuby/hdr_samples/make_multi_channels_v.rb
92
99
  - lib/HDLRuby/hdr_samples/make_multi_channels_vcd.rb
93
100
  - lib/HDLRuby/hdr_samples/mei8.rb
@@ -95,6 +102,8 @@ files:
95
102
  - lib/HDLRuby/hdr_samples/memory_test.rb
96
103
  - lib/HDLRuby/hdr_samples/multer_gen.rb
97
104
  - lib/HDLRuby/hdr_samples/multer_seq.rb
105
+ - lib/HDLRuby/hdr_samples/music.rb
106
+ - lib/HDLRuby/hdr_samples/named_sub.rb
98
107
  - lib/HDLRuby/hdr_samples/neg_arith_bench.rb
99
108
  - lib/HDLRuby/hdr_samples/neural/a.rb
100
109
  - lib/HDLRuby/hdr_samples/neural/a_sub.rb
@@ -131,6 +140,7 @@ files:
131
140
  - lib/HDLRuby/hdr_samples/with_decoder.rb
132
141
  - lib/HDLRuby/hdr_samples/with_fixpoint.rb
133
142
  - lib/HDLRuby/hdr_samples/with_fsm.rb
143
+ - lib/HDLRuby/hdr_samples/with_function_generator.rb
134
144
  - lib/HDLRuby/hdr_samples/with_linear.rb
135
145
  - lib/HDLRuby/hdr_samples/with_loop.rb
136
146
  - lib/HDLRuby/hdr_samples/with_memory.rb
@@ -199,10 +209,12 @@ files:
199
209
  - lib/HDLRuby/hruby_bstr.rb
200
210
  - lib/HDLRuby/hruby_check.rb
201
211
  - lib/HDLRuby/hruby_db.rb
212
+ - lib/HDLRuby/hruby_decorator.rb
202
213
  - lib/HDLRuby/hruby_error.rb
203
214
  - lib/HDLRuby/hruby_high.rb
204
215
  - lib/HDLRuby/hruby_low.rb
205
216
  - lib/HDLRuby/hruby_low2c.rb
217
+ - lib/HDLRuby/hruby_low2hdr.rb
206
218
  - lib/HDLRuby/hruby_low2high.rb
207
219
  - lib/HDLRuby/hruby_low2seq.rb
208
220
  - lib/HDLRuby/hruby_low2sym.rb
@@ -287,12 +299,15 @@ files:
287
299
  - lib/HDLRuby/std/decoder.rb
288
300
  - lib/HDLRuby/std/fixpoint.rb
289
301
  - lib/HDLRuby/std/fsm.rb
302
+ - lib/HDLRuby/std/function_generator.rb
303
+ - lib/HDLRuby/std/hruby_unit.rb
290
304
  - lib/HDLRuby/std/linear.rb
291
305
  - lib/HDLRuby/std/loop.rb
292
306
  - lib/HDLRuby/std/memory.rb
293
307
  - lib/HDLRuby/std/pipeline.rb
294
308
  - lib/HDLRuby/std/reconf.rb
295
309
  - lib/HDLRuby/std/task.rb
310
+ - lib/HDLRuby/template_expander.rb
296
311
  - lib/HDLRuby/test_hruby_bstr.rb
297
312
  - lib/HDLRuby/test_hruby_high.rb
298
313
  - lib/HDLRuby/test_hruby_high_low.rb
@@ -308,7 +323,7 @@ homepage: https://github.com/civol/HDLRuby
308
323
  licenses:
309
324
  - MIT
310
325
  metadata: {}
311
- post_install_message:
326
+ post_install_message:
312
327
  rdoc_options: []
313
328
  require_paths:
314
329
  - lib
@@ -325,7 +340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
325
340
  version: '0'
326
341
  requirements: []
327
342
  rubygems_version: 3.0.8
328
- signing_key:
343
+ signing_key:
329
344
  specification_version: 4
330
345
  summary: HDLRuby is a library for describing and simulating digital electronic systems.
331
346
  test_files: []