HDLRuby 2.7.11 → 2.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -1
- data/lib/HDLRuby/hdr_samples/adder_gen.rb +22 -0
- data/lib/HDLRuby/hdr_samples/adder_gen_gen.rb +40 -0
- data/lib/HDLRuby/hdr_samples/dff_unit.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_def.rb +29 -0
- data/lib/HDLRuby/hdr_samples/with_delay.rb +72 -0
- data/lib/HDLRuby/hdr_samples/with_handshake.rb +110 -0
- data/lib/HDLRuby/hdr_samples/with_of.rb +51 -0
- data/lib/HDLRuby/hdr_samples/with_reconf.rb +75 -72
- data/lib/HDLRuby/hdr_samples/with_terminate.rb +32 -0
- data/lib/HDLRuby/hdrcc.rb +51 -5
- data/lib/HDLRuby/hdrlib.rb +592 -0
- data/lib/HDLRuby/hruby_high.rb +221 -44
- data/lib/HDLRuby/hruby_low.rb +210 -5
- data/lib/HDLRuby/hruby_low2c.rb +98 -9
- data/lib/HDLRuby/hruby_low2vhd.rb +12 -0
- data/lib/HDLRuby/hruby_low_bool2select.rb +12 -0
- data/lib/HDLRuby/hruby_low_fix_types.rb +20 -1
- data/lib/HDLRuby/hruby_low_resolve.rb +1 -1
- data/lib/HDLRuby/hruby_low_without_connection.rb +1 -0
- data/lib/HDLRuby/hruby_low_without_select.rb +11 -1
- data/lib/HDLRuby/hruby_verilog.rb +9 -1
- data/lib/HDLRuby/sim/hruby_sim.h +23 -1
- data/lib/HDLRuby/sim/hruby_sim_calc.c +3 -2
- data/lib/HDLRuby/sim/hruby_sim_core.c +60 -6
- data/lib/HDLRuby/sim/hruby_sim_vcd.c +1 -1
- data/lib/HDLRuby/std/delays.rb +92 -0
- data/lib/HDLRuby/std/handshakes.rb +60 -0
- data/lib/HDLRuby/std/reconf.rb +3 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +11 -2
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -344,6 +344,7 @@ module HDLRuby::High
|
|
344
344
|
def initialize(name, *mixins, &ruby_block)
|
345
345
|
# Initialize the system type structure.
|
346
346
|
super(name,Scope.new(name,self))
|
347
|
+
# puts "new systemT=#{self}"
|
347
348
|
|
348
349
|
# Initialize the set of extensions to transmit to the instances'
|
349
350
|
# eigen class
|
@@ -373,6 +374,28 @@ module HDLRuby::High
|
|
373
374
|
make_instantiater(name,SystemI,&ruby_block)
|
374
375
|
end
|
375
376
|
|
377
|
+
|
378
|
+
# Tell if the current system is a descedent of +system+
|
379
|
+
def of?(system)
|
380
|
+
# Maybe self is system.
|
381
|
+
if (self == system) then
|
382
|
+
# Yes, consider it is adescendent of system.
|
383
|
+
return true
|
384
|
+
else
|
385
|
+
# Look into the generators.
|
386
|
+
@generators.each do |generator|
|
387
|
+
return true if generator.of?(system)
|
388
|
+
end
|
389
|
+
# Look into the included systems.
|
390
|
+
@to_includes.each do |included|
|
391
|
+
return true if included.of?(system)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
# Not found.
|
395
|
+
return false
|
396
|
+
end
|
397
|
+
|
398
|
+
|
376
399
|
# Converts to a namespace user.
|
377
400
|
def to_user
|
378
401
|
# Returns the scope.
|
@@ -418,9 +441,9 @@ module HDLRuby::High
|
|
418
441
|
res = self.add_output(SignalI.new(name,type,:output))
|
419
442
|
elsif name.is_a?(Hash) then
|
420
443
|
# Names associated with values.
|
421
|
-
|
422
|
-
res = self.
|
423
|
-
SignalI.new(
|
444
|
+
name.each do |key,value|
|
445
|
+
res = self.add_output(
|
446
|
+
SignalI.new(key,type,:output,value))
|
424
447
|
end
|
425
448
|
else
|
426
449
|
raise AnyError, "Invalid class for a name: #{name.class}"
|
@@ -451,6 +474,21 @@ module HDLRuby::High
|
|
451
474
|
end
|
452
475
|
|
453
476
|
|
477
|
+
# Gets an input signal by +name+ considering also the included
|
478
|
+
# systems
|
479
|
+
def get_input_with_included(name)
|
480
|
+
# Look in self.
|
481
|
+
found = self.get_input(name)
|
482
|
+
return found if found
|
483
|
+
# Not in self, look in the included systems.
|
484
|
+
self.scope.each_included do |included|
|
485
|
+
found = included.get_input_with_included(name)
|
486
|
+
return found if found
|
487
|
+
end
|
488
|
+
# Not found
|
489
|
+
return nil
|
490
|
+
end
|
491
|
+
|
454
492
|
# Gets an output signal by +name+ considering also the included
|
455
493
|
# systems
|
456
494
|
def get_output_with_included(name)
|
@@ -466,6 +504,36 @@ module HDLRuby::High
|
|
466
504
|
return nil
|
467
505
|
end
|
468
506
|
|
507
|
+
# Gets an inout signal by +name+ considering also the included
|
508
|
+
# systems
|
509
|
+
def get_inout_with_included(name)
|
510
|
+
# Look in self.
|
511
|
+
found = self.get_inout(name)
|
512
|
+
return found if found
|
513
|
+
# Not in self, look in the included systems.
|
514
|
+
self.scope.each_included do |included|
|
515
|
+
found = included.get_inout_with_included(name)
|
516
|
+
return found if found
|
517
|
+
end
|
518
|
+
# Not found
|
519
|
+
return nil
|
520
|
+
end
|
521
|
+
|
522
|
+
# Iterates over the all signals (input, output, inout, inner, constant),
|
523
|
+
# i.e, also the ones of the included systems.
|
524
|
+
#
|
525
|
+
# Returns an enumerator if no ruby block is given.
|
526
|
+
def each_signal_all_with_included(&ruby_block)
|
527
|
+
# No ruby block? Return an enumerator.
|
528
|
+
return to_enum(:each_signal_all_with_included) unless ruby_block
|
529
|
+
# Iterate on all the signals of the current system.
|
530
|
+
self.each_signal_all(&ruby_block)
|
531
|
+
# Recurse on the included systems.
|
532
|
+
self.scope.each_included do |included|
|
533
|
+
included.each_signal_all_with_included(&ruby_block)
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
469
537
|
# Iterates over the all interface signals, i.e, also the ones of
|
470
538
|
# the included systems.
|
471
539
|
#
|
@@ -473,7 +541,7 @@ module HDLRuby::High
|
|
473
541
|
def each_signal_with_included(&ruby_block)
|
474
542
|
# No ruby block? Return an enumerator.
|
475
543
|
return to_enum(:each_signal_with_included) unless ruby_block
|
476
|
-
# Iterate on the signals of the current system.
|
544
|
+
# Iterate on all the signals of the current system.
|
477
545
|
self.each_signal(&ruby_block)
|
478
546
|
# Recurse on the included systems.
|
479
547
|
self.scope.each_included do |included|
|
@@ -487,6 +555,14 @@ module HDLRuby::High
|
|
487
555
|
return each_signal_with_included.to_a[i]
|
488
556
|
end
|
489
557
|
|
558
|
+
# Gets a signal by +name+ considering also the included
|
559
|
+
# systems
|
560
|
+
def get_signal_with_included(name)
|
561
|
+
return get_input_with_included(name) ||
|
562
|
+
get_output_with_included(name) ||
|
563
|
+
get_inout_with_included(name)
|
564
|
+
end
|
565
|
+
|
490
566
|
# Iterates over the exported constructs
|
491
567
|
#
|
492
568
|
# NOTE: look into the scope.
|
@@ -571,6 +647,7 @@ module HDLRuby::High
|
|
571
647
|
|
572
648
|
# Sets the generators of the expanded result.
|
573
649
|
expanded.add_generator(self)
|
650
|
+
# puts "expanded=#{expanded}"
|
574
651
|
@to_includes.each { |system| expanded.add_generator(system) }
|
575
652
|
# Also for the previously includeds. */
|
576
653
|
self.scope.each_included.each { |system| expanded.add_generator(system) }
|
@@ -634,9 +711,8 @@ module HDLRuby::High
|
|
634
711
|
|
635
712
|
# Create the instance and sets its eigen system to +eigen+.
|
636
713
|
instance = @instance_class.new(i_name,eigen)
|
714
|
+
# puts "instance=#{instance}"
|
637
715
|
eigen.eigenize(instance)
|
638
|
-
# puts "instance interface=#{instance.each_signal.to_a.size}"
|
639
|
-
# puts "eigen interface=#{eigen.each_signal.to_a.size}"
|
640
716
|
|
641
717
|
# Extend the instance.
|
642
718
|
instance.eigen_extend(@singleton_instanceO)
|
@@ -846,7 +922,8 @@ module HDLRuby::High
|
|
846
922
|
# Initialize the set of exported inner signals and instances
|
847
923
|
@exports = {}
|
848
924
|
# Initialize the set of included systems.
|
849
|
-
@includes = {}
|
925
|
+
# @includes = {}
|
926
|
+
@includes = []
|
850
927
|
|
851
928
|
# Builds the scope if a ruby block is provided.
|
852
929
|
self.build(&ruby_block) if block_given?
|
@@ -933,7 +1010,8 @@ module HDLRuby::High
|
|
933
1010
|
# No ruby block? Return an enumerator.
|
934
1011
|
return to_enum(:each_included) unless ruby_block
|
935
1012
|
# A block? Apply it on each included system.
|
936
|
-
@includes.each_value(&ruby_block)
|
1013
|
+
# @includes.each_value(&ruby_block)
|
1014
|
+
@includes.each(&ruby_block)
|
937
1015
|
# And apply on the sub scopes if any.
|
938
1016
|
@scopes.each {|scope| scope.each_included(&ruby_block) }
|
939
1017
|
end
|
@@ -1226,13 +1304,16 @@ module HDLRuby::High
|
|
1226
1304
|
# Include a +system+ type with possible +args+ instanciation
|
1227
1305
|
# arguments.
|
1228
1306
|
def include(system,*args)
|
1229
|
-
if @includes.key?(system.name) then
|
1230
|
-
|
1307
|
+
# if @includes.key?(system.name) then
|
1308
|
+
# raise AnyError, "Cannot include twice the same system: #{system}"
|
1309
|
+
# end
|
1310
|
+
if @includes.include?(system) then
|
1311
|
+
raise AnyError, "Cannot include twice the same system: #{system}"
|
1231
1312
|
end
|
1232
|
-
# puts "Include system=#{system.name}"
|
1233
|
-
# Save the name of the included system, it will serve as key
|
1234
|
-
# for looking for the included expanded version.
|
1235
|
-
include_name = system.name
|
1313
|
+
# # puts "Include system=#{system.name}"
|
1314
|
+
# # Save the name of the included system, it will serve as key
|
1315
|
+
# # for looking for the included expanded version.
|
1316
|
+
# include_name = system.name
|
1236
1317
|
# Expand the system to include
|
1237
1318
|
system = system.expand(:"",*args)
|
1238
1319
|
# Add the included system interface to the current one.
|
@@ -1240,7 +1321,8 @@ module HDLRuby::High
|
|
1240
1321
|
space = self.namespace
|
1241
1322
|
# Interface signals
|
1242
1323
|
# puts "i_name=#{i_name} @to_includes=#{@to_includes.size}"
|
1243
|
-
system.each_signal_with_included do |signal|
|
1324
|
+
# system.each_signal_with_included do |signal|
|
1325
|
+
system.each_signal_all_with_included do |signal|
|
1244
1326
|
# puts "signal=#{signal.name}"
|
1245
1327
|
space.send(:define_singleton_method,signal.name) do
|
1246
1328
|
signal
|
@@ -1259,18 +1341,20 @@ module HDLRuby::High
|
|
1259
1341
|
end
|
1260
1342
|
end
|
1261
1343
|
# Adds it the list of includeds
|
1262
|
-
@includes[include_name] = system
|
1344
|
+
# @includes[include_name] = system
|
1345
|
+
@includes << system
|
1346
|
+
|
1263
1347
|
# puts "@includes=#{@includes}"
|
1264
1348
|
|
1265
1349
|
end
|
1266
1350
|
|
1267
|
-
#
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
end
|
1351
|
+
# Obsolete
|
1352
|
+
# # Casts as an included +system+.
|
1353
|
+
# def as(system)
|
1354
|
+
# # puts "as with name: #{system.name}"
|
1355
|
+
# system = system.name if system.respond_to?(:name)
|
1356
|
+
# return @includes[system].namespace
|
1357
|
+
# end
|
1274
1358
|
|
1275
1359
|
|
1276
1360
|
# Gets the current system.
|
@@ -1285,7 +1369,8 @@ module HDLRuby::High
|
|
1285
1369
|
# NOTE: name conflicts are treated in the current NameStack state.
|
1286
1370
|
def fill_low(scopeL)
|
1287
1371
|
# Adds the content of its included systems.
|
1288
|
-
@includes.each_value {|system| system.scope.fill_low(scopeL) }
|
1372
|
+
# @includes.each_value {|system| system.scope.fill_low(scopeL) }
|
1373
|
+
@includes.each {|system| system.scope.fill_low(scopeL) }
|
1289
1374
|
# Adds the declared local system types.
|
1290
1375
|
# NOTE: in the current version of HDLRuby::High, there should not
|
1291
1376
|
# be any of them (only eigen systems are real system types).
|
@@ -2051,26 +2136,28 @@ module HDLRuby::High
|
|
2051
2136
|
# Performs the connections.
|
2052
2137
|
connects.each do |key,value|
|
2053
2138
|
# Gets the signal corresponding to connect.
|
2054
|
-
signal = self.get_signal(key)
|
2055
|
-
unless signal then
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
end
|
2139
|
+
# signal = self.get_signal(key)
|
2140
|
+
# unless signal then
|
2141
|
+
# # Look into the included systems.
|
2142
|
+
# self.systemT.scope.each_included do |included|
|
2143
|
+
# signal = included.get_signal(key)
|
2144
|
+
# break if signal
|
2145
|
+
# end
|
2146
|
+
# end
|
2147
|
+
signal = self.systemT.get_signal_with_included(key)
|
2062
2148
|
# Check if it is an output.
|
2063
|
-
isout = self.get_output(key)
|
2064
|
-
unless isout then
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
end
|
2149
|
+
# isout = self.get_output(key)
|
2150
|
+
# unless isout then
|
2151
|
+
# # Look into the inlucded systems.
|
2152
|
+
# self.systemT.scope.each_included do |included|
|
2153
|
+
# isout = included.get_output(key)
|
2154
|
+
# break if isout
|
2155
|
+
# end
|
2156
|
+
# end
|
2157
|
+
isout = self.systemT.get_output_with_included(key)
|
2071
2158
|
# Convert it to a reference.
|
2159
|
+
# puts "key=#{key} value=#{value} signal=#{signal}"
|
2072
2160
|
ref = RefObject.new(self.to_ref,signal)
|
2073
|
-
# puts "key=#{key} value=#{value} signal=#{signal} ref=#{ref}"
|
2074
2161
|
# Make the connection.
|
2075
2162
|
if isout then
|
2076
2163
|
value <= ref
|
@@ -2119,6 +2206,54 @@ module HDLRuby::High
|
|
2119
2206
|
self.eigen_extend(@systemT.public_namespace)
|
2120
2207
|
end
|
2121
2208
|
|
2209
|
+
# Adds alternative system +systemT+
|
2210
|
+
def choice(configuration = {})
|
2211
|
+
# Process the argument.
|
2212
|
+
configuration.each do |k,v|
|
2213
|
+
k = k.to_sym
|
2214
|
+
unless v.is_a?(SystemT) then
|
2215
|
+
raise "Invalid class for a system type: #{v.class}"
|
2216
|
+
end
|
2217
|
+
# Create an eigen system.
|
2218
|
+
eigen = v.instantiate(HDLRuby.uniq_name(self.name)).systemT
|
2219
|
+
# Ensure its interface corresponds.
|
2220
|
+
my_signals = self.each_signal.to_a
|
2221
|
+
if (eigen.each_signal.with_index.find { |sig,i|
|
2222
|
+
!sig.eql?(my_signals[i])
|
2223
|
+
}) then
|
2224
|
+
raise "Invalid system for configuration: #{systemT.name}."
|
2225
|
+
end
|
2226
|
+
# Add it.
|
2227
|
+
# At the HDLRuby::High level
|
2228
|
+
@choices = { self.name => self.systemT } unless @choices
|
2229
|
+
@choices[k] = eigen
|
2230
|
+
# At the HDLRuby::Low level
|
2231
|
+
self.add_systemT(eigen)
|
2232
|
+
end
|
2233
|
+
end
|
2234
|
+
|
2235
|
+
# (Re)Configuration of system instance to systemT designated by +sys+.
|
2236
|
+
# +sys+ may be the index or the name of the configuration, the first
|
2237
|
+
# configuration being named by the systemI name.
|
2238
|
+
def configure(sys)
|
2239
|
+
if sys.respond_to?(:to_i) then
|
2240
|
+
# The argument is an index.
|
2241
|
+
# Create the (re)configuration node.
|
2242
|
+
High.top_user.add_statement(
|
2243
|
+
Configure.new(RefObject.new(RefThis.new,self),sys.to_i))
|
2244
|
+
else
|
2245
|
+
# The argument is a name (should be).
|
2246
|
+
# Get the index corresponding to the name.
|
2247
|
+
num = @choices.find_index { |k,_| k == sys.to_sym }
|
2248
|
+
unless num then
|
2249
|
+
raise "Invalid name for configuration: #{sys.to_s}"
|
2250
|
+
end
|
2251
|
+
# Create the (re)configuration node.
|
2252
|
+
High.top_user.add_statement(
|
2253
|
+
Configure.new(RefObject.new(RefThis.new,self),num))
|
2254
|
+
end
|
2255
|
+
end
|
2256
|
+
|
2122
2257
|
# include Hmissing
|
2123
2258
|
|
2124
2259
|
# Missing methods are looked for in the public namespace of the
|
@@ -2155,8 +2290,11 @@ module HDLRuby::High
|
|
2155
2290
|
# systemIL.properties[:low2high] = self.hdr_id
|
2156
2291
|
# self.properties[:high2low] = systemIL
|
2157
2292
|
# Adds the other systemTs.
|
2158
|
-
self.each_systemT do |
|
2159
|
-
|
2293
|
+
self.each_systemT do |systemTc|
|
2294
|
+
if systemTc != self.systemT
|
2295
|
+
systemTcL = systemTc.to_low
|
2296
|
+
systemIL.add_systemT(systemTcL)
|
2297
|
+
end
|
2160
2298
|
end
|
2161
2299
|
return systemIL
|
2162
2300
|
end
|
@@ -2433,6 +2571,18 @@ module HDLRuby::High
|
|
2433
2571
|
end
|
2434
2572
|
end
|
2435
2573
|
|
2574
|
+
##
|
2575
|
+
# Describes a timed terminate statement: not synthesizable!
|
2576
|
+
class TimeTerminate < Low::TimeTerminate
|
2577
|
+
include HStatement
|
2578
|
+
|
2579
|
+
# Converts the repeat statement to HDLRuby::Low.
|
2580
|
+
def to_low
|
2581
|
+
return HDLRuby::Low::TimeTerminate.new
|
2582
|
+
end
|
2583
|
+
end
|
2584
|
+
|
2585
|
+
|
2436
2586
|
|
2437
2587
|
##
|
2438
2588
|
# Module giving high-level expression properties
|
@@ -3072,7 +3222,8 @@ module HDLRuby::High
|
|
3072
3222
|
|
3073
3223
|
# Converts the name reference to a HDLRuby::Low::RefName.
|
3074
3224
|
def to_low
|
3075
|
-
# puts "to_low with base=#{@base} @object=#{@object
|
3225
|
+
# puts "to_low with base=#{@base} @object=#{@object}"
|
3226
|
+
# puts "@object.name=#{@object.name}"
|
3076
3227
|
refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
|
3077
3228
|
@base.to_ref.to_low,@object.name)
|
3078
3229
|
# # For debugging: set the source high object
|
@@ -3369,6 +3520,27 @@ module HDLRuby::High
|
|
3369
3520
|
end
|
3370
3521
|
|
3371
3522
|
|
3523
|
+
##
|
3524
|
+
# Describes a systemI (re)configure statement: not synthesizable!
|
3525
|
+
class Configure < Low::Configure
|
3526
|
+
High = HDLRuby::High
|
3527
|
+
|
3528
|
+
include HStatement
|
3529
|
+
|
3530
|
+
# Creates a new (re)configure statement for system instance refered
|
3531
|
+
# by +ref+ with system number +num+.
|
3532
|
+
def initialize(ref,num)
|
3533
|
+
super(ref,num)
|
3534
|
+
end
|
3535
|
+
|
3536
|
+
# Converts the connection to HDLRuby::Low.
|
3537
|
+
def to_low
|
3538
|
+
return HDLRuby::Low::Configure.new(self.ref.to_low, self.index)
|
3539
|
+
end
|
3540
|
+
|
3541
|
+
end
|
3542
|
+
|
3543
|
+
|
3372
3544
|
##
|
3373
3545
|
# Describes a connection.
|
3374
3546
|
class Connection < Low::Connection
|
@@ -3802,6 +3974,11 @@ module HDLRuby::High
|
|
3802
3974
|
def hprint(*args)
|
3803
3975
|
self.add_statement(Print.new(*args))
|
3804
3976
|
end
|
3977
|
+
|
3978
|
+
# Terminate the simulation.
|
3979
|
+
def terminate
|
3980
|
+
self.add_statement(TimeTerminate.new)
|
3981
|
+
end
|
3805
3982
|
end
|
3806
3983
|
|
3807
3984
|
|
data/lib/HDLRuby/hruby_low.rb
CHANGED
@@ -164,12 +164,27 @@ module HDLRuby::Low
|
|
164
164
|
end
|
165
165
|
|
166
166
|
|
167
|
+
# Handling the (re)configuration.
|
168
|
+
|
169
|
+
# Gets the configuration wrapper if any.
|
170
|
+
def wrapper
|
171
|
+
return defined? @wrapper ? @wrapper : nil
|
172
|
+
end
|
173
|
+
|
174
|
+
# Sets the configuration wrapper to +systemT+.
|
175
|
+
def wrapper=(systemT)
|
176
|
+
unless systemT.is_a?(SystemT) then
|
177
|
+
raise "Invalid class for a wrapper system type: #{systemT}."
|
178
|
+
end
|
179
|
+
@wrapper = systemT
|
180
|
+
end
|
181
|
+
|
167
182
|
|
168
183
|
# Handling the signals.
|
169
184
|
|
170
185
|
# Adds input +signal+.
|
171
186
|
def add_input(signal)
|
172
|
-
# print "add_input with signal: #{signal.name}\n"
|
187
|
+
# print "In #{self} add_input with signal: #{signal.name}\n"
|
173
188
|
# Check and add the signal.
|
174
189
|
unless signal.is_a?(SignalI)
|
175
190
|
raise AnyError,
|
@@ -274,6 +289,8 @@ module HDLRuby::Low
|
|
274
289
|
@inputs.each(&ruby_block)
|
275
290
|
@outputs.each(&ruby_block)
|
276
291
|
@inouts.each(&ruby_block)
|
292
|
+
# And each signal of the direct scope.
|
293
|
+
@scope.each_signal(&ruby_block)
|
277
294
|
end
|
278
295
|
|
279
296
|
# Iterates over all the signals of the system type and its scope.
|
@@ -282,7 +299,8 @@ module HDLRuby::Low
|
|
282
299
|
return to_enum(:each_signal_deep) unless ruby_block
|
283
300
|
# A ruby block?
|
284
301
|
# First iterate over the current system type's signals.
|
285
|
-
self.each_signal_all(&ruby_block)
|
302
|
+
# self.each_signal_all(&ruby_block)
|
303
|
+
self.each_signal(&ruby_block)
|
286
304
|
# Then apply on the behaviors (since in HDLRuby:High, blocks can
|
287
305
|
# include signals).
|
288
306
|
@scope.each_signal_deep(&ruby_block)
|
@@ -432,6 +450,27 @@ module HDLRuby::Low
|
|
432
450
|
end
|
433
451
|
end
|
434
452
|
end
|
453
|
+
|
454
|
+
# Iterates over the systemT deeply if any in order of reference
|
455
|
+
# to ensure the refered elements are processed first.
|
456
|
+
#
|
457
|
+
# Returns an enumerator if no ruby block is given.
|
458
|
+
def each_systemT_deep_ref(&ruby_block)
|
459
|
+
# No ruby block? Return an enumerator.
|
460
|
+
return to_enum(:each_systemT_deep_ref) unless ruby_block
|
461
|
+
# A ruby block?
|
462
|
+
# Recurse on the systemT accessible through the instances.
|
463
|
+
self.scope.each_scope_deep do |scope|
|
464
|
+
scope.each_systemI do |systemI|
|
465
|
+
# systemI.systemT.each_systemT_deep(&ruby_block)
|
466
|
+
systemI.each_systemT do |systemT|
|
467
|
+
systemT.each_systemT_deep_ref(&ruby_block)
|
468
|
+
end
|
469
|
+
end
|
470
|
+
end
|
471
|
+
# Finally apply it to current.
|
472
|
+
ruby_block.call(self)
|
473
|
+
end
|
435
474
|
end
|
436
475
|
|
437
476
|
|
@@ -2500,8 +2539,8 @@ module HDLRuby::Low
|
|
2500
2539
|
# NOTE: an instance can actually represented muliple layers
|
2501
2540
|
# of systems, the first one being the one actually instantiated
|
2502
2541
|
# in the final RTL code.
|
2503
|
-
# This
|
2504
|
-
#
|
2542
|
+
# This layering can be used for describing software or partial
|
2543
|
+
# (re)configuration.
|
2505
2544
|
class SystemI
|
2506
2545
|
|
2507
2546
|
include Hparent
|
@@ -2564,13 +2603,16 @@ module HDLRuby::Low
|
|
2564
2603
|
@name = name.to_sym
|
2565
2604
|
end
|
2566
2605
|
|
2567
|
-
## Adds a system
|
2606
|
+
## Adds a system configuration.
|
2568
2607
|
def add_systemT(systemT)
|
2569
2608
|
# puts "add_systemT #{systemT.name} to systemI #{self.name}"
|
2570
2609
|
# Check and add the systemT.
|
2571
2610
|
if !systemT.is_a?(SystemT) then
|
2572
2611
|
raise AnyError, "Invalid class for a system type: #{systemT.class}"
|
2573
2612
|
end
|
2613
|
+
# Set the base configuration of the added system.
|
2614
|
+
systemT.wrapper = self.systemT
|
2615
|
+
# Add it.
|
2574
2616
|
@systemTs << systemT
|
2575
2617
|
end
|
2576
2618
|
|
@@ -3781,6 +3823,93 @@ module HDLRuby::Low
|
|
3781
3823
|
end
|
3782
3824
|
end
|
3783
3825
|
end
|
3826
|
+
end
|
3827
|
+
|
3828
|
+
|
3829
|
+
##
|
3830
|
+
# Describes a system instance (re)configuration statement: not synthesizable!
|
3831
|
+
class Configure < Statement
|
3832
|
+
|
3833
|
+
# attr_reader :systemI, :systemT, :index
|
3834
|
+
attr_reader :ref, :index
|
3835
|
+
|
3836
|
+
# Creates a new (re)configure statement of system instance refered by
|
3837
|
+
# +ref+ with system number +index+
|
3838
|
+
def initialize(ref,index)
|
3839
|
+
super()
|
3840
|
+
# Process the arguments.
|
3841
|
+
index = index.to_i
|
3842
|
+
unless ref.is_a?(Ref) then
|
3843
|
+
raise "Invalid class for a reference: #{ref.class}."
|
3844
|
+
end
|
3845
|
+
# Sets the arguments.
|
3846
|
+
@ref = ref
|
3847
|
+
ref.parent = self
|
3848
|
+
@index = index
|
3849
|
+
# @systemT = systemI.each_systemT.to_a[index]
|
3850
|
+
# # Check the systemT is valid.
|
3851
|
+
# unless @systemT then
|
3852
|
+
# raise "Invalid configuration index: #{index}."
|
3853
|
+
# end
|
3854
|
+
end
|
3855
|
+
|
3856
|
+
# Comparison for hash: structural comparison.
|
3857
|
+
def eql?(obj)
|
3858
|
+
return false unless obj.is_a?(Configure)
|
3859
|
+
return false unless @ref.eql?(obj.ref)
|
3860
|
+
return false unless @index.eql?(obj.index)
|
3861
|
+
return true
|
3862
|
+
end
|
3863
|
+
|
3864
|
+
# Iterates over each object deeply.
|
3865
|
+
#
|
3866
|
+
# Returns an enumerator if no ruby block is given.
|
3867
|
+
def each_deep(&ruby_block)
|
3868
|
+
# No ruby block? Return an enumerator.
|
3869
|
+
return to_enum(:each_deep) unless ruby_block
|
3870
|
+
# A ruby block? First apply it to current.
|
3871
|
+
ruby_block.call(self)
|
3872
|
+
# Then apply on the reference.
|
3873
|
+
@ref.each_deep(&ruby_block)
|
3874
|
+
end
|
3875
|
+
|
3876
|
+
# Hash function.
|
3877
|
+
def hash
|
3878
|
+
return (@ref.hash + @index.hash).hash
|
3879
|
+
end
|
3880
|
+
|
3881
|
+
# Clones (deeply)
|
3882
|
+
def clone
|
3883
|
+
return Configure.new(@ref.clone,@index)
|
3884
|
+
end
|
3885
|
+
|
3886
|
+
# Iterates over the nodes deeply if any.
|
3887
|
+
def each_node_deep(&ruby_block)
|
3888
|
+
# No ruby block? Return an enumerator.
|
3889
|
+
return to_enum(:each_node_deep) unless ruby_block
|
3890
|
+
# A ruby block? First apply it to current.
|
3891
|
+
ruby_block.call(self)
|
3892
|
+
# And recurse on the reference.
|
3893
|
+
@ref.each_node_deep(&ruby_block)
|
3894
|
+
end
|
3895
|
+
|
3896
|
+
# Iterates over all the blocks contained in the current block.
|
3897
|
+
def each_block_deep(&ruby_block)
|
3898
|
+
# No ruby block? Return an enumerator.
|
3899
|
+
return to_enum(:each_block_deep) unless ruby_block
|
3900
|
+
# A ruby block?
|
3901
|
+
# Nothing more to do anyway.
|
3902
|
+
end
|
3903
|
+
|
3904
|
+
# Iterates over all the statements contained in the current block.
|
3905
|
+
def each_statement_deep(&ruby_block)
|
3906
|
+
# No ruby block? Return an enumerator.
|
3907
|
+
return to_enum(:each_statement_deep) unless ruby_block
|
3908
|
+
# A ruby block?
|
3909
|
+
# Apply it on self.
|
3910
|
+
ruby_block.call(self)
|
3911
|
+
# And that's all.
|
3912
|
+
end
|
3784
3913
|
|
3785
3914
|
end
|
3786
3915
|
|
@@ -3989,6 +4118,82 @@ module HDLRuby::Low
|
|
3989
4118
|
end
|
3990
4119
|
|
3991
4120
|
|
4121
|
+
##
|
4122
|
+
# Describes a timed terminate statement: not synthesizable!
|
4123
|
+
class TimeTerminate < Statement
|
4124
|
+
|
4125
|
+
# Creates a new timed terminate statement that terminate execution.
|
4126
|
+
def initialize
|
4127
|
+
super()
|
4128
|
+
end
|
4129
|
+
|
4130
|
+
# Iterates over each object deeply.
|
4131
|
+
#
|
4132
|
+
# Returns an enumerator if no ruby block is given.
|
4133
|
+
def each_deep(&ruby_block)
|
4134
|
+
# No ruby block? Return an enumerator.
|
4135
|
+
return to_enum(:each_deep) unless ruby_block
|
4136
|
+
# A ruby block? First apply it to current.
|
4137
|
+
ruby_block.call(self)
|
4138
|
+
# And that's all.
|
4139
|
+
end
|
4140
|
+
|
4141
|
+
# Iterates over all the nodes.
|
4142
|
+
def each_node(&ruby_block)
|
4143
|
+
# No ruby block? Return an enumerator.
|
4144
|
+
return to_enum(:each_node) unless ruby_block
|
4145
|
+
# A ruby block?
|
4146
|
+
# Nothing to do anyway.
|
4147
|
+
end
|
4148
|
+
|
4149
|
+
# Iterates over all the nodes deeply.
|
4150
|
+
def each_node_deep(&ruby_block)
|
4151
|
+
# No ruby block? Return an enumerator.
|
4152
|
+
return to_enum(:each_node_deep) unless ruby_block
|
4153
|
+
# A ruby block?
|
4154
|
+
# Apply of current node.
|
4155
|
+
ruby_block.call(self)
|
4156
|
+
# And that's all.
|
4157
|
+
end
|
4158
|
+
|
4159
|
+
# Iterates over all the statements deeply.
|
4160
|
+
def each_statement_deep(&ruby_block)
|
4161
|
+
# No ruby block? Return an enumerator.
|
4162
|
+
return to_enum(:each_statement_deep) unless ruby_block
|
4163
|
+
# A ruby block?
|
4164
|
+
# Apply of current node.
|
4165
|
+
ruby_block.call(self)
|
4166
|
+
# And that's all.
|
4167
|
+
end
|
4168
|
+
|
4169
|
+
# Iterates over all the blocks contained in the current block.
|
4170
|
+
def each_block_deep(&ruby_block)
|
4171
|
+
# No ruby block? Return an enumerator.
|
4172
|
+
return to_enum(:each_block_deep) unless ruby_block
|
4173
|
+
# A ruby block?
|
4174
|
+
# Nothing to do anyway.
|
4175
|
+
end
|
4176
|
+
|
4177
|
+
# Comparison for hash: structural comparison.
|
4178
|
+
def eql?(obj)
|
4179
|
+
return false unless obj.is_a?(TimeTerminate)
|
4180
|
+
return true
|
4181
|
+
end
|
4182
|
+
|
4183
|
+
# Hash function.
|
4184
|
+
def hash
|
4185
|
+
return TimeTerminate.hash
|
4186
|
+
end
|
4187
|
+
|
4188
|
+
# Clones the TimeRepeat (deeply)
|
4189
|
+
def clone
|
4190
|
+
return TimeTerminate.new
|
4191
|
+
end
|
4192
|
+
end
|
4193
|
+
|
4194
|
+
|
4195
|
+
|
4196
|
+
|
3992
4197
|
##
|
3993
4198
|
# Describes a block.
|
3994
4199
|
class Block < Statement
|