HDLRuby 2.6.16 → 2.6.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0defaa4d148c2fbdc008f29c75a6ab8a4b48726a932f3222e2dc19c7b229492c
4
- data.tar.gz: 9e2d4268200af09e0c078306b5c8a81494b589468b5b8b0084d300d14f922387
3
+ metadata.gz: 2d8c97794e72e7b03ad7d6db03c24ff4fb77748c3340bc9b9857a64537118e8f
4
+ data.tar.gz: 8077bcb0c9ce65c3372943ffcdeb2fd756fcd6969e94e135bb32a53b3de1e650
5
5
  SHA512:
6
- metadata.gz: ae9f4d696caa0c8f76caa7f0fd05bf1f6554da50c40871c86ad3b44f4c41f3dc184fe58141afd796d3c9448fcdfd04d6869fafc0246fe39236e5f3f48d6bd6a2
7
- data.tar.gz: 9cc5165ad15458f4c2f514107f7e15118534c079d061dc2f97aecb0982097fe534b0e26683834b901de34ced55132fc0f3608c19087b87ee5a9137174f49a4d1
6
+ metadata.gz: 104fae34f93944ecc476026b0e8c97b548220e92b7e14727f66af0dc8e6e3655b9dee20b1057f177263ad8947fd2a289333b7aa4378e9baaf16dac57cb41b988
7
+ data.tar.gz: 47c8c77471d8aff9cc4e601f403d3f32f254658f81884075cdc25e9c4ea422cbd3ef645664fcc3524f2cfb632c2a7c3f11d1cff20451a81e17422e3fab0f4130
@@ -0,0 +1,38 @@
1
+
2
+
3
+ # A benchmark for testing the enumarable properties of expression (reduce).
4
+ system :with_reduce_bench do
5
+ [8].inner :val,:res
6
+ [64].inner :val64
7
+
8
+ timed do
9
+ val <= _01101010
10
+ res <= val.reduce(_00000000,:+)
11
+ !10.ns
12
+ val <= _01010010
13
+ res <= val.reduce(_00000000,:+)
14
+ !10.ns
15
+ val <= _01101111
16
+ res <= val.reduce(_00000000,:+)
17
+ !10.ns
18
+ val64 <= _0110101001101010011010100110101001101010011010100110101001101010
19
+ res <= val64.reduce(_00000000,:+)
20
+ !10.ns
21
+ res <= val64[7..0]
22
+ !10.ns
23
+ res <= res.reduce(_00000000,:+)
24
+ !10.ns
25
+ res <= val64[63..60]
26
+ !10.ns
27
+ res <= res.reduce(_00000000,:+)
28
+ !10.ns
29
+ val64 <= ~(val64 ^ val64)
30
+ res <= val64.reduce(_00000000,:+)
31
+ !10.ns
32
+ val64[0] <= _0
33
+ val64[3] <= _0
34
+ val64[63] <= _0
35
+ res <= val64.reduce(_00000000,:+)
36
+ !10.ns
37
+ end
38
+ end
@@ -0,0 +1,14 @@
1
+
2
+
3
+ # A benchmark for testing conversion of strings to values.
4
+ system :with_str2value_bench do
5
+ [8].inner :val
6
+ [64].inner :val64
7
+
8
+ timed do
9
+ val <= "01010011".to_value
10
+ !10.ns
11
+ val64 <= ("01010011" * 8).to_value
12
+ !10.ns
13
+ end
14
+ end
@@ -0,0 +1,90 @@
1
+
2
+ system :four2eight do
3
+ [4].input :four
4
+ output :o0, :o1, :o2, :o3, :o4, :o5, :o6, :o7
5
+
6
+ o0 <= four[0]; o1 <= four[1]; o2 <= four[2]; o3 <= four[3]
7
+ o4 <= four[0]; o5 <= four[1]; o6 <= four[2]; o7 <= four[3]
8
+ end
9
+
10
+ system :four2sixfour do
11
+ [4].input :four
12
+ output :o00, :o01, :o02, :o03, :o04, :o05, :o06, :o07,
13
+ :o08, :o09, :o0A, :o0B, :o0C, :o0D, :o0E, :o0F,
14
+ :o10, :o11, :o12, :o13, :o14, :o15, :o16, :o17,
15
+ :o18, :o19, :o1A, :o1B, :o1C, :o1D, :o1E, :o1F,
16
+ :o20, :o21, :o22, :o23, :o24, :o25, :o26, :o27,
17
+ :o28, :o29, :o2A, :o2B, :o2C, :o2D, :o2E, :o2F,
18
+ :o30, :o31, :o32, :o33, :o34, :o35, :o36, :o37,
19
+ :o38, :o39, :o3A, :o3B, :o3C, :o3D, :o3E, :o3F
20
+
21
+
22
+ o00 <= four[0]; o01 <= four[1]; o02 <= four[2]; o03 <= four[3]
23
+ o04 <= four[0]; o05 <= four[1]; o06 <= four[2]; o07 <= four[3]
24
+ o08 <= four[0]; o09 <= four[1]; o0A <= four[2]; o0B <= four[3]
25
+ o0C <= four[0]; o0D <= four[1]; o0E <= four[2]; o0F <= four[3]
26
+ o10 <= four[0]; o11 <= four[1]; o12 <= four[2]; o13 <= four[3]
27
+ o14 <= four[0]; o15 <= four[1]; o16 <= four[2]; o17 <= four[3]
28
+ o18 <= four[0]; o19 <= four[1]; o1A <= four[2]; o1B <= four[3]
29
+ o1C <= four[0]; o1D <= four[1]; o1E <= four[2]; o1F <= four[3]
30
+ o20 <= four[0]; o21 <= four[1]; o22 <= four[2]; o23 <= four[3]
31
+ o24 <= four[0]; o25 <= four[1]; o26 <= four[2]; o27 <= four[3]
32
+ o28 <= four[0]; o29 <= four[1]; o2A <= four[2]; o2B <= four[3]
33
+ o2C <= four[0]; o2D <= four[1]; o2E <= four[2]; o2F <= four[3]
34
+ o30 <= four[0]; o31 <= four[1]; o32 <= four[2]; o33 <= four[3]
35
+ o34 <= four[0]; o35 <= four[1]; o36 <= four[2]; o37 <= four[3]
36
+ o38 <= four[0]; o39 <= four[1]; o3A <= four[2]; o3B <= four[3]
37
+ o3C <= four[0]; o3D <= four[1]; o3E <= four[2]; o3F <= four[3]
38
+ end
39
+
40
+
41
+
42
+ # A benchmark for testing some enumarable properties of expression (to_a).
43
+ system :with_to_a_bench do
44
+ [4].inner :four
45
+ [8].inner :val, :res, :eight
46
+ [64].inner :val64, :res64, :sixfour
47
+
48
+ vals = val.to_a
49
+ val64s = val64.to_a
50
+
51
+ four2eight(:my_four2eight).(four,*(eight.to_a.reverse))
52
+ four2sixfour(:my_four2sixfour).(four,*(sixfour.to_a.reverse))
53
+
54
+ timed do
55
+ val <= _01101010
56
+ res <= vals.reverse
57
+ !10.ns
58
+ val64 <= _0110101001101010011010100110101001101010011010100110101001101010
59
+ res64 <= val64s.reverse
60
+ !10.ns
61
+ val <= _00000000
62
+ val64 <= _0000000000000000000000000000000000000000000000000000000000000000
63
+ !10.ns
64
+ vals.each.with_index do |v,i|
65
+ v <= (i/2) & _1
66
+ end
67
+ res <= val
68
+ !10.ns
69
+ val64s.each.with_index do |v,i|
70
+ v <= (i/2) & _1
71
+ end
72
+ res64 <= val64
73
+ !10.ns
74
+ val <= _01010011
75
+ !10.ns
76
+ 8.times do |i|
77
+ val64s[i] <= val[i]
78
+ val64s[i+32] <= val[i]
79
+ val64s[i+56] <= val[i]
80
+ end
81
+ res64 <= val64
82
+ !10.ns
83
+ four <= _0000
84
+ !10.ns
85
+ four <= _0001
86
+ !10.ns
87
+ four <= _1100
88
+ !10.ns
89
+ end
90
+ end
data/lib/HDLRuby/hdrcc.rb CHANGED
@@ -110,7 +110,7 @@ module HDLRuby
110
110
  else
