HDLRuby 2.11.10 → 2.11.12

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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +55 -18
  3. data/ext/hruby_sim/hruby_rcsim_build.c +110 -83
  4. data/ext/hruby_sim/hruby_sim.h +3 -0
  5. data/ext/hruby_sim/hruby_sim_calc.c +14 -6
  6. data/ext/hruby_sim/hruby_sim_core.c +20 -7
  7. data/ext/hruby_sim/hruby_sim_list.c +1 -1
  8. data/ext/hruby_sim/hruby_sim_stack_calc.c +3 -2
  9. data/ext/hruby_sim/hruby_sim_tree_calc.c +8 -1
  10. data/ext/hruby_sim/hruby_sim_vcd.c +24 -7
  11. data/ext/hruby_sim/hruby_sim_vizualize.c +9 -1
  12. data/lib/HDLRuby/hdr_samples/constant_in_function.rb +3 -1
  13. data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +3 -1
  14. data/lib/HDLRuby/hdr_samples/huge_rom.rb +1 -1
  15. data/lib/HDLRuby/hdr_samples/mei8.rb +11 -11
  16. data/lib/HDLRuby/hdr_samples/mei8_bench.rb +11 -11
  17. data/lib/HDLRuby/hdr_samples/neg_arith_bench.rb +4 -4
  18. data/lib/HDLRuby/hdr_samples/rom_nest.rb +1 -1
  19. data/lib/HDLRuby/hdr_samples/ruby_fir_hw.rb +4 -4
  20. data/lib/HDLRuby/hdr_samples/struct.rb +44 -10
  21. data/lib/HDLRuby/hdr_samples/with_bram.rb +45 -0
  22. data/lib/HDLRuby/hdr_samples/with_casts.rb +3 -3
  23. data/lib/HDLRuby/hdr_samples/with_concat.rb +6 -6
  24. data/lib/HDLRuby/hdr_samples/with_connector_memory.rb +2 -2
  25. data/lib/HDLRuby/hdr_samples/with_def.rb +10 -3
  26. data/lib/HDLRuby/hdr_samples/with_define_operator.rb +44 -0
  27. data/lib/HDLRuby/hdr_samples/with_fixpoint.rb +12 -12
  28. data/lib/HDLRuby/hdr_samples/with_init.rb +3 -3
  29. data/lib/HDLRuby/hdr_samples/with_leftright.rb +21 -0
  30. data/lib/HDLRuby/hdr_samples/with_reduce.rb +13 -13
  31. data/lib/HDLRuby/hdr_samples/with_ref_array.rb +6 -6
  32. data/lib/HDLRuby/hdr_samples/with_subsums.rb +3 -3
  33. data/lib/HDLRuby/hdr_samples/with_terminate.rb +3 -3
  34. data/lib/HDLRuby/hdr_samples/with_to_a.rb +10 -10
  35. data/lib/HDLRuby/hdr_samples/with_values.rb +3 -3
  36. data/lib/HDLRuby/hdrcc.rb +14 -1
  37. data/lib/HDLRuby/hruby_bstr.rb +10 -5
  38. data/lib/HDLRuby/hruby_high.rb +114 -27
  39. data/lib/HDLRuby/hruby_low.rb +187 -16
  40. data/lib/HDLRuby/hruby_low2c.rb +71 -11
  41. data/lib/HDLRuby/hruby_low2vhd.rb +2 -1
  42. data/lib/HDLRuby/hruby_low_fix_types.rb +1 -0
  43. data/lib/HDLRuby/hruby_low_mutable.rb +30 -1
  44. data/lib/HDLRuby/hruby_low_resolve.rb +15 -2
  45. data/lib/HDLRuby/hruby_low_without_concat.rb +28 -8
  46. data/lib/HDLRuby/hruby_low_without_parinseq.rb +14 -4
  47. data/lib/HDLRuby/hruby_low_without_select.rb +2 -2
  48. data/lib/HDLRuby/hruby_low_without_subsignals.rb +279 -0
  49. data/lib/HDLRuby/hruby_rcsim.rb +99 -87
  50. data/lib/HDLRuby/hruby_rsim.rb +132 -7
  51. data/lib/HDLRuby/hruby_rsim_vcd.rb +99 -27
  52. data/lib/HDLRuby/hruby_values.rb +35 -31
  53. data/lib/HDLRuby/std/bram.rb +22 -0
  54. data/lib/HDLRuby/std/fixpoint.rb +2 -2
  55. data/lib/HDLRuby/std/fsm.rb +20 -3
  56. data/lib/HDLRuby/std/function_generator.rb +2 -2
  57. data/lib/HDLRuby/version.rb +1 -1
  58. metadata +7 -3
  59. data/lib/HDLRuby/hdr_samples/sumprod.rb +0 -29
