HDLRuby 2.7.5 → 2.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4995e808d0aa2901a483011a4848bb9416d68850c95c74b9c2f2bf1fb3f648dc
4
- data.tar.gz: 729643cd60228ab9ba4f3ab719e434b48963805ed6f4ac01dbcff2fdd6eb54b9
3
+ metadata.gz: 2c66f2d8f552623dabccc43ea54a7246d49eb42a6aaf0f6b8a1977e7675221ca
4
+ data.tar.gz: 10f9b15022166b3fdb90a9a026653f3fec8b5a05f807e468dfed2d1c97d9adf7
5
5
  SHA512:
6
- metadata.gz: 82316dd87a532dbfa67d86fcdb13ade3f8329912bb6aa56ae0b5a4efe0a6110922912f52ae3558c4683147bb224ae2ed0b67e1d60e265d5d30624b3a2bee77be
7
- data.tar.gz: 4df2cfb5c257838246fa2f953b3eeaa751902900ae4ea5319a69ca81f9e7eae49b75163fc621a81b2af1b399360c030ccf8717916c2abb7a5d2ffaad27d2b5df
6
+ metadata.gz: 3c56c51a83e75ddd03d34d0c305a17595c362077010213e299baf60e8a7e0b52e745c6b8f9ada7db3c4931b99809376ffdc54f3f4bbb122e002a82419f39e7fb
7
+ data.tar.gz: 3f056bd7523dea35b03188aa689a232afeadb7c24f7608f3207fc2479503081e1e1ce0a55c2ad3cc805721b60e7d559d464d9fa89a6f79f3f962388254eac6e7
@@ -0,0 +1,61 @@
1
+ # Check of various par and seq.
2
+
3
+ # A benchmark for the dff.
4
+ system :parseq_bench do
5
+ [4].inner :x0, :x1, :x2, :x3
6
+ [4].inner :y0, :y1, :y2, :y3
7
+ [4].inner :z00, :z01
8
+ [4].inner :z10, :z11
9
+ [4].inner :z20, :z21
10
+ [4].inner :z30, :z31
11
+ [4].inner :u0, :u1, :u2, :u3
12
+ bit[4][-16].constant mem: 16.times.to_a
13
+
14
+ par(x0) do
15
+ z00 <= x0 + y0
16
+ z01 <= z00 + 1
17
+ u0 <= mem[z00]
18
+ end
19
+
20
+ seq(y1) do
21
+ z10 <= x1 + y1
22
+ z11 <= z10 + 1
23
+ u1 <= mem[z10]
24
+ end
25
+
26
+ seq(x2,y2) do
27
+ z20 <= x2 + y2
28
+ z21 <= z20 + 1
29
+ u2 <= mem[z20]
30
+ end
31
+
32
+ par do
33
+ bit[4].constant inc: 1
34
+ z30 <= x3 + y3
35
+ z31 <= z30 + inc
36
+ u3 <= mem[z30]
37
+ end
38
+
39
+
40
+ timed do
41
+ x0 <= 1
42
+ x1 <= 1
43
+ x2 <= 1
44
+ x3 <= 1
45
+ !10.ns
46
+ y0 <= 2
47
+ y1 <= 2
48
+ y2 <= 2
49
+ y3 <= 2
50
+ !10.ns
51
+ x0 <= 3
52
+ x1 <= 3
53
+ x2 <= 3
54
+ x3 <= 3
55
+ y0 <= 4
56
+ y1 <= 4
57
+ y2 <= 4
58
+ y3 <= 4
59
+ !10.ns
60
+ end
61
+ end
@@ -3,13 +3,16 @@
3
3
  # A benchmark for the index access..
4
4
  system :if_bench do
5
5
  [8].inner :x
6
- [2].inner :r0,:r1,:r2,:r3
6
+ [2].inner :r0,:r1,:r2,:r3, :r4
7
+ inner :r5
7
8
 
8
9
  par do
9
10
  r0 <= x[1..0]
10
11
  r1 <= x[3..2]
11
12
  r2 <= x[5..4]
12
13
  r3 <= x[7..6]
14
+ r4 <= x[-1..-2]
15
+ r5 <= x[-1]
13
16
  end
14
17
 
15
18
  timed do
