HDLRuby 2.11.11 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.html +3274 -0
- data/README.md +608 -99
- data/ext/hruby_sim/hruby_rcsim_build.c +27 -0
- data/ext/hruby_sim/hruby_sim.h +3 -0
- data/ext/hruby_sim/hruby_sim_calc.c +2 -0
- data/ext/hruby_sim/hruby_sim_core.c +17 -5
- data/ext/hruby_sim/hruby_sim_stack_calc.c +1 -1
- data/ext/hruby_sim/hruby_sim_tree_calc.c +8 -1
- data/ext/hruby_sim/hruby_sim_vcd.c +24 -7
- data/ext/hruby_sim/hruby_sim_vizualize.c +9 -1
- data/lib/HDLRuby/backend/hruby_allocator.rb +2 -2
- data/lib/HDLRuby/backend/hruby_c_allocator.rb +7 -7
- data/lib/HDLRuby/hdr_samples/constant_in_function.rb +3 -1
- data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +3 -1
- data/lib/HDLRuby/hdr_samples/huge_rom.rb +1 -1
- data/lib/HDLRuby/hdr_samples/mei8.rb +11 -11
- data/lib/HDLRuby/hdr_samples/mei8_bench.rb +12 -12
- data/lib/HDLRuby/hdr_samples/neg_arith_bench.rb +4 -4
- data/lib/HDLRuby/hdr_samples/rom_nest.rb +1 -1
- data/lib/HDLRuby/hdr_samples/ruby_fir_hw.rb +4 -4
- data/lib/HDLRuby/hdr_samples/struct.rb +44 -10
- data/lib/HDLRuby/hdr_samples/with_bram.rb +45 -0
- data/lib/HDLRuby/hdr_samples/with_bram_frame_stack.rb +105 -0
- data/lib/HDLRuby/hdr_samples/with_bram_stack.rb +69 -0
- data/lib/HDLRuby/hdr_samples/with_casts.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_concat.rb +6 -6
- data/lib/HDLRuby/hdr_samples/with_connector_memory.rb +2 -2
- data/lib/HDLRuby/hdr_samples/with_def.rb +10 -3
- data/lib/HDLRuby/hdr_samples/with_define_operator.rb +44 -0
- data/lib/HDLRuby/hdr_samples/with_fixpoint.rb +12 -12
- data/lib/HDLRuby/hdr_samples/with_init.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_leftright.rb +21 -0
- data/lib/HDLRuby/hdr_samples/with_reduce.rb +13 -13
- data/lib/HDLRuby/hdr_samples/with_ref_array.rb +6 -6
- data/lib/HDLRuby/hdr_samples/with_register_stack.rb +150 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer.rb +190 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_deep.rb +91 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +405 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerator.rb +89 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_sync.rb +120 -0
- data/lib/HDLRuby/hdr_samples/with_subsums.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_terminate.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_to_a.rb +10 -10
- data/lib/HDLRuby/hdr_samples/with_values.rb +3 -3
- data/lib/HDLRuby/hdrcc.rb +29 -3
- data/lib/HDLRuby/hdrlib.rb +1 -1
- data/lib/HDLRuby/hruby_bstr.rb +10 -5
- data/lib/HDLRuby/hruby_db.rb +2 -2
- data/lib/HDLRuby/hruby_high.rb +152 -47
- data/lib/HDLRuby/hruby_high_fullname.rb +3 -1
- data/lib/HDLRuby/hruby_low.rb +189 -18
- data/lib/HDLRuby/hruby_low2c.rb +129 -54
- data/lib/HDLRuby/hruby_low2hdr.rb +66 -40
- data/lib/HDLRuby/hruby_low2high.rb +86 -44
- data/lib/HDLRuby/hruby_low2seq.rb +26 -18
- data/lib/HDLRuby/hruby_low2sym.rb +14 -13
- data/lib/HDLRuby/hruby_low2vhd.rb +80 -44
- data/lib/HDLRuby/hruby_low_bool2select.rb +61 -46
- data/lib/HDLRuby/hruby_low_casts_without_expression.rb +56 -44
- data/lib/HDLRuby/hruby_low_cleanup.rb +18 -16
- data/lib/HDLRuby/hruby_low_fix_types.rb +65 -32
- data/lib/HDLRuby/hruby_low_mutable.rb +83 -119
- data/lib/HDLRuby/hruby_low_resolve.rb +38 -30
- data/lib/HDLRuby/hruby_low_with_bool.rb +33 -16
- data/lib/HDLRuby/hruby_low_with_port.rb +3 -3
- data/lib/HDLRuby/hruby_low_with_var.rb +23 -9
- data/lib/HDLRuby/hruby_low_without_concat.rb +45 -19
- data/lib/HDLRuby/hruby_low_without_namespace.rb +47 -32
- data/lib/HDLRuby/hruby_low_without_parinseq.rb +32 -16
- data/lib/HDLRuby/hruby_low_without_select.rb +37 -24
- data/lib/HDLRuby/hruby_low_without_subsignals.rb +280 -0
- data/lib/HDLRuby/hruby_rcsim.rb +158 -134
- data/lib/HDLRuby/hruby_rsim.rb +194 -20
- data/lib/HDLRuby/hruby_rsim_mute.rb +2 -3
- data/lib/HDLRuby/hruby_rsim_vcd.rb +125 -50
- data/lib/HDLRuby/hruby_values.rb +48 -33
- data/lib/HDLRuby/hruby_verilog.rb +90 -48
- data/lib/HDLRuby/soft/stacks.rb +219 -0
- data/lib/HDLRuby/std/bram.rb +26 -0
- data/lib/HDLRuby/std/clocks.rb +1 -1
- data/lib/HDLRuby/std/fixpoint.rb +2 -2
- data/lib/HDLRuby/std/fsm.rb +48 -11
- data/lib/HDLRuby/std/function_generator.rb +2 -2
- data/lib/HDLRuby/std/sequencer.rb +1857 -0
- data/lib/HDLRuby/std/sequencer_sync.rb +400 -0
- data/lib/HDLRuby/std/std.rb +12 -0
- data/lib/HDLRuby/version.rb +1 -1
- data/tuto/adder_sat_flags_vcd.png +0 -0
- data/tuto/addsub_vcd.png +0 -0
- data/tuto/alu_vcd.png +0 -0
- data/tuto/bit_pong_vcd.png +0 -0
- data/tuto/checksum_vcd.png +0 -0
- data/tuto/circuit_hdr.odg +0 -0
- data/tuto/circuit_hdr.png +0 -0
- data/tuto/circuit_hie.odg +0 -0
- data/tuto/circuit_hie.png +0 -0
- data/tuto/circuit_view.odg +0 -0
- data/tuto/circuit_view.png +0 -0
- data/tuto/clock_counter_vcd.png +0 -0
- data/tuto/counter_ext_vcd.png +0 -0
- data/tuto/fact_vcd.png +0 -0
- data/tuto/hw_flow.odg +0 -0
- data/tuto/hw_flow.png +0 -0
- data/tuto/maxxer_vcd.png +0 -0
- data/tuto/pingpong0_vcd.png +0 -0
- data/tuto/pingpong1_vcd.png +0 -0
- data/tuto/pingpong2_vcd.png +0 -0
- data/tuto/ram_vcd.png +0 -0
- data/tuto/serializer_vcd.png +0 -0
- data/tuto/sw_flow.odg +0 -0
- data/tuto/sw_flow.png +0 -0
- data/tuto/the_counter_vcd.png +0 -0
- data/tuto/tutorial_sw.html +2359 -0
- data/tuto/tutorial_sw.md +2684 -0
- data/tuto/tutorial_sw.pdf +0 -0
- data/tuto/tutorial_sw_jp.md +417 -0
- metadata +49 -3
- data/lib/HDLRuby/hdr_samples/sumprod.rb +0 -29
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -26,6 +26,14 @@ module HDLRuby::High
|
|
26
26
|
return HDLRuby::Infinity
|
27
27
|
end
|
28
28
|
|
29
|
+
# Reimplementation of the Proc's curry that transmit the context for
|
30
|
+
# execution.
|
31
|
+
def curry_with_context(*args,&ruby_block)
|
32
|
+
return proc do |cxt,*new_args|
|
33
|
+
cxt.instance_exec(*(args+new_args),&ruby_block)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
29
37
|
|
30
38
|
|
31
39
|
##
|
@@ -38,7 +46,7 @@ module HDLRuby::High
|
|
38
46
|
# puts "eigen_extend for #{self} class=#{self.class}"
|
39
47
|
obj.singleton_methods.each do |name|
|
40
48
|
next if name == :yaml_tag # Do not know why we need to skip
|
41
|
-
puts "name=#{name}"
|
49
|
+
# puts "name=#{name}"
|
42
50
|
self.define_singleton_method(name, &obj.singleton_method(name))
|
43
51
|
end
|
44
52
|
end
|
@@ -403,6 +411,11 @@ module HDLRuby::High
|
|
403
411
|
return @scope
|
404
412
|
end
|
405
413
|
|
414
|
+
# Converts to a new reference.
|
415
|
+
def to_ref
|
416
|
+
return RefObject.new(this,self)
|
417
|
+
end
|
418
|
+
|
406
419
|
# Creates and adds a set of inputs typed +type+ from a list of +names+.
|
407
420
|
#
|
408
421
|
# NOTE: a name can also be a signal, is which case it is duplicated.
|
@@ -1397,6 +1410,7 @@ module HDLRuby::High
|
|
1397
1410
|
# Merge the included systems interface in +systemT+
|
1398
1411
|
# NOTE: incompatible with further to_low transformation.
|
1399
1412
|
def merge_included(systemT)
|
1413
|
+
# puts "merge_included for scope=#{self.name} with behaviors=#{self.each_behavior.count}"
|
1400
1414
|
# Recurse on the sub.
|
1401
1415
|
self.each_scope {|scope| scope.merge_included(systemT) }
|
1402
1416
|
# Include for current scope.
|
@@ -1437,6 +1451,8 @@ module HDLRuby::High
|
|
1437
1451
|
end
|
1438
1452
|
# Adds its subscopes.
|
1439
1453
|
included.scope.each_scope do |scope|
|
1454
|
+
# Do not override scopes with same name since it is prioritary!
|
1455
|
+
next if !scope.name.empty? && systemT.scope.each_scope.find {|sc| sc.name == scope.name}
|
1440
1456
|
scope.no_parent!
|
1441
1457
|
systemT.scope.add_scope(scope)
|
1442
1458
|
end
|
@@ -1709,10 +1725,27 @@ module HDLRuby::High
|
|
1709
1725
|
# Set the new method for the operator.
|
1710
1726
|
self.define_singleton_method(comp_operator(operator)) do |*args|
|
1711
1727
|
# puts "Top user=#{HDLRuby::High.top_user}"
|
1712
|
-
HDLRuby::High.top_user.
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1728
|
+
HDLRuby::High.top_user.sub(HDLRuby.uniq_name) do
|
1729
|
+
ruby_block.call(*args)
|
1730
|
+
end
|
1731
|
+
end
|
1732
|
+
end
|
1733
|
+
|
1734
|
+
# Redefinition of +operator+ when requiring the context to be passed
|
1735
|
+
# as argument (normally only used internally).
|
1736
|
+
def define_operator_with_context(operator,&ruby_block)
|
1737
|
+
# Ensure there is a block.
|
1738
|
+
ruby_block = proc {} unless block_given?
|
1739
|
+
# Register the operator as overloaded.
|
1740
|
+
@overloads ||= {}
|
1741
|
+
@overloads[operator] = ruby_block
|
1742
|
+
# Set the new method for the operator.
|
1743
|
+
self.define_singleton_method(comp_operator(operator)) do |*args|
|
1744
|
+
# puts "Top user=#{HDLRuby::High.top_user}"
|
1745
|
+
HDLRuby::High.top_user.sub(HDLRuby.uniq_name) do
|
1746
|
+
# It is assumed that the first argument of the ruby_block
|
1747
|
+
# is the context in which it must be executed.
|
1748
|
+
ruby_block.call(self,*args)
|
1716
1749
|
end
|
1717
1750
|
end
|
1718
1751
|
end
|
@@ -1945,7 +1978,8 @@ module HDLRuby::High
|
|
1945
1978
|
gtype)
|
1946
1979
|
# Adds the possible overloaded operators.
|
1947
1980
|
self.each_overload do |op,ruby_block|
|
1948
|
-
gtype.define_operator(op,&(ruby_block.curry[*args]))
|
1981
|
+
# gtype.define_operator(op,&(ruby_block.curry[*args]))
|
1982
|
+
gtype.define_operator_with_context(op,&(High.curry_with_context(*args,&ruby_block)))
|
1949
1983
|
end
|
1950
1984
|
# Returns the resulting type
|
1951
1985
|
return gtype
|
@@ -2010,7 +2044,7 @@ module HDLRuby::High
|
|
2010
2044
|
end
|
2011
2045
|
|
2012
2046
|
##
|
2013
|
-
# Describes
|
2047
|
+
# Describes an unsigned integer data type.
|
2014
2048
|
class TypeUnsigned < TypeVector
|
2015
2049
|
|
2016
2050
|
# Creates a new vector type named +name+ from +base+ type and with
|
@@ -2051,10 +2085,10 @@ module HDLRuby::High
|
|
2051
2085
|
|
2052
2086
|
# Converts the type to HDLRuby::Low and set its +name+.
|
2053
2087
|
def to_low(name = self.name)
|
2054
|
-
#
|
2055
|
-
# *@types.map
|
2056
|
-
typeTupleL = HDLRuby::Low::TypeTuple.new(name,self.direction
|
2057
|
-
|
2088
|
+
# typeTupleL = HDLRuby::Low::TypeTuple.new(name,self.direction,
|
2089
|
+
# *@types.map do |typ| typ.to_low )
|
2090
|
+
typeTupleL = HDLRuby::Low::TypeTuple.new(name,self.direction)
|
2091
|
+
@types.each { |typ| typeTupleL.add_type(typ.to_low) }
|
2058
2092
|
# # For debugging: set the source high object
|
2059
2093
|
# typeTupleL.properties[:low2high] = self.hdr_id
|
2060
2094
|
# self.properties[:high2low] = typeTupleL
|
@@ -2116,6 +2150,7 @@ module HDLRuby::High
|
|
2116
2150
|
gtype = type.generate(*args)
|
2117
2151
|
# And add it as a local type of the system.
|
2118
2152
|
HDLRuby::High.top_user.add_type(gtype)
|
2153
|
+
gtype
|
2119
2154
|
end
|
2120
2155
|
end
|
2121
2156
|
else
|
@@ -2820,17 +2855,17 @@ module HDLRuby::High
|
|
2820
2855
|
|
2821
2856
|
# Casts to a bit vector type.
|
2822
2857
|
def to_bit
|
2823
|
-
return self.as(bit[self.width])
|
2858
|
+
return self.as(HDLRuby::High.top_user.bit[self.type.width])
|
2824
2859
|
end
|
2825
2860
|
|
2826
2861
|
# Casts to an unsigned bit vector type.
|
2827
2862
|
def to_unsigned
|
2828
|
-
return self.as(unsigned[self.width])
|
2863
|
+
return self.as(HDLRuby::High.top_user.unsigned[self.type.width])
|
2829
2864
|
end
|
2830
2865
|
|
2831
2866
|
# Casts to a signed bit vector type.
|
2832
|
-
def
|
2833
|
-
return self.as(signed[self.width])
|
2867
|
+
def to_signed
|
2868
|
+
return self.as(HDLRuby::High.top_user.signed[self.type.width])
|
2834
2869
|
end
|
2835
2870
|
|
2836
2871
|
# Extends on the left to +n+ bits filling with +v+ bit values.
|
@@ -2962,6 +2997,12 @@ module HDLRuby::High
|
|
2962
2997
|
define_method(orig_operator(operator),&meth)
|
2963
2998
|
end
|
2964
2999
|
|
3000
|
+
# The <=> operator is also supported by is transformed into a sub
|
3001
|
+
# with a signed result.
|
3002
|
+
def <=>(expr)
|
3003
|
+
return (self.as(self.type.base[self.type.width+1])-expr).to_signed
|
3004
|
+
end
|
3005
|
+
|
2965
3006
|
|
2966
3007
|
# Creates an access to elements of range +rng+ of the signal.
|
2967
3008
|
#
|
@@ -3153,7 +3194,7 @@ module HDLRuby::High
|
|
3153
3194
|
|
3154
3195
|
|
3155
3196
|
##
|
3156
|
-
# Describes a
|
3197
|
+
# Describes a selection operation (generalization of the ternary operator).
|
3157
3198
|
#
|
3158
3199
|
# NOTE: choice is using the value of +select+ as an index.
|
3159
3200
|
class Select < Low::Select
|
@@ -3208,6 +3249,7 @@ module HDLRuby::High
|
|
3208
3249
|
# expr.to_low
|
3209
3250
|
# end
|
3210
3251
|
# )
|
3252
|
+
i = 0
|
3211
3253
|
concatL = HDLRuby::Low::Concat.new(self.type.to_low,
|
3212
3254
|
self.each_expression.map do |expr|
|
3213
3255
|
expr.to_low
|
@@ -3292,7 +3334,8 @@ module HDLRuby::High
|
|
3292
3334
|
|
3293
3335
|
# Converts to a new event.
|
3294
3336
|
def to_event
|
3295
|
-
return Event.new(:change,self.to_ref)
|
3337
|
+
# return Event.new(:change,self.to_ref)
|
3338
|
+
return Event.new(:anyedge,self.to_ref)
|
3296
3339
|
end
|
3297
3340
|
|
3298
3341
|
# Iterate over the elements.
|
@@ -3307,6 +3350,12 @@ module HDLRuby::High
|
|
3307
3350
|
end
|
3308
3351
|
end
|
3309
3352
|
|
3353
|
+
# Get the refered objects.
|
3354
|
+
def objects
|
3355
|
+
return [ self.object] if self.is_a?(RefObject)
|
3356
|
+
return self.each.map { |ref| ref.objects }.flatten
|
3357
|
+
end
|
3358
|
+
|
3310
3359
|
# Reference can be used like enumerator
|
3311
3360
|
include Enumerable
|
3312
3361
|
end
|
@@ -3370,8 +3419,19 @@ module HDLRuby::High
|
|
3370
3419
|
def to_low
|
3371
3420
|
# puts "to_low with base=#{@base} @object=#{@object}"
|
3372
3421
|
# puts "@object.name=#{@object.name}"
|
3373
|
-
|
3422
|
+
if @base.is_a?(RefThis) &&
|
3423
|
+
(@object.parent != High.top_user) &&
|
3424
|
+
(@object.parent != High.cur_system) &&
|
3425
|
+
(!@object.parent.name.empty?) then
|
3426
|
+
# Need to have a hierachical access.
|
3427
|
+
# puts "Indirect access for #{self.object.name}: #{self.object.parent.name}(#{self.object.parent.class}) != #{High.cur_system.name}(#{High.top_user.class})"
|
3428
|
+
refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
|
3429
|
+
@object.parent.to_ref.to_low,@object.name)
|
3430
|
+
else
|
3431
|
+
# Direct access is enough.
|
3432
|
+
refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
|
3374
3433
|
@base.to_ref.to_low,@object.name)
|
3434
|
+
end
|
3375
3435
|
# # For debugging: set the source high object
|
3376
3436
|
# refNameL.properties[:low2high] = self.hdr_id
|
3377
3437
|
# self.properties[:high2low] = refNameL
|
@@ -3801,11 +3861,15 @@ module HDLRuby::High
|
|
3801
3861
|
|
3802
3862
|
# Hierarchical type allows access to sub references, so generate
|
3803
3863
|
# the corresponding methods.
|
3864
|
+
# For that first get the real type.
|
3865
|
+
type = type.def while type.is_a?(TypeDef)
|
3866
|
+
# Now process it if it is a structured type.
|
3804
3867
|
if type.struct? then
|
3805
3868
|
type.each_name do |name|
|
3869
|
+
sig = SignalI.new(name,type.get_type(name),dir)
|
3870
|
+
self.add_signal(sig)
|
3806
3871
|
self.define_singleton_method(name) do
|
3807
|
-
RefObject.new(self.to_ref,
|
3808
|
-
SignalI.new(name,type.get_type(name),dir))
|
3872
|
+
RefObject.new(self.to_ref,sig)
|
3809
3873
|
end
|
3810
3874
|
end
|
3811
3875
|
end
|
@@ -3838,17 +3902,41 @@ module HDLRuby::High
|
|
3838
3902
|
|
3839
3903
|
# Creates a positive edge event from the signal.
|
3840
3904
|
def posedge
|
3841
|
-
return Event.new(:posedge,self.to_ref)
|
3905
|
+
# return Event.new(:posedge,self.to_ref)
|
3906
|
+
# Is there any sub signals?
|
3907
|
+
if self.each_signal.any? then
|
3908
|
+
# Yes, make events with them instead.
|
3909
|
+
return self.each_signal.map { |sig| sig.posedge }
|
3910
|
+
else
|
3911
|
+
# No, create a single event.
|
3912
|
+
return Event.new(:posedge,self.to_ref)
|
3913
|
+
end
|
3842
3914
|
end
|
3843
3915
|
|
3844
3916
|
# Creates a negative edge event from the signal.
|
3845
3917
|
def negedge
|
3846
|
-
return Event.new(:negedge,self.to_ref)
|
3918
|
+
# return Event.new(:negedge,self.to_ref)
|
3919
|
+
# Is there any sub signals?
|
3920
|
+
if self.each_signal.any? then
|
3921
|
+
# Yes, make events with them instead.
|
3922
|
+
return self.each_signal.map { |sig| sig.negedge }
|
3923
|
+
else
|
3924
|
+
# No, create a single event.
|
3925
|
+
return Event.new(:negedge,self.to_ref)
|
3926
|
+
end
|
3847
3927
|
end
|
3848
3928
|
|
3849
3929
|
# Creates an edge event from the signal.
|
3850
|
-
def
|
3851
|
-
return Event.new(:edge,self.to_ref)
|
3930
|
+
def anyedge
|
3931
|
+
# return Event.new(:edge,self.to_ref)
|
3932
|
+
# Is there any sub signals?
|
3933
|
+
if self.each_signal.any? then
|
3934
|
+
# Yes, make events with them instead.
|
3935
|
+
return self.each_signal.map { |sig| sig.anyedge }
|
3936
|
+
else
|
3937
|
+
# No, create a single event.
|
3938
|
+
return Event.new(:anyedge,self.to_ref)
|
3939
|
+
end
|
3852
3940
|
end
|
3853
3941
|
|
3854
3942
|
# Converts to a new reference.
|
@@ -3871,6 +3959,10 @@ module HDLRuby::High
|
|
3871
3959
|
# return HDLRuby::Low::SignalI.new(name,self.type.to_low)
|
3872
3960
|
valueL = self.value ? self.value.to_low : nil
|
3873
3961
|
signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low,valueL)
|
3962
|
+
# Recurse on the sub signals if any.
|
3963
|
+
self.each_signal do |sig|
|
3964
|
+
signalIL.add_signal(sig.to_low)
|
3965
|
+
end
|
3874
3966
|
# # For debugging: set the source high object
|
3875
3967
|
# signalIL.properties[:low2high] = self.hdr_id
|
3876
3968
|
# self.properties[:high2low] = signalIL
|
@@ -3937,6 +4029,10 @@ module HDLRuby::High
|
|
3937
4029
|
# self.value.to_low)
|
3938
4030
|
signalCL = HDLRuby::Low::SignalC.new(name,self.type.to_low,
|
3939
4031
|
self.value.to_low)
|
4032
|
+
# Recurse on the sub signals if any.
|
4033
|
+
self.each_signal do |sig|
|
4034
|
+
signalCL.add_signal(sig.to_low)
|
4035
|
+
end
|
3940
4036
|
# # For debugging: set the source high object
|
3941
4037
|
# signalCL.properties[:low2high] = self.hdr_id
|
3942
4038
|
# self.properties[:high2low] = signalCL
|
@@ -4062,7 +4158,8 @@ module HDLRuby::High
|
|
4062
4158
|
# +ruby_block+.
|
4063
4159
|
#
|
4064
4160
|
# NOTE: the else part is defined through the helse method.
|
4065
|
-
def hif(condition, mode = nil, &ruby_block)
|
4161
|
+
# def hif(condition, mode = nil, &ruby_block)
|
4162
|
+
def hif(condition, mode = self.mode, &ruby_block)
|
4066
4163
|
# Ensure there is a block.
|
4067
4164
|
ruby_block = proc {} unless block_given?
|
4068
4165
|
# Creates the if statement.
|
@@ -4325,14 +4422,14 @@ module HDLRuby::High
|
|
4325
4422
|
super(nil)
|
4326
4423
|
# # Save the Location for debugging information
|
4327
4424
|
# @location = caller_locations
|
4328
|
-
# Sets the current behavior
|
4329
|
-
@@cur_behavior = self
|
4330
|
-
# Add the events
|
4331
|
-
events.each { |event| self.add_event(event) }
|
4425
|
+
# # Sets the current behavior
|
4426
|
+
# @@cur_behavior = self
|
4427
|
+
# Add the events (they may be hierarchical to flatten)
|
4428
|
+
events.flatten.each { |event| self.add_event(event) }
|
4332
4429
|
# Create and add the block.
|
4333
4430
|
self.block = High.make_block(mode,&ruby_block)
|
4334
|
-
# Unset the current behavior
|
4335
|
-
@@cur_behavior = nil
|
4431
|
+
# # Unset the current behavior
|
4432
|
+
# @@cur_behavior = nil
|
4336
4433
|
end
|
4337
4434
|
|
4338
4435
|
# Sets an event to the behavior.
|
@@ -4499,12 +4596,21 @@ module HDLRuby::High
|
|
4499
4596
|
end
|
4500
4597
|
end
|
4501
4598
|
|
4502
|
-
# The current behavior: by default none.
|
4503
|
-
@@cur_behavior = nil
|
4599
|
+
# # The current behavior: by default none.
|
4600
|
+
# @@cur_behavior = nil
|
4504
4601
|
|
4505
4602
|
# Gets the enclosing behavior if any.
|
4506
4603
|
def self.cur_behavior
|
4507
|
-
return @@cur_behavior
|
4604
|
+
# return @@cur_behavior
|
4605
|
+
if in_behavior? then
|
4606
|
+
user = top_user
|
4607
|
+
while(user && !user.is_a?(Behavior)) do
|
4608
|
+
user = user.parent
|
4609
|
+
end
|
4610
|
+
return user
|
4611
|
+
else
|
4612
|
+
return nil
|
4613
|
+
end
|
4508
4614
|
end
|
4509
4615
|
|
4510
4616
|
# Tell if we are in a behavior.
|
@@ -4680,13 +4786,10 @@ module HDLRuby::High
|
|
4680
4786
|
return Value.new(TypeSigned.new(:"",self.bit_length..0),self)
|
4681
4787
|
end
|
4682
4788
|
end
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4686
|
-
|
4687
|
-
# Converts to a new high-level expression.
|
4688
|
-
def to_expr
|
4689
|
-
return Value.new(Float,self)
|
4789
|
+
|
4790
|
+
# Gets the bit width
|
4791
|
+
def width
|
4792
|
+
return self.bit_length
|
4690
4793
|
end
|
4691
4794
|
end
|
4692
4795
|
|
@@ -4982,19 +5085,21 @@ module HDLRuby::High
|
|
4982
5085
|
def to_value
|
4983
5086
|
str = self.to_s
|
4984
5087
|
return nil if str[0] != "_" # Bit string are prefixed by "_"
|
4985
|
-
# Remove the "_" not needed any longer.
|
4986
|
-
str = str[1..-1]
|
4987
5088
|
# Get and check the type
|
4988
|
-
type = str[0]
|
4989
|
-
|
5089
|
+
# type = str[0]
|
5090
|
+
type = str[1]
|
5091
|
+
if ["0", "1", "z", "Z", "o", "d", "h"].include?(type) then
|
4990
5092
|
# Default binary
|
4991
5093
|
type = "b"
|
4992
5094
|
else
|
4993
5095
|
# Not a default type
|
4994
|
-
str = str[1..-1]
|
5096
|
+
# str = str[1..-1]
|
5097
|
+
str = str[2..-1]
|
4995
5098
|
end
|
4996
|
-
return nil if str.empty?
|
4997
5099
|
return nil unless ["b","u","s"].include?(type)
|
5100
|
+
# Remove the "_"
|
5101
|
+
str = str.delete("_")
|
5102
|
+
return nil if str.empty?
|
4998
5103
|
# Get the width if any.
|
4999
5104
|
if str[0].match(/[0-9]/) then
|
5000
5105
|
width = str.scan(/[0-9]*/)[0]
|
@@ -5,10 +5,11 @@ require "HDLRuby/hruby_high"
|
|
5
5
|
module HDLRuby::High
|
6
6
|
|
7
7
|
##
|
8
|
-
# Library for
|
8
|
+
# Library for adding the fullname method to HDLRuby::High objects.
|
9
9
|
#
|
10
10
|
########################################################################
|
11
11
|
|
12
|
+
|
12
13
|
class SystemT
|
13
14
|
|
14
15
|
## Returns the name of the signal with its hierarchy.
|
@@ -32,6 +33,7 @@ module HDLRuby::High
|
|
32
33
|
|
33
34
|
end
|
34
35
|
|
36
|
+
|
35
37
|
class Scope
|
36
38
|
include WithFullname
|
37
39
|
end
|