HDLRuby 2.4.27 → 2.6.2

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/HDLRuby/drivers/xcd.rb +79 -0
  3. data/lib/HDLRuby/drivers/xcd/dummy.xcd +4 -0
  4. data/lib/HDLRuby/hdr_samples/adder.rb +1 -1
  5. data/lib/HDLRuby/hdr_samples/adder_bench.rb +1 -1
  6. data/lib/HDLRuby/hdr_samples/adder_gen.rb +1 -1
  7. data/lib/HDLRuby/hdr_samples/constant_in_function.rb +27 -0
  8. data/lib/HDLRuby/hdr_samples/dff_properties.rb +19 -0
  9. data/lib/HDLRuby/hdr_samples/dff_unit.rb +54 -0
  10. data/lib/HDLRuby/hdr_samples/huge_rom.rb +25 -0
  11. data/lib/HDLRuby/hdr_samples/logic_bench.rb +21 -0
  12. data/lib/HDLRuby/hdr_samples/mei8_bench.rb +1 -1
  13. data/lib/HDLRuby/hdr_samples/music.rb +79 -0
  14. data/lib/HDLRuby/hdr_samples/named_sub.rb +42 -0
  15. data/lib/HDLRuby/hdr_samples/rom.rb +16 -0
  16. data/lib/HDLRuby/hdr_samples/seqpar_bench.rb +59 -0
  17. data/lib/HDLRuby/hdr_samples/with_function_generator.rb +25 -0
  18. data/lib/HDLRuby/hdrcc.rb +140 -24
  19. data/lib/HDLRuby/hruby_decorator.rb +250 -0
  20. data/lib/HDLRuby/hruby_high.rb +468 -91
  21. data/lib/HDLRuby/hruby_low.rb +913 -45
  22. data/lib/HDLRuby/hruby_low2c.rb +189 -168
  23. data/lib/HDLRuby/hruby_low2hdr.rb +738 -0
  24. data/lib/HDLRuby/hruby_low2high.rb +331 -549
  25. data/lib/HDLRuby/hruby_low2vhd.rb +39 -2
  26. data/lib/HDLRuby/hruby_low_bool2select.rb +29 -0
  27. data/lib/HDLRuby/hruby_low_casts_without_expression.rb +27 -0
  28. data/lib/HDLRuby/hruby_low_fix_types.rb +25 -0
  29. data/lib/HDLRuby/hruby_low_mutable.rb +70 -0
  30. data/lib/HDLRuby/hruby_low_resolve.rb +28 -0
  31. data/lib/HDLRuby/hruby_low_without_connection.rb +6 -3
  32. data/lib/HDLRuby/hruby_low_without_namespace.rb +7 -4
  33. data/lib/HDLRuby/hruby_low_without_parinseq.rb +151 -0
  34. data/lib/HDLRuby/hruby_low_without_select.rb +13 -0
  35. data/lib/HDLRuby/hruby_tools.rb +11 -1
  36. data/lib/HDLRuby/hruby_verilog.rb +1602 -1629
  37. data/lib/HDLRuby/sim/hruby_sim.h +25 -2
  38. data/lib/HDLRuby/sim/hruby_sim_calc.c +63 -6
  39. data/lib/HDLRuby/sim/hruby_sim_vcd.c +5 -1
  40. data/lib/HDLRuby/sim/hruby_sim_vizualize.c +22 -6
  41. data/lib/HDLRuby/std/fixpoint.rb +9 -0
  42. data/lib/HDLRuby/std/function_generator.rb +139 -0
  43. data/lib/HDLRuby/std/hruby_unit.rb +75 -0
  44. data/lib/HDLRuby/template_expander.rb +61 -0
  45. data/lib/HDLRuby/version.rb +1 -1
  46. metadata +22 -5
@@ -347,6 +347,12 @@ module HDLRuby::High
347
347
  end
348
348
  end
349
349
  @to_includes = mixins
350
+
351
+ # The list of systems the current system is expanded from if any.
352
+ # The first one is the main system, the other ones are the
353
+ # mixins.
354
+ @generators = []
355
+
350
356
  # Prepare the instantiation methods
351
357
  make_instantiater(name,SystemI,&ruby_block)
352
358
  end
@@ -472,6 +478,24 @@ module HDLRuby::High
472
478
  @scope.each_export(&ruby_block)
473
479
  end
474
480
 
481
+ # Adds a generator system.
482
+ def add_generator(gen)
483
+ unless gen.is_a?(SystemT) then
484
+ raise "Invalid class for a generator system"
485
+ end
486
+ @generators << gen
487
+ end
488
+
489
+ # Iterates over the origin systems.
490
+ #
491
+ # Returns an enumerator if no ruby block is given.
492
+ def each_generator(&ruby_block)
493
+ # No ruby block? Return an enumerator.
494
+ return to_enum(:each_generator) unless ruby_block
495
+ # A block? Apply it on each generator.
496
+ @generators.each(&ruby_block)
497
+ end
498
+
475
499
  # Gets class containing the extension for the instances.
476
500
  def singleton_instance
477
501
  @singleton_instanceO.singleton_class
@@ -527,6 +551,10 @@ module HDLRuby::High
527
551
  # Include the mixin systems given when declaring the system.
528
552
  @to_includes.each { |system| expanded.scope.include(system) }
529
553
 
554
+ # Sets the generators of the expanded result.
555
+ expanded.add_generator(self)
556
+ @to_includes.each { |system| expanded.add_generator(system) }
557
+
530
558
  # Fills the scope of the expanded class.
531
559
  # puts "Build top with #{self.name} for #{name}"
532
560
  expanded.scope.build_top(self.scope,*args)
@@ -592,8 +620,8 @@ module HDLRuby::High
592
620
  # Extend the instance.
593
621
  instance.eigen_extend(@singleton_instanceO)
594
622
  # puts "instance scope= #{instance.systemT.scope}"
595
- # Add the instance.
596
- High.top_user.send(:add_systemI,instance)
623
+ # Add the instance if instantiating within another system.
624
+ High.top_user.send(:add_systemI,instance) if High.top_user
597
625
 
598
626
  # Execute the post instantiation tasks.
599
627
  eigen.each_on_instance { |task| task.(instance) }
@@ -730,13 +758,17 @@ module HDLRuby::High
730
758
  "Cannot convert a system without a name to HDLRuby::Low."
731
759
  end
732
760
  # Create the resulting low system type.