@@ -850,6 +850,7 @@ module HDLRuby::Low
850
850
 
851
851
  # Adds inner signal +signal+.
852
852
  def add_inner(signal)
853
+ # puts "adding inner signal: #{signal.name}(#{signal})"
853
854
  # Check and add the signal.
854
855
  unless signal.is_a?(SignalI)
855
856
  raise AnyError,
@@ -1632,6 +1633,112 @@ module HDLRuby::Low
1632
1633
 
1633
1634
  alias_method :each_deep, :each_type_deep
1634
1635
 
1636
+ # Tells if the type signed.
1637
+ def signed?
1638
+ return @def.signed?
1639
+ end
1640
+
1641
+ # Tells if the type is unsigned.
1642
+ def unsigned?
1643
+ return @def.unsigned?
1644
+ end
1645
+
1646
+ # Tells if the type is fixed point.
1647
+ def fixed?
1648
+ return @def.fixed?
1649
+ end
1650
+
1651
+ # Tells if the type is floating point.
1652
+ def float?
1653
+ return @def.float?
1654
+ end
1655
+
1656
+ # Tells if the type is a leaf.
1657
+ def leaf?
1658
+ return @def.leaf?
1659
+ end
1660
+
1661
+ # Tells if the type of of vector kind.
1662
+ def vector?
1663
+ return @def.vector?
1664
+ end
1665
+
1666
+ # Gets the bitwidth of the type, by default 0.
1667
+ # Bit, signed, unsigned and Float base have a width of 1.
1668
+ def width
1669
+ return @def.width
1670
+ end
1671
+
1672
+ # Gets the type max value if any.
1673
+ # Default: not defined.
1674
+ def max
1675
+ return @def.max
1676
+ end
1677
+
1678
+ # Gets the type min value if any.
1679
+ # Default: not defined.
1680
+ def min
1681
+ return @def.min
1682
+ end
1683
+
1684
+ # Get the direction of the type, little or big endian.
1685
+ def direction
1686
+ return @def.direction
1687
+ end
1688
+
1689
+ # Tells if the type has a range.
1690
+ def range?
1691
+ return @def.range?
1692
+ end
1693
+
1694
+ # Gets the range of the type, by default range is not defined.
1695
+ def range
1696
+ return @def.range
1697
+ end
1698
+
1699
+ # Tells if the type has a base.
1700
+ def base?
1701
+ return @def.base?
1702
+ end
1703
+
1704
+ # Gets the base type, by default base type is not defined.
1705
+ def base
1706
+ return @def.base
1707
+ end
1708
+
1709
+ # Tells if the type has sub types.
1710
+ def types?
1711
+ return @def.types?
1712
+ end
1713
+
1714
+ # Tells if the type is regular (applies for tuples).
1715
+ def regular?
1716
+ return @def.regular?
1717
+ end
1718
+
1719
+ # Tells if the type has named sub types.
1720
+ def struct?
1721
+ return @def.struct?
1722
+ end
1723
+
1724
+ # Tells if the type is hierarchical.
1725
+ def hierarchical?
1726
+ return @def.hierarchical?
1727
+ end
1728
+
1729
+ # Tell if +type+ is equivalent to current type.
1730
+ #
1731
+ # NOTE: type can be compatible while not being equivalent, please
1732
+ # refer to `hruby_types.rb` for type compatibility.
1733
+ def equivalent?(type)
1734
+ return @def.equivalent?(type)
1735
+ end
1736
+
1737
+ # Converts to a bit vector.
1738
+ def to_vector
1739
+ return @def.to_vector
1740
+ end
1741
+
1635
1742
  end
1636
1743
 
1637
1744
 
@@ -1925,7 +2032,7 @@ module HDLRuby::Low
1925
2032
  def each(&ruby_block)
1926
2033
  # No ruby block? Return an enumerator.
1927
2034
  return to_enum(:each) unless ruby_block
1928
- # A ruby block? Apply it on each input signal instance.
2035
+ # A ruby block? Apply it on each sub name/type pair.
1929
2036
  @types.each(&ruby_block)