@@ -0,0 +1,27 @@
1
+ # Rom access generator, def case.
2
+ def rom_gen(addr,&func)
3
+ bit[8][-8].constant tbl? => 8.times.map {|i| func.(i).to_i }
4
+ tbl![addr]
5
+ end
6
+
7
+
8
+
9
+ system :test_rom do
10
+ [2..0].inner :addr
11
+ [7..0].inner :data0, :data1, :data2, :data3
12
+
13
+ data0 <= rom_gen(addr) { |i| i*i }
14
+ data1 <= rom_gen(addr) { |i| i*i }
15
+
16
+ par do
17
+ data2 <= rom_gen(addr) { |i| i*i }
18
+ data3 <= rom_gen(addr) { |i| i*i }
19
+ end
20
+
21
+ timed do
22
+ 8.times do |i|
23
+ addr <= i
24
+ !10.ns
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,128 @@
1
+ require 'std/channel.rb'
2
+ require 'std/hruby_unit.rb'
3
+
4
+ include HDLRuby::High::Std
5
+
6
+ # A clocked handshake channel for testing purpuse.
7
+ channel(:handshake) do |typ,clk|
8
+ inner has_data: 0
9
+ inner :set_data
10
+ inner :get_data
11
+ typ.inner :data, :data_val
12
+
13
+ writer_input :has_data
14
+ writer_output :set_data, :data_val
15
+ reader_input :has_data, :data
16
+ reader_output :get_data
17
+
18
+ par(clk.negedge) do
19
+ hif(set_data) do
20
+ data <= data_val
21
+ has_data <= 1
22
+ end
23
+ helsif(get_data) do
24
+ has_data <= 0
25
+ end
26
+ end
27
+
28
+ # The writer.
29
+ writer do |blk,target|
30
+ hif(~has_data) do
31
+ set_data <= 1
32
+ data_val <= target
33
+ blk.call if blk
34
+ end
35
+ helse { set_data <= 0 }
36
+ end
37
+
38
+ # The reader
39
+ reader do |blk,target|
40
+ hif(has_data) do
41
+ target <= data
42
+ get_data <= 1
43
+ blk.call if blk
44
+ end
45
+ helse { get_data <= 0 }
46
+ end
47
+ end
48
+
49
+
50
+
51
+ # A system writing indefinitely to a channel.
52
+ # Checking usage of channel without declaring a port.
53
+ system :producer8 do |channel|
54
+ # Inputs of the producer: clock and reset.
55
+ input :clk, :rst
56
+ # Inner 8-bit counter for generating values.
57
+ [8].inner :counter
58
+
59
+ # The value production process
60
+ par(clk.posedge) do
61
+ hif(rst) { counter <= 0 }
62
+ helse do
63
+ channel.write(counter) { counter <= counter + 1 }
64
+ end
65
+ end
66
+ end
67
+
68
+ # A system reading indefinitely from a channel.
69
+ system :consummer8 do |channel|
70
+ # Input of the consummer: a clock is enough.
71
+ input :clk
72
+ # # Instantiate the channel ports
73
+ # channel.input :ch
74
+ # Inner buffer for storing the cunsummed value.
75
+ [8].inner :buf
76
+
77
+ # The value consumption process
78
+ par(clk.posedge) do
79
+ channel.read(buf)
80
+ end
81
+ end
82
+
83
+
84
+ # A system testing the handshaker.
85
+ Unit.system :hs_test do
86
+ inner :clk,:rst
87
+
88
+ # Declares two handshakers
89
+ handshake(bit[8],clk).(:hs)
90
+
91
+ # For the first handshake
92
+
93
+ # Instantiate the producer.
94
+ producer8(hs).(:producerI).(clk,rst)
95
+
96
+ # Instantiate the consummer.
97
+ consummer8(hs).(:consummerI).(clk)
98
+
99
+ test do
100
+ clk <= 0
101
+ rst <= 0
102
+ !10.ns
103
+ clk <= 1
104
+ !10.ns
105
+ clk <= 0
106
+ rst <= 1
107
+ !10.ns
108
+ clk <= 1
109
+ !10.ns
110
+ clk <= 0
111
+ !10.ns
112
+ !10.ns
113
+ clk <= 1
114
+ !10.ns
115
+ clk <= 0
116
+ rst <= 0
117
+ !10.ns
118
+ clk <= 1
119
+ !10.ns
120
+ 10.times do
121
+ clk <= 0
122
+ !10.ns
123
+ clk <= 1
124
+ !10.ns
125
+ end
126
+ end
127
+
128
+ end
@@ -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
@@ -832,8 +848,7 @@ module HDLRuby::High
832
848
  # Initialize the set of included systems.