111
111
  # A standard file is found, skip it since it does not
112
112
  # need to be read.
113
- # puts "Standard files: #{founds}"
113
+ # show? "Standard files: #{founds}"
114
114
  return false
115
115
  end
116
116
  end
@@ -134,7 +134,7 @@ module HDLRuby
134
134
  file = @top_file_name
135
135
  end
136
136
  end
137
- # puts "read_all with file=#{file}"
137
+ # show? "read_all with file=#{file}"
138
138
  # Read the file
139
139
  # read(file)
140
140
  unless read(file) then
@@ -158,7 +158,7 @@ module HDLRuby
158
158
 
159
159
  # Displays the syntax tree of all the files.
160
160
  def show_all(outfile = $stdout)
161
- # puts "@checks.size=#{@checks.size}"
161
+ # show? "@checks.size=#{@checks.size}"
162
162
  @checks.each { |check| check.show(outfile) }
163
163
  end
164
164
 
@@ -166,7 +166,7 @@ module HDLRuby
166
166
  def get_top
167
167
  # Get all the systems.
168
168
  systems = @checks.reduce([]) {|ar,check| ar + check.get_all_systems}
169
- # puts "First systems=#{systems}"
169
+ # show? "First systems=#{systems}"
170
170
  # Remove the systems that are instantiated or included
171
171
  # (they cannot be tops)
172
172
  @checks.each do |check|
@@ -183,7 +183,7 @@ module HDLRuby
183
183
  systems -= check.get_inherit_systems(inherit)
184
184
  end
185
185
  end
186
- # puts "Now systems=#{systems}"
186
+ # show? "Now systems=#{systems}"
187
187
  # Return the first top of the list.
188
188
  return systems[-1]
189
189
  end
@@ -195,7 +195,7 @@ module HDLRuby
195
195
  if @top_system == "" then
196
196
  # No, look for it.
197
197
  @top_system = get_top
198
- # puts "@top_system=#{@top_system}"
198
+ # show? "@top_system=#{@top_system}"
199
199
  unless @top_system then
200
200
  # Not found? Error.
201
201
  # Maybe it is a parse error, look for it.
@@ -238,7 +238,7 @@ module HDLRuby
238
238
  # Dump to a file.
239
239
  if chunk.name != :sim then