1930
2037
  end
1931
2038
 
@@ -1935,7 +2042,7 @@ module HDLRuby::Low
1935
2042
  def each_type(&ruby_block)
1936
2043
  # No ruby block? Return an enumerator.
1937
2044
  return to_enum(:each_type) unless ruby_block
1938
- # A ruby block? Apply it on each input signal instance.
2045
+ # A ruby block? Apply it on each sub type.
1939
2046
  @types.each(&ruby_block)
1940
2047
  end
1941
2048
 
@@ -2021,16 +2128,18 @@ module HDLRuby::Low
2021
2128
  ##
2022
2129
  # Describes a structure type.
2023
2130
  class TypeStruct < Type
2024
- # Creates a new structure type named +name+ with +direction+ and
2131
+ attr_reader :direction
2132
+
2133
+ # Creates a new structure type named +name+ with direction +dir+ and
2025
2134
  # whose hierachy is given by +content+.
2026
- def initialize(name,direction,content)
2135
+ def initialize(name,dir,content)
2027
2136
  # Initialize the type.
2028
2137
  super(name)
2029
2138
 
2030
2139
  # Set the direction.
2031
- @direction = direction.to_sym
2140
+ @direction = dir.to_sym
2032
2141
  unless [:little, :big].include?(@direction)
2033
- raise AnyError, "Invalid direction for a type: #{direction}"
2142
+ raise AnyError, "Invalid direction for a type: #{dir}"
2034
2143
  end
2035
2144
 
2036
2145
  # Check and set the content.
@@ -2046,7 +2155,8 @@ module HDLRuby::Low
2046
2155
  # Comparison for hash: structural comparison.
2047
2156
  def eql?(obj)
2048
2157
  # General type comparison.
2049
- return false unless super(obj)
2158
+ # return false unless super(obj)
2159
+ return false unless obj.is_a?(TypeStruct)
2050
2160
  # Specific comparison.
2051
2161
  idx = 0
2052
2162
  obj.each_key do |name|
@@ -2078,8 +2188,13 @@ module HDLRuby::Low
2078
2188
  end
2079
2189
 
2080
2190
  # Gets a sub type by +name+.
2191
+ # NOTE: +name+ can also be an index.
2081
2192
  def get_type(name)
2082
- return @types[name.to_sym]
2193
+ if name.respond_to?(:to_sym) then
2194
+ return @types[name.to_sym]
2195
+ else
2196
+ return @types.values[name.to_i]
2197
+ end
2083
2198
  end
2084
2199
 
2085
2200
  # Iterates over the sub name/type pair.
@@ -2088,7 +2203,7 @@ module HDLRuby::Low
2088
2203
  def each(&ruby_block)
2089
2204
  # No ruby block? Return an enumerator.
2090
2205
  return to_enum(:each) unless ruby_block
2091
- # A ruby block? Apply it on each input signal instance.
2206
+ # A ruby block? Apply it on each sub name/type pair.
2092
2207
  @types.each(&ruby_block)
2093
2208
  end
2094
2209
 
@@ -2098,17 +2213,27 @@ module HDLRuby::Low
2098
2213
  def each_type(&ruby_block)
2099
2214
  # No ruby block? Return an enumerator.
2100
2215
  return to_enum(:each_type) unless ruby_block
2101
- # A ruby block? Apply it on each input signal instance.
2216
+ # A ruby block? Apply it on each sub type.
2102
2217
  @types.each_value(&ruby_block)
2103
2218
  end
2104
2219
 
2220
+ # Iterates over the keys.
2221
+ #
2222
+ # Returns an enumerator if no ruby block is given.
2223
+ def each_key(&ruby_block)
2224
+ # No ruby block? Return an enumerator.
2225
+ return to_enum(:each_key) unless ruby_block
2226
+ # A ruby block? Apply it on each key.
2227
+ @types.each_key(&ruby_block)
2228
+ end
2229
+
2105
2230
  # Iterates over the sub type names.
2106
2231
  #
2107
2232
  # Returns an enumerator if no ruby block is given.
2108
2233
  def each_name(&ruby_block)
2109
2234
  # No ruby block? Return an enumerator.
2110
2235
  return to_enum(:each_name) unless ruby_block
2111
- # A ruby block? Apply it on each input signal instance.
2236
+ # A ruby block? Apply it on each name.
2112
2237
  @types.each_key(&ruby_block)
