HDLRuby 2.4.28 → 2.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) 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/with_function_generator.rb +25 -0
  17. data/lib/HDLRuby/hdrcc.rb +165 -26
  18. data/lib/HDLRuby/hruby_decorator.rb +250 -0
  19. data/lib/HDLRuby/hruby_high.rb +468 -91
  20. data/lib/HDLRuby/hruby_low.rb +913 -45
  21. data/lib/HDLRuby/hruby_low2c.rb +189 -168
  22. data/lib/HDLRuby/hruby_low2hdr.rb +738 -0
  23. data/lib/HDLRuby/hruby_low2high.rb +331 -549
  24. data/lib/HDLRuby/hruby_low2vhd.rb +39 -2
  25. data/lib/HDLRuby/hruby_low_bool2select.rb +29 -0
  26. data/lib/HDLRuby/hruby_low_casts_without_expression.rb +27 -0
  27. data/lib/HDLRuby/hruby_low_fix_types.rb +25 -0
  28. data/lib/HDLRuby/hruby_low_mutable.rb +70 -0
  29. data/lib/HDLRuby/hruby_low_resolve.rb +28 -0
  30. data/lib/HDLRuby/hruby_low_without_connection.rb +6 -3
  31. data/lib/HDLRuby/hruby_low_without_namespace.rb +7 -4
  32. data/lib/HDLRuby/hruby_low_without_select.rb +13 -0
  33. data/lib/HDLRuby/hruby_tools.rb +11 -1
  34. data/lib/HDLRuby/hruby_verilog.rb +1577 -1709
  35. data/lib/HDLRuby/sim/hruby_sim.h +29 -3
  36. data/lib/HDLRuby/sim/hruby_sim_calc.c +63 -6
  37. data/lib/HDLRuby/sim/hruby_sim_core.c +24 -9
  38. data/lib/HDLRuby/sim/hruby_sim_vcd.c +5 -1
  39. data/lib/HDLRuby/sim/hruby_sim_vizualize.c +22 -6
  40. data/lib/HDLRuby/std/fixpoint.rb +9 -0
  41. data/lib/HDLRuby/std/function_generator.rb +139 -0
  42. data/lib/HDLRuby/std/hruby_unit.rb +75 -0
  43. data/lib/HDLRuby/template_expander.rb +61 -0
  44. data/lib/HDLRuby/version.rb +1 -1
  45. metadata +20 -5
@@ -32,6 +32,13 @@ module HDLRuby::Low
32
32
  return [1.to_i].pack("i").size*8
33
33
  end
34
34
 
35
+ ## Converts string +str+ to a C-compatible string.
36
+ def self.c_string(str)
37
+ str = str.gsub(/\n/,"\\n")
38
+ str.gsub!(/\t/,"\\t")
39
+ return str
40
+ end
41
+
35
42
  ## Tells if a +name+ is C-compatible.
36
43
  # To ensure compatibile, assume all the character must have the
37
44
  # same case.
@@ -139,10 +146,10 @@ module HDLRuby::Low
139
146
  end
140
147
 
141
148
 
142
- ## Extends the SystemT class with generation of HDLRuby::High C text.
149
+ ## Extends the SystemT class with generation of C text.
143
150
  class SystemT
144
151
 
145
- # Generates the text of the equivalent HDLRuby::High code.
152
+ # Generates the text of the equivalent HDLRuby code.
146
153
  # +level+ is the hierachical level of the object and +hnames+
147
154
  # is the list of extra h files to include.
148
155
  def to_c(level = 0, *hnames)
@@ -178,6 +185,7 @@ module HDLRuby::Low
178
185
  end
179
186
  end
180
187
  self.scope.each_block_deep do |block|
188
+ # puts "treating for block=#{Low2C.obj_name(block)} with=#{block.each_inner.count} inners"
181
189
  block.each_inner do |signal|
182
190
  # res << signal.value.to_c_make(level) if signal.value
183
191
  signal.value.each_node_deep do |node|
@@ -344,10 +352,10 @@ module HDLRuby::Low
344
352
  end
345
353
 
346
354
 
347
- ## Extends the Scope class with generation of HDLRuby::High C text.
355
+ ## Extends the Scope class with generation of C text.
348
356
  class Scope
349
357
 
350
- # Generates the text of the equivalent HDLRuby::High code.
358
+ # Generates the C text of the equivalent HDLRuby code.
351
359
  # +level+ is the hierachical level of the object.
352
360
  def to_c(level = 0)
353
361
  # The resulting string.
@@ -497,10 +505,10 @@ module HDLRuby::Low
497
505
  end
498
506
 
499
507
 
