HDLRuby 2.7.1 → 2.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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/case_bench.rb +23 -18
- data/lib/HDLRuby/hdr_samples/dff_unit.rb +1 -1
- data/lib/HDLRuby/hdr_samples/parseq_bench.rb +61 -0
- data/lib/HDLRuby/hdr_samples/range_bench.rb +4 -1
- data/lib/HDLRuby/hdr_samples/rom_nest.rb +27 -0
- data/lib/HDLRuby/hdr_samples/with_channel_other.rb +128 -0
- data/lib/HDLRuby/hdr_samples/with_def.rb +29 -0
- data/lib/HDLRuby/hdr_samples/with_init.rb +18 -0
- data/lib/HDLRuby/hdr_samples/with_instance.rb +42 -0
- data/lib/HDLRuby/hdr_samples/with_reconf.rb +75 -67
- data/lib/HDLRuby/hdr_samples/with_terminate.rb +32 -0
- data/lib/HDLRuby/hdr_samples/with_values.rb +3 -0
- data/lib/HDLRuby/hdrcc.rb +8 -1
- data/lib/HDLRuby/hruby_high.rb +178 -29
- data/lib/HDLRuby/hruby_low.rb +210 -4
- data/lib/HDLRuby/hruby_low2c.rb +186 -71
- 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 +30 -1
- data/lib/HDLRuby/hruby_low_without_select.rb +11 -1
- data/lib/HDLRuby/hruby_tools.rb +1 -0
- data/lib/HDLRuby/hruby_verilog.rb +9 -1
- data/lib/HDLRuby/sim/hruby_sim.h +26 -1
- data/lib/HDLRuby/sim/hruby_sim_core.c +65 -8
- data/lib/HDLRuby/sim/hruby_sim_stack_calc.c +11 -0
- data/lib/HDLRuby/sim/hruby_sim_vcd.c +1 -1
- data/lib/HDLRuby/std/reconf.rb +3 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +10 -2
data/lib/HDLRuby/hdrcc.rb
CHANGED
@@ -647,12 +647,19 @@ elsif $options[:clang] then
|
|
647
647
|
init_visualizer = $options[:vcd] ? "init_vcd_visualizer" :
|
648
648
|
"init_default_visualizer"
|
649
649
|
|
650
|
+
# Gather the system to generate and sort them in the right order
|
651
|
+
# to ensure references are generated before being used.
|
652
|
+
# Base: reverse order of the tree.
|
653
|
+
# Then, multiple configuration of a system instance must be
|
654
|
+
# reverversed so that the base configuration is generated first.
|
655
|
+
c_systems = $top_system.each_systemT_deep_ref
|
650
656
|
# Generate the code of the main function.
|
651
657
|
# HDLRuby start code
|
652
658
|
$main << HDLRuby::Low::Low2C.main("hruby_simulator",
|
653
659
|
init_visualizer,
|
654
660
|
$top_system,
|
655
|
-
|
661
|
+
c_systems,
|
662
|
+
$hnames)
|
656
663
|
$main.close
|
657
664
|
|
658
665
|
$top_system.each_systemT_deep do |systemT|
|
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -133,6 +133,8 @@ module HDLRuby::High
|
|
133
133
|
module Hmissing
|
134
134
|
High = HDLRuby::High
|
135
135
|
|
136
|
+
NAMES = { }
|
137
|
+
|
136
138
|
# Missing methods may be immediate values, if not, they are looked up
|
137
139
|
# in the upper level of the namespace if any.
|
138
140
|
def method_missing(m, *args, &ruby_block)
|
@@ -140,6 +142,20 @@ module HDLRuby::High
|
|
140
142
|
# Is the missing method an immediate value?
|
141
143
|
value = m.to_value
|
142
144
|
return value if value and args.empty?
|
145
|
+
# Or is it a uniq name generator?
|
146
|
+
if (m[-1] == '?') then
|
147
|
+
# Yes
|
148
|
+
m = m[0..-2]
|
149
|
+
return NAMES[m] = HDLRuby.uniq_name(m)
|
150
|
+
end
|
151
|
+
# Is in a previous uniq name?
|
152
|
+
if (m[-1] == '!') then
|
153
|
+
pm = m[0..-2]
|
154
|
+
if NAMES.key?(pm) then
|
155
|
+
# Yes, returns the current corresponding uniq name.
|
156
|
+
return self.send(NAMES[pm],*args,&ruby_block)
|
157
|
+
end
|
158
|
+
end
|
143
159
|
# No, is there an upper namespace, i.e. is the current object
|
144
160
|
# present in the space?
|
145
161
|
if High.space_index(self) then
|
@@ -256,9 +272,9 @@ module HDLRuby::High
|
|
256
272
|
SignalI.new(name,type,:inner))
|
257
273
|
elsif name.is_a?(Hash) then
|
258
274
|
# Names associated with values.
|
259
|
-
|
275
|
+
name.each do |key,value|
|
260
276
|
res = self.add_inner(
|
261
|
-
SignalI.new(
|
277
|
+
SignalI.new(key,type,:inner,value))
|
262
278
|
end
|
263
279
|
else
|
264
280
|
raise AnyError,
|
@@ -550,10 +566,14 @@ module HDLRuby::High
|
|
550
566
|
expanded = self.class.new(name.to_s) {}
|
551
567
|
# Include the mixin systems given when declaring the system.
|
552
568
|
@to_includes.each { |system| expanded.scope.include(system) }
|
569
|
+
# Include the previously includeds. */
|
570
|
+
self.scope.each_included { |system| expanded.scope.include(system) }
|
553
571
|
|
554
572
|
# Sets the generators of the expanded result.
|
555
573
|
expanded.add_generator(self)
|
556
574
|
@to_includes.each { |system| expanded.add_generator(system) }
|
575
|
+
# Also for the previously includeds. */
|
576
|
+
self.scope.each_included.each { |system| expanded.add_generator(system) }
|
557
577
|
|
558
578
|
# Fills the scope of the expanded class.
|
559
579
|
# puts "Build top with #{self.name} for #{name}"
|
@@ -828,8 +848,7 @@ module HDLRuby::High
|
|
828
848
|
# Initialize the set of included systems.
|
829
849
|
@includes = {}
|
830
850
|
|
831
|
-
# Builds the scope if a ruby block is provided
|
832
|
-
# (which means the scope is not the top of a system).
|
851
|
+
# Builds the scope if a ruby block is provided.
|
833
852
|
self.build(&ruby_block) if block_given?
|
834
853
|
end
|
835
854
|
|
@@ -940,18 +959,20 @@ module HDLRuby::High
|
|
940
959
|
# Set the namespace for buidling the scope.
|
941
960
|
High.space_push(@namespace)
|
942
961
|
# Build the scope.
|
943
|
-
|
944
|
-
res = High.top_user.instance_eval(&ruby_block)
|
962
|
+
@return_value = High.top_user.instance_eval(&ruby_block)
|
963
|
+
# res = High.top_user.instance_eval(&ruby_block)
|
945
964
|
High.space_pop
|
946
|
-
# Now gain access to the result within the sub scope.
|
947
|
-
if (res.is_a?(HRef)) then
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
965
|
+
# # Now gain access to the result within the sub scope.
|
966
|
+
# # if (res.is_a?(HRef)) then
|
967
|
+
# if (res.is_a?(HExpression)) then
|
968
|
+
# High.space_push(@namespace)
|
969
|
+
# @return_value = res.type.inner(HDLRuby.uniq_name)
|
970
|
+
# @return_value <= res
|
971
|
+
# High.space_pop
|
972
|
+
# @return_value = RefObject.new(self,@return_value)
|
973
|
+
# else
|
974
|
+
# @return_value = res
|
975
|
+
# end
|
955
976
|
# This will be the return value.
|
956
977
|
@return_value
|
957
978
|
end
|
@@ -1083,10 +1104,12 @@ module HDLRuby::High
|
|
1083
1104
|
# Declares a sub scope with possible +name+ and built from +ruby_block+.
|
1084
1105
|
def sub(name = :"", &ruby_block)
|
1085
1106
|
# Creates the new scope.
|
1086
|
-
scope = Scope.new(name,&ruby_block)
|
1087
|
-
|
1107
|
+
# scope = Scope.new(name,&ruby_block)
|
1108
|
+
scope = Scope.new(name)
|
1088
1109
|
# Add it
|
1089
1110
|
self.add_scope(scope)
|
1111
|
+
# Build it.
|
1112
|
+
scope.build(&ruby_block)
|
1090
1113
|
# puts "self=#{self}"
|
1091
1114
|
# puts "self scopes=#{self.each_scope.to_a.join(",")}"
|
1092
1115
|
# Use its return value
|
@@ -1237,6 +1260,7 @@ module HDLRuby::High
|
|
1237
1260
|
end
|
1238
1261
|
# Adds it the list of includeds
|
1239
1262
|
@includes[include_name] = system
|
1263
|
+
# puts "@includes=#{@includes}"
|
1240
1264
|
|
1241
1265
|
end
|
1242
1266
|
|
@@ -1960,9 +1984,6 @@ module HDLRuby::High
|
|
1960
1984
|
&ruby_block)
|
1961
1985
|
# ruby_block.call(*args)
|
1962
1986
|
end
|
1963
|
-
# sub do
|
1964
|
-
# ruby_block.call(*args,*other_block)
|
1965
|
-
# end
|
1966
1987
|
end
|
1967
1988
|
else
|
1968
1989
|
define_method(name.to_sym) do |*args,&other_block|
|
@@ -1970,10 +1991,8 @@ module HDLRuby::High
|
|
1970
1991
|
sub(HDLRuby.uniq_name(name)) do
|
1971
1992
|
HDLRuby::High.top_user.instance_exec(*args,*other_block,
|
1972
1993
|
&ruby_block)
|
1994
|
+
# ruby_block.call(*args,*other_block)
|
1973
1995
|
end
|
1974
|
-
# sub do
|
1975
|
-
# ruby_block.call(*args,*other_block)
|
1976
|
-
# end
|
1977
1996
|
end
|
1978
1997
|
end
|
1979
1998
|
end
|
@@ -2033,10 +2052,25 @@ module HDLRuby::High
|
|
2033
2052
|
connects.each do |key,value|
|
2034
2053
|
# Gets the signal corresponding to connect.
|
2035
2054
|
signal = self.get_signal(key)
|
2055
|
+
unless signal then
|
2056
|
+
# Look into the included systems.
|
2057
|
+
self.systemT.scope.each_included do |included|
|
2058
|
+
signal = included.get_signal(key)
|
2059
|
+
break if signal
|
2060
|
+
end
|
2061
|
+
end
|
2036
2062
|
# Check if it is an output.
|
2037
2063
|
isout = self.get_output(key)
|
2064
|
+
unless isout then
|
2065
|
+
# Look into the inlucded systems.
|
2066
|
+
self.systemT.scope.each_included do |included|
|
2067
|
+
isout = included.get_output(key)
|
2068
|
+
break if isout
|
2069
|
+
end
|
2070
|
+
end
|
2038
2071
|
# Convert it to a reference.
|
2039
2072
|
ref = RefObject.new(self.to_ref,signal)
|
2073
|
+
# puts "key=#{key} value=#{value} signal=#{signal} ref=#{ref}"
|
2040
2074
|
# Make the connection.
|
2041
2075
|
if isout then
|
2042
2076
|
value <= ref
|
@@ -2085,6 +2119,54 @@ module HDLRuby::High
|
|
2085
2119
|
self.eigen_extend(@systemT.public_namespace)
|
2086
2120
|
end
|
2087
2121
|
|
2122
|
+
# Adds alternative system +systemT+
|
2123
|
+
def choice(configuration = {})
|
2124
|
+
# Process the argument.
|
2125
|
+
configuration.each do |k,v|
|
2126
|
+
k = k.to_sym
|
2127
|
+
unless v.is_a?(SystemT) then
|
2128
|
+
raise "Invalid class for a system type: #{v.class}"
|
2129
|
+
end
|
2130
|
+
# Create an eigen system.
|
2131
|
+
eigen = v.instantiate(HDLRuby.uniq_name(self.name)).systemT
|
2132
|
+
# Ensure its interface corresponds.
|
2133
|
+
my_signals = self.each_signal.to_a
|
2134
|
+
if (eigen.each_signal.with_index.find { |sig,i|
|
2135
|
+
!sig.eql?(my_signals[i])
|
2136
|
+
}) then
|
2137
|
+
raise "Invalid system for configuration: #{systemT.name}."
|
2138
|
+
end
|
2139
|
+
# Add it.
|
2140
|
+
# At the HDLRuby::High level
|
2141
|
+
@choices = { self.name => self.systemT } unless @choices
|
2142
|
+
@choices[k] = eigen
|
2143
|
+
# At the HDLRuby::Low level
|
2144
|
+
self.add_systemT(eigen)
|
2145
|
+
end
|
2146
|
+
end
|
2147
|
+
|
2148
|
+
# (Re)Configuration of system instance to systemT designated by +sys+.
|
2149
|
+
# +sys+ may be the index or the name of the configuration, the first
|
2150
|
+
# configuration being named by the systemI name.
|
2151
|
+
def configure(sys)
|
2152
|
+
if sys.respond_to?(:to_i) then
|
2153
|
+
# The argument is an index.
|
2154
|
+
# Create the (re)configuration node.
|
2155
|
+
High.top_user.add_statement(
|
2156
|
+
Configure.new(RefObject.new(RefThis.new,self),sys.to_i))
|
2157
|
+
else
|
2158
|
+
# The argument is a name (should be).
|
2159
|
+
# Get the index corresponding to the name.
|
2160
|
+
num = @choices.find_index { |k,_| k == sys.to_sym }
|
2161
|
+
unless num then
|
2162
|
+
raise "Invalid name for configuration: #{sys.to_s}"
|
2163
|
+
end
|
2164
|
+
# Create the (re)configuration node.
|
2165
|
+
High.top_user.add_statement(
|
2166
|
+
Configure.new(RefObject.new(RefThis.new,self),num))
|
2167
|
+
end
|
2168
|
+
end
|
2169
|
+
|
2088
2170
|
# include Hmissing
|
2089
2171
|
|
2090
2172
|
# Missing methods are looked for in the public namespace of the
|
@@ -2121,8 +2203,11 @@ module HDLRuby::High
|
|
2121
2203
|
# systemIL.properties[:low2high] = self.hdr_id
|
2122
2204
|
# self.properties[:high2low] = systemIL
|
2123
2205
|
# Adds the other systemTs.
|
2124
|
-
self.each_systemT do |
|
2125
|
-
|
2206
|
+
self.each_systemT do |systemTc|
|
2207
|
+
if systemTc != self.systemT
|
2208
|
+
systemTcL = systemTc.to_low
|
2209
|
+
systemIL.add_systemT(systemTcL)
|
2210
|
+
end
|
2126
2211
|
end
|
2127
2212
|
return systemIL
|
2128
2213
|
end
|
@@ -2399,6 +2484,18 @@ module HDLRuby::High
|
|
2399
2484
|
end
|
2400
2485
|
end
|
2401
2486
|
|
2487
|
+
##
|
2488
|
+
# Describes a timed terminate statement: not synthesizable!
|
2489
|
+
class TimeTerminate < Low::TimeTerminate
|
2490
|
+
include HStatement
|
2491
|
+
|
2492
|
+
# Converts the repeat statement to HDLRuby::Low.
|
2493
|
+
def to_low
|
2494
|
+
return HDLRuby::Low::TimeTerminate.new
|
2495
|
+
end
|
2496
|
+
end
|
2497
|
+
|
2498
|
+
|
2402
2499
|
|
2403
2500
|
##
|
2404
2501
|
# Module giving high-level expression properties
|
@@ -2651,6 +2748,20 @@ module HDLRuby::High
|
|
2651
2748
|
#
|
2652
2749
|
# NOTE: +rng+ can be a single expression in which case it is an index.
|
2653
2750
|
def [](rng)
|
2751
|
+
if rng.is_a?(::Range) then
|
2752
|
+
first = rng.first
|
2753
|
+
if (first.is_a?(::Integer)) then
|
2754
|
+
first = self.type.size+first if first < 0
|
2755
|
+
end
|
2756
|
+
last = rng.last
|
2757
|
+
if (last.is_a?(::Integer)) then
|
2758
|
+
last = self.type.size+last if last < 0
|
2759
|
+
end
|
2760
|
+
rng = first..last
|
2761
|
+
end
|
2762
|
+
if rng.is_a?(::Integer) && rng < 0 then
|
2763
|
+
rng = self.type.size+rng
|
2764
|
+
end
|
2654
2765
|
if rng.respond_to?(:to_expr) then
|
2655
2766
|
# Number range: convert it to an expression.
|
2656
2767
|
rng = rng.to_expr
|
@@ -2987,6 +3098,7 @@ module HDLRuby::High
|
|
2987
3098
|
|
2988
3099
|
# Creates a new reference from a +base+ reference and named +object+.
|
2989
3100
|
def initialize(base,object)
|
3101
|
+
# puts "New RefObjet with base=#{base}, object=#{object.name}"
|
2990
3102
|
if object.respond_to?(:type) then
|
2991
3103
|
# Typed object, so typed reference.
|
2992
3104
|
super(object.type)
|
@@ -3023,7 +3135,7 @@ module HDLRuby::High
|
|
3023
3135
|
|
3024
3136
|
# Converts the name reference to a HDLRuby::Low::RefName.
|
3025
3137
|
def to_low
|
3026
|
-
# puts "to_low with base=#{@base} @object=#{@object}"
|
3138
|
+
# puts "to_low with base=#{@base} @object=#{@object.name}"
|
3027
3139
|
refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
|
3028
3140
|
@base.to_ref.to_low,@object.name)
|
3029
3141
|
# # For debugging: set the source high object
|
@@ -3081,7 +3193,8 @@ module HDLRuby::High
|
|
3081
3193
|
# Converts to a new reference.
|
3082
3194
|
def to_ref
|
3083
3195
|
return RefIndex.new(self.type,
|
3084
|
-
self.ref.to_ref,self.index.to_expr)
|
3196
|
+
# self.ref.to_ref,self.index.to_expr)
|
3197
|
+
self.ref.to_expr,self.index.to_expr)
|
3085
3198
|
end
|
3086
3199
|
|
3087
3200
|
# Converts the index reference to HDLRuby::Low.
|
@@ -3319,6 +3432,27 @@ module HDLRuby::High
|
|
3319
3432
|
end
|
3320
3433
|
|
3321
3434
|
|
3435
|
+
##
|
3436
|
+
# Describes a systemI (re)configure statement: not synthesizable!
|
3437
|
+
class Configure < Low::Configure
|
3438
|
+
High = HDLRuby::High
|
3439
|
+
|
3440
|
+
include HStatement
|
3441
|
+
|
3442
|
+
# Creates a new (re)configure statement for system instance refered
|
3443
|
+
# by +ref+ with system number +num+.
|
3444
|
+
def initialize(ref,num)
|
3445
|
+
super(ref,num)
|
3446
|
+
end
|
3447
|
+
|
3448
|
+
# Converts the connection to HDLRuby::Low.
|
3449
|
+
def to_low
|
3450
|
+
return HDLRuby::Low::Configure.new(self.ref.to_low, self.index)
|
3451
|
+
end
|
3452
|
+
|
3453
|
+
end
|
3454
|
+
|
3455
|
+
|
3322
3456
|
##
|
3323
3457
|
# Describes a connection.
|
3324
3458
|
class Connection < Low::Connection
|
@@ -3496,7 +3630,8 @@ module HDLRuby::High
|
|
3496
3630
|
# Converts the system to HDLRuby::Low and set its +name+.
|
3497
3631
|
def to_low(name = self.name)
|
3498
3632
|
# return HDLRuby::Low::SignalI.new(name,self.type.to_low)
|
3499
|
-
|
3633
|
+
valueL = self.value ? self.value.to_low : nil
|
3634
|
+
signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low,valueL)
|
3500
3635
|
# # For debugging: set the source high object
|
3501
3636
|
# signalIL.properties[:low2high] = self.hdr_id
|
3502
3637
|
# self.properties[:high2low] = signalIL
|
@@ -3586,6 +3721,15 @@ module HDLRuby::High
|
|
3586
3721
|
High.space_push(@namespace)
|
3587
3722
|
@return_value = High.top_user.instance_eval(&ruby_block)
|
3588
3723
|
High.space_pop
|
3724
|
+
# if @return_value.is_a?(HExpression) then
|
3725
|
+
# res = @return_value
|
3726
|
+
# High.space_push(@namespace)
|
3727
|
+
# @return_value = res.type.inner(HDLRuby.uniq_name)
|
3728
|
+
# puts "@return_value name=#{@return_value.name}"
|
3729
|
+
# @return_value <= res
|
3730
|
+
# High.space_pop
|
3731
|
+
# @return_value = RefObject.new(self,@return_value)
|
3732
|
+
# end
|
3589
3733
|
@return_value
|
3590
3734
|
end
|
3591
3735
|
|
@@ -3742,6 +3886,11 @@ module HDLRuby::High
|
|
3742
3886
|
def hprint(*args)
|
3743
3887
|
self.add_statement(Print.new(*args))
|
3744
3888
|
end
|
3889
|
+
|
3890
|
+
# Terminate the simulation.
|
3891
|
+
def terminate
|
3892
|
+
self.add_statement(TimeTerminate.new)
|
3893
|
+
end
|
3745
3894
|
end
|
3746
3895
|
|
3747
3896
|
|
@@ -3775,7 +3924,7 @@ module HDLRuby::High
|
|
3775
3924
|
# Converts the block to HDLRuby::Low.
|
3776
3925
|
def to_low
|
3777
3926
|
# Create the resulting block
|
3778
|
-
blockL = HDLRuby::Low::Block.new(self.mode)
|
3927
|
+
blockL = HDLRuby::Low::Block.new(self.mode,self.name)
|
3779
3928
|
# # For debugging: set the source high object
|
3780
3929
|
# blockL.properties[:low2high] = self.hdr_id
|
3781
3930
|
# self.properties[:high2low] = blockL
|
data/lib/HDLRuby/hruby_low.rb
CHANGED
@@ -165,6 +165,22 @@ module HDLRuby::Low
|
|
165
165
|
|
166
166
|
|
167
167
|
|
168
|
+
# Handling the (re)configuration.
|
169
|
+
|
170
|
+
# Gets the configuration wrapper if any.
|
171
|
+
def wrapper
|
172
|
+
return defined? @wrapper ? @wrapper : nil
|
173
|
+
end
|
174
|
+
|
175
|
+
# Sets the configuration wrapper to +systemT+.
|
176
|
+
def wrapper=(systemT)
|
177
|
+
unless systemT.is_a?(SystemT) then
|
178
|
+
raise "Invalid class for a wrapper system type: #{systemT}."
|
179
|
+
end
|
180
|
+
@wrapper = systemT
|
181
|
+
end
|
182
|
+
|
183
|
+
|
168
184
|
# Handling the signals.
|
169
185
|
|
170
186
|
# Adds input +signal+.
|
@@ -432,6 +448,27 @@ module HDLRuby::Low
|
|
432
448
|
end
|
433
449
|
end
|
434
450
|
end
|
451
|
+
|
452
|
+
# Iterates over the systemT deeply if any in order of reference
|
453
|
+
# to ensure the refered elements are processed first.
|
454
|
+
#
|
455
|
+
# Returns an enumerator if no ruby block is given.
|
456
|
+
def each_systemT_deep_ref(&ruby_block)
|
457
|
+
# No ruby block? Return an enumerator.
|
458
|
+
return to_enum(:each_systemT_deep_ref) unless ruby_block
|
459
|
+
# A ruby block?
|
460
|
+
# Recurse on the systemT accessible through the instances.
|
461
|
+
self.scope.each_scope_deep do |scope|
|
462
|
+
scope.each_systemI do |systemI|
|
463
|
+
# systemI.systemT.each_systemT_deep(&ruby_block)
|
464
|
+
systemI.each_systemT do |systemT|
|
465
|
+
systemT.each_systemT_deep_ref(&ruby_block)
|
466
|
+
end
|
467
|
+
end
|
468
|
+
end
|
469
|
+
# Finally apply it to current.
|
470
|
+
ruby_block.call(self)
|
471
|
+
end
|
435
472
|
end
|
436
473
|
|
437
474
|
|
@@ -2500,8 +2537,8 @@ module HDLRuby::Low
|
|
2500
2537
|
# NOTE: an instance can actually represented muliple layers
|
2501
2538
|
# of systems, the first one being the one actually instantiated
|
2502
2539
|
# in the final RTL code.
|
2503
|
-
# This
|
2504
|
-
#
|
2540
|
+
# This layering can be used for describing software or partial
|
2541
|
+
# (re)configuration.
|
2505
2542
|
class SystemI
|
2506
2543
|
|
2507
2544
|
include Hparent
|
@@ -2564,13 +2601,16 @@ module HDLRuby::Low
|
|
2564
2601
|
@name = name.to_sym
|
2565
2602
|
end
|
2566
2603
|
|
2567
|
-
## Adds a system
|
2604
|
+
## Adds a system configuration.
|
2568
2605
|
def add_systemT(systemT)
|
2569
2606
|
# puts "add_systemT #{systemT.name} to systemI #{self.name}"
|
2570
2607
|
# Check and add the systemT.
|
2571
2608
|
if !systemT.is_a?(SystemT) then
|
2572
2609
|
raise AnyError, "Invalid class for a system type: #{systemT.class}"
|
2573
2610
|
end
|
2611
|
+
# Set the base configuration of the added system.
|
2612
|
+
systemT.wrapper = self.systemT
|
2613
|
+
# Add it.
|
2574
2614
|
@systemTs << systemT
|
2575
2615
|
end
|
2576
2616
|
|
@@ -3781,6 +3821,93 @@ module HDLRuby::Low
|
|
3781
3821
|
end
|
3782
3822
|
end
|
3783
3823
|
end
|
3824
|
+
end
|
3825
|
+
|
3826
|
+
|
3827
|
+
##
|
3828
|
+
# Describes a system instance (re)configuration statement: not synthesizable!
|
3829
|
+
class Configure < Statement
|
3830
|
+
|
3831
|
+
# attr_reader :systemI, :systemT, :index
|
3832
|
+
attr_reader :ref, :index
|
3833
|
+
|
3834
|
+
# Creates a new (re)configure statement of system instance refered by
|
3835
|
+
# +ref+ with system number +index+
|
3836
|
+
def initialize(ref,index)
|
3837
|
+
super()
|
3838
|
+
# Process the arguments.
|
3839
|
+
index = index.to_i
|
3840
|
+
unless ref.is_a?(Ref) then
|
3841
|
+
raise "Invalid class for a reference: #{ref.class}."
|
3842
|
+
end
|
3843
|
+
# Sets the arguments.
|
3844
|
+
@ref = ref
|
3845
|
+
ref.parent = self
|
3846
|
+
@index = index
|
3847
|
+
# @systemT = systemI.each_systemT.to_a[index]
|
3848
|
+
# # Check the systemT is valid.
|
3849
|
+
# unless @systemT then
|
3850
|
+
# raise "Invalid configuration index: #{index}."
|
3851
|
+
# end
|
3852
|
+
end
|
3853
|
+
|
3854
|
+
# Comparison for hash: structural comparison.
|
3855
|
+
def eql?(obj)
|
3856
|
+
return false unless obj.is_a?(Configure)
|
3857
|
+
return false unless @ref.eql?(obj.ref)
|
3858
|
+
return false unless @index.eql?(obj.index)
|
3859
|
+
return true
|
3860
|
+
end
|
3861
|
+
|
3862
|
+
# Iterates over each object deeply.
|
3863
|
+
#
|
3864
|
+
# Returns an enumerator if no ruby block is given.
|
3865
|
+
def each_deep(&ruby_block)
|
3866
|
+
# No ruby block? Return an enumerator.
|
3867
|
+
return to_enum(:each_deep) unless ruby_block
|
3868
|
+
# A ruby block? First apply it to current.
|
3869
|
+
ruby_block.call(self)
|
3870
|
+
# Then apply on the reference.
|
3871
|
+
@ref.each_deep(&ruby_block)
|
3872
|
+
end
|
3873
|
+
|
3874
|
+
# Hash function.
|
3875
|
+
def hash
|
3876
|
+
return (@ref.hash + @index.hash).hash
|
3877
|
+
end
|
3878
|
+
|
3879
|
+
# Clones (deeply)
|
3880
|
+
def clone
|
3881
|
+
return Configure.new(@ref.clone,@index)
|
3882
|
+
end
|
3883
|
+
|
3884
|
+
# Iterates over the nodes deeply if any.
|
3885
|
+
def each_node_deep(&ruby_block)
|
3886
|
+
# No ruby block? Return an enumerator.
|
3887
|
+
return to_enum(:each_node_deep) unless ruby_block
|
3888
|
+
# A ruby block? First apply it to current.
|
3889
|
+
ruby_block.call(self)
|
3890
|
+
# And recurse on the reference.
|
3891
|
+
@ref.each_node_deep(&ruby_block)
|
3892
|
+
end
|
3893
|
+
|
3894
|
+
# Iterates over all the blocks contained in the current block.
|
3895
|
+
def each_block_deep(&ruby_block)
|
3896
|
+
# No ruby block? Return an enumerator.
|
3897
|
+
return to_enum(:each_block_deep) unless ruby_block
|
3898
|
+
# A ruby block?
|
3899
|
+
# Nothing more to do anyway.
|
3900
|
+
end
|
3901
|
+
|
3902
|
+
# Iterates over all the statements contained in the current block.
|
3903
|
+
def each_statement_deep(&ruby_block)
|
3904
|
+
# No ruby block? Return an enumerator.
|
3905
|
+
return to_enum(:each_statement_deep) unless ruby_block
|
3906
|
+
# A ruby block?
|
3907
|
+
# Apply it on self.
|
3908
|
+
ruby_block.call(self)
|
3909
|
+
# And that's all.
|
3910
|
+
end
|
3784
3911
|
|
3785
3912
|
end
|
3786
3913
|
|
@@ -3989,6 +4116,82 @@ module HDLRuby::Low
|
|
3989
4116
|
end
|
3990
4117
|
|
3991
4118
|
|
4119
|
+
##
|
4120
|
+
# Describes a timed terminate statement: not synthesizable!
|
4121
|
+
class TimeTerminate < Statement
|
4122
|
+
|
4123
|
+
# Creates a new timed terminate statement that terminate execution.
|
4124
|
+
def initialize
|
4125
|
+
super()
|
4126
|
+
end
|
4127
|
+
|
4128
|
+
# Iterates over each object deeply.
|
4129
|
+
#
|
4130
|
+
# Returns an enumerator if no ruby block is given.
|
4131
|
+
def each_deep(&ruby_block)
|
4132
|
+
# No ruby block? Return an enumerator.
|
4133
|
+
return to_enum(:each_deep) unless ruby_block
|
4134
|
+
# A ruby block? First apply it to current.
|
4135
|
+
ruby_block.call(self)
|
4136
|
+
# And that's all.
|
4137
|
+
end
|
4138
|
+
|
4139
|
+
# Iterates over all the nodes.
|
4140
|
+
def each_node(&ruby_block)
|
4141
|
+
# No ruby block? Return an enumerator.
|
4142
|
+
return to_enum(:each_node) unless ruby_block
|
4143
|
+
# A ruby block?
|
4144
|
+
# Nothing to do anyway.
|
4145
|
+
end
|
4146
|
+
|
4147
|
+
# Iterates over all the nodes deeply.
|
4148
|
+
def each_node_deep(&ruby_block)
|
4149
|
+
# No ruby block? Return an enumerator.
|
4150
|
+
return to_enum(:each_node_deep) unless ruby_block
|
4151
|
+
# A ruby block?
|
4152
|
+
# Apply of current node.
|
4153
|
+
ruby_block.call(self)
|
4154
|
+
# And that's all.
|
4155
|
+
end
|
4156
|
+
|
4157
|
+
# Iterates over all the statements deeply.
|
4158
|
+
def each_statement_deep(&ruby_block)
|
4159
|
+
# No ruby block? Return an enumerator.
|
4160
|
+
return to_enum(:each_statement_deep) unless ruby_block
|
4161
|
+
# A ruby block?
|
4162
|
+
# Apply of current node.
|
4163
|
+
ruby_block.call(self)
|
4164
|
+
# And that's all.
|
4165
|
+
end
|
4166
|
+
|
4167
|
+
# Iterates over all the blocks contained in the current block.
|
4168
|
+
def each_block_deep(&ruby_block)
|
4169
|
+
# No ruby block? Return an enumerator.
|
4170
|
+
return to_enum(:each_block_deep) unless ruby_block
|
4171
|
+
# A ruby block?
|
4172
|
+
# Nothing to do anyway.
|
4173
|
+
end
|
4174
|
+
|
4175
|
+
# Comparison for hash: structural comparison.
|
4176
|
+
def eql?(obj)
|
4177
|
+
return false unless obj.is_a?(TimeTerminate)
|
4178
|
+
return true
|
4179
|
+
end
|
4180
|
+
|
4181
|
+
# Hash function.
|
4182
|
+
def hash
|
4183
|
+
return TimeTerminate.hash
|
4184
|
+
end
|
4185
|
+
|
4186
|
+
# Clones the TimeRepeat (deeply)
|
4187
|
+
def clone
|
4188
|
+
return TimeTerminate.new
|
4189
|
+
end
|
4190
|
+
end
|
4191
|
+
|
4192
|
+
|
4193
|
+
|
4194
|
+
|
3992
4195
|
##
|
3993
4196
|
# Describes a block.
|
3994
4197
|
class Block < Statement
|
@@ -4058,6 +4261,7 @@ module HDLRuby::Low
|
|
4058
4261
|
|
4059
4262
|
# Adds inner signal +signal+.
|
4060
4263
|
def add_inner(signal)
|
4264
|
+
# puts "add inner=#{signal.name} in block=#{self}"
|
4061
4265
|
# Check and add the signal.
|
4062
4266
|
unless signal.is_a?(SignalI)
|
4063
4267
|
raise AnyError,
|
@@ -4087,6 +4291,7 @@ module HDLRuby::Low
|
|
4087
4291
|
|
4088
4292
|
## Gets an inner signal by +name+.
|
4089
4293
|
def get_inner(name)
|
4294
|
+
# puts "name=#{name}, inners=#{@inners.each_key.to_a}"
|
4090
4295
|
return @inners[name.to_sym]
|
4091
4296
|
end
|
4092
4297
|
alias_method :get_signal, :get_inner
|
@@ -5342,7 +5547,8 @@ module HDLRuby::Low
|
|
5342
5547
|
def initialize(type,ref,index)
|
5343
5548
|
super(type)
|
5344
5549
|
# Check and set the accessed reference.
|
5345
|
-
unless ref.is_a?(Ref) then
|
5550
|
+
# unless ref.is_a?(Ref) then
|
5551
|
+
unless ref.is_a?(Expression) then
|
5346
5552
|
raise AnyError, "Invalid class for a reference: #{ref.class}."
|
5347
5553
|
end
|
5348
5554
|
@ref = ref
|