2113
2238
  end
2114
2239
 
@@ -2128,7 +2253,11 @@ module HDLRuby::Low
2128
2253
  #
2129
2254
  # NOTE: must be redefined for specific types.
2130
2255
  def width
2131
- return @types.reduce(0) {|sum,type| sum + type.width }
2256
+ if @types.is_a?(Array) then
2257
+ return @types.reduce(0) {|sum,type| sum + type.width }
2258
+ else
2259
+ return @types.each_value.reduce(0) {|sum,type| sum + type.width }
2260
+ end
2132
2261
  end
2133
2262
 
2134
2263
  # # Checks the compatibility with +type+
@@ -2506,8 +2635,9 @@ module HDLRuby::Low
2506
2635
  end
2507
2636
  @value = val
2508
2637
  val.parent = self
2509
- else
2510
- @value = nil
2638
+ # For memory optimization: no initialization if not used.
2639
+ # else
2640
+ # @value = nil
2511
2641
  end
2512
2642
  end
2513
2643
 
@@ -2517,6 +2647,40 @@ module HDLRuby::Low
2517
2647
  false
2518
2648
  end
2519
2649
 
2650
+ # Adds sub signal +sig+
2651
+ def add_signal(sig)
2652
+ # puts "add sub=#{sig.name} in signal=#{self}"
2653
+ # Sets the hash of sub signals if none.
2654
+ @signals = HashName.new unless @signals
2655
+ # Check and add the signal.
2656
+ unless sig.is_a?(SignalI)
2657
+ raise AnyError,
2658
+ "Invalid class for a signal instance: #{sig.class}"
2659
+ end
2660
+ # if @signals.include?(sig) then
2661
+ # raise AnyError, "SignalI #{sig.name} already present."
2662
+ # end
2663
+ # Set its parent.
2664
+ sig.parent = self
2665
+ # And add it
2666
+ @signals.add(sig)
2667
+ end
2668
+
2669
+ # Gets a sub signal by name.
2670
+ def get_signal(name)
2671
+ return @signals ? @signals[name] : nil
2672
+ end
2673
+
2674
+ # Iterates over the sub signals.
2675
+ #
2676
+ # Returns an enumerator if no ruby block is given.
2677
+ def each_signal(&ruby_block)
2678
+ # No ruby block? Return an enumerator.
2679
+ return to_enum(:each_signal) unless ruby_block
2680
+ # A ruby block? Apply it on each sub signal instance if any.
2681
+ @signals.each(&ruby_block) if @signals
2682
+ end
2683
+
2520
2684
  # # Add decorator capability (modifies intialize to put after).
2521
2685
  # include Hdecorator
2522
2686
 
@@ -4717,8 +4881,15 @@ module HDLRuby::Low
4717
4881
  content.is_a?(HDLRuby::BitString)
4718
4882
  # content = HDLRuby::BitString.new(content.to_s)
4719
4883
  content = content.to_s
4720
- if self.type.unsigned? && content[0] != 0 then
4721
- content = "0" + content.rjust(self.type.width,content[0])
4884
+ if self.type.unsigned? && content[0] != "0" then
4885
+ # content = "0" + content.rjust(self.type.width,content[0])
4886
+ if content[0] == "1" then
4887
+ # Do not extend the 1, but 0 instead.
4888
+ content = "0" + content.rjust(self.type.width,"0")
4889
+ else
4890
+ # But extend the other.
4891
+ content = "0" + content.rjust(self.type.width,content[0])
4892
+ end
4722
4893
  end
4723
4894
  content = HDLRuby::BitString.new(content)
4724
4895
  end
@@ -641,12 +641,10 @@ module HDLRuby::Low
641
641
  # +level+ is the hierachical level of the object.
642
642
  # def to_c(level = 0)
643
643
  def to_c(res,level = 0)
644
- # return "get_type_struct(#{self.each.join(",") do |key,type|
645
- # "\"#{key.to_s}\",#{type.to_c(level+1)}"
646
- # end})"
647
- res << "get_type_struct(#{self.each.join(",") do |key,type|
648
- "\"#{key.to_s}\",#{type.to_c("",level+1)}"
649
- end})"
644
+ # res << "get_type_struct(#{self.each.map do |key,type|
645
+ # "\"#{key.to_s}\",#{type.to_c("",level+1)}"
646
+ # end.join(",")})"
647
+ self.to_vector.to_c(res,level)
650
648
  return res
