HDLRuby 2.6.18 → 2.6.24

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: 2d49fb40d2d1233c59c0ae1f6d7afea51ab17e70aaac5f605295f4c44e478fa4
4
- data.tar.gz: 0b14393197c0af246dae6c221d2beb94580fa9b4c30b234e82efdae4eebf5bca
3
+ metadata.gz: 935f56ddd3e2db8f8cd72ae2d8156af2dbf9c1961be139a1b2c4f27b2e0d483c
4
+ data.tar.gz: 5a6d8a611f8cf6e0e9ae859721a26b2940c569436479f74f01cced46b741d810
5
5
  SHA512:
6
- metadata.gz: e2c55c6966faa1274aee2ae712b376aec22670e9a574b4d5312e73a8a8a1f85713b8312d6b923e4daef030398667c327245ee8aeb813c3d379d137dd63ec9af8
7
- data.tar.gz: a28d25d1a5ff5893e64ede5229a4b53c7ad0c4ff6479807e3f76764c9f464fc5d0b6a41f8cce3ea8b49338895a3d95e8582760c64a0d8df21a5683fd0acba4d3
6
+ metadata.gz: c2df833c800000df44afdd2178414f6a282b4f597ec6d6b000a26e15ddff990f3ad0784e8d93d1dc75c4948f638824ea12a731340e896c8eb976ad83a61ff6eb
7
+ data.tar.gz: 84b29e842be879ed848aeb475f80cc34654a31d0ca0fbfa45093082374dca6a90ad8dce3b1774ae339d1c962fcf63a81e5821bddd924ea6be84f2a6f8b566e84
@@ -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
@@ -2499,7 +2499,11 @@ module HDLRuby::High
2499
2499
 
2500
2500
  # Casts as +type+.
2501
2501
  def as(type)
2502
- return Cast.new(type.to_type,self.to_expr)
2502
+ if (self.parent)
2503
+ return Cast.new(type.to_type,self.to_expr)
2504
+ else
2505
+ return Cast.new(type.to_type,self)
2506
+ end
2503
2507
  end
2504
2508
 
2505
2509
  # Casts to a bit vector type.
@@ -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
@@ -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.18"
2
+ VERSION = "2.6.24"
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.18
4
+ version: 2.6.24
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-10-01 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