HDLRuby 2.10.5 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HDLRuby.gemspec +1 -0
- data/README.md +8 -4
- data/Rakefile +8 -0
- data/{lib/HDLRuby/sim/Makefile → ext/hruby_sim/Makefile_csim} +0 -0
- data/ext/hruby_sim/extconf.rb +13 -0
- data/ext/hruby_sim/hruby_rcsim_build.c +1188 -0
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim.h +255 -16
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_calc.c +310 -181
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_core.c +34 -17
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_list.c +0 -0
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_stack_calc.c +4 -1
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_stack_calc.c.sav +0 -0
- data/ext/hruby_sim/hruby_sim_tree_calc.c +375 -0
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_vcd.c +5 -5
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_vizualize.c +2 -2
- data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_value_pool.c +4 -1
- data/lib/HDLRuby/hdr_samples/bstr_bench.rb +2 -0
- data/lib/HDLRuby/hdr_samples/case_bench.rb +2 -2
- data/lib/HDLRuby/hdr_samples/counter_bench.rb +0 -1
- data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +46 -0
- data/lib/HDLRuby/hdr_samples/dff_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/print_bench.rb +62 -0
- data/lib/HDLRuby/hdr_samples/rom.rb +5 -3
- data/lib/HDLRuby/hdr_samples/simple_counter_bench.rb +43 -0
- data/lib/HDLRuby/hdrcc.rb +54 -8
- data/lib/HDLRuby/hruby_bstr.rb +1175 -917
- data/lib/HDLRuby/hruby_high.rb +200 -90
- data/lib/HDLRuby/hruby_high_fullname.rb +82 -0
- data/lib/HDLRuby/hruby_low.rb +41 -23
- data/lib/HDLRuby/hruby_low2c.rb +7 -0
- data/lib/HDLRuby/hruby_rcsim.rb +978 -0
- data/lib/HDLRuby/hruby_rsim.rb +1134 -0
- data/lib/HDLRuby/hruby_rsim_vcd.rb +322 -0
- data/lib/HDLRuby/hruby_values.rb +362 -18
- data/lib/HDLRuby/hruby_verilog.rb +21 -3
- data/lib/HDLRuby/version.rb +1 -1
- metadata +24 -13
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -825,8 +825,20 @@ module HDLRuby::High
|
|
825
825
|
|
826
826
|
include Hmux
|
827
827
|
|
828
|
+
|
829
|
+
# Merge the included systems interface in current system.
|
830
|
+
# NOTE: incompatible with further to_low transformation.
|
831
|
+
def merge_included!
|
832
|
+
# puts "merge_included! for system=#{self.name}"
|
833
|
+
# Recurse on the system instances.
|
834
|
+
self.scope.merge_included!
|
835
|
+
# Merge for current system.
|
836
|
+
self.scope.merge_included(self)
|
837
|
+
end
|
838
|
+
|
839
|
+
|
828
840
|
# Fills the interface of a low level system.
|
829
|
-
def
|
841
|
+
def fill_interface_low(systemTlow)
|
830
842
|
# Adds its input signals.
|
831
843
|
self.each_input { |input| systemTlow.add_input(input.to_low) }
|
832
844
|
# Adds its output signals.
|
@@ -835,7 +847,7 @@ module HDLRuby::High
|
|
835
847
|
self.each_inout { |inout| systemTlow.add_inout(inout.to_low) }
|
836
848
|
# Adds the interface of its included systems.
|
837
849
|
self.scope.each_included do |included|
|
838
|
-
included.
|
850
|
+
included.fill_interface_low(systemTlow)
|
839
851
|
end
|
840
852
|
end
|
841
853
|
|
@@ -844,7 +856,7 @@ module HDLRuby::High
|
|
844
856
|
# NOTE: name conflicts are treated in the current NameStack state.
|
845
857
|
def fill_low(systemTlow)
|
846
858
|
# Fills the interface
|
847
|
-
self.
|
859
|
+
self.fill_interface_low(systemTlow)
|
848
860
|
end
|
849
861
|
|
850
862
|
# Converts the system to HDLRuby::Low and set its +name+.
|
@@ -1380,6 +1392,72 @@ module HDLRuby::High
|
|
1380
1392
|
|
1381
1393
|
include Hmux
|
1382
1394
|
|
1395
|
+
|
1396
|
+
|
1397
|
+
# Merge the included systems interface in +systemT+
|
1398
|
+
# NOTE: incompatible with further to_low transformation.
|
1399
|
+
def merge_included(systemT)
|
1400
|
+
# Recurse on the sub.
|
1401
|
+
self.each_scope {|scope| scope.merge_included(systemT) }
|
1402
|
+
# Include for current scope.
|
1403
|
+
self.each_included do |included|
|
1404
|
+
included.merge_included!
|
1405
|
+
# Adds its interface signals.
|
1406
|
+
included.each_input do |input|
|
1407
|
+
input.no_parent!
|
1408
|
+
systemT.add_input(input)
|
1409
|
+
end
|
1410
|
+
included.each_output do |output|
|
1411
|
+
output.no_parent!
|
1412
|
+
systemT.add_output(output)
|
1413
|
+
end
|
1414
|
+
included.each_inout do |inout|
|
1415
|
+
inout.no_parent!
|
1416
|
+
systemT.add_inout(inout)
|
1417
|
+
end
|
1418
|
+
# Adds its behaviors.
|
1419
|
+
included.scope.each_behavior do |beh|
|
1420
|
+
beh.no_parent!
|
1421
|
+
systemT.scope.add_behavior(beh)
|
1422
|
+
end
|
1423
|
+
# Adds its connections.
|
1424
|
+
included.scope.each_connection do |cx|
|
1425
|
+
cx.no_parent!
|
1426
|
+
systemT.scope.add_connection(cx)
|
1427
|
+
end
|
1428
|
+
# Adds its sytem instances.
|
1429
|
+
included.scope.each_systemI do |sys|
|
1430
|
+
sys.no_parent!
|
1431
|
+
systemT.scope.add_systemI(sys)
|
1432
|
+
end
|
1433
|
+
# Adds its code.
|
1434
|
+
included.scope.each_code do |code|
|
1435
|
+
code.no_parent!
|
1436
|
+
systemT.scope.add_code(code)
|
1437
|
+
end
|
1438
|
+
# Adds its subscopes.
|
1439
|
+
included.scope.each_scope do |scope|
|
1440
|
+
scope.no_parent!
|
1441
|
+
systemT.scope.add_scope(scope)
|
1442
|
+
end
|
1443
|
+
# Add its inner signals.
|
1444
|
+
included.scope.each_inner do |inner|
|
1445
|
+
inner.no_parent!
|
1446
|
+
systemT.scope.add_inner(inner)
|
1447
|
+
end
|
1448
|
+
end
|
1449
|
+
end
|
1450
|
+
|
1451
|
+
# Merge the included systems interface in system instances.
|
1452
|
+
# NOTE: incompatible with further to_low transformation.
|
1453
|
+
def merge_included!
|
1454
|
+
# Recurse on the sub.
|
1455
|
+
self.each_scope {|scope| scope.merge_included! }
|
1456
|
+
# Merge in the system instances.
|
1457
|
+
self.each_systemI {|systemI| systemI.systemT.merge_included! }
|
1458
|
+
end
|
1459
|
+
|
1460
|
+
|
1383
1461
|
# Fills a low level scope with self's contents.
|
1384
1462
|
#
|
1385
1463
|
# NOTE: name conflicts are treated in the current NameStack state.
|
@@ -2194,8 +2272,6 @@ module HDLRuby::High
|
|
2194
2272
|
else
|
2195
2273
|
# No, perform a connection is order of declaration
|
2196
2274
|
connects.each.with_index do |csig,i|
|
2197
|
-
csig = csig.to_expr
|
2198
|
-
# puts "csig=#{csig} i=#{i}"
|
2199
2275
|
# puts "systemT inputs=#{systemT.each_input.to_a.size}"
|
2200
2276
|
# Gets i-est signal to connect
|
2201
2277
|
ssig = self.systemT.get_interface_with_included(i)
|
@@ -2207,8 +2283,10 @@ module HDLRuby::High
|
|
2207
2283
|
# Make the connection.
|
2208
2284
|
if isout then
|
2209
2285
|
csig <= ssig
|
2286
|
+
# csig.to_ref <= ssig
|
2210
2287
|
else
|
2211
2288
|
ssig <= csig
|
2289
|
+
# ssig <= csig.to_expr
|
2212
2290
|
end
|
2213
2291
|
end
|
2214
2292
|
end
|
@@ -2775,30 +2853,39 @@ module HDLRuby::High
|
|
2775
2853
|
return self.ljust(self[-1])
|
2776
2854
|
end
|
2777
2855
|
|
2778
|
-
# Match the type with +typ+:
|
2779
|
-
# - Recurse on the sub expr if hierachical type, raising an
|
2780
|
-
# if the expression is not hierarchical.
|
2781
|
-
# - Directly cast otherwise.
|
2856
|
+
# # Match the type with +typ+:
|
2857
|
+
# # - Recurse on the sub expr if hierachical type, raising an error
|
2858
|
+
# # if the expression is not hierarchical.
|
2859
|
+
# # - Directly cast otherwise.
|
2860
|
+
# def match_type(typ)
|
2861
|
+
# # Has the type sub types?
|
2862
|
+
# if typ.types? then
|
2863
|
+
# unless self.is_a?(Concat) then
|
2864
|
+
# raise AnyError,
|
2865
|
+
# "Invalid class for assignment to hierarchical: #{self.class}."
|
2866
|
+
# end
|
2867
|
+
# return Concat.new(typ,
|
2868
|
+
# self.each_expression.zip(typ.each_type).map do |e,t|
|
2869
|
+
# e.match_type(t)
|
2870
|
+
# end)
|
2871
|
+
# elsif typ.vector? && typ.base.hierarchical? then
|
2872
|
+
# unless self.is_a?(Concat) then
|
2873
|
+
# raise AnyError,
|
2874
|
+
# "Invalid class for assignment to hierarchical: #{self.class}."
|
2875
|
+
# end
|
2876
|
+
# return Concat.new(typ,
|
2877
|
+
# self.each_expression.map do |e|
|
2878
|
+
# e.match_type(typ.base)
|
2879
|
+
# end)
|
2880
|
+
# else
|
2881
|
+
# return self.as(typ)
|
2882
|
+
# end
|
2883
|
+
# end
|
2884
|
+
|
2885
|
+
# Match the type with +typ+: cast if different type.
|
2782
2886
|
def match_type(typ)
|
2783
|
-
|
2784
|
-
|
2785
|
-
unless self.is_a?(Concat) then
|
2786
|
-
raise AnyError,
|
2787
|
-
"Invalid class for assignment to hierarchical: #{self.class}."
|
2788
|
-
end
|
2789
|
-
return Concat.new(typ,
|
2790
|
-
self.each_expression.zip(typ.each_type).map do |e,t|
|
2791
|
-
e.match_type(t)
|
2792
|
-
end)
|
2793
|
-
elsif typ.vector? && typ.base.hierarchical? then
|
2794
|
-
unless self.is_a?(Concat) then
|
2795
|
-
raise AnyError,
|
2796
|
-
"Invalid class for assignment to hierarchical: #{self.class}."
|
2797
|
-
end
|
2798
|
-
return Concat.new(typ,
|
2799
|
-
self.each_expression.map do |e|
|
2800
|
-
e.match_type(typ.base)
|
2801
|
-
end)
|
2887
|
+
if self.type.eql?(typ) then
|
2888
|
+
return self
|
2802
2889
|
else
|
2803
2890
|
return self.as(typ)
|
2804
2891
|
end
|
@@ -2875,54 +2962,58 @@ module HDLRuby::High
|
|
2875
2962
|
define_method(orig_operator(operator),&meth)
|
2876
2963
|
end
|
2877
2964
|
|
2878
|
-
# Creates an access to elements of range +rng+ of the signal.
|
2879
|
-
#
|
2880
|
-
# NOTE: +rng+ can be a single expression in which case it is an index.
|
2881
|
-
def [](rng)
|
2882
|
-
if rng.is_a?(::Range) then
|
2883
|
-
first = rng.first
|
2884
|
-
if (first.is_a?(::Integer)) then
|
2885
|
-
first = self.type.size+first if first < 0
|
2886
|
-
end
|
2887
|
-
last = rng.last
|
2888
|
-
if (last.is_a?(::Integer)) then
|
2889
|
-
last = self.type.size+last if last < 0
|
2890
|
-
end
|
2891
|
-
rng = first..last
|
2892
|
-
end
|
2893
|
-
if rng.is_a?(::Integer) && rng < 0 then
|
2894
|
-
rng = self.type.size+rng
|
2895
|
-
end
|
2896
|
-
if rng.respond_to?(:to_expr) then
|
2897
|
-
# Number range: convert it to an expression.
|
2898
|
-
rng = rng.to_expr
|
2899
|
-
end
|
2900
|
-
if rng.is_a?(HDLRuby::Low::Expression) then
|
2901
|
-
# Index case
|
2902
|
-
return RefIndex.new(self.type.base,self.to_expr,rng)
|
2903
|
-
else
|
2904
|
-
# Range case, ensure it is made among expression.
|
2905
|
-
first = rng.first.to_expr
|
2906
|
-
last = rng.last.to_expr
|
2907
|
-
# Abd create the reference.
|
2908
|
-
return RefRange.new(self.type.slice(first..last),
|
2909
|
-
self.to_expr,first..last)
|
2910
|
-
end
|
2911
|
-
end
|
2912
2965
|
|
2913
|
-
|
2914
|
-
|
2915
|
-
|
2916
|
-
|
2917
|
-
|
2918
|
-
|
2919
|
-
|
2920
|
-
|
2921
|
-
|
2922
|
-
|
2923
|
-
|
2924
|
-
|
2925
|
-
|
2966
|
+
# Creates an access to elements of range +rng+ of the signal.
|
2967
|
+
#
|
2968
|
+
# NOTE: +rng+ can be a single expression in which case it is an index.
|
2969
|
+
def [](rng)
|
2970
|
+
if rng.is_a?(::Range) then
|
2971
|
+
first = rng.first
|
2972
|
+
if (first.is_a?(::Integer)) then
|
2973
|
+
first = self.type.size+first if first < 0
|
2974
|
+
end
|
2975
|
+
last = rng.last
|
2976
|
+
if (last.is_a?(::Integer)) then
|
2977
|
+
last = self.type.size+last if last < 0
|
2978
|
+
end
|
2979
|
+
rng = first..last
|
2980
|
+
end
|
2981
|
+
if rng.is_a?(::Integer) && rng < 0 then
|
2982
|
+
rng = self.type.size+rng
|
2983
|
+
end
|
2984
|
+
if rng.respond_to?(:to_expr) then
|
2985
|
+
# Number range: convert it to an expression.
|
2986
|
+
rng = rng.to_expr
|
2987
|
+
end
|
2988
|
+
if rng.is_a?(HDLRuby::Low::Expression) then
|
2989
|
+
# Index case
|
2990
|
+
return RefIndex.new(self.type.base,self.to_expr,rng)
|
2991
|
+
else
|
2992
|
+
# Range case, ensure it is made among expression.
|
2993
|
+
first = rng.first.to_expr
|
2994
|
+
last = rng.last.to_expr
|
2995
|
+
# Abd create the reference.
|
2996
|
+
return RefRange.new(self.type.slice(first..last),
|
2997
|
+
self.to_expr,first..last)
|
2998
|
+
end
|
2999
|
+
end
|
3000
|
+
|
3001
|
+
# And save it so that it can still be accessed if overidden.
|
3002
|
+
alias_method orig_operator(:[]), :[]
|
3003
|
+
|
3004
|
+
# Converts to a select operator using current expression as
|
3005
|
+
# condition for one of the +choices+.
|
3006
|
+
#
|
3007
|
+
# NOTE: +choices+ can either be a list of arguments or an array.
|
3008
|
+
# If +choices+ has only two entries
|
3009
|
+
# (and it is not a hash), +value+ will be converted to a boolean.
|
3010
|
+
def mux(*choices)
|
3011
|
+
# Process the choices.
|
3012
|
+
choices = choices.flatten(1) if choices.size == 1
|
3013
|
+
choices.map! { |choice| choice.to_expr }
|
3014
|
+
# Generate the select expression.
|
3015
|
+
return Select.new(choices[0].type,"?",self.to_expr,*choices)
|
3016
|
+
end
|
2926
3017
|
|
2927
3018
|
|
2928
3019
|
|
@@ -2966,19 +3057,25 @@ module HDLRuby::High
|
|
2966
3057
|
#
|
2967
3058
|
# NOTE: it is converted afterward to an expression if required.
|
2968
3059
|
def <=(expr)
|
3060
|
+
# Generate a ref from self for the left of the transmit.
|
3061
|
+
left = self.to_ref
|
2969
3062
|
# Cast expr to self if required.
|
2970
|
-
expr = expr.to_expr.match_type(
|
3063
|
+
expr = expr.to_expr.match_type(left.type)
|
3064
|
+
# Ensure expr is an expression.
|
3065
|
+
expr = expr.to_expr
|
3066
|
+
# Cast it to left if necessary.
|
3067
|
+
expr = expr.as(left.type) unless expr.type.eql?(left.type)
|
2971
3068
|
# Generate the transmit.
|
2972
3069
|
if High.top_user.is_a?(HDLRuby::Low::Block) then
|
2973
3070
|
# We are in a block, so generate and add a Transmit.
|
2974
3071
|
High.top_user.
|
2975
|
-
# add_statement(Transmit.new(self.to_ref,expr
|
2976
|
-
add_statement(Transmit.new(
|
3072
|
+
# add_statement(Transmit.new(self.to_ref,expr))
|
3073
|
+
add_statement(Transmit.new(left,expr))
|
2977
3074
|
else
|
2978
3075
|
# We are in a system type, so generate and add a Connection.
|
2979
3076
|
High.top_user.
|
2980
|
-
# add_connection(Connection.new(self.to_ref,expr
|
2981
|
-
add_connection(Connection.new(
|
3077
|
+
# add_connection(Connection.new(self.to_ref,expr))
|
3078
|
+
add_connection(Connection.new(left,expr))
|
2982
3079
|
end
|
2983
3080
|
end
|
2984
3081
|
end
|
@@ -3229,7 +3326,7 @@ module HDLRuby::High
|
|
3229
3326
|
|
3230
3327
|
# Creates a new reference from a +base+ reference and named +object+.
|
3231
3328
|
def initialize(base,object)
|
3232
|
-
# puts "New RefObjet with base=#{base}, object=#{object
|
3329
|
+
# puts "New RefObjet with base=#{base}, object=#{object}"
|
3233
3330
|
if object.respond_to?(:type) then
|
3234
3331
|
# Typed object, so typed reference.
|
3235
3332
|
super(object.type)
|
@@ -3246,6 +3343,11 @@ module HDLRuby::High
|
|
3246
3343
|
@object = object
|
3247
3344
|
end
|
3248
3345
|
|
3346
|
+
# Clones.
|
3347
|
+
def clone
|
3348
|
+
return RefObject.new(self.base.clone,self.object)
|
3349
|
+
end
|
3350
|
+
|
3249
3351
|
# Tell if the expression is constant.
|
3250
3352
|
def constant?
|
3251
3353
|
return self.base.constant?
|
@@ -3395,6 +3497,11 @@ module HDLRuby::High
|
|
3395
3497
|
High = HDLRuby::High
|
3396
3498
|
include HRef
|
3397
3499
|
|
3500
|
+
# Clones.
|
3501
|
+
def clone
|
3502
|
+
return RefThis.new
|
3503
|
+
end
|
3504
|
+
|
3398
3505
|
# Converts to a new reference.
|
3399
3506
|
def to_ref
|
3400
3507
|
return RefThis.new
|
@@ -4597,13 +4704,19 @@ module HDLRuby::High
|
|
4597
4704
|
# # Use it to create the new value.
|
4598
4705
|
# return Value.new(Bit[bstr.width],self)
|
4599
4706
|
# end
|
4707
|
+
|
4708
|
+
# Tell if the expression can be converted to a value.
|
4709
|
+
def to_value?
|
4710
|
+
return true
|
4711
|
+
end
|
4600
4712
|
|
4601
4713
|
# Converts to a new high-level value.
|
4602
4714
|
def to_value
|
4603
4715
|
# Convert the string to a bit string.
|
4604
4716
|
bstr = BitString.new(self)
|
4605
4717
|
# Use it to create the new value.
|
4606
|
-
return Value.new(Bit[bstr.width],
|
4718
|
+
# return Value.new(Bit[bstr.width],bstr)
|
4719
|
+
return Value.new(Bit[self.length],bstr)
|
4607
4720
|
end
|
4608
4721
|
|
4609
4722
|
# Convert to a new high-level string expression
|
@@ -4717,9 +4830,6 @@ module HDLRuby::High
|
|
4717
4830
|
|
4718
4831
|
# Converts to a new high-level expression.
|
4719
4832
|
def to_expr
|
4720
|
-
# expr = Concat.new(TypeTuple.new(:"",:little,*self.map do |elem|
|
4721
|
-
# elem.to_expr.type
|
4722
|
-
# end))
|
4723
4833
|
elems = self.map {|elem| elem.to_expr }
|
4724
4834
|
typ= TypeTuple.new(:"",:little)
|
4725
4835
|
elems.each {|elem| typ.add_type(elem.type) }
|
@@ -4730,7 +4840,6 @@ module HDLRuby::High
|
|
4730
4840
|
|
4731
4841
|
# Converts to a new high-level reference.
|
4732
4842
|
def to_ref
|
4733
|
-
# expr = RefConcat.new
|
4734
4843
|
expr = RefConcat.new(TypeTuple.new(:"",:little,*self.map do |elem|
|
4735
4844
|
elem.to_ref.type
|
4736
4845
|
end))
|
@@ -4797,10 +4906,11 @@ module HDLRuby::High
|
|
4797
4906
|
end
|
4798
4907
|
end
|
4799
4908
|
|
4800
|
-
#
|
4801
|
-
|
4802
|
-
|
4803
|
-
|
4909
|
+
# Moved to HArrow.
|
4910
|
+
# # Add support of the left arrow operator.
|
4911
|
+
# def <=(expr)
|
4912
|
+
# self.to_expr <= expr
|
4913
|
+
# end
|
4804
4914
|
|
4805
4915
|
# Array construction shortcuts
|
4806
4916
|
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require "HDLRuby/hruby_high"
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
module HDLRuby::High
|
6
|
+
|
7
|
+
##
|
8
|
+
# Library for describing adding the fullname method to HDLRuby::High objects.
|
9
|
+
#
|
10
|
+
########################################################################
|
11
|
+
|
12
|
+
class SystemT
|
13
|
+
|
14
|
+
## Returns the name of the signal with its hierarchy.
|
15
|
+
def fullname
|
16
|
+
@fullname ||= (self.parent ? self.parent.fullname + ":" : "") +
|
17
|
+
self.name.to_s
|
18
|
+
return @fullname
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
##
|
24
|
+
# Module for extending named classes with fullname (other than SystemT).
|
25
|
+
module WithFullname
|
26
|
+
|
27
|
+
## Returns the name of the signal with its hierarchy.
|
28
|
+
def fullname
|
29
|
+
@fullname ||= self.parent.fullname + ":" + self.name.to_s
|
30
|
+
return @fullname
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
class Scope
|
36
|
+
include WithFullname
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
class Behavior
|
41
|
+
|
42
|
+
## Returns the name of the signal with its hierarchy.
|
43
|
+
def fullname
|
44
|
+
return self.parent.fullname
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
class TimeBehavior
|
50
|
+
|
51
|
+
## Returns the name of the signal with its hierarchy.
|
52
|
+
def fullname
|
53
|
+
return self.parent.fullname
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
class SignalI
|
59
|
+
include WithFullname
|
60
|
+
end
|
61
|
+
|
62
|
+
class SignalC
|
63
|
+
include WithFullname
|
64
|
+
end
|
65
|
+
|
66
|
+
class SystemI
|
67
|
+
include WithFullname
|
68
|
+
end
|
69
|
+
|
70
|
+
class Code
|
71
|
+
# TODO
|
72
|
+
end
|
73
|
+
|
74
|
+
class Block
|
75
|
+
include WithFullname
|
76
|
+
end
|
77
|
+
|
78
|
+
class TimeBlock
|
79
|
+
include WithFullname
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
data/lib/HDLRuby/hruby_low.rb
CHANGED
@@ -57,6 +57,11 @@ module HDLRuby::Low
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
# Clears the parent.
|
61
|
+
def no_parent!
|
62
|
+
@parent = nil
|
63
|
+
end
|
64
|
+
|
60
65
|
# Get the parent scope.
|
61
66
|
def scope
|
62
67
|
cur = self.parent
|
@@ -1456,6 +1461,10 @@ module HDLRuby::Low
|
|
1456
1461
|
# The bit type leaf.
|
1457
1462
|
class << ( Bit = Type.new(:bit) )
|
1458
1463
|
include LLeaf
|
1464
|
+
# Tells if the type is unsigned.
|
1465
|
+
def unsigned?
|
1466
|
+
return true
|
1467
|
+
end
|
1459
1468
|
# Tells if the type fixed point.
|
1460
1469
|
def fixed?
|
1461
1470
|
return true
|
@@ -1597,10 +1606,11 @@ module HDLRuby::Low
|
|
1597
1606
|
|
1598
1607
|
# Comparison for hash: structural comparison.
|
1599
1608
|
def eql?(obj)
|
1600
|
-
# General type comparison.
|
1601
|
-
return false unless super(obj)
|
1609
|
+
# # General type comparison.
|
1610
|
+
# return false unless super(obj)
|
1602
1611
|
# Specific comparison.
|
1603
1612
|
return false unless obj.is_a?(TypeDef)
|
1613
|
+
return false unless @name.eql?(obj.name)
|
1604
1614
|
return false unless @def.eql?(obj.def)
|
1605
1615
|
return true
|
1606
1616
|
end
|
@@ -1675,8 +1685,8 @@ module HDLRuby::Low
|
|
1675
1685
|
|
1676
1686
|
# Comparison for hash: structural comparison.
|
1677
1687
|
def eql?(obj)
|
1678
|
-
# General type comparison.
|
1679
|
-
return false unless super(obj)
|
1688
|
+
# # General type comparison.
|
1689
|
+
# return false unless super(obj)
|
1680
1690
|
# Specific comparison.
|
1681
1691
|
return false unless obj.is_a?(TypeVector)
|
1682
1692
|
return false unless @base.eql?(obj.base)
|
@@ -1867,8 +1877,9 @@ module HDLRuby::Low
|
|
1867
1877
|
|
1868
1878
|
# Comparison for hash: structural comparison.
|
1869
1879
|
def eql?(obj)
|
1870
|
-
# General type comparison.
|
1871
|
-
return false unless super(obj)
|
1880
|
+
# # General type comparison.
|
1881
|
+
# return false unless super(obj)
|
1882
|
+
return false unless obj.is_a?(TypeTuple)
|
1872
1883
|
# Specific comparison.
|
1873
1884
|
idx = 0
|
1874
1885
|
obj.each_type do |type|
|
@@ -2523,18 +2534,18 @@ module HDLRuby::Low
|
|
2523
2534
|
self.value.each_deep(&ruby_block) if self.value
|
2524
2535
|
end
|
2525
2536
|
|
2526
|
-
# Comparison for hash: structural comparison.
|
2527
|
-
def eql?(obj)
|
2528
|
-
|
2529
|
-
|
2530
|
-
|
2531
|
-
|
2532
|
-
end
|
2537
|
+
# # Comparison for hash: structural comparison.
|
2538
|
+
# def eql?(obj)
|
2539
|
+
# return false unless obj.is_a?(SignalI)
|
2540
|
+
# return false unless @name.eql?(obj.name)
|
2541
|
+
# return false unless @type.eql?(obj.type)
|
2542
|
+
# return true
|
2543
|
+
# end
|
2533
2544
|
|
2534
|
-
# Hash function.
|
2535
|
-
def hash
|
2536
|
-
|
2537
|
-
end
|
2545
|
+
# # Hash function.
|
2546
|
+
# def hash
|
2547
|
+
# return [@name,@type].hash
|
2548
|
+
# end
|
2538
2549
|
|
2539
2550
|
# Gets the bit width.
|
2540
2551
|
def width
|
@@ -4594,7 +4605,8 @@ module HDLRuby::Low
|
|
4594
4605
|
# Yes so it is also a left value if it is a sub ref.
|
4595
4606
|
if parent.respond_to?(:ref) then
|
4596
4607
|
# It might nor be a sub ref.
|
4597
|
-
return parent.ref == self
|
4608
|
+
# return parent.ref == self
|
4609
|
+
return parent.ref.eql?(self)
|
4598
4610
|
else
|
4599
4611
|
# It is necessarily a sub ref (case of RefConcat for now).
|
4600
4612
|
return true
|
@@ -4602,7 +4614,8 @@ module HDLRuby::Low
|
|
4602
4614
|
end
|
4603
4615
|
# No, therefore maybe it is directly a left value.
|
4604
4616
|
return (parent.is_a?(Transmit) || parent.is_a?(Connection)) &&
|
4605
|
-
parent.left == self
|
4617
|
+
# parent.left == self
|
4618
|
+
parent.left.eql?(self)
|
4606
4619
|
end
|
4607
4620
|
|
4608
4621
|
# Tells if the expression is a right value.
|
@@ -4676,12 +4689,16 @@ module HDLRuby::Low
|
|
4676
4689
|
# Creates a new value typed +type+ and containing +content+.
|
4677
4690
|
def initialize(type,content)
|
4678
4691
|
super(type)
|
4679
|
-
|
4692
|
+
if content.nil? then
|
4680
4693
|
# Handle the nil content case.
|
4681
4694
|
unless type.eql?(Void) then
|
4682
4695
|
raise AnyError, "A value with nil content must have the Void type."
|
4683
4696
|
end
|
4684
4697
|
@content = content
|
4698
|
+
elsif content.is_a?(FalseClass) then
|
4699
|
+
@content = 0
|
4700
|
+
elsif content.is_a?(TrueClass) then
|
4701
|
+
@content = 1
|
4685
4702
|
else
|
4686
4703
|
# Checks and set the content: Ruby Numeric and HDLRuby
|
4687
4704
|
# BitString are supported. Strings or equivalent are
|
@@ -4718,8 +4735,8 @@ module HDLRuby::Low
|
|
4718
4735
|
|
4719
4736
|
# Comparison for hash: structural comparison.
|
4720
4737
|
def eql?(obj)
|
4721
|
-
# General comparison.
|
4722
|
-
return false unless super(obj)
|
4738
|
+
# # General comparison.
|
4739
|
+
# return false unless super(obj)
|
4723
4740
|
# Specific comparison.
|
4724
4741
|
return false unless obj.is_a?(Value)
|
4725
4742
|
return false unless @content.eql?(obj.content)
|
@@ -5118,7 +5135,7 @@ module HDLRuby::Low
|
|
5118
5135
|
|
5119
5136
|
|
5120
5137
|
##
|
5121
|
-
# Describes a
|
5138
|
+
# Describes a selection operation (generalization of the ternary operator).
|
5122
5139
|
#
|
5123
5140
|
# NOTE: choice is using the value of +select+ as an index.
|
5124
5141
|
class Select < Operation
|
@@ -5284,6 +5301,7 @@ module HDLRuby::Low
|
|
5284
5301
|
# def initialize(expressions = [])
|
5285
5302
|
def initialize(type,expressions = [])
|
5286
5303
|
super(type)
|
5304
|
+
# puts "Building concat=#{self} with direction=#{type.direction}\n"
|
5287
5305
|
# Initialize the array of expressions that are concatenated.
|
5288
5306
|
@expressions = []
|
5289
5307
|
# Check and add the expressions.
|
data/lib/HDLRuby/hruby_low2c.rb
CHANGED
@@ -709,6 +709,10 @@ module HDLRuby::Low
|
|
709
709
|
# Tells if the behavior is timed or not.
|
710
710
|
res << " " * (level+1)*3
|
711
711
|
res << "behavior->timed = #{time ? 1 : 0};\n"
|
712
|
+
|
713
|
+
# Set the active time to 0.
|
714
|
+
res << " " * (level+1)*3
|
715
|
+
res << "behavior->active_time = 0;\n"
|
712
716
|
|
713
717
|
# Is it a clocked behavior?
|
714
718
|
events = self.each_event.to_a
|
@@ -858,6 +862,7 @@ module HDLRuby::Low
|
|
858
862
|
# +level+ is the hierachical level of the object.
|
859
863
|
# def to_c(level = 0)
|
860
864
|
def to_c(res,level = 0)
|
865
|
+
|
861
866
|
# puts "Signal.to_c with name: #{Low2C.obj_name(self)}"
|
862
867
|
# Declare the global variable holding the signal.
|
863
868
|
res << "SignalI "
|
@@ -2546,6 +2551,7 @@ module HDLRuby::Low
|
|
2546
2551
|
# Generates the C text for the equivalent HDLRuby code.
|
2547
2552
|
# +level+ is the hierachical level of the object.
|
2548
2553
|
def to_c(res,level = 0)
|
2554
|
+
# puts "to_c fo concat=#{self} with type=#{self.type} and direction=#{self.type.direction}"
|
2549
2555
|
# Save the value pool state.
|
2550
2556
|
res << (" " * (level*3)) << "PV;\n"
|
2551
2557
|
# Gather the content to concat.
|
@@ -2556,6 +2562,7 @@ module HDLRuby::Low
|
|
2556
2562
|
end
|
2557
2563
|
# Compute the resulting concatenation.
|
2558
2564
|
res << (" " * ((level+1)*3))
|
2565
|
+
# puts "self.type.direction=#{self.type.direction}\n"
|
2559
2566
|
res << "sconcat(#{expressions.size},"
|
2560
2567
|
res << (self.type.direction == :little ? "1" : "0")
|
2561
2568
|
res << ");\n"
|