733
- systemTlow = HDLRuby::Low::SystemT.new(High.names_create(name),
761
+ systemTL = HDLRuby::Low::SystemT.new(High.names_create(name),
734
762
  self.scope.to_low)
763
+ # For debugging: set the source high object
764
+ systemTL.properties[:low2high] = self.hdr_id
765
+ self.properties[:high2low] = systemTL
766
+
735
767
  # Fills the interface of the new system
736
768
  # from the included systems.
737
- self.fill_low(systemTlow)
769
+ self.fill_low(systemTL)
738
770
  # Return theresulting system.
739
- return systemTlow
771
+ return systemTL
740
772
  end
741
773
  end
742
774
 
@@ -905,8 +937,19 @@ module HDLRuby::High
905
937
  # Set the namespace for buidling the scope.
906
938
  High.space_push(@namespace)
907
939
  # Build the scope.
908
- @return_value = High.top_user.instance_eval(&ruby_block)
940
+ # @return_value = High.top_user.instance_eval(&ruby_block)
941
+ res = High.top_user.instance_eval(&ruby_block)
909
942
  High.space_pop
943
+ # Now gain access to the result within the sub scope.
944
+ if (res.is_a?(HRef)) then
945
+ @return_value = res.type.inner(HDLRuby.uniq_name)
946
+ High.space_push(@namespace)
947
+ @return_value <= res
948
+ High.space_pop
949
+ else
950
+ @return_value = res
951
+ end
952
+ # This will be the return value.
910
953
  @return_value
911
954
  end
912
955
 
@@ -1213,26 +1256,26 @@ module HDLRuby::High
1213
1256
  # Fills a low level scope with self's contents.
1214
1257
  #
1215
1258
  # NOTE: name conflicts are treated in the current NameStack state.
1216
- def fill_low(scopeLow)
1259
+ def fill_low(scopeL)
1217
1260
  # Adds the content of its included systems.
1218
- @includes.each_value {|system| system.scope.fill_low(scopeLow) }
1261
+ @includes.each_value {|system| system.scope.fill_low(scopeL) }
1219
1262
  # Adds the declared local system types.
1220
1263
  # NOTE: in the current version of HDLRuby::High, there should not
1221
1264
  # be any of them (only eigen systems are real system types).
1222
- self.each_systemT { |systemT| scopeLow.add_systemT(systemT.to_low) }
1265
+ self.each_systemT { |systemT| scopeL.add_systemT(systemT.to_low) }
1223
1266
  # Adds the local types.
1224
- self.each_type { |type| scopeLow.add_type(type.to_low) }
1267
+ self.each_type { |type| scopeL.add_type(type.to_low) }
1225
1268
  # Adds the inner scopes.
1226
- self.each_scope { |scope| scopeLow.add_scope(scope.to_low) }
1269
+ self.each_scope { |scope| scopeL.add_scope(scope.to_low) }
1227
1270
  # Adds the inner signals.
1228
- self.each_inner { |inner| scopeLow.add_inner(inner.to_low) }
1271
+ self.each_inner { |inner| scopeL.add_inner(inner.to_low) }
1229
1272
  # Adds the instances.
1230
1273
  # Single ones.
1231
1274
  self.each_systemI do |systemI|
1232
1275
  # puts "Filling with systemI=#{systemI.name}"
1233
- systemI_low = scopeLow.add_systemI(systemI.to_low)
1276
+ systemI_low = scopeL.add_systemI(systemI.to_low)
1234
1277
  # Also add the eigen system to the list of local systems.
1235
- scopeLow.add_systemT(systemI_low.systemT)
1278
+ scopeL.add_systemT(systemI_low.systemT)
1236
1279
  end
1237
1280
  # Grouped ones.
1238
1281
  self.each_groupI do |name,systemIs|
@@ -1242,42 +1285,46 @@ module HDLRuby::High
1242
1285
  # puts "systemI.respond_to?=#{systemI.respond_to?(:name=)}"
1243
1286
  systemI.name = name.to_s + "[#{i}]"
1244
1287
  # And convert it to low
1245
- systemI_low = scopeLow.add_systemI(systemI.to_low())
1288
+ systemI_low = scopeL.add_systemI(systemI.to_low())
1246
1289
  # Also add the eigen system to the list of local systems.
1247
- scopeLow.add_systemT(systemI_low.systemT)
1290
+ scopeL.add_systemT(systemI_low.systemT)
1248
1291
  }
1249
1292
  end
1250
1293
  # Adds the code chunks.
1251
- self.each_code { |code| scopeLow.add_code(code.to_low) }
1294
+ self.each_code { |code| scopeL.add_code(code.to_low) }
1252
1295
  # Adds the connections.
1253
1296
  self.each_connection { |connection|
1254
1297
  # puts "connection=#{connection}"
1255
- scopeLow.add_connection(connection.to_low)
1298
+ scopeL.add_connection(connection.to_low)
1256
1299
  }
1257
1300
  # Adds the behaviors.
1258
1301
  self.each_behavior { |behavior|
1259
- scopeLow.add_behavior(behavior.to_low)
1302
+ scopeL.add_behavior(behavior.to_low)
1260
1303
  }
1261
1304
  end
1262
1305
 
1263
1306
  # Converts the scope to HDLRuby::Low.
1264
1307
  def to_low()
1265
1308
  # Create the resulting low scope.
1266
- # scopeLow = HDLRuby::Low::Scope.new()
1267
- scopeLow = HDLRuby::Low::Scope.new(self.name)
1309
+ # scopeL = HDLRuby::Low::Scope.new()
1310
+ scopeL = HDLRuby::Low::Scope.new(self.name)
1311
+ # For debugging: set the source high object
1312
+ scopeL.properties[:low2high] = self.hdr_id
1313
+ self.properties[:high2low] = scopeL
1314
+
1268
1315
  # Push the private namespace for the low generation.
1269
1316
  High.space_push(@namespace)
1270
1317
  # Pushes on the name stack for converting the internals of
1271
1318
  # the system.
1272
1319
  High.names_push
1273
1320
  # Adds the content of the actual system.
1274
- self.fill_low(scopeLow)
1321
+ self.fill_low(scopeL)
1275
1322
  # Restores the name stack.
1276
1323
  High.names_pop
1277
1324
  # Restores the namespace stack.
1278
1325
  High.space_pop
1279
1326
  # Return theresulting system.
1280
- return scopeLow
1327
+ return scopeL
1281
1328
  end
1282
1329
  end
1283
1330
 
@@ -1493,7 +1540,12 @@ module HDLRuby::High
1493
1540
  #
1494
1541
  # NOTE: should be overridden by other type classes.
1495
1542
  def to_low(name = self.name)