500
- ## Extends the Type class with generation of HDLRuby::High text.
508
+ ## Extends the Type class with generation of C text.
501
509
  class Type
502
510
 
503
- # Generates the C text of the equivalent HDLRuby::High code.
511
+ # Generates the C text of the equivalent HDLRuby code.
504
512
  # +level+ is the hierachical level of the object.
505
513
  def to_c(level = 0)
506
514
  # return Low2C.c_name(self.name)
@@ -515,10 +523,10 @@ module HDLRuby::Low
515
523
  end
516
524
  end
517
525
 
518
- ## Extends the TypeDef class with generation of HDLRuby::High text.
526
+ ## Extends the TypeDef class with generation of C text.
519
527
  class TypeDef
520
528
 
521
- # Generates the C text of the equivalent HDLRuby::High code.
529
+ # Generates the C text of the equivalent HDLRuby code.
522
530
  # +level+ is the hierachical level of the object.
523
531
  def to_c(level = 0)
524
532
  # # Simply use the name of the type.
@@ -528,10 +536,10 @@ module HDLRuby::Low
528
536
  end
529
537
  end
530
538
 
531
- ## Extends the TypeVector class with generation of HDLRuby::High text.
539
+ ## Extends the TypeVector class with generation of C text.
532
540
  class TypeVector
533
541
 
534
- # Generates the C text of the equivalent HDLRuby::High code.
542
+ # Generates the C text of the equivalent HDLRuby code.
535
543
  # +level+ is the hierachical level of the object.
536
544
  def to_c(level = 0)
537
545
  # The resulting string.
@@ -540,10 +548,10 @@ module HDLRuby::Low
540
548
  end
541
549
  end
542
550
 
543
- ## Extends the TypeTuple class with generation of HDLRuby::High text.
551
+ ## Extends the TypeTuple class with generation of C text.
544
552
  class TypeTuple
545
553
 
546
- # Generates the text of the equivalent HDLRuby::High code.
554
+ # Generates the C text of the equivalent HDLRuby code.
547
555
  # +level+ is the hierachical level of the object.
548
556
  #
549
557
  # NOTE: type tuples are converted to bit vector of their contents.
@@ -556,10 +564,10 @@ module HDLRuby::Low
556
564
  end
557
565
 
558
566
 
559
- ## Extends the TypeStruct class with generation of HDLRuby::High text.
567
+ ## Extends the TypeStruct class with generation of C text.
560
568
  class TypeStruct
561
569
 
562
- # Generates the text of the equivalent HDLRuby::High code.
570
+ # Generates the text of the equivalent HDLRuby code.
563
571
  # +level+ is the hierachical level of the object.
564
572
  def to_c(level = 0)
565
573
  return "get_type_struct(#{self.each.join(",") do |key,type|
@@ -569,10 +577,10 @@ module HDLRuby::Low
569
577
  end
570
578
 
571
579
 
572
- ## Extends the Behavior class with generation of HDLRuby::High text.
580
+ ## Extends the Behavior class with generation of C text.
573
581
  class Behavior
574
582
 
575
- # Generates the text of the equivalent HDLRuby::High code.
583
+ # Generates the text of the equivalent HDLRuby code.
576
584
  # +level+ is the hierachical level of the object and
577
585
  # +time+ is a flag telling if the behavior is timed or not.
578
586
  def to_c(level = 0, time = false)
@@ -705,10 +713,10 @@ module HDLRuby::Low
705
713
  end
706
714
  end
707
715
 
708
- ## Extends the TimeBehavior class with generation of HDLRuby::High text.
716
+ ## Extends the TimeBehavior class with generation of C text.
709
717
  class TimeBehavior
710
718
 
711
- # Generates the C text of the equivalent HDLRuby::High code.
719
+ # Generates the C text of the equivalent HDLRuby code.
712
720
  # +level+ is the hierachical level of the object.
713
721
  def to_c(level = 0)
714
722
  super(level,true)
@@ -716,10 +724,10 @@ module HDLRuby::Low
716
724
  end
717
725
 
718
726
 
719
- ## Extends the Event class with generation of HDLRuby::High text.
727
+ ## Extends the Event class with generation of C text.
720
728
  class Event
721
729
 
722
- # Generates the C text of the equivalent HDLRuby::High code.
730
+ # Generates the C text of the equivalent HDLRuby code.
723
731
  # +level+ is the hierachical level of the object.
724
732
  def to_c(level = 0)
725
733
  edge = "ANYEDGE"
@@ -731,7 +739,7 @@ module HDLRuby::Low
731
739
  end
732
740
 
733
741
 
734
- ## Extends the SignalI class with generation of HDLRuby::High text.
742
+ ## Extends the SignalI class with generation of C text.
735
743
  class SignalI
