HDLRuby 2.6.22 → 2.7.1
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 +4 -4
- data/lib/HDLRuby/hdr_samples/case_bench.rb +30 -0
- data/lib/HDLRuby/hdr_samples/constant_in_function.rb +1 -1
- data/lib/HDLRuby/hdr_samples/if_bench.rb +24 -0
- data/lib/HDLRuby/hdr_samples/index_bench.rb +37 -0
- data/lib/HDLRuby/hdr_samples/range_bench.rb +47 -0
- data/lib/HDLRuby/hdr_samples/with_casts.rb +30 -0
- data/lib/HDLRuby/hdr_samples/with_concat.rb +26 -0
- data/lib/HDLRuby/hdr_samples/with_ref_array.rb +26 -0
- data/lib/HDLRuby/hdr_samples/with_str2value.rb +14 -0
- data/lib/HDLRuby/hdr_samples/with_subsums.rb +33 -0
- data/lib/HDLRuby/hdr_samples/with_to_a.rb +90 -0
- data/lib/HDLRuby/hdr_samples/with_values.rb +58 -0
- data/lib/HDLRuby/hdrcc.rb +38 -25
- data/lib/HDLRuby/hruby_high.rb +11 -1
- data/lib/HDLRuby/hruby_low.rb +11 -0
- data/lib/HDLRuby/hruby_low2c.rb +1339 -550
- data/lib/HDLRuby/hruby_low_casts_without_expression.rb +78 -55
- data/lib/HDLRuby/hruby_low_mutable.rb +33 -0
- data/lib/HDLRuby/hruby_low_with_port.rb +21 -6
- data/lib/HDLRuby/hruby_low_without_namespace.rb +4 -2
- data/lib/HDLRuby/hruby_tools.rb +8 -1
- data/lib/HDLRuby/hruby_verilog.rb +218 -149
- data/lib/HDLRuby/sim/hruby_sim.h +114 -0
- data/lib/HDLRuby/sim/hruby_sim_calc.c +38 -9
- data/lib/HDLRuby/sim/hruby_sim_stack_calc.c +239 -0
- data/lib/HDLRuby/sim/hruby_sim_stack_calc.c.sav +100 -0
- data/lib/HDLRuby/sim/hruby_value_pool.c +36 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +15 -2
@@ -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
|
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
|
-
|
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
|
-
|
242
|
-
|
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
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
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
|
+
self.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
|
-
|
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
|
-
|
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
|
-
|
299
|
-
|
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
|
-
|
312
|
-
|
313
|
-
|
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
|
-
|
326
|
-
|
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
|
-
|
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
|
@@ -221,6 +221,12 @@ module HDLRuby::Low
|
|
221
221
|
connection
|
222
222
|
end
|
223
223
|
|
224
|
+
# Deletes all the connections.
|
225
|
+
def delete_all_conncetions!
|
226
|
+
@connections.each { |cnx| cnx.parent = nil }
|
227
|
+
@connections = []
|
228
|
+
end
|
229
|
+
|
224
230
|
# Deletes a behavior.
|
225
231
|
def delete_behavior!(behavior)
|
226
232
|
if @behaviors.include?(behavior) then
|
@@ -231,6 +237,12 @@ module HDLRuby::Low
|
|
231
237
|
end
|
232
238
|
end
|
233
239
|
|
240
|
+
# Deletes all the behaviors.
|
241
|
+
def delete_all_behaviors!
|
242
|
+
@behaviors.each { |beh| beh.parent = nil }
|
243
|
+
@behaviors = []
|
244
|
+
end
|
245
|
+
|
234
246
|
# Deletes the elements related to one of +names+: either they have
|
235
247
|
# one of the names or they use an element with these names.
|
236
248
|
# NOTE: only delete actual instantiated elements, types or
|
@@ -1959,4 +1971,25 @@ module HDLRuby::Low
|
|
1959
1971
|
# Nothing to do.
|
1960
1972
|
end
|
1961
1973
|
end
|
1974
|
+
|
1975
|
+
##
|
1976
|
+
# Describes a string.
|
1977
|
+
#
|
1978
|
+
# NOTE: This is not synthesizable!
|
1979
|
+
class StringE
|
1980
|
+
|
1981
|
+
# Maps on the arguments.
|
1982
|
+
def map_args!(&ruby_block)
|
1983
|
+
@args.map! do |arg|
|
1984
|
+
arg = ruby_block.call(arg)
|
1985
|
+
arg.parent = self unless arg.parent
|
1986
|
+
arg
|
1987
|
+
end
|
1988
|
+
end
|
1989
|
+
|
1990
|
+
# Maps on the children.
|
1991
|
+
def map_nodes!(&ruby_block)
|
1992
|
+
self.map_args!(&ruby_block)
|
1993
|
+
end
|
1994
|
+
end
|
1962
1995
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
1
3
|
require "HDLRuby/hruby_error"
|
2
4
|
require "HDLRuby/hruby_low_mutable"
|
3
5
|
require "HDLRuby/hruby_low2sym"
|
@@ -88,14 +90,19 @@ module HDLRuby::Low
|
|
88
90
|
# self.each_scope(&:with_port!)
|
89
91
|
# Gather the references to instance ports.
|
90
92
|
# Also remember if the references were left values or not.
|
93
|
+
# And remember where the node was.
|
91
94
|
refs = []
|
92
95
|
ref_sym2leftvalue = {}
|
96
|
+
# ref_parents = Set.new
|
97
|
+
ref_parents = []
|
93
98
|
self.each_block_deep do |block|
|
94
99
|
block.each_node_deep do |node|
|
95
100
|
if instance_port?(node) then
|
96
101
|
# puts "port for node: #{node.ref.name}.#{node.name}"
|
97
102
|
refs << node
|
98
103
|
ref_sym2leftvalue[node.to_sym] = node.leftvalue?
|
104
|
+
ref_parents << node.parent
|
105
|
+
# ref_parents[node.parent] = node
|
99
106
|
end
|
100
107
|
end
|
101
108
|
end
|
@@ -106,6 +113,8 @@ module HDLRuby::Low
|
|
106
113
|
# puts "leftvalue? #{node.leftvalue?}"
|
107
114
|
refs << node
|
108
115
|
ref_sym2leftvalue[node.to_sym] = node.leftvalue?
|
116
|
+
ref_parents << node.parent
|
117
|
+
# ref_parents[node.parent] = node
|
109
118
|
end
|
110
119
|
end
|
111
120
|
end
|
@@ -117,17 +126,23 @@ module HDLRuby::Low
|
|
117
126
|
# Replace the references by their corresponding port wires.
|
118
127
|
self.each_block_deep do |block|
|
119
128
|
block.each_node_deep do |node|
|
120
|
-
node
|
121
|
-
|
122
|
-
|
129
|
+
if ref_parents.include?(node) then
|
130
|
+
node.map_nodes! do |expr|
|
131
|
+
next expr unless instance_port?(expr)
|
132
|
+
portw = ref_sym2portw[expr.to_sym]
|
133
|
+
portw ? portw2ref(portw) : expr
|
134
|
+
end
|
123
135
|
end
|
124
136
|
end
|
125
137
|
end
|
126
138
|
self.each_connection do |connection|
|
127
139
|
connection.each_node_deep do |node|
|
128
|
-
node
|
129
|
-
|
130
|
-
|
140
|
+
if ref_parents.include?(node) then
|
141
|
+
node.map_nodes! do |expr|
|
142
|
+
next expr unless instance_port?(expr)
|
143
|
+
portw = ref_sym2portw[expr.to_sym]
|
144
|
+
portw ? portw2ref(portw) : expr
|
145
|
+
end
|
131
146
|
end
|
132
147
|
end
|
133
148
|
end
|
@@ -133,7 +133,8 @@ module HDLRuby::Low
|
|
133
133
|
# Get the behaviors.
|
134
134
|
behs = self.each_behavior.to_a
|
135
135
|
# Remove them from the scope.
|
136
|
-
behs.each { |beh| self.delete_behavior!(beh) }
|
136
|
+
# behs.each { |beh| self.delete_behavior!(beh) }
|
137
|
+
self.delete_all_behaviors!
|
137
138
|
# Return the behaviors.
|
138
139
|
return behs
|
139
140
|
end
|
@@ -145,7 +146,8 @@ module HDLRuby::Low
|
|
145
146
|
# Get the connections.
|
146
147
|
cnxs = self.each_connection.to_a
|
147
148
|
# Remove them from the scope.
|
148
|
-
cnxs.each { |
|
149
|
+
# cnxs.each { |cnx| self.delete_connection!(cnx) }
|
150
|
+
cnxs.delete_all_connections!
|
149
151
|
# Return the connections.
|
150
152
|
return cnxs
|
151
153
|
end
|
data/lib/HDLRuby/hruby_tools.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
1
3
|
module HDLRuby
|
2
4
|
|
3
5
|
##
|
@@ -11,16 +13,21 @@ module HDLRuby
|
|
11
13
|
|
12
14
|
@@absoluteCounter = -1 # The absolute name counter.
|
13
15
|
|
16
|
+
@@uniq_names = Set.new(Symbol.all_symbols.map {|sym| sym.to_s})
|
17
|
+
|
14
18
|
# Generates an absolute uniq name.
|
15
19
|
def self.uniq_name(base = "")
|
16
20
|
@@absoluteCounter += 1
|
17
21
|
name = base.to_s + ":#{@@absoluteCounter}"
|
18
|
-
if Symbol.all_symbols.find {|symbol| symbol.to_s == name } then
|
22
|
+
# if Symbol.all_symbols.find {|symbol| symbol.to_s == name } then
|
23
|
+
if @@uniq_names.include?(name) then
|
19
24
|
# The symbol exists, try again.
|
20
25
|
return self.uniq_name
|
21
26
|
else
|
27
|
+
@@uniq_names.add(name)
|
22
28
|
return name.to_sym
|
23
29
|
end
|
30
|
+
# return base.to_s + ":#{@@absoluteCounter}"
|
24
31
|
end
|
25
32
|
|
26
33
|
|