833
849
  @includes = {}
834
850
 
835
- # Builds the scope if a ruby block is provided
836
- # (which means the scope is not the top of a system).
851
+ # Builds the scope if a ruby block is provided.
837
852
  self.build(&ruby_block) if block_given?
838
853
  end
839
854
 
@@ -944,18 +959,20 @@ module HDLRuby::High
944
959
  # Set the namespace for buidling the scope.
945
960
  High.space_push(@namespace)
946
961
  # Build the scope.
947
- # @return_value = High.top_user.instance_eval(&ruby_block)
948
- 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)
949
964
  High.space_pop
950
- # Now gain access to the result within the sub scope.
951
- if (res.is_a?(HRef)) then
952
- @return_value = res.type.inner(HDLRuby.uniq_name)
953
- High.space_push(@namespace)
954
- @return_value <= res
955
- High.space_pop
956
- else
957
- @return_value = res
958
- end
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
959
976
  # This will be the return value.
960
977
  @return_value
961
978
  end
@@ -1087,10 +1104,12 @@ module HDLRuby::High
1087
1104
  # Declares a sub scope with possible +name+ and built from +ruby_block+.
1088
1105
  def sub(name = :"", &ruby_block)
1089
1106
  # Creates the new scope.
1090
- scope = Scope.new(name,&ruby_block)
1091
- # puts "new scope=#{scope}"
1107
+ # scope = Scope.new(name,&ruby_block)
1108
+ scope = Scope.new(name)
1092
1109
  # Add it
1093
1110
  self.add_scope(scope)
1111
+ # Build it.
1112
+ scope.build(&ruby_block)
1094
1113
  # puts "self=#{self}"
1095
1114
  # puts "self scopes=#{self.each_scope.to_a.join(",")}"
1096
1115
  # Use its return value
@@ -1965,9 +1984,6 @@ module HDLRuby::High
1965
1984
  &ruby_block)
1966
1985
  # ruby_block.call(*args)
1967
1986
  end
1968
- # sub do
1969
- # ruby_block.call(*args,*other_block)
1970
- # end
1971
1987
  end
1972
1988
  else
1973
1989
  define_method(name.to_sym) do |*args,&other_block|
@@ -1975,10 +1991,8 @@ module HDLRuby::High
1975
1991
  sub(HDLRuby.uniq_name(name)) do
1976
1992
  HDLRuby::High.top_user.instance_exec(*args,*other_block,
1977
1993
  &ruby_block)
1994
+ # ruby_block.call(*args,*other_block)
1978
1995
  end
1979
- # sub do
1980
- # ruby_block.call(*args,*other_block)
1981
- # end
1982
1996
  end
1983
1997
  end
1984
1998
  end
@@ -2671,6 +2685,20 @@ module HDLRuby::High
2671
2685
  #
2672
2686
  # NOTE: +rng+ can be a single expression in which case it is an index.
2673
2687
  def [](rng)
2688
+ if rng.is_a?(::Range) then
2689
+ first = rng.first
2690
+ if (first.is_a?(::Integer)) then
2691
+ first = self.type.size+first if first < 0
2692
+ end
2693
+ last = rng.last
2694
+ if (last.is_a?(::Integer)) then
2695
+ last = self.type.size+last if last < 0
2696
+ end
2697
+ rng = first..last
2698
+ end
2699
+ if rng.is_a?(::Integer) && rng < 0 then
2700
+ rng = self.type.size+rng
2701
+ end
2674
2702
  if rng.respond_to?(:to_expr) then
2675
2703
  # Number range: convert it to an expression.
2676
2704
  rng = rng.to_expr
@@ -3007,6 +3035,7 @@ module HDLRuby::High
3007
3035
 
3008
3036
  # Creates a new reference from a +base+ reference and named +object+.
3009
3037
  def initialize(base,object)
3038
+ # puts "New RefObjet with base=#{base}, object=#{object.name}"
3010
3039
  if object.respond_to?(:type) then