1496
- return HDLRuby::Low::Type.new(name)
1543
+ # return HDLRuby::Low::Type.new(name)
1544
+ typeL = HDLRuby::Low::Type.new(name)
1545
+ # For debugging: set the source high object
1546
+ typeL.properties[:low2high] = self.hdr_id
1547
+ self.properties[:high2low] = typeL
1548
+ return typeL
1497
1549
  end
1498
1550
  end
1499
1551
 
@@ -1578,6 +1630,18 @@ module HDLRuby::High
1578
1630
  include HbasicType
1579
1631
  end
1580
1632
 
1633
+ # The string type
1634
+ StringT = define_type(:string)
1635
+ class << StringT
1636
+ # Converts the type to HDLRuby::Low.
1637
+ def to_low
1638
+ return Low::StringT
1639
+ end
1640
+
1641
+ include HbasicType
1642
+ end
1643
+
1644
+
1581
1645
  # # The infer type.
1582
1646
  # # Unspecified, but automatically infered when connected.
1583
1647
  # Infer = define_type(:infer)
@@ -1630,7 +1694,12 @@ module HDLRuby::High
1630
1694
  #
1631
1695
  # NOTE: should be overridden by other type classes.
1632
1696
  def to_low(name = self.name)
1633
- return HDLRuby::Low::TypeDef.new(name,self.def.to_low)
1697
+ # return HDLRuby::Low::TypeDef.new(name,self.def.to_low)
1698
+ typeDefL = HDLRuby::Low::TypeDef.new(name,self.def.to_low)
1699
+ # For debugging: set the source high object
1700
+ typeDefL.properties[:low2high] = self.hdr_id
1701
+ self.properties[:high2low] = typeDefL
1702
+ return typeDefL
1634
1703
  end
1635
1704
  end
1636
1705
 
@@ -1678,7 +1747,12 @@ module HDLRuby::High
1678
1747
  #
1679
1748
  # NOTE: should be overridden by other type classes.
1680
1749
  def to_low(name = self.name)
1681
- return HDLRuby::Low::TypeDef.new(name,self.def.to_low)
1750
+ # return HDLRuby::Low::TypeDef.new(name,self.def.to_low)
1751
+ typeDefL = HDLRuby::Low::TypeDef.new(name,self.def.to_low)
1752
+ # For debugging: set the source high object
1753
+ typeDefL.properties[:low2high] = self.hdr_id
1754
+ self.properties[:high2low] = typeDefL
1755
+ return typeDefL
1682
1756
  end
1683
1757
  end
1684
1758
 
@@ -1689,8 +1763,14 @@ module HDLRuby::High
1689
1763
  # Converts the type to HDLRuby::Low and set its +name+.
1690
1764
  def to_low(name = self.name)
1691
1765
  # Generate and return the new type.