736
744
 
737
745
  ## Generates the C text for an access to the signal.
@@ -747,7 +755,7 @@ module HDLRuby::Low
747
755
  return res
748
756
  end
749
757
 
750
- ## Generates the C text of the equivalent HDLRuby::High code.
758
+ ## Generates the C text of the equivalent HDLRuby code.
751
759
  # +level+ is the hierachical level of the object.
752
760
  def to_c(level = 0)
753
761
  # The resulting string.
@@ -837,6 +845,7 @@ module HDLRuby::Low
837
845
  ## Generates the content of the h file.
838
846
  def to_ch
839
847
  res = ""
848
+ # puts "to_ch for SignalI: #{self.to_c_signal()}"
840
849
  # Declare the global variable holding the signal.
841
850
  res << "extern SignalI #{self.to_c_signal()};\n\n"
842
851
 
@@ -848,10 +857,10 @@ module HDLRuby::Low
848
857
  end
849
858
 
850
859
 
851
- ## Extends the SystemI class with generation of HDLRuby::High text.
860
+ ## Extends the SystemI class with generation of C text.
852
861
  class SystemI
853
862
 
854
- ## Generates the C text of the equivalent HDLRuby::High code.
863
+ ## Generates the C text of the equivalent HDLRuby code.
855
864
  # +level+ is the hierachical level of the object.
856
865
  def to_c(level = 0)
857
866
  # The resulting string.
@@ -917,7 +926,7 @@ module HDLRuby::Low
917
926
  # Extend the Chunk cass with generation of text code.
918
927
  class HDLRuby::Low::Chunk
919
928
 
920
- # Generates the text of the equivalent HDLRuby::High code.
929
+ # Generates the C text of the equivalent HDLRuby code.
921
930
  # +level+ is the hierachical level of the object.
922
931
  def to_c(level = 0)
923
932
  res = " " * level
@@ -933,9 +942,9 @@ module HDLRuby::Low
933
942
  end
934
943
 
935
944
 
936
- ## Extends the SystemI class with generation of HDLRuby::High text.
945
+ ## Extends the SystemI class with generation of C text.
937
946
  class Code
938
- # Generates the text of the equivalent HDLRuby::High code.
947
+ # Generates the C text of the equivalent HDLRuby code.
939
948
  # +level+ is the hierachical level of the object.
940
949
  def to_c(level = 0)
941
950
  # puts "For behavior: #{self}"
@@ -1040,16 +1049,22 @@ module HDLRuby::Low
1040
1049
  end
1041
1050
 
1042
1051
 
1043
- ## Extends the Statement class with generation of HDLRuby::High text.
1052
+ ## Extends the Statement class with generation of C text.
1044
1053
  class Statement
1045
1054
 
1046
- # Generates the C text of the equivalent HDLRuby::High code.
1055
+ # Generates the C text of the equivalent HDLRuby code.
1047
1056
  # +level+ is the hierachical level of the object.
1048
1057
  def to_c(level = 0)
1049
1058
  # Should never be here.
1050
1059
  raise AnyError, "Internal error: to_c should be implemented in class :#{self.class}"
1051
1060
  end
1052
1061
 
1062
+ ## Generates the content of the h file.
1063
+ def to_ch
1064
+ # By default nothing to generate.
1065
+ return ""
1066
+ end
1067
+
1053
1068
  # Adds the c code of the blocks to +res+ at +level+
1054
1069
  def add_blocks_code(res,level)
1055
1070
  if self.respond_to?(:each_node) then
@@ -1060,12 +1075,23 @@ module HDLRuby::Low
1060
1075
  end
1061
1076
  end
1062
1077
  end
1078
+
1079
+ # Adds the creation of the blocks to +res+ at +level+.
1080
+ def add_make_block(res,level)
1081
+ if self.respond_to?(:each_node) then
1082
+ self.each_node do |node|
1083
+ if node.respond_to?(:add_blocks_code) then
1084
+ node.add_make_block(res,level)
1085
+ end
1086
+ end
1087
+ end
1088
+ end
1063
1089
  end
1064
1090
 
1065
- ## Extends the Transmit class with generation of HDLRuby::High text.
1091
+ ## Extends the Transmit class with generation of C text.
1066
1092
  class Transmit
1067
1093
 
1068
- # Generates the C text of the equivalent HDLRuby::High code.
1094
+ # Generates the C text of the equivalent HDLRuby code.
1069
1095
  # +level+ is the hierachical level of the object.
1070
1096
  def to_c(level = 0)
1071
1097
  # Save the state of the value pool.
@@ -1097,11 +1123,48 @@ module HDLRuby::Low
1097
1123
  end