3011
3040
  # Typed object, so typed reference.
3012
3041
  super(object.type)
@@ -3043,7 +3072,7 @@ module HDLRuby::High
3043
3072
 
3044
3073
  # Converts the name reference to a HDLRuby::Low::RefName.
3045
3074
  def to_low
3046
- # puts "to_low with base=#{@base} @object=#{@object}"
3075
+ # puts "to_low with base=#{@base} @object=#{@object.name}"
3047
3076
  refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
3048
3077
  @base.to_ref.to_low,@object.name)
3049
3078
  # # For debugging: set the source high object
@@ -3608,6 +3637,15 @@ module HDLRuby::High
3608
3637
  High.space_push(@namespace)
3609
3638
  @return_value = High.top_user.instance_eval(&ruby_block)
3610
3639
  High.space_pop
3640
+ # if @return_value.is_a?(HExpression) then
3641
+ # res = @return_value
3642
+ # High.space_push(@namespace)
3643
+ # @return_value = res.type.inner(HDLRuby.uniq_name)
3644
+ # puts "@return_value name=#{@return_value.name}"
3645
+ # @return_value <= res
3646
+ # High.space_pop
3647
+ # @return_value = RefObject.new(self,@return_value)
3648
+ # end
3611
3649
  @return_value
3612
3650
  end
3613
3651
 
@@ -3797,7 +3835,7 @@ module HDLRuby::High
3797
3835
  # Converts the block to HDLRuby::Low.
3798
3836
  def to_low
3799
3837
  # Create the resulting block
3800
- blockL = HDLRuby::Low::Block.new(self.mode)
3838
+ blockL = HDLRuby::Low::Block.new(self.mode,self.name)
3801
3839
  # # For debugging: set the source high object
3802
3840
  # blockL.properties[:low2high] = self.hdr_id
3803
3841
  # self.properties[:high2low] = blockL
@@ -4058,6 +4058,7 @@ module HDLRuby::Low
4058
4058
 
4059
4059
  # Adds inner signal +signal+.
4060
4060
  def add_inner(signal)
4061
+ # puts "add inner=#{signal.name} in block=#{self}"
4061
4062
  # Check and add the signal.
4062
4063
  unless signal.is_a?(SignalI)
4063
4064
  raise AnyError,
@@ -4087,6 +4088,7 @@ module HDLRuby::Low
4087
4088
 
4088
4089
  ## Gets an inner signal by +name+.
4089
4090
  def get_inner(name)
4091
+ # puts "name=#{name}, inners=#{@inners.each_key.to_a}"
4090
4092
  return @inners[name.to_sym]
4091
4093
  end
4092
4094
  alias_method :get_signal, :get_inner
@@ -356,8 +356,13 @@ module HDLRuby::Low
356
356
  end
357
357
  self.scope.each_block_deep do |block|
358
358
  block.each_inner do |signal|
359
- # res << signal.value.to_ch if signal.value
360
- signal.value.to_ch(res) if signal.value
359
+ # signal.value.to_ch(res) if signal.value
360
+ if signal.value then
361
+ signal.value.each_node_deep do |node|
362
+ # res << node.to_ch if node.is_a?(Value)
363
+ node.to_ch(res) if node.is_a?(Value)
364
+ end
365
+ end
361
366
  end
362
367
  block.each_node_deep do |node|
363
368
  # res << node.to_ch if node.is_a?(Value)
@@ -702,6 +707,10 @@ module HDLRuby::Low
702
707
  end.to_a
703
708
  # Keep only one ref per signal.
704
709
  refs.uniq! { |node| node.full_name }
710
+ # Remove the inner signals from the list.
711
+ self.block.each_inner do |inner|
712
+ refs.delete_if {|r| r.name == inner.name }
713
+ end
705
714
  # Generate the event.
706
715
  events = refs.map {|ref| Event.new(:anyedge,ref.clone) }
707
716
  # Add them to the behavior for further processing.
@@ -891,11 +900,12 @@ module HDLRuby::Low
891
900
  if self.value then
892
901
  # There is an initial value.
893
902
  res << " " * (level+1)*3
894
- # res << "copy_value(#{self.value.to_c(level+2)}," +
895
- # "signalI->c_value);\n"
903
+ # res << "copy_value("
904
+ # self.value.to_c_expr(res,level+2)
905
+ # res << ",signalI->c_value);\n"
896
906
  res << "copy_value("