240
240
  # The chunk is to be dumbed to a file.
241
- # puts "Outputing chunk:#{HDLRuby::Low::Low2C.obj_name(chunk)}"
241
+ # show? "Outputing chunk:#{HDLRuby::Low::Low2C.obj_name(chunk)}"
242
242
  outfile = File.open(path + "/" +
243
243
  HDLRuby::Low::Low2C.obj_name(chunk) + "." +
244
244
  chunk.name.to_s,"w")
@@ -351,6 +351,12 @@ $optparse = OptionParser.new do |opts|
351
351
  opts.on("-D", "--debug","Set the HDLRuby debug mode") do |d|
352
352
  $options[:debug] = d
353
353
  end
354
+ opts.on("--verbose","Set verbose mode.") do |d|
355
+ HDLRuby.verbosity = 2
356
+ end
357
+ opts.on("--volubile","Set extreme verbose mode.") do |d|
358
+ HDLRuby.verbosity = 3
359
+ end
354
360
  opts.on("-T","--test t0,t1,t2","Compile the unit tests named t0,t1,...") do |t|
355
361
  $options[:test] = t
356
362
  end
@@ -396,7 +402,7 @@ $optparse = OptionParser.new do |opts|
396
402
  end
397
403
  $optparse.parse!
398
404
 
399
- # puts "options=#{$options}"
405
+ # show? "options=#{$options}"
400
406
 
401
407
  # Check the compatibility of the options
402
408
  if $options.count {|op| [:yaml,:hdr,:verilog,:vhdl].include?(op) } > 1 then
@@ -436,7 +442,7 @@ if ($options[:test] || $options[:testall]) then
436
442
  $test_file.write("require 'std/hruby_unit.rb'\nrequire_relative '#{$input}'\n\n" +
437
443
  "HDLRuby::Unit.test(:\"#{$top}\"#{tests})\n")
438
444
  # $test_file.rewind
439
- # puts $test_file.read
445
+ # show? $test_file.read
440
446
  # exit
441
447
  $test_file.rewind
442
448
  # It is the new input file.
@@ -491,11 +497,11 @@ end
491
497
 
492
498
  # Generate the result.
493
499
  # Get the top systemT.
494
- puts Time.now
500
+ HDLRuby.show Time.now
495
501
  $top_system = $top_instance.to_low.systemT
496
502
  $top_intance = nil # Free as much memory as possible.
497
- puts "##### Top system built #####"
498
- puts Time.now
503
+ HDLRuby.show "##### Top system built #####"
504
+ HDLRuby.show Time.now
499
505
 
500
506
 
501
507
  # # Apply the pre drivers if any.
@@ -562,23 +568,23 @@ elsif $options[:clang] then
562
568
  # top_system = $top_system
563
569
  # Preprocess the HW description for valid C generation.
564
570
  $top_system.each_systemT_deep do |systemT|
565
- puts "seq2seq step..."
571
+ HDLRuby.show "seq2seq step..."
566
572
  # Coverts the par blocks in seq blocks to seq blocks to match
567
573
  # the simulation engine.
568
574
  systemT.par_in_seq2seq!
569
- puts Time.now
570
- puts "connections_to_behaviors step..."
575
+ HDLRuby.show Time.now
576
+ HDLRuby.show "connections_to_behaviors step..."
571
577
  # Converts the connections to behaviors.
572
578
  systemT.connections_to_behaviors!
573
- puts Time.now
579
+ HDLRuby.show Time.now
574
580
  # Break the RefConcat.
575
- puts "concat_assigns step..."
581
+ HDLRuby.show "concat_assigns step..."
576
582
  systemT.break_concat_assigns!
577
- puts Time.now
583
+ HDLRuby.show Time.now
578
584
  # Explicits the types.
579
- puts "explicit_types step..."
585
+ HDLRuby.show "explicit_types step..."
580
586
  systemT.explicit_types!
581
- puts Time.now
587
+ HDLRuby.show Time.now
582
588
  end
583
589
  # Generate the C.
584
590
  if $options[:multiple] then
@@ -649,7 +655,7 @@ elsif $options[:clang] then
649
655
  name = $output + "/" +
650
656
  HDLRuby::Low::Low2C.c_name(systemT.name) +
651
657
  ".c"
652
- # puts "for systemT=#{systemT.name} generating: #{name}"
658
+ # show? "for systemT=#{systemT.name} generating: #{name}"
653
659
  # Open the file for current systemT
654
660
  outfile = File.open(name,"w")
655
661
  # Generate the C code in to.
@@ -703,26 +709,26 @@ elsif $options[:verilog] then
703
709
  # top_system = $top_system
704
710
  # Make description compatible with verilog generation.
705
711
  $top_system.each_systemT_deep do |systemT|
706
- puts "casts_without_expression! step..."
712
+ HDLRuby.show "casts_without_expression! step..."
707
713
  systemT.casts_without_expression!
708
- puts Time.now
709
- puts "to_upper_space! step..."
714
+ HDLRuby.show Time.now
715
+ HDLRuby.show "to_upper_space! step..."
710
716
  systemT.to_upper_space!
711
- puts Time.now
712
- puts "to_global_space! step..."
717
+ HDLRuby.show Time.now
718
+ HDLRuby.show "to_global_space! step..."
713
719
  systemT.to_global_systemTs!
714
- puts Time.now
720
+ HDLRuby.show Time.now
715
721
  # systemT.break_types!