1098
1124
  end
1099
1125
 
1126
+
1127
+ ## Extends the Print class with generation of C text.
1128
+ class Print
1129
+
1130
+ # Generates the C text of the equivalent HDLRuby code.
1131
+ # +level+ is the hierachical level of the object.
1132
+ def to_c(level = 0)
1133
+ # Save the state of the value pool.
1134
+ res = (" " * ((level)*3))
1135
+ res << "{\n"
1136
+ res << (" " * ((level+1)*3))
1137
+ res << "unsigned int pool_state = get_value_pos();\n"
1138
+ # Perform the copy and the touching only if the new content
1139
+ # is different.
1140
+ res << (" " * ((level+1)*3))
1141
+ # Is it a sequential execution model?
1142
+ seq = self.block.mode == :seq ? "_seq" : ""
1143
+ # Generate the print.
1144
+ self.each_arg do |arg|
1145
+ if (arg.is_a?(StringE)) then
1146
+ res << "printer.print_string(\"" +
1147
+ Low2C.c_string(arg.content) + "\");\n"
1148
+ elsif (arg.is_a?(Expression)) then
1149
+ res << "printer.print_string_value(" + arg.to_c + ");\n"
1150
+ else
1151
+ res << "printer.print_string_name(" + arg.to_c + ");\n"
1152
+ end
1153
+ end
1154
+ # Restore the value pool state.
1155
+ res << (" " * ((level+1)*3))
1156
+ res << "set_value_pos(pool_state);\n"
1157
+ res << (" " * ((level)*3))
1158
+ res << "}\n"
1159
+ return res
1160
+ end
1161
+ end
1162
+
1100
1163
 
1101
- ## Extends the If class with generation of HDLRuby::High text.
1164
+ ## Extends the If class with generation of C text.
1102
1165
  class If
1103
1166
 
1104
- # Generates the C text of the equivalent HDLRuby::High code.
1167
+ # Generates the C text of the equivalent HDLRuby code.
1105
1168
  # +level+ is the hierachical level of the object.
1106
1169
  def to_c(level = 0)
1107
1170
  # The result string.
@@ -1143,12 +1206,24 @@ module HDLRuby::Low
1143
1206
  # Return the result.
1144
1207
  return res
1145
1208
  end
1209
+
1210
+ ## Generates the content of the h file.
1211
+ def to_ch
1212
+ res = ""
1213
+ # Recurse on the sub statements.
1214
+ res << self.yes.to_ch
1215
+ self.each_noif do |cond,stmnt|
1216
+ res << stmnt.to_ch
1217
+ end
1218
+ res << self.no.to_ch if self.no
1219
+ return res
1220
+ end
1146
1221
  end
1147
1222
 
1148
- ## Extends the When class with generation of HDLRuby::High text.
1223
+ ## Extends the When class with generation of C text.
1149
1224
  class When
1150
1225
 
1151
- # Generates the C text of the equivalent HDLRuby::High code.
1226
+ # Generates the C text of the equivalent HDLRuby code.
1152
1227
  # +level+ is the hierachical level of the object.
1153
1228
  def to_c(level = 0)
1154
1229
  # The result string.
@@ -1164,16 +1239,26 @@ module HDLRuby::Low
1164
1239
  return res
1165
1240
  end
1166
1241
 
1242
+ ## Generates the content of the h file.
1243
+ def to_ch
1244
+ return self.statement.to_ch
1245
+ end
1246
+
1167
1247
  # Adds the c code of the blocks to +res+ at +level+
1168
1248
  def add_blocks_code(res,level)
1169
1249
  self.statement.add_blocks_code(res,level)
1170
1250
  end
1251
+
1252
+ # Adds the creation of the blocks to +res+ at +level+.
1253
+ def add_make_block(res,level)
1254
+ self.statement.add_make_block(res,level)
1255
+ end
1171
1256
  end
1172
1257
 
1173
- ## Extends the Case class with generation of HDLRuby::High text.
1258
+ ## Extends the Case class with generation of C text.
1174
1259
  class Case
1175
1260
 
1176
- # Generates the text of the equivalent HDLRuby::High code.
1261
+ # Generates the text of the equivalent HDLRuby code.
1177
1262
  # +level+ is the hierachical level of the object.
1178
1263
  def to_c(level = 0)
1179
1264
  res = ""
@@ -1215,13 +1300,23 @@ module HDLRuby::Low
1215
1300
  # Return the resulting string.
1216
1301
  return res
1217
1302
  end