897
907
  self.value.to_c_expr(res,level+2)
898
- res << ",signalI->c_value);\n"
908
+ res << ",signalI->f_value);\n"
899
909
  end
900
910
 
901
911
  # Initially the signal can be overwritten by anything.
@@ -1893,6 +1903,16 @@ module HDLRuby::Low
1893
1903
  # Should never be here.
1894
1904
  raise AnyError, "Internal error: to_c should be implemented in class :#{self.class}"
1895
1905
  end
1906
+
1907
+ ## Generates the C text for an expression access to the expression,
1908
+ # default case.
1909
+ # +level+ is the hierachical level of the object.
1910
+ def to_c_expr(res,level = 0)
1911
+ res << "({"
1912
+ self.to_c(res,level+1)
1913
+ res << (" " * ((level+1)*3))
1914
+ res << "pop();})"
1915
+ end
1896
1916
  end
1897
1917
 
1898
1918
 
@@ -2455,46 +2475,64 @@ module HDLRuby::Low
2455
2475
  return res
2456
2476
  end
2457
2477
 
2458
- # Generates the C text of expression for the equivalent HDLRuby code.
2459
- # +level+ is the hierachical level of the object.
2460
- def to_c_expr(res,level = 0)
2461
- # Gather the content to concat.
2462
- expressions = self.each_expression.to_a
2463
- # Create the resulting string.
2464
- res << "({\n"
2465
- # Overrides the upper src0, src1, ..., and dst...
2466
- # And allocates a new value for dst.
2467
- res << (" " * ((level+1)*3))
2468
- res << "Value "
2469
- res << expressions.size.times.map do |i|
2470
- "src#{i}"
2471
- end.join(",")
2472
- res << ";\n"
2473
- res << (" " * ((level+1)*3))
2474
- res << "Value dst = get_value();\n"
2475
- # Save the value pool state.
2476
- res << (" " * (level*3)) << "SV;\n"
2477
- # Compute each sub expression.
2478
- expressions.each_with_index do |expr,i|
2479
- res << (" " * ((level+1)*3))
2480
- res << "src#{i} = "
2481
- expr.to_c_expr(res,level+2)
2482
- res << ";\n"
2483
- end
2484
- # Compute the direction.
2485
- # Compute the resulting concatenation.
2486
- res << (" " * ((level+1)*3))
2487
- res << "concat_value(#{expressions.size},"
2488
- res << "#{self.type.direction == :little ? 1 : 0},dst,"
2489
- res << expressions.size.times.map { |i| "src#{i}" }.join(",")
2490
- res << ");\n"
2491
- # Save the value pool state.
2492
- res << (" " * (level*3)) << "SV;\n"
2493
- # Close the computation.
2494
- res << (" " * (level*3))
2495
- res << "dst; })"
2496
- return res
2497
- end
2478
+ # # # Generates the C text of expression for the equivalent HDLRuby code.
2479
+ # # # +level+ is the hierachical level of the object.
2480
+ # # def to_c_expr(res,level = 0)
2481
+ # # # Gather the content to concat.
2482
+ # # expressions = self.each_expression.to_a
2483
+ # # # Create the resulting string.
2484
+ # # res << "({\n"
2485
+ # # # Overrides the upper src0, src1, ..., and dst...
2486
+ # # # And allocates a new value for dst.
2487
+ # # res << (" " * ((level+1)*3))
2488
+ # # res << "Value "
2489
+ # # res << expressions.size.times.map do |i|
2490
+ # # "src#{i}"
2491
+ # # end.join(",")
2492
+ # # res << ";\n"
2493
+ # # res << (" " * ((level+1)*3))
2494
+ # # res << "Value dst = get_value();\n"
2495
+ # # # Save the value pool state.
2496
+ # # res << (" " * (level*3)) << "SV;\n"
2497
+ # # # Compute each sub expression.
2498
+ # # expressions.each_with_index do |expr,i|
2499
+ # # res << (" " * ((level+1)*3))
2500
+ # # res << "src#{i} = "
2501
+ # # expr.to_c_expr(res,level+2)
2502
+ # # res << ";\n"
2503
+ # # end
2504
+ # # # Compute the direction.
2505
+ # # # Compute the resulting concatenation.
2506
+ # # res << (" " * ((level+1)*3))
2507
+ # # res << "concat_value(#{expressions.size},"
2508
+ # # res << "#{self.type.direction == :little ? 1 : 0},dst,"
2509
+ # # res << expressions.size.times.map { |i| "src#{i}" }.join(",")
2510
+ # # res << ");\n"
2511
+ # # # Save the value pool state.
2512
+ # # res << (" " * (level*3)) << "SV;\n"
2513
+ # # # Close the computation.
2514
+ # # res << (" " * (level*3))
2515
+ # # res << "dst; })"
2516
+ # # return res
2517
+ # # end
2518
+ # def to_c_expr(res,level = 0)
2519
+ # # Save the value pool state.
2520
+ # res << "({ PV;"
2521
+ # # Gather the content to concat.
2522
+ # expressions = self.each_expression.to_a
2523
+ # # Compute each sub expression.
2524
+ # expressions.each_with_index do |expr,i|
2525
+ # expr.to_c(res,level+2)
2526
+ # end
2527
+ # # Compute the resulting concatenation.
2528
+ # res << (" " * ((level+1)*3))
2529
+ # res << "sconcat(#{expressions.size},"
2530
+ # res << (self.type.direction == :little ? "1" : "0")
2531
+ # res << ");\n"
2532
+ # # Restore the value pool state.
2533
+ # res << "RV; pop();})"
2534
+ # return res
2535
+ # end
2498
2536
  end