716
722
  # systemT.expand_types!
717
- puts "par_in_seq2seq! step..."
723
+ HDLRuby.show "par_in_seq2seq! step..."
718
724
  systemT.par_in_seq2seq!
719
- puts Time.now
720
- puts "initial_concat_to_timed! step..."
725
+ HDLRuby.show Time.now
726
+ HDLRuby.show "initial_concat_to_timed! step..."
721
727
  systemT.initial_concat_to_timed!
722
- puts Time.now
723
- puts "with_port! step..."
728
+ HDLRuby.show Time.now
729
+ HDLRuby.show "with_port! step..."
724
730
  systemT.with_port!
725
- puts Time.now
731
+ HDLRuby.show Time.now
726
732
  end
727
733
  # # Verilog generation
728
734
  # $output << top_system.to_verilog
@@ -1575,9 +1575,10 @@ module HDLRuby::Low
1575
1575
  if str =~ /^[01]+$/ && str.length <= 64 then
1576
1576
  # Yes, generate a numeral value.
1577
1577
  res << " " * (level+1)*3
1578
- res << "static unsigned long long data[] = { "
1578
+ # res << "static unsigned long long data[] = { "
1579
+ res << "static unsigned int data[] = { "
1579
1580
  res << str.scan(/.{1,#{Low2C.int_width}}/m).map do |sub|
1580
- sub.to_i(2).to_s + "ULL"
1581
+ sub.to_i(2).to_s # + "ULL"
1581
1582
  end.join(",")
1582
1583
  res << " };\n"
1583
1584
  # Create the value.
@@ -1930,11 +1931,10 @@ module HDLRuby::Low
1930
1931
  res << "ref = #{self.ref.to_c(level+2)};\n"
1931
1932
  # Compute the index.
1932
1933
  res << (" " * ((level+1)*3))
1933
- # res << "idx = read64(#{self.index.to_c(level+2)});\n"
1934
1934
  res << "idx = value2integer(#{self.index.to_c(level+2)});\n"
1935
1935
  # Make the access.
1936
1936
  res << (" " * ((level+1)*3))
1937
- # res << "dst = read_range(ref,idx,idx,#{self.ref.type.base.to_c(level)},dst);\n"
1937
+ # puts "self.type.width=#{self.type.width}"
1938
1938
  res << "dst = read_range(ref,idx,idx,#{self.type.to_c(level)},dst);\n"
1939
1939
  # Restore the state of the value pool.
1940
1940
  res << (" " * ((level+1)*3))
@@ -1947,7 +1947,9 @@ module HDLRuby::Low
1947
1947
  # Generates the C text for reference as left value to a signal.
1948
1948
  # +level+ is the hierarchical level of the object.
1949
1949
  def to_c_signal(level = 0)
1950
+ # puts "to_c_signal for RefIndex"
1950
1951
  return "make_ref_rangeS(#{self.ref.to_c_signal(level)}," +
1952
+ "#{self.type.to_c(level)}," +
1951
1953
  "value2integer(#{self.index.to_c(level)}),value2integer(#{self.index.to_c(level)}))"
1952
1954
  end
1953
1955
  end
@@ -1985,7 +1987,7 @@ module HDLRuby::Low
1985
1987
  # Make the access.
1986
1988
  res << (" " * ((level+1)*3))
1987
1989
  # res << "dst = #{command}_range(ref,first,last,#{self.ref.type.base.to_c(level)},dst);\n"
1988
- # puts "will read_range for #{self.ref.name} with width=#{self.ref.type.width} with base width=#{self.ref.type.base.width} with range=#{self.ref.type.range} with range=#{self.range.first.content}..#{self.range.last.content}"
1990
+ # puts "#{command}_range with first=#{self.range.first} and last=#{self.range.last}"
1989
1991
  res << "dst = #{command}_range(ref,first,last,#{self.type.base.to_c(level)},dst);\n"
1990
1992
  # Restore the state of the value pool.
1991
1993
  res << (" " * ((level+1)*3))
@@ -56,9 +56,9 @@ module HDLRuby::Low
56
56
  # Extracts the expressions from the casts.
57
57
  def casts_without_expression!
58
58
  # Apply on the left value.
59
- self.set_left!(self.left.casts_without_expression)
59
+ self.set_left!(self.left.casts_without_expression!)
60
60
  # Apply on the right value.
61
- self.set_right!(self.right.casts_without_expression)
61
+ self.set_right!(self.right.casts_without_expression!)
62
62
  return self
63
63
  end
64
64
  end
@@ -71,7 +71,7 @@ module HDLRuby::Low
71
71
  # Extracts the expressions from the casts.
72
72
  def casts_without_expression!
73
73
  # Apply on the arguments.
74
- self.map_args!(&:casts_without_expression)
74
+ self.map_args!(&:casts_without_expression!)
75
75
  return self
76
76
  end
77
77
  end
@@ -84,12 +84,12 @@ module HDLRuby::Low
84
84
  # Extracts the expressions from the casts.
85
85
  def casts_without_expression!
86
86
  # Apply on the condition.
87
- self.set_condition!(self.condition.casts_without_expression)
87
+ self.set_condition!(self.condition.casts_without_expression!)
88
88
  # Apply on the yes.
89
89
  self.yes.casts_without_expression!
90
90
  # Apply on the noifs.
91
91
  @noifs.map! do |cond,stmnt|
92
- [cond.casts_without_expression,stmnt.casts_without_expression!]
92
+ [cond.casts_without_expression!,stmnt.casts_without_expression!]
93
93
  end
94
94
  # Apply on the no if any.
95
95
  self.no.casts_without_expression! if self.no
@@ -104,7 +104,7 @@ module HDLRuby::Low
104
104
  # Extracts the expressions from the casts.
105
105
  def casts_without_expression!
106
106
  # Apply on the match.
107
- self.set_match!(self.match.casts_without_expression)
107
+ self.set_match!(self.match.casts_without_expression!)
108
108
  # Apply on the statement.
109
109
  self.statement.casts_without_expression!
110
110
  return self
@@ -120,7 +120,7 @@ module HDLRuby::Low
120
120
  def casts_without_expression!
121
121
  # No need to apply on the value!
122
122
  # Apply on the value.
123
- self.set_value!(self.value.casts_without_expression)
123
+ self.set_value!(self.value.casts_without_expression!)
124
124
  # Apply on the whens.
125
125
  self.each_when(&:casts_without_expression!)
126
126
  # Apply on the default if any.
@@ -169,9 +169,10 @@ module HDLRuby::Low
169
169
  # expressions from cast.
170
170
  class Value
171
171
  # Extracts the expressions from the casts.
172
- def casts_without_expression
173
- # Simple clones.
174
- return self.clone
172
+ def casts_without_expression!
173
+ # # Simple clones.
174
+ # return self.clone
175
+ return self
175
176
  end
176
177
  end
177
178
 
@@ -180,9 +181,10 @@ module HDLRuby::Low
180
181
  # expressions from cast.
181
182
  class Cast
182
183
  # Extracts the expressions from the casts.
183
- def casts_without_expression
184
+ def casts_without_expression!
184
185
  # Recurse on the child.
185
- nchild = self.child.casts_without_expression
186
+ nchild = self.child.casts_without_expression!
187
+ nchild.parent = nil
186
188
  # Process the cast.
187
189
  unless (nchild.is_a?(Ref)) then
188
190
  # Need to extract the child.
@@ -221,10 +223,11 @@ module HDLRuby::Low
221
223
  class Unary
222
224
 
223
225
  # Extracts the expressions from the casts.
224
- def casts_without_expression
225
- # Recurse on the sub node.
226
- return Unary.new(self.type,self.operator,
227
- self.child.casts_without_expression)
226
+ def casts_without_expression!
227
+ # # Recurse on the sub node.
228
+ # return Unary.new(self.type,self.operator,
229
+ # self.child.casts_without_expression)
230
+ self.set_child!(self.child.casts_without_expression!)
228
231
  return self
229
232
  end
230
233
  end
@@ -235,11 +238,14 @@ module HDLRuby::Low
235
238
  class Binary
236
239
 
237
240
  # Extracts the expressions from the casts.
238
- def casts_without_expression
239
- # Recurse on the sub nodes.
240
- return Binary.new(self.type,self.operator,
241
- self.left.casts_without_expression,
242
- self.right.casts_without_expression)
241
+ def casts_without_expression!
242
+ # # Recurse on the sub nodes.
243
+ # return Binary.new(self.type,self.operator,
244
+ # self.left.casts_without_expression,
245
+ # self.right.casts_without_expression)
246
+ self.set_left!(self.left.casts_without_expression!)
247
+ self.set_right!(self.right.casts_without_expression!)
248
+ return self
243
249
  end
244
250
  end
245
251
 
@@ -250,13 +256,15 @@ module HDLRuby::Low
250
256
  class Select
251
257
 
252
258
  # Extracts the expressions from the casts.
253
- def casts_without_expression
259
+ def casts_without_expression!
254
260
  # Recurse on the sub node.
255
- return Select.new(self.type,"?",
256
- self.select.casts_without_expression,
257
- *self.each_choice.map do |choice|
258
- choice.casts_without_expression
259
- end )
261
+ # return Select.new(self.type,"?",
262
+ # self.select.casts_without_expression,
263
+ # *self.each_choice.map do |choice|
264
+ # choice.casts_without_expression
265
+ # end )
266
+ self.set_select!(self.select.casts_without_expression!)
267
+ sef.map_choices! { |choice| choice.casts_without_expression! }
260
268
  return self
261
269
  end
262
270
  end
@@ -266,11 +274,13 @@ module HDLRuby::Low
266
274
  # in assignments to select operators.
267
275
  class Concat
268
276
  # Extracts the expressions from the casts.
269
- def casts_without_expression
277
+ def casts_without_expression!
270
278
  # Recurse on the sub expressions.
271
- return Concat.new(self.type,self.each_expression.map do |expr|
272
- expr.casts_without_expression
273
- end )
279
+ # return Concat.new(self.type,self.each_expression.map do |expr|
280
+ # expr.casts_without_expression
281
+ # end )
282
+ self.map_expressions! {|expr| expr.casts_without_expression! }
283
+ return self
274
284
  end
275
285
  end
276
286
 
@@ -279,11 +289,13 @@ module HDLRuby::Low
279
289
  # in assignments to select operators.
280
290
  class RefConcat
281
291
  # Extracts the expressions from the casts.
282
- def casts_without_expression
283
- # Recurse on the sub references.
284
- return RefConcat.new(self.type,self.each_expression.map do |expr|
285
- expr.casts_without_expression
286
- end )
292
+ def casts_without_expression!
293
+ # # Recurse on the sub references.
294
+ # return RefConcat.new(self.type,self.each_expression.map do |expr|
295
+ # expr.casts_without_expression
296
+ # end )
297
+ self.map_expressions! {|expr| expr.casts_without_expression! }
298
+ return self
287
299
  end
288
300
  end
289
301
 
@@ -292,11 +304,14 @@ module HDLRuby::Low
292
304
  # in assignments to select operators.
293
305
  class RefIndex
294
306
  # Extracts the expressions from the casts.
295
- def casts_without_expression
307
+ def casts_without_expression!
296
308
  # Recurse on the sub references.
297
- return RefIndex.new(self.type,
298
- self.ref.casts_without_expression,
299
- self.index.casts_without_expression)
309
+ # return RefIndex.new(self.type,
310
+ # self.ref.casts_without_expression,
311
+ # self.index.casts_without_expression)
312
+ self.set_ref!(self.ref.casts_without_expression!)
313
+ self.set_index!(self.index.casts_without_expression!)
314
+ return self
300
315
  end
301
316
  end
302
317
 
@@ -305,12 +320,16 @@ module HDLRuby::Low
305
320
  # in assignments to select operators.
306
321
  class RefRange
307
322
  # Extracts the expressions from the casts.
308
- def casts_without_expression
323
+ def casts_without_expression!
309
324
  # Recurse on the sub references.
310
- return RefRange.new(self.type,
311
- self.ref.casts_without_expression,
312
- self.range.first.casts_without_expression ..
313
- self.range.last.casts_without_expression)
325
+ # return RefRange.new(self.type,
326
+ # self.ref.casts_without_expression,
327
+ # self.range.first.casts_without_expression ..
328
+ # self.range.last.casts_without_expression)
329
+ self.set_ref!(self.ref.casts_without_expression!)
330
+ self.set_range!(self.range.first.casts_without_expression! ..
331
+ self.range.last.casts_without_expression!)
332
+ return self
314
333
  end
315
334
  end
316
335
 
@@ -319,11 +338,13 @@ module HDLRuby::Low
319
338
  # in assignments to select operators.
320
339
  class RefName
321
340
  # Extracts the expressions from the casts.
322
- def casts_without_expression
341
+ def casts_without_expression!
323
342
  # Recurse on the sub references.
324
- return RefName.new(self.type,
325
- self.ref.casts_without_expression,
326
- self.name)
343
+ # return RefName.new(self.type,
344
+ # self.ref.casts_without_expression,
345
+ # self.name)
346
+ self.set_ref!(self.ref.casts_without_expression!)
347
+ return self
327
348
  end
328
349
  end
329
350
 
@@ -332,9 +353,10 @@ module HDLRuby::Low
332
353
  # in assignments to select operators.
333
354
  class RefThis
334
355
  # Extracts the expressions from the casts.
335
- def casts_without_expression
336
- # Simply clone.
337
- return self.clone
356
+ def casts_without_expression!
357
+ # # Simply clone.
358
+ # return self.clone
359
+ return self
338
360
  end
339
361
  end
340
362
 
@@ -344,9 +366,10 @@ module HDLRuby::Low
344
366
  class StringE
345
367
 
346
368
  # Extracts the expressions from the casts.
347
- def casts_without_expression
348
- return StringE.new(self.content,
349
- *self.each_arg.map(&:cast_without_expression))
369
+ def casts_without_expression!
370
+ # return StringE.new(self.content,
371
+ # *self.each_arg.map(&:casts_without_expression))
372
+ self.map_args! {|arg| arg.casts_without_expression! }
350
373
  return self
351
374
  end
352
375
  end
@@ -1959,4 +1959,25 @@ module HDLRuby::Low
1959
1959
  # Nothing to do.
1960
1960
  end
1961
1961
  end
1962
+
1963
+ ##
1964
+ # Describes a string.
1965
+ #
1966
+ # NOTE: This is not synthesizable!
1967
+ class StringE
1968
+
1969
+ # Maps on the arguments.
1970
+ def map_args!(&ruby_block)
1971
+ @args.map! do |arg|
1972
+ arg = ruby_block.call(arg)
1973
+ arg.parent = self unless arg.parent
1974
+ arg
1975
+ end
1976
+ end
1977
+
1978
+ # Maps on the children.
1979
+ def map_nodes!(&ruby_block)
1980
+ self.map_args!(&ruby_block)
1981
+ end
1982
+ end
1962
1983
  end
@@ -44,8 +44,10 @@ module HDLRuby::Low
44
44
  def to_global_systemTs!
45
45
  # Force a name if not.
46
46
  self.force_name!
47
+ # puts "to_global_systemTs! for #{self.name}"
47
48
  # For each local systemT
48
49
  self.scope.each_systemT.to_a.each do |systemT|
50
+ # puts "Processing system: #{systemT}"
49
51
  # Rename it for globalization.
50
52
  former = systemT.name
51
53
  self.extend_name!(systemT)
@@ -211,6 +213,7 @@ module HDLRuby::Low
211
213
  # Replaces recursively +former+ name by +nname+ until it is redeclared
212
214
  # in the internals.
213
215
  def replace_names_subs!(former,nname)
216
+ # puts "replace_names_subs! for #{self} with former=#{former} and nname=#{nname}"
214
217
  self.each_type do |type|
215
218
  type.replace_names!(former,nname)
216
219
  end
@@ -416,8 +419,9 @@ module HDLRuby::Low
416
419
  if self.name == former then
417
420
  self.set_name!(nname)
418
421
  end
419
- # Recurse on the system type.
420
- self.systemT.replace_names!(former,nname)
422
+ # Not needed since treated through scope and systemT.
423
+ # # Recurse on the system type.
424
+ # self.systemT.replace_names!(former,nname)
421
425
  end
422
426
  end
423
427
 
@@ -50,4 +50,28 @@ module HDLRuby
50
50
 
51
51
  end
52
52
 
53
+
54
+ # Display some messages depending on the verbosity mode.
55
+ @@verbosity = 1 # The verbosity level: default 1, only critical messages.
56
+
57
+ # Sets the verbosity.
58
+ def self.verbosity=(val)
59
+ @@verbosity = val.to_i
60
+ end
61
+
62
+ # Display a critical message.
63
+ def self.show!(*args)
64
+ puts(*args) if @@verbosity > 0
65
+ end
66
+
67
+ # Display a common message.
68
+ def self.show(*args)
69
+ puts(*args) if @@verbosity > 1
70
+ end
71
+
72
+ # Display a minor message.
73
+ def self.show?(*args)
74
+ puts(*args) if @@verbosity > 2
75
+ end
76
+
53
77
  end
@@ -6,63 +6,35 @@ module HDLRuby::Verilog
6
6
  # This is sample.
7
7
  # n = "abc_ABC_いろは"
8
8
  # puts n
9
- # name = n.split("")
9
+ # name = n.split("")
10
+
11
+ @@hdr2verilog = {}
10
12
 
11
13
  # Since it is possible to use $ and numbers other than the beginning of the character string, it is divided.
12
14
  def name_to_verilog(name)
13
- # ref = "" # For storing the converted character.
14
- # name = name.to_s # Ensure name is a string
15
- #
16
- # if (name[0] =~ /[a-zA-Z]/) then
17
- # ref << name[0]
18
- # # _ To convert it to __.
19
- # elsif (name[0] == "_") then
20
- # ref << "__"
21
- # # If it does not satisfy the above, it is another character.
22
- # # In that case, convert it to UTF-8 and convert it to a usable character string.
23
- # else
24
- # l = name[0].bytes.map{|v| v.to_s(16)}.join # Conversion to UTF-8 hexadecimal number.
25
-
26
- # ref << "_" + l.rjust(6,"0") # Add an underscore indicating conversion.
27
- # # The remainder of 6 digits is filled with 0.
28
- # end
29
- #
30
- # name[1..-1].each_char do |c|
31
- # # Confirmation of characters in array.
32
- # # If it is a-zA-Z 0 - 9, it is added to ref as it is.
33
- # if (c =~ /[a-zA-Z0-9]|\$/) then
34
- # ref << c
35
- # # _ To convert it to __.
36
- # elsif (c == "_") then
37
- # ref << "__"
38
- # # If it does not satisfy the above, it is another character.
39
- # # In that case, convert it to UTF-8 and convert it to a usable character string.
40
- # else
41
- # l = c.bytes.map{|v| v.to_s(16)}.join # Conversion to UTF-8 hexadecimal number.
42
- #
43
- # ref << "_" + l.rjust(6,"0") # Add an underscore indicating conversion.
44
- # # The remainder of 6 digits is filled with 0.
45
- # end
46
- # end
47
- # return ref
48
-
49
-
15
+ # name = name.to_s
16
+ # # Convert special characters.
17
+ # name = name.each_char.map do |c|
18
+ # if c=~ /[a-z0-9]/ then
19
+ # c
20
+ # elsif c == "_" then
21
+ # "__"
22
+ # else
23
+ # "_" + c.ord.to_s
24
+ # end
25
+ # end.join
26
+ # # First character: only letter is possible.
27
+ # unless name[0] =~ /[a-z_]/ then
28
+ # name = "_" + name
29
+ # end
30
+ # return name
50
31
  name = name.to_s
51
- # Convert special characters.
52
- name = name.each_char.map do |c|
53
- if c=~ /[a-z0-9]/ then
54
- c
55
- elsif c == "_" then
56
- "__"
57
- else
58
- "_" + c.ord.to_s
59
- end
60
- end.join
61
- # First character: only letter is possible.
62
- unless name[0] =~ /[a-z_]/ then
63
- name = "_" + name
32
+ vname = @@hdr2verilog[name]
33
+ unless vname then
34
+ vname = "_v#{@@hdr2verilog.size}_#{name.split(/[^a-zA-Z_0-9]/)[-1]}"
35
+ @@hdr2verilog[name] = vname
64
36
  end
65
- return name
37
+ return vname
66
38
  end
67
39
 
68
40
  #puts ref
@@ -101,6 +101,7 @@ typedef struct ValueS_ {
101
101
  /* The tructure of a reference to a range in a value. */
102
102
  typedef struct RefRangeS_ {
103
103
  SignalI signal; /* The refered signal. */
104
+ Type type; /* The tyep of the elements. */
104
105
  unsigned long long first; /* The first index in the range. */
105
106
  unsigned long long last; /* The last index in the range. */
106
107
  } RefRangeS;
@@ -308,11 +309,12 @@ extern int same_content_value_range(Value value0, unsigned long long first,
308
309
 
309
310
  /** Creates a reference to a range inside a signal.
310
311
  * @param signal the signal to refer
312
+ * @param typ the type of the elements.
311
313
  * @param first the start index of the range
312
314
  * @param last the end index of the range
313
315
  * @return the resulting reference */
314
- extern RefRangeS make_ref_rangeS(SignalI signal, unsigned long long first,
315
- unsigned long long last);
316
+ extern RefRangeS make_ref_rangeS(SignalI signal, Type typ,
317
+ unsigned long long first, unsigned long long last);
316
318
 
317
319
 
318
320
  /* The interface for the lists. */
@@ -2171,7 +2171,8 @@ Value read_range_numeric(Value value, long long first, long long last,
2171
2171
  /* Compute the read mask. */
2172
2172
  // unsigned long long mask = ((-1LL) << first) & (~((-1LL) << (last+1)));
2173
2173
  /* NOTE: once again, << 64 does not work like expected. */
2174
- unsigned long long mask = mask+bw < 64 ? (~((-1LL) << (last+bw))) : -1LL;
2174
+ unsigned long long mask = last+bw < 64 ? (~((-1LL) << (last+bw))) : -1LL;
2175
+ // printf("mask=%llx\n",mask);
2175
2176
  /* Performs the read. */
2176
2177
  unsigned long long data = (value->data_int & mask) >> first;
2177
2178
  /* Write it to the destination. */
@@ -2216,7 +2217,9 @@ Value write_range_numeric(Value src, long long first, long long last,
2216
2217
  /* Copy from the source. */
2217
2218
  unsigned long long src_data = src->data_int & ~((-1LL) << (last-first+1));
2218
2219
  /* Cleans the destination where to place the data. */
2219
- unsigned long long mask = ~(((-1LL) << first) & ~((-1LL) << (last+1)));
2220
+ unsigned long long mask;
2221
+ if (last<63) mask = ~(((-1LL) << first) & ~((-1LL) << (last+1)));
2222
+ else mask = ~((-1LL)<<first);
2220
2223
  unsigned long long dst_data = dst->data_int & mask;
2221
2224
  // printf("src_data=%llx mask=%llx dst_data=%llx\n",src_data,mask,dst_data);
2222
2225
  /* Write the data. */
@@ -2947,12 +2950,13 @@ int same_content_value_range(Value value0,
2947
2950
 
2948
2951
  /** Creates a reference to a range inside a signal.
2949
2952
  * @param signal the signal to refer
2953
+ * @param typ the type of the elements
2950
2954
  * @param first the start index of the range
2951
2955
  * @param last the end index of the range
2952
2956
  * @return the resulting reference */
2953
- RefRangeS make_ref_rangeS(SignalI signal, unsigned long long first,
2957
+ RefRangeS make_ref_rangeS(SignalI signal, Type typ, unsigned long long first,
2954
2958
  unsigned long long last) {
2955
- RefRangeS result = { signal, first, last };
2959
+ RefRangeS result = { signal, typ, first, last };
2956
2960
  return result;
2957
2961
  }
2958
2962
 
@@ -586,12 +586,14 @@ void transmit_to_signal_range_seq(Value value, RefRangeS ref) {
586
586
  SignalI signal = ref.signal;
587
587
  unsigned long long first = ref.first;
588
588
  unsigned long long last = ref.last;
589
- // printf("Tansmit to signal range: %s(%p)\n",signal->name,signal);
589
+ // printf("Tansmit to signal range: %s(%p) [%llu,%llu]\n",signal->name,signal,first,last);
590
590
  /* Can transmit, copy the content. */
591
591
  if (signal->fading)
592
- write_range(value,first,last,signal->f_value->type,signal->f_value);
592
+ // write_range(value,first,last,signal->f_value->type,signal->f_value);
593
+ write_range(value,first,last,ref.type,signal->f_value);
593
594
  else
594
- write_range_no_z(value,first,last,signal->f_value->type,signal->f_value);
595
+ // write_range_no_z(value,first,last,signal->f_value->type,signal->f_value);
596
+ write_range_no_z(value,first,last,ref.type,signal->f_value);
595
597
  /* And touch the signal. */
596
598
  touch_signal_seq(signal);
597
599
  }
@@ -1,3 +1,3 @@
1
1
  module HDLRuby
2
- VERSION = "2.6.16"
2
+ VERSION = "2.6.23"
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.6.16
4
+ version: 2.6.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lovic Gauthier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-20 00:00:00.000000000 Z
11
+ date: 2021-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -150,6 +150,9 @@ files:
150
150
  - lib/HDLRuby/hdr_samples/with_memory_rom.rb
151
151
  - lib/HDLRuby/hdr_samples/with_multi_channels.rb
152
152
  - lib/HDLRuby/hdr_samples/with_reconf.rb
153
+ - lib/HDLRuby/hdr_samples/with_reduce.rb
154
+ - lib/HDLRuby/hdr_samples/with_str2value.rb
155
+ - lib/HDLRuby/hdr_samples/with_to_a.rb
153
156
  - lib/HDLRuby/hdr_samples/with_to_array.rb
154
157
  - lib/HDLRuby/hdrcc.rb
155
158
  - lib/HDLRuby/high_samples/_adder_fault.rb