1692
- return HDLRuby::Low::TypeVector.new(name,self.base.to_low,
1766
+ # return HDLRuby::Low::TypeVector.new(name,self.base.to_low,
1767
+ # self.range.to_low)
1768
+ typeVectorL = HDLRuby::Low::TypeVector.new(name,self.base.to_low,
1693
1769
  self.range.to_low)
1770
+ # For debugging: set the source high object
1771
+ typeVectorL.properties[:low2high] = self.hdr_id
1772
+ self.properties[:high2low] = typeVectorL
1773
+ return typeVectorL
1694
1774
  end
1695
1775
  end
1696
1776
 
@@ -1763,8 +1843,14 @@ module HDLRuby::High
1763
1843
 
1764
1844
  # Converts the type to HDLRuby::Low and set its +name+.
1765
1845
  def to_low(name = self.name)
1766
- return HDLRuby::Low::TypeTuple.new(name,self.direction,
1846
+ # return HDLRuby::Low::TypeTuple.new(name,self.direction,
1847
+ # *@types.map { |type| type.to_low } )
1848
+ typeTupleL = HDLRuby::Low::TypeTuple.new(name,self.direction,
1767
1849
  *@types.map { |type| type.to_low } )
1850
+ # For debugging: set the source high object
1851
+ typeTupleL.properties[:low2high] = self.hdr_id
1852
+ self.properties[:high2low] = typeTupleL
1853
+ return typeTupleL
1768
1854
  end
1769
1855
  end
1770
1856
 
@@ -1778,8 +1864,14 @@ module HDLRuby::High
1778
1864
 
1779
1865
  # Converts the type to HDLRuby::Low and set its +name+.
1780
1866
  def to_low(name = self.name)
1781
- return HDLRuby::Low::TypeStruct.new(name,self.direction,
1867
+ # return HDLRuby::Low::TypeStruct.new(name,self.direction,
1868
+ # @types.map { |name,type| [name,type.to_low] } )
1869
+ typeStructL = HDLRuby::Low::TypeStruct.new(name,self.direction,
1782
1870
  @types.map { |name,type| [name,type.to_low] } )
1871
+ # For debugging: set the source high object
1872
+ typeStructL.properties[:low2high] = self.hdr_id
1873
+ self.properties[:high2low] = typeStructL
1874
+ return typeStructL
1783
1875
  end
1784
1876
  end
1785
1877
 
@@ -1946,7 +2038,8 @@ module HDLRuby::High
1946
2038
  else
1947
2039
  # No, perform a connection is order of declaration
1948
2040
  connects.each.with_index do |csig,i|
1949
- # puts "csig=#{csig.name} i=#{i}"
2041
+ csig = csig.to_expr
2042
+ # puts "csig=#{csig} i=#{i}"
1950
2043
  # puts "systemT inputs=#{systemT.each_input.to_a.size}"
1951
2044
  # Gets i-est signal to connect
1952
2045
  ssig = self.systemT.get_interface_with_included(i)
@@ -2011,15 +2104,18 @@ module HDLRuby::High
2011
2104
  def to_low(name = self.name)
2012
2105
  # puts "to_low with #{self} (#{self.name}) #{self.systemT}"
2013
2106
  # Converts the system of the instance to HDLRuby::Low
2014
- systemTlow = self.systemT.to_low
2107
+ systemTL = self.systemT.to_low
2015
2108
  # Creates the resulting HDLRuby::Low instance
2016
- systemIlow = HDLRuby::Low::SystemI.new(High.names_create(name),
2017
- systemTlow)
2109
+ systemIL = HDLRuby::Low::SystemI.new(High.names_create(name),
2110
+ systemTL)
2111
+ # For debugging: set the source high object
2112
+ systemIL.properties[:low2high] = self.hdr_id
2113
+ self.properties[:high2low] = systemIL
2018
2114
  # Adds the other systemTs.
2019
2115
  self.each_systemT do |systemT|
2020
- systemIlow.add_systemT(systemT.to_low) unless systemT == self.systemT
2116
+ systemIL.add_systemT(systemT.to_low) unless systemT == self.systemT
2021
2117
  end
2022
- return systemIlow
2118
+ return systemIL
2023
2119
  end
2024
2120
  end
2025
2121
 
@@ -2030,11 +2126,20 @@ module HDLRuby::High
2030
2126
  class Chunk < HDLRuby::Low::Chunk
2031
2127
  # Converts the if to HDLRuby::Low.
2032
2128
  def to_low
2033
- return HDLRuby::Low::Chunk.new(self.name,
2129
+ # return HDLRuby::Low::Chunk.new(self.name,
2130
+ # *self.each_lump.map do |lump|
2131
+ # lump = lump.respond_to?(:to_low) ? lump.to_low : lump.to_s
2132
+ # lump
2133
+ # end)
2134
+ chunkL = HDLRuby::Low::Chunk.new(self.name,
2034
2135
  *self.each_lump.map do |lump|
2035
2136
  lump = lump.respond_to?(:to_low) ? lump.to_low : lump.to_s
2036
2137
  lump
2037
2138
  end)
2139
+ # For debugging: set the source high object
2140
+ chunkL.properties[:low2high] = self.hdr_id
2141
+ self.properties[:high2low] = chunkL
2142
+ return chunkL
2038
2143
  end
2039
2144
  end
2040
2145
 
@@ -2044,13 +2149,16 @@ module HDLRuby::High
2044
2149
  # Converts the if to HDLRuby::Low.
2045
2150
  def to_low
2046
2151
  # Create the resulting code.
2047
- res = HDLRuby::Low::Code.new
2152
+ codeL = HDLRuby::Low::Code.new
2153
+ # For debugging: set the source high object
2154
+ codeL.properties[:low2high] = self.hdr_id
2155
+ self.properties[:high2low] = codeL
2048
2156
  # Add the low-level events.
2049
- self.each_event { |event| res.add_event(event.to_low) }
2157
+ self.each_event { |event| codeL.add_event(event.to_low) }
2050
2158
  # Add the low-level code chunks.
2051
- self.each_chunk { |chunk| res.add_chunk(chunk.to_low) }
2159
+ self.each_chunk { |chunk| codeL.add_chunk(chunk.to_low) }
2052
2160
  # Return the resulting code.
2053
- return res
2161
+ return codeL
2054
2162
  end
2055
2163
  end
2056
2164
 
@@ -2133,10 +2241,13 @@ module HDLRuby::High
2133
2241
  # no may be nil, so treat it appart
2134
2242
  noL = self.no ? self.no.to_low : nil
2135
2243
  # Now generate the low-level if.
2136
- low = HDLRuby::Low::If.new(self.condition.to_low,
2244
+ ifL = HDLRuby::Low::If.new(self.condition.to_low,
2137
2245
  self.yes.to_low,noL)
2138
- self.each_noif {|cond,block| low.add_noif(cond.to_low,block.to_low)}
2139
- return low
2246
+ self.each_noif {|cond,block| ifL.add_noif(cond.to_low,block.to_low)}
2247
+ # For debugging: set the source high object
2248
+ ifL.properties[:low2high] = self.hdr_id
2249
+ self.properties[:high2low] = ifL
2250
+ return ifL
2140
2251
  end
2141
2252
  end
2142
2253
 
@@ -2154,8 +2265,14 @@ module HDLRuby::High
2154
2265
 
2155
2266
  # Converts the if to HDLRuby::Low.
2156
2267
  def to_low
2157
- return HDLRuby::Low::When.new(self.match.to_low,
2268
+ # return HDLRuby::Low::When.new(self.match.to_low,
2269
+ # self.statement.to_low)
2270
+ whenL = HDLRuby::Low::When.new(self.match.to_low,
2158
2271
  self.statement.to_low)
2272
+ # For debugging: set the source high object
2273
+ whenL.properties[:low2high] = self.hdr_id
2274
+ self.properties[:high2low] = whenL
2275
+ return whenL
2159
2276
  end
2160
2277
  end
2161
2278
 
@@ -2200,6 +2317,9 @@ module HDLRuby::High
2200
2317
  def to_low
2201
2318
  # Create the low level case.
2202
2319
  caseL = HDLRuby::Low::Case.new(@value.to_low)
2320
+ # For debugging: set the source high object
2321
+ caseL.properties[:low2high] = self.hdr_id
2322
+ self.properties[:high2low] = caseL
2203
2323
  # Add each when case.
2204
2324
  self.each_when do |w|
2205
2325
  caseL.add_when(w.to_low)
@@ -2226,7 +2346,12 @@ module HDLRuby::High
2226
2346
 
2227
2347
  # Converts the delay to HDLRuby::Low.
2228
2348
  def to_low
2229
- return HDLRuby::Low::Delay.new(self.value, self.unit)
2349
+ # return HDLRuby::Low::Delay.new(self.value, self.unit)
2350
+ delayL = HDLRuby::Low::Delay.new(self.value, self.unit)
2351
+ # For debugging: set the source high object
2352
+ delayL.properties[:low2high] = self.hdr_id
2353
+ self.properties[:high2low] = delayL
2354
+ return delayL
2230
2355
  end
2231
2356
  end
2232
2357
 
@@ -2237,7 +2362,12 @@ module HDLRuby::High
2237
2362
 
2238
2363
  # Converts the wait statement to HDLRuby::Low.
2239
2364
  def to_low
2240
- return HDLRuby::Low::TimeWait.new(self.delay.to_low)
2365
+ # return HDLRuby::Low::TimeWait.new(self.delay.to_low)
2366
+ timeWaitL = HDLRuby::Low::TimeWait.new(self.delay.to_low)
2367
+ # For debugging: set the source high object
2368
+ timeWaitL.properties[:low2high] = self.hdr_id
2369
+ self.properties[:high2low] = timeWaitL
2370
+ return timeWaitL
2241
2371
  end
2242
2372
  end
2243
2373
 
@@ -2249,8 +2379,14 @@ module HDLRuby::High
2249
2379
 
2250
2380
  # Converts the repeat statement to HDLRuby::Low.
2251
2381
  def to_low
2252
- return HDLRuby::Low::TimeRepeat.new(self.statement.to_low,
2382
+ # return HDLRuby::Low::TimeRepeat.new(self.statement.to_low,
2383
+ # self.delay.to_low)
2384
+ timeRepeatL = HDLRuby::Low::TimeRepeat.new(self.statement.to_low,
2253
2385
  self.delay.to_low)
2386
+ # For debugging: set the source high object
2387
+ timeRepeatL.properties[:low2high] = self.hdr_id
2388
+ self.properties[:high2low] = timeRepeatL
2389
+ return timeRepeatL
2254
2390
  end
2255
2391
  end
2256
2392
 
@@ -2398,6 +2534,35 @@ module HDLRuby::High
2398
2534
  return self.ljust(self[-1])
2399
2535
  end
2400
2536
 
2537
+ # Match the type with +typ+:
2538
+ # - Recurse on the sub expr if hierachical type, raising an arror
2539
+ # if the expression is not hierarchical.
2540
+ # - Directly cast otherwise.
2541
+ def match_type(typ)
2542
+ # Has the type sub types?
2543
+ if typ.types? then
2544
+ unless self.is_a?(Concat) then
2545
+ raise AnyError,
2546
+ "Invalid class for assignment to hierarchical: #{self.class}."
2547
+ end
2548
+ return Concat.new(typ,
2549
+ self.each_expression.zip(typ.each_type).map do |e,t|
2550
+ e.match_type(t)
2551
+ end)
2552
+ elsif typ.vector? && typ.base.hierarchical? then
2553
+ unless self.is_a?(Concat) then
2554
+ raise AnyError,
2555
+ "Invalid class for assignment to hierarchical: #{self.class}."
2556
+ end
2557
+ return Concat.new(typ,
2558
+ self.each_expression.map do |e|
2559
+ e.match_type(typ.base)
2560
+ end)
2561
+ else
2562
+ return self.as(typ)
2563
+ end
2564
+ end
2565
+
2401
2566
  # Gets the origin method for operation +op+.
2402
2567
  def self.orig_operator(op)
2403
2568
  return (op.to_s + "_orig").to_sym
@@ -2546,14 +2711,19 @@ module HDLRuby::High
2546
2711
  #
2547
2712
  # NOTE: it is converted afterward to an expression if required.
2548
2713
  def <=(expr)
2714
+ # Cast expr to self if required.
2715
+ expr = expr.to_expr.match_type(self.type)
2716
+ # Generate the transmit.
2549
2717
  if High.top_user.is_a?(HDLRuby::Low::Block) then
2550
2718
  # We are in a block, so generate and add a Transmit.
2551
2719
  High.top_user.
2552
- add_statement(Transmit.new(self.to_ref,expr.to_expr))
2720
+ # add_statement(Transmit.new(self.to_ref,expr.to_expr))
2721
+ add_statement(Transmit.new(self.to_ref,expr))
2553
2722
  else
2554
2723
  # We are in a system type, so generate and add a Connection.
2555
2724
  High.top_user.
2556
- add_connection(Connection.new(self.to_ref,expr.to_expr))
2725
+ # add_connection(Connection.new(self.to_ref,expr.to_expr))
2726
+ add_connection(Connection.new(self.to_ref,expr))
2557
2727
  end
2558
2728
  end
2559
2729
  end
@@ -2571,7 +2741,12 @@ module HDLRuby::High
2571
2741
 
2572
2742
  # Converts the unary expression to HDLRuby::Low.
2573
2743
  def to_low
2574
- return HDLRuby::Low::Cast.new(self.type.to_low,self.child.to_low)
2744
+ # return HDLRuby::Low::Cast.new(self.type.to_low,self.child.to_low)
2745
+ castL =HDLRuby::Low::Cast.new(self.type.to_low,self.child.to_low)
2746
+ # For debugging: set the source high object
2747
+ castL.properties[:low2high] = self.hdr_id
2748
+ self.properties[:high2low] = castL
2749
+ return castL
2575
2750
  end
2576
2751
  end
2577
2752
 
@@ -2588,8 +2763,14 @@ module HDLRuby::High
2588
2763
 
2589
2764
  # Converts the unary expression to HDLRuby::Low.
2590
2765
  def to_low
2591
- return HDLRuby::Low::Unary.new(self.type.to_low, self.operator,
2766
+ # return HDLRuby::Low::Unary.new(self.type.to_low, self.operator,
2767
+ # self.child.to_low)
2768
+ unaryL = HDLRuby::Low::Unary.new(self.type.to_low, self.operator,
2592
2769
  self.child.to_low)
2770
+ # For debugging: set the source high object
2771
+ unaryL.properties[:low2high] = self.hdr_id
2772
+ self.properties[:high2low] = unaryL
2773
+ return unaryL
2593
2774
  end
2594
2775
  end
2595
2776
 
@@ -2607,9 +2788,14 @@ module HDLRuby::High
2607
2788
 
2608
2789
  # Converts the binary expression to HDLRuby::Low.
2609
2790
  def to_low
2610
- # return HDLRuby::Low::Binary.new(self.operator,
2611
- return HDLRuby::Low::Binary.new(self.type.to_low, self.operator,
2791
+ # return HDLRuby::Low::Binary.new(self.type.to_low, self.operator,
2792
+ # self.left.to_low, self.right.to_low)
2793
+ binaryL = HDLRuby::Low::Binary.new(self.type.to_low, self.operator,
2612
2794
  self.left.to_low, self.right.to_low)
2795
+ # For debugging: set the source high object
2796
+ binaryL.properties[:low2high] = self.hdr_id
2797
+ self.properties[:high2low] = binaryL
2798
+ return binaryL
2613
2799
  end
2614
2800
  end
2615
2801
 
@@ -2631,11 +2817,20 @@ module HDLRuby::High
2631
2817
 
2632
2818
  # Converts the selection expression to HDLRuby::Low.
2633
2819
  def to_low
2634
- return HDLRuby::Low::Select.new(self.type.to_low,"?",
2820
+ # return HDLRuby::Low::Select.new(self.type.to_low,"?",
2821
+ # self.select.to_low,
2822
+ # *self.each_choice.map do |choice|
2823
+ # choice.to_low
2824
+ # end)
2825
+ selectL = HDLRuby::Low::Select.new(self.type.to_low,"?",
2635
2826
  self.select.to_low,
2636
2827
  *self.each_choice.map do |choice|
2637
2828
  choice.to_low
2638
2829
  end)
2830
+ # For debugging: set the source high object
2831
+ selectL.properties[:low2high] = self.hdr_id
2832
+ self.properties[:high2low] = selectL
2833
+ return selectL
2639
2834
  end
2640
2835
  end
2641
2836
 
@@ -2656,11 +2851,20 @@ module HDLRuby::High
2656
2851
 
2657
2852
  # Converts the concatenation expression to HDLRuby::Low.
2658
2853
  def to_low
2659
- return HDLRuby::Low::Concat.new(self.type.to_low,
2854
+ # return HDLRuby::Low::Concat.new(self.type.to_low,
2855
+ # self.each_expression.map do |expr|
2856
+ # expr.to_low
2857
+ # end
2858
+ # )
2859
+ concatL = HDLRuby::Low::Concat.new(self.type.to_low,
2660
2860
  self.each_expression.map do |expr|
2661
2861
  expr.to_low
2662
2862
  end
2663
2863
  )
2864
+ # For debugging: set the source high object
2865
+ concatL.properties[:low2high] = self.hdr_id
2866
+ self.properties[:high2low] = concatL
2867
+ return concatL
2664
2868
  end
2665
2869
  end
2666
2870
 
@@ -2699,7 +2903,12 @@ module HDLRuby::High
2699
2903
  # Clone the content if possible
2700
2904
  content = self.content.frozen? ? self.content : self.content.clone
2701
2905
  # Create and return the resulting low-level value
2702
- return HDLRuby::Low::Value.new(self.type.to_low,self.content)
2906
+ # return HDLRuby::Low::Value.new(self.type.to_low,self.content)
2907
+ valueL = HDLRuby::Low::Value.new(self.type.to_low,self.content)
2908
+ # For debugging: set the source high object
2909
+ valueL.properties[:low2high] = self.hdr_id
2910
+ self.properties[:high2low] = valueL
2911
+ return valueL
2703
2912
  end
2704
2913
 
2705
2914
  end
@@ -2801,9 +3010,13 @@ module HDLRuby::High
2801
3010
 
2802
3011
  # Converts the name reference to a HDLRuby::Low::RefName.
2803
3012
  def to_low
2804
- # return HDLRuby::Low::RefName.new(@base.to_ref.to_low,@object.name)
2805
- return HDLRuby::Low::RefName.new(self.type.to_low,
3013
+ # puts "to_low with base=#{@base} @object=#{@object}"
3014
+ refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
2806
3015
  @base.to_ref.to_low,@object.name)
3016
+ # For debugging: set the source high object
3017
+ refNameL.properties[:low2high] = self.hdr_id
3018
+ self.properties[:high2low] = refNameL
3019
+ return refNameL
2807
3020
  end
2808
3021
 
2809
3022
  # Missing methods are looked for into the refered object.
@@ -2830,11 +3043,20 @@ module HDLRuby::High
2830
3043
 
2831
3044
  # Converts the concat reference to HDLRuby::Low.
2832
3045
  def to_low
2833
- return HDLRuby::Low::RefConcat.new(self.type.to_low,
3046
+ # return HDLRuby::Low::RefConcat.new(self.type.to_low,
3047
+ # self.each_ref.map do |ref|
3048
+ # ref.to_low
3049
+ # end
3050
+ # )
3051
+ refConcatL = HDLRuby::Low::RefConcat.new(self.type.to_low,
2834
3052
  self.each_ref.map do |ref|
2835
3053
  ref.to_low
2836
3054
  end
2837
3055
  )
3056
+ # For debugging: set the source high object
3057
+ refConcatL.properties[:low2high] = self.hdr_id
3058
+ self.properties[:high2low] = refConcatL
3059
+ return refConcatL
2838
3060
  end
2839
3061
  end
2840
3062
 
@@ -2851,8 +3073,14 @@ module HDLRuby::High
2851
3073
 
2852
3074
  # Converts the index reference to HDLRuby::Low.
2853
3075
  def to_low
2854
- return HDLRuby::Low::RefIndex.new(self.type.to_low,
2855
- self.ref.to_low,self.index.to_low)
3076
+ # return HDLRuby::Low::RefIndex.new(self.type.to_low,
3077
+ # self.ref.to_low,self.index.to_low)
3078
+ refIndexL = HDLRuby::Low::RefIndex.new(self.type.to_low,
3079
+ self.ref.to_low,self.index.to_low)
3080
+ # For debugging: set the source high object
3081
+ refIndexL.properties[:low2high] = self.hdr_id
3082
+ self.properties[:high2low] = refIndexL
3083
+ return refIndexL
2856
3084
  end
2857
3085
  end
2858
3086
 
@@ -2869,8 +3097,14 @@ module HDLRuby::High
2869
3097
 
2870
3098
  # Converts the range reference to HDLRuby::Low.
2871
3099
  def to_low
2872
- return HDLRuby::Low::RefRange.new(self.type.to_low,
3100
+ # return HDLRuby::Low::RefRange.new(self.type.to_low,
3101
+ # self.ref.to_low,self.range.to_low)
3102
+ refRangeL = HDLRuby::Low::RefRange.new(self.type.to_low,
2873
3103
  self.ref.to_low,self.range.to_low)
3104
+ # For debugging: set the source high object
3105
+ refRangeL.properties[:low2high] = self.hdr_id
3106
+ self.properties[:high2low] = refRangeL
3107
+ return refRangeL
2874
3108
  end
2875
3109
  end
2876
3110
 
@@ -2881,14 +3115,19 @@ module HDLRuby::High
2881
3115
 
2882
3116
  # Converts to a new reference.
2883
3117
  def to_ref
2884
- return RefName.new(self.ref.to_ref,self.name)
3118
+ return RefName.new(self.type,self.ref.to_ref,self.name)
2885
3119
  end
2886
3120
 
2887
3121
  # Converts the name reference to HDLRuby::Low.
2888
3122
  def to_low
2889
- # puts "To low for ref with name=#{self.name} and subref=#{self.ref}"
2890
- return HDLRuby::Low::RefName.new(self.type.to_low,
3123
+ # return HDLRuby::Low::RefName.new(self.type.to_low,
3124
+ # self.ref.to_low,self.name)
3125
+ refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
2891
3126
  self.ref.to_low,self.name)
3127
+ # For debugging: set the source high object
3128
+ refNameL.properties[:low2high] = self.hdr_id
3129
+ self.properties[:high2low] = refNameL
3130
+ return refNameL
2892
3131
  end
2893
3132
  end
2894
3133
 
@@ -2920,14 +3159,53 @@ module HDLRuby::High
2920
3159
 
2921
3160
  # Converts the this reference to HDLRuby::Low.
2922
3161
  def to_low
2923
- return HDLRuby::Low::RefThis.new
3162
+ # return HDLRuby::Low::RefThis.new
3163
+ refThisL = HDLRuby::Low::RefThis.new
3164
+ # For debugging: set the source high object
3165
+ refThisL.properties[:low2high] = self.hdr_id
3166
+ self.properties[:high2low] = refThisL
3167
+ return refThisL
3168
+ end
3169
+ end
3170
+
3171
+ ##
3172
+ # Describes a string.
3173
+ #
3174
+ # NOTE: This is not synthesizable!
3175
+ class StringE < Low::StringE
3176
+ include HExpression
3177
+
3178
+ # Converts to an expression.
3179
+ def to_expr
3180
+ return StringE.new(self.content,*self.each_arg.map(&:to_expr))
3181
+ end
3182
+
3183
+ # Converts the connection to HDLRuby::Low.
3184
+ def to_low
3185
+ return HDLRuby::Low::StringE.new(self.content,
3186
+ *self.each_arg.map(&:to_low))
3187
+ end
3188
+ end
3189
+
3190
+
3191
+
3192
+
3193
+ # Sets the current this to +obj+.
3194
+ #
3195
+ # NOTE: do not use a this= style to avoid confusion.
3196
+ def set_this(obj = proc { RefThis.new })
3197
+ if (obj.is_a?(Proc)) then
3198
+ @@this = obj
3199
+ else
3200
+ @@this = proc { RefObject.new(RefThis.new,obj) }
2924
3201
  end
2925
3202
  end
2926
3203
 
2927
3204
 
2928
3205
  # Gives access to the *this* reference.
2929
3206
  def this
2930
- RefThis.new
3207
+ # RefThis.new
3208
+ @@this.call
2931
3209
  end
2932
3210
 
2933
3211
 
@@ -2954,7 +3232,12 @@ module HDLRuby::High
2954
3232
 
2955
3233
  # Converts the event to HDLRuby::Low.
2956
3234
  def to_low
2957
- return HDLRuby::Low::Event.new(self.type,self.ref.to_low)
3235
+ # return HDLRuby::Low::Event.new(self.type,self.ref.to_low)
3236
+ eventL = HDLRuby::Low::Event.new(self.type,self.ref.to_low)
3237
+ # For debugging: set the source high object
3238
+ eventL.properties[:low2high] = self.hdr_id
3239
+ self.properties[:high2low] = eventL
3240
+ return eventL
2958
3241
  end
2959
3242
  end
2960
3243
 
@@ -2990,11 +3273,39 @@ module HDLRuby::High
2990
3273
 
2991
3274
  # Converts the transmit to HDLRuby::Low.
2992
3275
  def to_low
2993
- return HDLRuby::Low::Transmit.new(self.left.to_low,
3276
+ # return HDLRuby::Low::Transmit.new(self.left.to_low,
3277
+ # self.right.to_low)
3278
+ transmitL = HDLRuby::Low::Transmit.new(self.left.to_low,
2994
3279
  self.right.to_low)
3280
+ # For debugging: set the source high object
3281
+ transmitL.properties[:low2high] = self.hdr_id
3282
+ self.properties[:high2low] = transmitL
3283
+ return transmitL
2995
3284
  end
2996
3285
  end
2997
3286
 
3287
+
3288
+ ##
3289
+ # Describes a print statement: not synthesizable!
3290
+ class Print < Low::Print
3291
+ High = HDLRuby::High
3292
+
3293
+ include HStatement
3294
+
3295
+ # Creates a new statement for printing +args+.
3296
+ def initialize(*args)
3297
+ # Process the arguments.
3298
+ super(*args.map(&:to_expr))
3299
+ end
3300
+
3301
+ # Converts the connection to HDLRuby::Low.
3302
+ def to_low
3303
+ return HDLRuby::Low::Print.new(*self.each_arg.map(&:to_low))
3304
+ end
3305
+
3306
+ end
3307
+
3308
+
2998
3309
  ##
2999
3310
  # Describes a connection.
3000
3311
  class Connection < Low::Connection
@@ -3055,8 +3366,14 @@ module HDLRuby::High
3055
3366
 
3056
3367
  # Converts the connection to HDLRuby::Low.
3057
3368
  def to_low
3058
- return HDLRuby::Low::Connection.new(self.left.to_low,
3369
+ # return HDLRuby::Low::Connection.new(self.left.to_low,
3370
+ # self.right.to_low)
3371
+ connectionL = HDLRuby::Low::Connection.new(self.left.to_low,
3059
3372
  self.right.to_low)
3373
+ # For debugging: set the source high object
3374
+ connectionL.properties[:low2high] = self.hdr_id
3375
+ self.properties[:high2low] = connectionL
3376
+ return connectionL
3060
3377
  end
3061
3378
  end
3062
3379
 
@@ -3086,7 +3403,7 @@ module HDLRuby::High
3086
3403
  # NOTE: +dir+ can be :input, :output, :inout or :inner
3087
3404
  def initialize(name,type,dir,value = nil)
3088
3405
  # Check the value.
3089
- value = value.to_expr if value
3406
+ value = value.to_expr.match_type(type) if value
3090
3407
  # Initialize the type structure.
3091
3408
  super(name,type,value)
3092
3409
 
@@ -3165,7 +3482,12 @@ module HDLRuby::High
3165
3482
 
3166
3483
  # Converts the system to HDLRuby::Low and set its +name+.
3167
3484
  def to_low(name = self.name)
3168
- return HDLRuby::Low::SignalI.new(name,self.type.to_low)
3485
+ # return HDLRuby::Low::SignalI.new(name,self.type.to_low)
3486
+ signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low)
3487
+ # For debugging: set the source high object
3488
+ signalIL.properties[:low2high] = self.hdr_id
3489
+ self.properties[:high2low] = signalIL
3490
+ return signalIL
3169
3491
  end
3170
3492
  end
3171
3493
 
@@ -3181,7 +3503,7 @@ module HDLRuby::High
3181
3503
  # and +value+.
3182
3504
  def initialize(name,type,value)
3183
3505
  # Check the value is a constant.
3184
- value = value.to_expr
3506
+ value = value.to_expr.match_type(type)
3185
3507
  unless value.constant? then
3186
3508
  raise AnyError,"Non-constant value assignment to constant."
3187
3509
  end
@@ -3224,8 +3546,14 @@ module HDLRuby::High
3224
3546
 
3225
3547
  # Converts the system to HDLRuby::Low and set its +name+.
3226
3548
  def to_low(name = self.name)
3227
- return HDLRuby::Low::SignalC.new(name,self.type.to_low,
3549
+ # return HDLRuby::Low::SignalC.new(name,self.type.to_low,
3550
+ # self.value.to_low)
3551
+ signalCL = HDLRuby::Low::SignalC.new(name,self.type.to_low,
3228
3552
  self.value.to_low)
3553
+ # For debugging: set the source high object
3554
+ signalCL.properties[:low2high] = self.hdr_id
3555
+ self.properties[:high2low] = signalCL
3556
+ return signalCL
3229
3557
  end
3230
3558
  end
3231
3559
 
@@ -3298,13 +3626,6 @@ module HDLRuby::High
3298
3626
  # Use its return value.
3299
3627
  return block.return_value
3300
3628
  end
3301
-
3302
- # # Get the current mode of the block.
3303
- # #
3304
- # # NOTE: for name coherency purpose only.
3305
- # def block
3306
- # return self.mode
3307
- # end
3308
3629
 
3309
3630
  # Gets the current block.
3310
3631
  def cur_block
@@ -3402,6 +3723,12 @@ module HDLRuby::High
3402
3723
  end
3403
3724
  statement.hwhen(match, mode, &ruby_block)
3404
3725
  end
3726
+
3727
+
3728
+ # Prints.
3729
+ def hprint(*args)
3730
+ self.add_statement(Print.new(*args))
3731
+ end
3405
3732
  end
3406
3733
 
3407
3734
 
@@ -3436,6 +3763,9 @@ module HDLRuby::High
3436
3763
  def to_low
3437
3764
  # Create the resulting block
3438
3765
  blockL = HDLRuby::Low::Block.new(self.mode)
3766
+ # For debugging: set the source high object
3767
+ blockL.properties[:low2high] = self.hdr_id
3768
+ self.properties[:high2low] = blockL
3439
3769
  # Push the namespace for the low generation.
3440
3770
  High.space_push(@namespace)
3441
3771
  # Pushes on the name stack for converting the internals of
@@ -3503,6 +3833,9 @@ module HDLRuby::High
3503
3833
  def to_low
3504
3834
  # Create the resulting block
3505
3835
  blockL = HDLRuby::Low::TimeBlock.new(self.mode)
3836
+ # For debugging: set the source high object
3837
+ blockL.properties[:low2high] = self.hdr_id
3838
+ self.properties[:high2low] = blockL
3506
3839
  # Add the inner signals
3507
3840
  self.each_inner { |inner| blockL.add_inner(inner.to_low) }
3508
3841
  # Add the statements
@@ -3594,6 +3927,9 @@ module HDLRuby::High
3594
3927
  eventLs = self.each_event.map { |event| event.to_low }
3595
3928
  # Create and return the resulting low level behavior.
3596
3929
  behaviorL = HDLRuby::Low::Behavior.new(blockL)
3930
+ # For debugging: set the source high object
3931
+ behaviorL.properties[:low2high] = self.hdr_id
3932
+ self.properties[:high2low] = behaviorL
3597
3933
  eventLs.each(&behaviorL.method(:add_event))
3598
3934
  return behaviorL
3599
3935
  end
@@ -3620,9 +3956,12 @@ module HDLRuby::High
3620
3956
  # Create the low level events.
3621
3957
  eventLs = self.each_event.map { |event| event.to_low }
3622
3958
  # Create and return the resulting low level behavior.
3623
- behaviorL = HDLRuby::Low::TimeBehavior.new(blockL)
3624
- eventLs.each(&behaviorL.method(:add_event))
3625
- return behaviorL
3959
+ timeBehaviorL = HDLRuby::Low::TimeBehavior.new(blockL)
3960
+ # For debugging: set the source high object
3961
+ timeBehaviorL.properties[:low2high] = self.hdr_id
3962
+ self.properties[:high2low] = timeBehaviorL
3963
+ eventLs.each(&timeBehaviorL.method(:add_event))
3964
+ return timeBehaviorL
3626
3965
  end
3627
3966
  end
3628
3967
 
@@ -3927,13 +4266,40 @@ module HDLRuby::High
3927
4266
 
3928
4267
  # Extends the String class for computing conversion to expression.
3929
4268
  class ::String
3930
- # Converts to a new high-level expression.
3931
- def to_expr
4269
+ # # Converts to a new high-level expression.
4270
+ # def to_expr
4271
+ # # Convert the string to a bit string.
4272
+ # bstr = BitString.new(self)
4273
+ # # Use it to create the new value.
4274
+ # return Value.new(Bit[bstr.width],self)
4275
+ # end
4276
+
4277
+ # Converts to a new high-level value.
4278
+ def to_value
3932
4279
  # Convert the string to a bit string.
3933
4280
  bstr = BitString.new(self)
3934
4281
  # Use it to create the new value.
3935
4282
  return Value.new(Bit[bstr.width],self)
3936
4283
  end
4284
+
4285
+ # Convert to a new high-level string expression
4286
+ def to_expr
4287
+ return StringE.new(self)
4288
+ end
4289
+
4290
+ # For now deactivated, needs rethinking.
4291
+ # # Rework format to generate HDLRuby string.
4292
+ # alias_method :__format_old__, :%
4293
+ # def %(args)
4294
+ # # Is there any HW argument?
4295
+ # if args.any? { |arg| arg.is_a?(HDLRuby::Low::Hparent) } then
4296
+ # # Yes generate a HDLRuby string.
4297
+ # return StringE.new(self,*args)
4298
+ # else
4299
+ # # No process the format normally.
4300
+ # self.__format_old__(args)
4301
+ # end
4302
+ # end
3937
4303
  end
3938
4304
 
3939
4305
 
@@ -4027,11 +4393,14 @@ module HDLRuby::High
4027
4393
 
4028
4394
  # Converts to a new high-level expression.
4029
4395
  def to_expr
4030
- # expr = Concat.new
4031
- expr = Concat.new(TypeTuple.new(:"",:little,*self.map do |elem|
4032
- elem.to_expr.type
4033
- end))
4034
- self.each {|elem| expr.add_expression(elem.to_expr) }
4396
+ # expr = Concat.new(TypeTuple.new(:"",:little,*self.map do |elem|
4397
+ # elem.to_expr.type
4398
+ # end))
4399
+ elems = self.map {|elem| elem.to_expr }
4400
+ typ= TypeTuple.new(:"",:little)
4401
+ elems.each {|elem| typ.add_type(elem.type) }
4402
+ expr = Concat.new(typ)
4403
+ elems.each {|elem| expr.add_expression(elem) }
4035
4404
  expr
4036
4405
  end
4037
4406
 
@@ -4102,6 +4471,11 @@ module HDLRuby::High
4102
4471
  end
4103
4472
  end
4104
4473
 
4474
+ # Add support of the left arrow operator.
4475
+ def <=(expr)
4476
+ self.to_expr <= expr
4477
+ end
4478
+
4105
4479
  # Array construction shortcuts
4106
4480
 
4107
4481
  # Create an array whose number of elements is given by the content
@@ -4394,6 +4768,9 @@ def self.configure_high
4394
4768
  end
4395
4769
  end
4396
4770
 
4771
+ # Initialize the this.
4772
+ set_this
4773
+
4397
4774
  # Generate the standard signals
4398
4775
  $clk = Universe.scope.inner :__universe__clk__
4399
4776
  $rst = Universe.scope.inner :__universe__rst__