1303
+
1304
+ ## Generates the content of the h file.
1305
+ def to_ch
1306
+ res = ""
1307
+ # Recurse on the whens.
1308
+ self.each_when {|w| res << w.to_ch }
1309
+ # Recurse on the default statement.
1310
+ res << self.default.to_ch if self.default
1311
+ return res
1312
+ end
1218
1313
  end
1219
1314
 
1220
1315
 
1221
- ## Extends the Delay class with generation of HDLRuby::High text.
1316
+ ## Extends the Delay class with generation of C text.
1222
1317
  class Delay
1223
1318
 
1224
- # Generates the C text of the equivalent HDLRuby::High code.
1319
+ # Generates the C text of the equivalent HDLRuby code.
1225
1320
  # +level+ is the hierachical level of the object.
1226
1321
  def to_c(level = 0)
1227
1322
  return "make_delay(#{self.value.to_s}," +
@@ -1230,10 +1325,10 @@ module HDLRuby::Low
1230
1325
  end
1231
1326
 
1232
1327
 
1233
- ## Extends the TimeWait class with generation of HDLRuby::High text.
1328
+ ## Extends the TimeWait class with generation of C text.
1234
1329
  class TimeWait
1235
1330
 
1236
- # Generates the C text of the equivalent HDLRuby::High code.
1331
+ # Generates the C text of the equivalent HDLRuby code.
1237
1332
  # +level+ is the hierachical level of the object.
1238
1333
  def to_c(level = 0)
1239
1334
  # The resulting string.
@@ -1246,10 +1341,10 @@ module HDLRuby::Low
1246
1341
  end
1247
1342
  end
1248
1343
 
1249
- ## Extends the TimeRepeat class with generation of HDLRuby::High text.
1344
+ ## Extends the TimeRepeat class with generation of C text.
1250
1345
  class TimeRepeat
1251
1346
 
1252
- # Generates the C text of the equivalent HDLRuby::High code.
1347
+ # Generates the C text of the equivalent HDLRuby code.
1253
1348
  # +level+ is the hierachical level of the object.
1254
1349
  def to_c(level = 0)
1255
1350
  # The resulting string.
@@ -1264,7 +1359,7 @@ module HDLRuby::Low
1264
1359
  end
1265
1360
  end
1266
1361
 
1267
- ## Extends the Block class with generation of HDLRuby::High text.
1362
+ ## Extends the Block class with generation of C text.
1268
1363
  class Block
1269
1364
 
1270
1365
  # Adds the c code of the blocks to +res+ at +level+
@@ -1272,7 +1367,13 @@ module HDLRuby::Low
1272
1367
  res << self.to_c_code(level)
1273
1368
  end
1274
1369
 
1275
- # Generates the C text of the equivalent HDLRuby::High code.
1370
+ # Adds the creation of the blocks to +res+ at +level+.
1371
+ def add_make_block(res,level)
1372
+ res << " " * level*3
1373
+ res << "#{Low2C.make_name(self)}();\n"
1374
+ end
1375
+
1376
+ # Generates the C text of the equivalent HDLRuby code.
1276
1377
  # +level+ is the hierachical level of the object.
1277
1378
  def to_c_code(level = 0)
1278
1379
  # The resulting string.
@@ -1351,6 +1452,11 @@ module HDLRuby::Low
1351
1452
  res << " " * (level+1)*3
1352
1453
  res << "block->function = &#{Low2C.code_name(self)};\n"
1353
1454
 
1455
+ # Generate creation of the sub blocks.
1456
+ self.each_statement do |stmnt|
1457
+ stmnt.add_make_block(res,level+1)
1458
+ end
1459
+
1354
1460
  # Generate the Returns of the result.
1355
1461
  res << "\n"
1356
1462
  res << " " * (level+1)*3
@@ -1363,7 +1469,7 @@ module HDLRuby::Low
1363
1469
  end
1364
1470
 
1365
1471
  # Generates the execution of the block C text of the equivalent
1366
- # HDLRuby::High code.
1472
+ # HDLRuby code.
1367
1473
  # +level+ is the hierachical level of the object.
1368
1474
  def to_c(level = 0)
1369
1475
  res = " " * (level)
@@ -1373,6 +1479,7 @@ module HDLRuby::Low
1373
1479
 
1374
1480
  ## Generates the content of the h file.
1375
1481
  def to_ch
1482
+ # puts "to_ch for block=#{Low2C.obj_name(self)} with=#{self.each_inner.count} inners"
1376
1483
  res = ""
1377
1484
  # Declare the global variable holding the block.
1378
1485
  res << "extern Block #{Low2C.obj_name(self)};\n\n"
@@ -1383,27 +1490,31 @@ module HDLRuby::Low
1383
1490
  # Generate the accesses to the ports.
1384
1491
  self.each_inner { |inner| res << inner.to_ch }