651
649
  end
652
650
  end
@@ -897,8 +895,17 @@ module HDLRuby::Low
897
895
  # +level+ is the hierachical level of the object.
898
896
  # def to_c(level = 0)
899
897
  def to_c(res,level = 0)
898
+ # First generate the sub signals if any.
899
+ if self.each_signal.any? then
900
+ self.each_signal do |signal|
901
+ signal.to_c(res,level)
902
+ end
903
+ # return res
904
+ end
900
905
 
901
- # puts "Signal.to_c with name: #{Low2C.obj_name(self)}"
906
+ # No sub signals, generate for the current one.
907
+
908
+ # puts "Signal.to_c with signal #{self.name} and c_name: #{Low2C.obj_name(self)}"
902
909
  # Declare the global variable holding the signal.
903
910
  res << "SignalI "
904
911
  self.to_c_signal(res,level+1)
@@ -943,6 +950,22 @@ module HDLRuby::Low
943
950
  res << "signalI->type = "
944
951
  self.type.to_c(res,level+2)
945
952
  res << ";\n"
953
+
954
+ # Generate and set the sub signals if any.
955
+ res << " " * (level+1)*3
956
+ num_sig = self.each_signal.to_a.size
957
+ res << "signalI->num_signals = #{num_sig};\n"
958
+ if num_sig > 0 then
959
+ res << " " * (level+1)*3
960
+ res << "signalI->signals = calloc(sizeof(SignalI),#{num_sig});\n"
961
+ self.each_signal.with_index do |sig,i|
962
+ res << " " * (level+1)*3
963
+ res << "#{Low2C.obj_name(sig)} = #{Low2C.make_name(sig)}();\n"
964
+ res << " " * (level+1)*3
965
+ res << "signalI->signals[#{i}] = #{Low2C.obj_name(sig)};\n"
966
+ end
967
+ end
968
+
946
969
  # Set the current and the next value.
947
970
  res << " " * (level+1)*3
948
971
  res << "signalI->c_value = make_value(signalI->type,0);\n"
@@ -1000,6 +1023,15 @@ module HDLRuby::Low
1000
1023
  ## Generates the content of the h file.
1001
1024
  # def to_ch
1002
1025
  def to_ch(res)
1026
+ # First generate the sub signals if any.
1027
+ if self.each_signal.any? then
1028
+ self.each_signal do |signal|
1029
+ signal.to_ch(res)
1030
+ end
1031
+ # return res
1032
+ end
1033
+
1034
+ # No sub sub signal, generate for the current signal.
1003
1035
  # res = ""
1004
1036
  # puts "to_ch for SignalI: #{self.to_c_signal()}"
1005
1037
  # Declare the global variable holding the signal.
@@ -2205,7 +2237,7 @@ module HDLRuby::Low
2205
2237
  res << "value->data_int = #{self.content}LLU;\n"
2206
2238
  else
2207
2239
  res << "value->data_int = "
2208
- res << "#{self.content & 0xFFFFFFFFFFFF}LLU;\n"
2240
+ res << "#{self.content & 0xFFFF_FFFF_FFFF_FFFF}LLU;\n"
2209
2241
  end
2210
2242
  # Close the value.
2211
2243
  res << " " * (level+1)*3
@@ -2697,7 +2729,7 @@ module HDLRuby::Low
2697
2729
  end
2698
2730
  # Compute the resulting concatenation.
2699
2731
  res << (" " * ((level+1)*3))
2700
- # puts "self.type.direction=#{self.type.direction}\n"
2732
+ # puts "self.type=#{self.type} self.type.direction=#{self.type.direction}\n"
2701
2733
  res << "sconcat(#{expressions.size},"
2702
2734
  res << (self.type.direction == :little ? "1" : "0")
2703
2735
  res << ");\n"
@@ -3054,14 +3086,42 @@ module HDLRuby::Low
3054
3086
  res << "->" << (left ? "f_value" : "c_value")
3055
3087
  res << ");\n"
3056
3088
  return res