2499
2537
 
2500
2538
 
@@ -2778,17 +2816,11 @@ module HDLRuby::Low
2778
2816
  # +left+ tells if it is a left value or not.
2779
2817
  # def to_c(level = 0, left = false)
2780
2818
  def to_c(res,level = 0, left = false)
2781
- # # puts "RefName to_c for #{self.name}"
2782
- # self.resolve.to_c_signal(res,level+1)
2783
- # res << "->" << (left ? "f_value" : "c_value")
2784
- # return res
2785
2819
  # puts "RefName to_c for #{self.name}"
2786
2820
  res << (" " * (level*3))
2787
- # res << "d="
2788
2821
  res << "push("
2789
2822
  self.resolve.to_c_signal(res,level+1)
2790
2823
  res << "->" << (left ? "f_value" : "c_value")
2791
- # res << ";\n"
2792
2824
  res << ");\n"
2793
2825
  return res
2794
2826
  end
@@ -50,9 +50,25 @@ module HDLRuby::Low
50
50
  return found if found
51
51
  # Maybe it is a sub scope.
52
52
  return self.each_scope.find { |scope| scope.name == name }
53
+ # Maybe it in the behavior.
54
+ return self.behavior.get_by_name
53
55
  end
54
56
  end
55
57
 
58
+ ##
59
+ # Extends Behavior with the capability of finding one of its inner object
60
+ # by name.
61
+ class Behavior
62
+
63
+ ## Find an inner object by +name+.
64
+ # NOTE: return nil if not found.
65
+ def get_by_name(name)
66
+ if (self.block.name == name.to_sym) then
67
+ return self.block
68
+ end
69
+ return self.block.get_by_name(name)
70
+ end
71
+ end
56
72
 
57
73
  ##
58
74
  # Extends SystemI with the capability of finding one of its inner object
@@ -79,7 +95,16 @@ module HDLRuby::Low
79
95
  # Ensure the name is a symbol.
80
96
  name = name.to_sym
81
97
  # Look in the signals.
82
- return self.get_inner(name)
98
+ found = self.get_inner(name)
99
+ return found if found
100
+ # Check the sub blocks names.
101
+ self.each_block do |block|
102
+ # puts "block=#{block.name}"
103
+ if (block.name == name) then
104
+ return block
105
+ end
106
+ end
107
+ return nil
83
108
  end
84
109
  end
85
110
 
@@ -199,6 +224,7 @@ module HDLRuby::Low
199
224
  if self.ref.is_a?(RefName) then
200
225
  # puts "ref name=#{self.ref.name}"
201
226
  obj = self.ref.resolve
227
+ # puts "obj=#{obj}"
202
228
  # Look into the object for the name.
203
229
  return obj.get_by_name(self.name)
204
230
  else