1385
1492
 
1493
+ # Recurse on the statements.
1494
+ self.each_statement { |stmnt| res << stmnt.to_ch }
1495
+
1496
+
1386
1497
  return res
1387
1498
  end
1388
1499
  end
1389
1500
 
1390
1501
 
1391
- ## Extends the Block class with generation of HDLRuby::High text.
1502
+ ## Extends the Block class with generation of C text.
1392
1503
  class TimeBlock
1393
1504
  # TimeBlock is identical to Block in C
1394
1505
  end
1395
1506
 
1396
1507
 
1397
- ## Extends the Connection class with generation of HDLRuby::High text.
1508
+ ## Extends the Connection class with generation of C text.
1398
1509
  class Connection
1399
1510
  # Nothing required, Transmit is generated identically.
1400
1511
  end
1401
1512
 
1402
1513
 
1403
- ## Extends the Expression class with generation of HDLRuby::High text.
1514
+ ## Extends the Expression class with generation of C text.
1404
1515
  class Expression
1405
1516
 
1406
- # Generates the C text of the equivalent HDLRuby::High code.
1517
+ # Generates the C text of the equivalent HDLRuby code.
1407
1518
  # +level+ is the hierachical level of the object.
1408
1519
  def to_c(level = 0)
1409
1520
  # Should never be here.
@@ -1412,7 +1523,7 @@ module HDLRuby::Low
1412
1523
  end
1413
1524
 
1414
1525
 
1415
- ## Extends the Value class with generation of HDLRuby::High text.
1526
+ ## Extends the Value class with generation of C text.
1416
1527
  class Value
1417
1528
 
1418
1529
  ## Generates the C text for an access to the value.
@@ -1491,10 +1602,10 @@ module HDLRuby::Low
1491
1602
  end
1492
1603
  end
1493
1604
 
1494
- ## Extends the Cast class with generation of HDLRuby::High text.
1605
+ ## Extends the Cast class with generation of C text.
1495
1606
  class Cast
1496
1607
 
1497
- # Generates the C text of the equivalent HDLRuby::High code.
1608
+ # Generates the C text of the equivalent HDLRuby code.
1498
1609
  # +level+ is the hierachical level of the object.
1499
1610
  def to_c(level = 0)
1500
1611
  res = "({\n"
@@ -1522,10 +1633,10 @@ module HDLRuby::Low
1522
1633
  end
1523
1634
 
1524
1635
 
1525
- ## Extends the Operation class with generation of HDLRuby::High text.
1636
+ ## Extends the Operation class with generation of C text.
1526
1637
  class Operation
1527
1638
 
1528
- # Generates the C text of the equivalent HDLRuby::High code.
1639
+ # Generates the C text of the equivalent HDLRuby code.
1529
1640
  # +level+ is the hierachical level of the object.
1530
1641
  def to_c(level = 0)
1531
1642
  # Should never be here.
@@ -1533,10 +1644,10 @@ module HDLRuby::Low
1533
1644
  end
1534
1645
  end
1535
1646
 
1536
- ## Extends the Unary class with generation of HDLRuby::High text.
1647
+ ## Extends the Unary class with generation of C text.
1537
1648
  class Unary
1538
1649
 
1539
- # Generates the C text of the equivalent HDLRuby::High code.
1650
+ # Generates the C text of the equivalent HDLRuby code.
1540
1651
  # +level+ is the hierachical level of the object.
1541
1652
  def to_c(level = 0)
1542
1653
  res = "({\n"
@@ -1578,80 +1689,10 @@ module HDLRuby::Low
1578
1689
  end
1579
1690
 
1580
1691
 
1581
- ## Extends the Binary class with generation of HDLRuby::High text.
1692
+ ## Extends the Binary class with generation of C text.
1582
1693
  class Binary
1583
1694
 