3089
+ # sig = self.resolve
3090
+ # if sig.each_signal.any? then
3091
+ # # Save the value pool state.
3092
+ # res << (" " * (level*3)) << "PV;\n"
3093
+ # # There are sub signals, get and concat their values.
3094
+ # subs = sig.each_signal.to_a
3095
+ # subs.each do |sub|
3096
+ # res << (" " * (level*3))
3097
+ # res << "push("
3098
+ # sub.to_c_signal(res,level+1)
3099
+ # res << "->" << (left ? "f_value" : "c_value")
3100
+ # res << ");\n"
3101
+ # end
3102
+ # # Compute the resulting concatenation.
3103
+ # res << (" " * ((level+1)*3))
3104
+ # res << "sconcat(#{subs.size},"
3105
+ # res << (sig.type.direction == :little ? "1" : "0")
3106
+ # res << ");\n"
3107
+ # # Restore the value pool state.
3108
+ # res << (" " * (level*3)) << "RV;\n"
3109
+ # else
3110
+ # # There is no sub signals, get the signal value.
3111
+ # res << (" " * (level*3))
3112
+ # res << "push("
3113
+ # sig.to_c_signal(res,level+1)
3114
+ # res << "->" << (left ? "f_value" : "c_value")
3115
+ # res << ");\n"
3116
+ # end
3117
+ # return res
3057
3118
  end
3058
3119
 
3059
3120
  # Generates the C text for reference as left value to a signal.
3060
3121
  # +level+ is the hierarchical level of the object.
3061
3122
  # def to_c_signal(level = 0)
3062
3123
  def to_c_signal(res,level = 0)
3063
- # puts "to_c_signal with self=#{self.name}, resolve=#{self.resolve}"
3064
- # return "#{self.resolve.to_c_signal(level+1)}"
3124
+ # puts "to_c_signal with self=#{self.name}"
3065
3125
  self.resolve.to_c_signal(res,level+1)
3066
3126
  return res
3067
3127
  end
@@ -807,7 +807,8 @@ module HDLRuby::Low
807
807
  res << " " * (level*3)
808
808
  res << "begin\n"
809
809
  # Generate the edges if any.
810
- if self.each_event.find {|event| event.type != :change} then
810
+ # if self.each_event.find {|event| event.type != :change} then
811
+ if self.each_event.find {|event| event.type != :anyedge} then
811
812
  # Generate the edge test.
812
813
  level = level + 1
813
814
  res << " " * (level*3)
@@ -389,6 +389,7 @@ module HDLRuby::Low
389
389
  # No, recurse on the sub expressions.
390
390
  return RefConcat.new(self.type,self.each_ref.map.with_index do
391
391
  |ref,i|
392
+ puts "self.type=#{self.type}"
392
393
  ref.explicit_types(self.type.get_type(i))
393
394
  end)
394
395
  end
@@ -600,6 +600,9 @@ module HDLRuby::Low
600
600
  right.parent = self unless right.parent
601
601
  end
602
602
 
603
+ alias_method :map_expressions!, :map_nodes!
604
+
605
+
603
606
  # Replaces sub expressions using +node2rep+ table indicating the
604
607
  # node to replace and the corresponding replacement.
605
608
  # Returns the actually replaced nodes and their corresponding
@@ -908,6 +911,10 @@ module HDLRuby::Low
908
911
  # Sets the default.
909
912
  def set_default!(default)
910
913
  # Checks and set the default case if any.
914
+ if self.default then
915
+ # There is a default first detach it.
916
+ @default = nil
917
+ end
911
918
  self.default = default
912
919
  end
913
920
 
@@ -1172,7 +1179,11 @@ module HDLRuby::Low
1172
1179
  raise AnyError, "Invalid type for a statement: #{stmnt.class}"
1173
1180
  end
1174
1181
  idx = @statements.index(org)
1175
- @statements[idx] = stmnt if idx
1182
+ # @statements[idx] = stmnt if idx
1183
+ if idx then
1184
+ @statements[idx] = stmnt
1185
+ stmnt.parent = self unless stmnt.parent
1186
+ end
1176
1187
  end
1177
1188
 
1178
1189
  # Maps on the statements.
@@ -1403,6 +1414,8 @@ module HDLRuby::Low
1403
1414
  @child.parent = self unless @child.parent
1404
1415
  end
1405
1416
 
1417
+ alias_method :map_expressions!, :map_nodes!
1418
+
1406
1419
  # Replaces sub expressions using +node2rep+ table indicating the
1407
1420
  # node to replace and the corresponding replacement.
1408
1421
  # Returns the actually replaced nodes and their corresponding
@@ -1507,6 +1520,8 @@ module HDLRuby::Low
1507
1520
  @right.parent = self unless @right.parent