@@ -208,12 +234,15 @@ module HDLRuby::Low
208
234
  while parent
209
235
  # puts "parent=#{parent}"
210
236
  if parent.respond_to?(:get_by_name) then
237
+ # puts "get_by_name"
211
238
  found = parent.get_by_name(self.name)
239
+ # puts "found" if found
212
240
  return found if found
213
241
  end
214
242
  parent = parent.parent
215
243
  end
216
244
  # Not found.
245
+ # puts "Not found!"
217
246
  return nil
218
247
  end
219
248
  end
@@ -1,5 +1,6 @@
1
1
  require 'set'
2
2
 
3
+
3
4
  module HDLRuby
4
5
 
5
6
  ##
@@ -108,7 +108,7 @@ void register_signal(SignalI signal) {
108
108
  /** Recursively update the signals until no (untimed) behavior are
109
109
  * activated. */
110
110
  void hruby_sim_update_signals() {
111
- // printf("hruby_sim_update_signals...\n");
111
+ // printf("hruby_sim_update_signals...\n");
112
112
  /* As long as the list of touched signals is not empty go on computing. */
113
113
  while(!empty_list(touched_signals) || !empty_list(touched_signals_seq)) {
114
114
  // printf("## Checking touched signals.\n");
@@ -121,7 +121,6 @@ void hruby_sim_update_signals() {
121
121
  /* Is there a change? */
122
122
  if (same_content_value(sig->c_value,sig->f_value)) continue;
123
123
  /* Yes, process the signal. */
124
- // println_signal(sig);
125
124
  printer.print_signal(sig);
126
125
  // printf("c_value="); printer.print_value(sig->c_value);
127
126
  // printf("\nf_value="); printer.print_value(sig->f_value); printf("\n");
@@ -441,6 +440,10 @@ void hruby_sim_core(char* name, void (*init_vizualizer)(char*),
441
440
  /* Update the signal values (recursively executing blocks locked
442
441
  * on the signals). */
443
442
  hruby_sim_update_signals();
443
+ if (hruby_sim_time == 0) {
444
+ /* Initially touch all the signals. */
445
+ each_all_signal(&touch_signal);
446
+ }
444
447
  if (num_run_behaviors <= 0) break;
445
448
  /* Advance time to next timestep. */
446
449
  hruby_sim_advance_time();
@@ -1,3 +1,3 @@
1
1
  module HDLRuby
2
- VERSION = "2.7.5"
2
+ VERSION = "2.7.11"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: HDLRuby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.5
4
+ version: 2.7.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lovic Gauthier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-11 00:00:00.000000000 Z
11
+ date: 2022-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -125,11 +125,13 @@ files:
125
125
  - lib/HDLRuby/hdr_samples/neural/selector.rb
126
126
  - lib/HDLRuby/hdr_samples/neural/sigmoid.rb
127
127
  - lib/HDLRuby/hdr_samples/neural/z.rb
128
+ - lib/HDLRuby/hdr_samples/parseq_bench.rb
128
129
  - lib/HDLRuby/hdr_samples/prog.obj
129
130
  - lib/HDLRuby/hdr_samples/ram.rb
130
131
  - lib/HDLRuby/hdr_samples/range_bench.rb
131
132
  - lib/HDLRuby/hdr_samples/register_with_code_bench.rb
132
133
  - lib/HDLRuby/hdr_samples/rom.rb
134
+ - lib/HDLRuby/hdr_samples/rom_nest.rb
133
135
  - lib/HDLRuby/hdr_samples/ruby_fir_hw.rb
134
136
  - lib/HDLRuby/hdr_samples/seqpar_bench.rb
135
137
  - lib/HDLRuby/hdr_samples/struct.rb
@@ -142,6 +144,7 @@ files:
142
144
  - lib/HDLRuby/hdr_samples/type_minmax_bench.rb
143
145
  - lib/HDLRuby/hdr_samples/with_casts.rb
144
146
  - lib/HDLRuby/hdr_samples/with_channel.rb
147
+ - lib/HDLRuby/hdr_samples/with_channel_other.rb
145
148
  - lib/HDLRuby/hdr_samples/with_class.rb
146
149
  - lib/HDLRuby/hdr_samples/with_concat.rb
147
150
  - lib/HDLRuby/hdr_samples/with_connector.rb