1584
- # # Generates the C text of the equivalent HDLRuby::High code.
1585
- # # +level+ is the hierachical level of the object.
1586
- # def to_c(level = 0)
1587
- # res = ""
1588
- # case self.operator
1589
- # when :+ then
1590
- # return "add_value(#{self.left.to_c(level)}," +
1591
- # "#{self.right.to_c(level)})"
1592
- # when :- then
1593
- # return "sub_value(#{self.left.to_c(level)}," +
1594
- # "#{self.right.to_c(level)})"
1595
- # when :* then
1596
- # return "mul_value(#{self.left.to_c(level)}," +
1597
- # "#{self.right.to_c(level)})"
1598
- # when :/ then
1599
- # return "div_value(#{self.left.to_c(level)}," +
1600
- # "#{self.right.to_c(level)})"
1601
- # when :% then
1602
- # return "mod_value(#{self.left.to_c(level)}," +
1603
- # "#{self.right.to_c(level)})"
1604
- # when :** then
1605
- # return "pow_value(#{self.left.to_c(level)}," +
1606
- # "#{self.right.to_c(level)})"
1607
- # when :& then
1608
- # return "and_value(#{self.left.to_c(level)}," +
1609
- # "#{self.right.to_c(level)})"
1610
- # when :| then
1611
- # return "or_value(#{self.left.to_c(level)}," +
1612
- # "#{self.right.to_c(level)})"
1613
- # when :^ then
1614
- # return "xor_value(#{self.left.to_c(level)}," +
1615
- # "#{self.right.to_c(level)})"
1616
- # when :<<,:ls then
1617
- # return "shift_left_value(#{self.left.to_c(level)}," +
1618
- # "#{self.right.to_c(level)})"
1619
- # when :>>,:rs then
1620
- # return "shift_right_value(#{self.left.to_c(level)}," +
1621
- # "#{self.right.to_c(level)})"
1622
- # when :lr then
1623
- # return "rotate_left_value(#{self.left.to_c(level)}," +
1624
- # "#{self.right.to_c(level)})"
1625
- # when :rr then
1626
- # return "rotate_right_value(#{self.left.to_c(level)}," +
1627
- # "#{self.right.to_c(level)})"
1628
- # when :== then
1629
- # return "equal_value(#{self.left.to_c(level)}," +
1630
- # "#{self.right.to_c(level)})"
1631
- # when :!= then
1632
- # # return "not_equal_value(#{self.left.to_c(level)}," +
1633
- # # "#{self.right.to_c(level)})"
1634
- # return "xor_value(#{self.left.to_c(level)}," +
1635
- # "#{self.right.to_c(level)})"
1636
- # when :> then
1637
- # return "greater_value(#{self.left.to_c(level)}," +
1638
- # "#{self.right.to_c(level)})"
1639
- # when :< then
1640
- # return "lesser_value(#{self.left.to_c(level)}," +
1641
- # "#{self.right.to_c(level)})"
1642
- # when :>= then
1643
- # return "greater_equal_value(#{self.left.to_c(level)}," +
1644
- # "#{self.right.to_c(level)})"
1645
- # when :<= then
1646
- # return "lesser_equal_value(#{self.left.to_c(level)}," +
1647
- # "#{self.right.to_c(level)})"
1648
- # else
1649
- # raise "Invalid binary operator: #{self.operator}."
1650
- # end
1651
- # return res
1652
- # end
1653
-
1654
- # Generates the C text of the equivalent HDLRuby::High code.
1695
+ # Generates the C text of the equivalent HDLRuby code.
1655
1696
  # +level+ is the hierachical level of the object.
1656
1697
  def to_c(level = 0)
1657
1698
  # res = " " * (level*3)
@@ -1728,17 +1769,12 @@ module HDLRuby::Low
1728
1769
  end
1729
1770
  end
1730
1771
 
1731
- ## Extends the Select class with generation of HDLRuby::High text.
1772
+ ## Extends the Select class with generation of C text.
1732
1773
  class Select
1733
1774
 
1734
- # Generates the C text of the equivalent HDLRuby::High code.
1775
+ # Generates the C text of the equivalent HDLRuby code.
1735
1776
  # +level+ is the hierachical level of the object.
1736
1777
  def to_c(level = 0)
1737
- # res = "select_value(#{self.select.to_c(level)}," +
1738
- # "#{self.each_choice.to_a.size}"
1739
- # self.each_choice { |choice| res << ",#{choice.to_c(level)}" }
1740
- # res << ")"
1741
- # return res
1742
1778
  # Gather the possible selection choices.
1743
1779
  expressions = self.each_choice.to_a
1744
1780
  # Create the resulting string.
@@ -1779,10 +1815,10 @@ module HDLRuby::Low
1779
1815
  end
1780
1816
  end
1781
1817
 
1782
- ## Extends the Concat class with generation of HDLRuby::High text.
1818
+ ## Extends the Concat class with generation of C text.
1783
1819
  class Concat
1784
1820
 
1785
- # Generates the C text of the equivalent HDLRuby::High code.
1821
+ # Generates the C text of the equivalent HDLRuby code.
1786
1822
  # +level+ is the hierachical level of the object.
1787
1823
  def to_c(level = 0)
1788
1824
  # Gather the content to concat.
@@ -1826,10 +1862,10 @@ module HDLRuby::Low
1826
1862
  end
1827
1863
 
1828
1864
 
1829
- ## Extends the Ref class with generation of HDLRuby::High text.
1865
+ ## Extends the Ref class with generation of C text.
1830
1866
  class Ref