1508
1521
  end
1509
1522
 
1523
+ alias_method :map_expressions!, :map_nodes!
1524
+
1510
1525
  # Replaces sub expressions using +node2rep+ table indicating the
1511
1526
  # node to replace and the corresponding replacement.
1512
1527
  # Returns the actually replaced nodes and their corresponding
@@ -1590,6 +1605,8 @@ module HDLRuby::Low
1590
1605
  map_choices!(&ruby_block)
1591
1606
  end
1592
1607
 
1608
+ alias_method :map_expressions!, :map_nodes!
1609
+
1593
1610
  # Replaces sub expressions using +node2rep+ table indicating the
1594
1611
  # node to replace and the corresponding replacement.
1595
1612
  # Returns the actually replaced nodes and their corresponding
@@ -1707,6 +1724,8 @@ module HDLRuby::Low
1707
1724
  def map_nodes!(&ruby_block)
1708
1725
  # Nothing to do.
1709
1726
  end
1727
+
1728
+ alias_method :map_expressions!, :map_nodes!
1710
1729
  end
1711
1730
 
1712
1731
 
@@ -1775,6 +1794,8 @@ module HDLRuby::Low
1775
1794
  @ref.parent = self unless @ref.parent
1776
1795
  end
1777
1796
 
1797
+ alias_method :map_expressions!, :map_nodes!
1798
+
1778
1799
  # Replaces sub expressions using +node2rep+ table indicating the
1779
1800
  # node to replace and the corresponding replacement.
1780
1801
  # Returns the actually replaced nodes and their corresponding
@@ -1856,6 +1877,8 @@ module HDLRuby::Low
1856
1877
  @ref.parent = self unless @ref.parent
1857
1878
  end
1858
1879
 
1880
+ alias_method :map_expressions!, :map_nodes!
1881
+
1859
1882
  # Replaces sub expressions using +node2rep+ table indicating the
1860
1883
  # node to replace and the corresponding replacement.
1861
1884
  # Returns the actually replaced nodes and their corresponding
@@ -1934,6 +1957,8 @@ module HDLRuby::Low
1934
1957
  @ref.parent = self unless @ref.parent
1935
1958
  end
1936
1959
 
1960
+ alias_method :map_expressions!, :map_nodes!
1961
+
1937
1962
  # Replaces sub expressions using +node2rep+ table indicating the
1938
1963
  # node to replace and the corresponding replacement.
1939
1964
  # Returns the actually replaced nodes and their corresponding
@@ -1970,6 +1995,8 @@ module HDLRuby::Low
1970
1995
  def map_nodes!(&ruby_block)
1971
1996
  # Nothing to do.
1972
1997
  end
1998
+
1999
+ alias_method :map_expressions!, :map_nodes!
1973
2000
  end
1974
2001
 
1975
2002
  ##
@@ -1991,5 +2018,7 @@ module HDLRuby::Low
1991
2018
  def map_nodes!(&ruby_block)
1992
2019
  self.map_args!(&ruby_block)
1993
2020
  end
2021
+
2022
+ alias_method :map_expressions!, :map_nodes!
1994
2023
  end
1995
2024
  end
@@ -109,6 +109,20 @@ module HDLRuby::Low
109
109
  end
110
110
 
111
111
 
112
+ ##
113
+ # Extends SignalI with the capability of finding one of its inner object
114
+ # by name.
115
+ class SignalI
116
+
117
+ ## Find an inner object by +name+.
118
+ # NOTE: return nil if not found.
119
+ def get_by_name(name)
120
+ return self.get_signal(name)
121
+ end
122
+ end
123
+
124
+
125
+
112
126
  ##
113
127
  # Extends RefIndex with the capability of finding the object it
114
128
  # refered to.
@@ -219,10 +233,9 @@ module HDLRuby::Low
219
233
  # corresponding object.
220
234
  # NOTE: return nil if could not resolve.
221
235
  def resolve
222
- # puts "Resolve with #{self} and name=#{self.name}"
236
+ # puts "Resolve with #{self} and name=#{self.name} and ref=#{self.ref.class}"
223
237
  # First resolve the sub reference if possible.
224
238
  if self.ref.is_a?(RefName) then
225
- # puts "ref name=#{self.ref.name}"
226
239
  obj = self.ref.resolve
227
240
  # puts "obj=#{obj}"
228
241
  # Look into the object for the name.