1831
1867
 
1832
- # Generates the C text of the equivalent HDLRuby::High code.
1868
+ # Generates the C text of the equivalent HDLRuby code.
1833
1869
  # +level+ is the hierachical level of the object and
1834
1870
  # +left+ tells if it is a left value or not.
1835
1871
  def to_c(level = 0, left = false)
@@ -1838,10 +1874,11 @@ module HDLRuby::Low
1838
1874
  end
1839
1875
  end
1840
1876
 
1841
- ## Extends the RefConcat class with generation of HDLRuby::High text.
1877
+
1878
+ ## Extends the RefConcat class with generation of C text.
1842
1879
  class RefConcat
1843
1880
 
1844
- # Generates the C text of the equivalent HDLRuby::High code.
1881
+ # Generates the C text of the equivalent HDLRuby code.
1845
1882
  # +level+ is the hierachical level of the object and
1846
1883
  # +left+ tells if it is a left value or not.
1847
1884
  def to_c(level = 0, left = false)
@@ -1870,10 +1907,10 @@ module HDLRuby::Low
1870
1907
  end
1871
1908
 
1872
1909
 
1873
- ## Extends the RefIndex class with generation of HDLRuby::High text.
1910
+ ## Extends the RefIndex class with generation of C text.
1874
1911
  class RefIndex
1875
1912
 
1876
- # Generates the C text of the equivalent HDLRuby::High code.
1913
+ # Generates the C text of the equivalent HDLRuby code.
1877
1914
  # +level+ is thehierachical level of the object and
1878
1915
  # +left+ tells if it is a left value or not.
1879
1916
  def to_c(level = 0, left = false)
@@ -1914,22 +1951,13 @@ module HDLRuby::Low
1914
1951
  end
1915
1952
 
1916
1953
 
1917
- ## Extends the RefRange class with generation of HDLRuby::High text.
1954
+ ## Extends the RefRange class with generation of C text.
1918
1955
  class RefRange
1919
1956
 
1920
- # Generates the C text of the equivalent HDLRuby::High code.
1957
+ # Generates the C text of the equivalent HDLRuby code.
1921
1958
  # +level+ is the hierachical level of the object and
1922
1959
  # +left+ tells if it is a left value or not.
1923
1960
  def to_c(level = 0, left = false)
1924
- # if left then
1925
- # res = "write_range(#{self.ref.to_c(level,left)},"
1926
- # else
1927
- # res = "read_range(#{self.ref.to_c(level,left)},"
1928
- # end
1929
- # res << "read64(#{self.range.first.to_c(level)})," +
1930
- # "read64(#{self.range.last.to_c(level)})," +
1931
- # "#{self.type.base.to_c(level)})"
1932
- # return res
1933
1961
  # Decide if it is a read or a write
1934
1962
  command = left ? "write" : "read"
1935
1963
  res = "({\n"
@@ -1974,10 +2002,11 @@ module HDLRuby::Low
1974
2002
  end
1975
2003
  end
1976
2004
 
1977
- ## Extends the RefName class with generation of HDLRuby::High text.
2005
+
2006
+ ## Extends the RefName class with generation of C text.
1978
2007
  class RefName
1979
2008
 
1980
- # Generates the C text of the equivalent HDLRuby::High code.
2009
+ # Generates the C text of the equivalent HDLRuby code.
1981
2010
  # +level+ is the hierachical level of the object and
1982
2011
  # +left+ tells if it is a left value or not.
1983
2012
  def to_c(level = 0, left = false)
@@ -1994,9 +2023,10 @@ module HDLRuby::Low
1994
2023
  end
1995
2024
  end
1996
2025
 
1997
- ## Extends the RefThis class with generation of HDLRuby::High text.
2026
+
2027
+ ## Extends the RefThis class with generation of C text.
1998
2028
  class RefThis
1999
- # Generates the C text of the equivalent HDLRuby::High code.
2029
+ # Generates the C text of the equivalent HDLRuby code.
2000
2030
  # +level+ is the hierachical level of the object and
2001
2031
  # +left+ tells if it is a left value or not.
2002
2032
  def to_c(level = 0, left = false)
@@ -2010,14 +2040,5 @@ module HDLRuby::Low
2010
2040
  end
2011
2041
  end
2012
2042
 
2013
- # ## Extends the Numeric class with generation of HDLRuby::High text.
2014
- # class ::Numeric
2015
-
2016
- # # Generates the text of the equivalent HDLRuby::High code.
2017
- # # +level+ is the hierachical level of the object.
2018
- # def to_c(level = 0)
2019
- # return self.to_s
2020
- # end
2021
- # end
2022
2043
 
2023
2044
  end