HDLRuby 2.5.1 → 2.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/HDLRuby/hdr_samples/adder.rb +1 -1
- data/lib/HDLRuby/hdr_samples/adder_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/adder_gen.rb +1 -1
- data/lib/HDLRuby/hdr_samples/constant_in_function.rb +27 -0
- data/lib/HDLRuby/hdr_samples/dff_unit.rb +3 -3
- data/lib/HDLRuby/hdr_samples/huge_rom.rb +25 -0
- data/lib/HDLRuby/hdr_samples/logic_bench.rb +21 -0
- data/lib/HDLRuby/hdr_samples/mei8_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/music.rb +79 -0
- data/lib/HDLRuby/hdr_samples/named_sub.rb +42 -0
- data/lib/HDLRuby/hdr_samples/rom.rb +16 -0
- data/lib/HDLRuby/hdr_samples/with_function_generator.rb +25 -0
- data/lib/HDLRuby/hdrcc.rb +41 -7
- data/lib/HDLRuby/hruby_decorator.rb +3 -1
- data/lib/HDLRuby/hruby_high.rb +214 -26
- data/lib/HDLRuby/hruby_low.rb +402 -45
- data/lib/HDLRuby/hruby_low2c.rb +122 -168
- data/lib/HDLRuby/hruby_low2hdr.rb +738 -0
- data/lib/HDLRuby/hruby_low2high.rb +331 -549
- data/lib/HDLRuby/hruby_low2vhd.rb +39 -2
- data/lib/HDLRuby/hruby_low_bool2select.rb +29 -0
- data/lib/HDLRuby/hruby_low_casts_without_expression.rb +27 -0
- data/lib/HDLRuby/hruby_low_fix_types.rb +25 -0
- data/lib/HDLRuby/hruby_low_mutable.rb +70 -0
- data/lib/HDLRuby/hruby_low_resolve.rb +28 -0
- data/lib/HDLRuby/hruby_low_without_connection.rb +6 -3
- data/lib/HDLRuby/hruby_low_without_namespace.rb +7 -4
- data/lib/HDLRuby/hruby_low_without_select.rb +13 -0
- data/lib/HDLRuby/hruby_tools.rb +11 -1
- data/lib/HDLRuby/hruby_verilog.rb +1572 -1723
- data/lib/HDLRuby/sim/hruby_sim.h +25 -2
- data/lib/HDLRuby/sim/hruby_sim_calc.c +63 -6
- data/lib/HDLRuby/sim/hruby_sim_vcd.c +5 -1
- data/lib/HDLRuby/sim/hruby_sim_vizualize.c +22 -6
- data/lib/HDLRuby/std/fixpoint.rb +9 -0
- data/lib/HDLRuby/std/function_generator.rb +139 -0
- data/lib/HDLRuby/std/hruby_unit.rb +75 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +14 -6
- data/lib/HDLRuby/hruby_unit.rb +0 -43
data/lib/HDLRuby/hruby_low2c.rb
CHANGED
@@ -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
|
149
|
+
## Extends the SystemT class with generation of C text.
|
143
150
|
class SystemT
|
144
151
|
|
145
|
-
# Generates the text of the equivalent HDLRuby
|
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)
|
@@ -345,10 +352,10 @@ module HDLRuby::Low
|
|
345
352
|
end
|
346
353
|
|
347
354
|
|
348
|
-
## Extends the Scope class with generation of
|
355
|
+
## Extends the Scope class with generation of C text.
|
349
356
|
class Scope
|
350
357
|
|
351
|
-
# Generates the text of the equivalent HDLRuby
|
358
|
+
# Generates the C text of the equivalent HDLRuby code.
|
352
359
|
# +level+ is the hierachical level of the object.
|
353
360
|
def to_c(level = 0)
|
354
361
|
# The resulting string.
|
@@ -498,10 +505,10 @@ module HDLRuby::Low
|
|
498
505
|
end
|
499
506
|
|
500
507
|
|
501
|
-
## Extends the Type class with generation of
|
508
|
+
## Extends the Type class with generation of C text.
|
502
509
|
class Type
|
503
510
|
|
504
|
-
# Generates the C text of the equivalent HDLRuby
|
511
|
+
# Generates the C text of the equivalent HDLRuby code.
|
505
512
|
# +level+ is the hierachical level of the object.
|
506
513
|
def to_c(level = 0)
|
507
514
|
# return Low2C.c_name(self.name)
|
@@ -516,10 +523,10 @@ module HDLRuby::Low
|
|
516
523
|
end
|
517
524
|
end
|
518
525
|
|
519
|
-
## Extends the TypeDef class with generation of
|
526
|
+
## Extends the TypeDef class with generation of C text.
|
520
527
|
class TypeDef
|
521
528
|
|
522
|
-
# Generates the C text of the equivalent HDLRuby
|
529
|
+
# Generates the C text of the equivalent HDLRuby code.
|
523
530
|
# +level+ is the hierachical level of the object.
|
524
531
|
def to_c(level = 0)
|
525
532
|
# # Simply use the name of the type.
|
@@ -529,10 +536,10 @@ module HDLRuby::Low
|
|
529
536
|
end
|
530
537
|
end
|
531
538
|
|
532
|
-
## Extends the TypeVector class with generation of
|
539
|
+
## Extends the TypeVector class with generation of C text.
|
533
540
|
class TypeVector
|
534
541
|
|
535
|
-
# Generates the C text of the equivalent HDLRuby
|
542
|
+
# Generates the C text of the equivalent HDLRuby code.
|
536
543
|
# +level+ is the hierachical level of the object.
|
537
544
|
def to_c(level = 0)
|
538
545
|
# The resulting string.
|
@@ -541,10 +548,10 @@ module HDLRuby::Low
|
|
541
548
|
end
|
542
549
|
end
|
543
550
|
|
544
|
-
## Extends the TypeTuple class with generation of
|
551
|
+
## Extends the TypeTuple class with generation of C text.
|
545
552
|
class TypeTuple
|
546
553
|
|
547
|
-
# Generates the text of the equivalent HDLRuby
|
554
|
+
# Generates the C text of the equivalent HDLRuby code.
|
548
555
|
# +level+ is the hierachical level of the object.
|
549
556
|
#
|
550
557
|
# NOTE: type tuples are converted to bit vector of their contents.
|
@@ -557,10 +564,10 @@ module HDLRuby::Low
|
|
557
564
|
end
|
558
565
|
|
559
566
|
|
560
|
-
## Extends the TypeStruct class with generation of
|
567
|
+
## Extends the TypeStruct class with generation of C text.
|
561
568
|
class TypeStruct
|
562
569
|
|
563
|
-
# Generates the text of the equivalent HDLRuby
|
570
|
+
# Generates the text of the equivalent HDLRuby code.
|
564
571
|
# +level+ is the hierachical level of the object.
|
565
572
|
def to_c(level = 0)
|
566
573
|
return "get_type_struct(#{self.each.join(",") do |key,type|
|
@@ -570,10 +577,10 @@ module HDLRuby::Low
|
|
570
577
|
end
|
571
578
|
|
572
579
|
|
573
|
-
## Extends the Behavior class with generation of
|
580
|
+
## Extends the Behavior class with generation of C text.
|
574
581
|
class Behavior
|
575
582
|
|
576
|
-
# Generates the text of the equivalent HDLRuby
|
583
|
+
# Generates the text of the equivalent HDLRuby code.
|
577
584
|
# +level+ is the hierachical level of the object and
|
578
585
|
# +time+ is a flag telling if the behavior is timed or not.
|
579
586
|
def to_c(level = 0, time = false)
|
@@ -706,10 +713,10 @@ module HDLRuby::Low
|
|
706
713
|
end
|
707
714
|
end
|
708
715
|
|
709
|
-
## Extends the TimeBehavior class with generation of
|
716
|
+
## Extends the TimeBehavior class with generation of C text.
|
710
717
|
class TimeBehavior
|
711
718
|
|
712
|
-
# Generates the C text of the equivalent HDLRuby
|
719
|
+
# Generates the C text of the equivalent HDLRuby code.
|
713
720
|
# +level+ is the hierachical level of the object.
|
714
721
|
def to_c(level = 0)
|
715
722
|
super(level,true)
|
@@ -717,10 +724,10 @@ module HDLRuby::Low
|
|
717
724
|
end
|
718
725
|
|
719
726
|
|
720
|
-
## Extends the Event class with generation of
|
727
|
+
## Extends the Event class with generation of C text.
|
721
728
|
class Event
|
722
729
|
|
723
|
-
# Generates the C text of the equivalent HDLRuby
|
730
|
+
# Generates the C text of the equivalent HDLRuby code.
|
724
731
|
# +level+ is the hierachical level of the object.
|
725
732
|
def to_c(level = 0)
|
726
733
|
edge = "ANYEDGE"
|
@@ -732,7 +739,7 @@ module HDLRuby::Low
|
|
732
739
|
end
|
733
740
|
|
734
741
|
|
735
|
-
## Extends the SignalI class with generation of
|
742
|
+
## Extends the SignalI class with generation of C text.
|
736
743
|
class SignalI
|
737
744
|
|
738
745
|
## Generates the C text for an access to the signal.
|
@@ -748,7 +755,7 @@ module HDLRuby::Low
|
|
748
755
|
return res
|
749
756
|
end
|
750
757
|
|
751
|
-
## Generates the C text of the equivalent HDLRuby
|
758
|
+
## Generates the C text of the equivalent HDLRuby code.
|
752
759
|
# +level+ is the hierachical level of the object.
|
753
760
|
def to_c(level = 0)
|
754
761
|
# The resulting string.
|
@@ -850,10 +857,10 @@ module HDLRuby::Low
|
|
850
857
|
end
|
851
858
|
|
852
859
|
|
853
|
-
## Extends the SystemI class with generation of
|
860
|
+
## Extends the SystemI class with generation of C text.
|
854
861
|
class SystemI
|
855
862
|
|
856
|
-
## Generates the C text of the equivalent HDLRuby
|
863
|
+
## Generates the C text of the equivalent HDLRuby code.
|
857
864
|
# +level+ is the hierachical level of the object.
|
858
865
|
def to_c(level = 0)
|
859
866
|
# The resulting string.
|
@@ -919,7 +926,7 @@ module HDLRuby::Low
|
|
919
926
|
# Extend the Chunk cass with generation of text code.
|
920
927
|
class HDLRuby::Low::Chunk
|
921
928
|
|
922
|
-
# Generates the text of the equivalent HDLRuby
|
929
|
+
# Generates the C text of the equivalent HDLRuby code.
|
923
930
|
# +level+ is the hierachical level of the object.
|
924
931
|
def to_c(level = 0)
|
925
932
|
res = " " * level
|
@@ -935,9 +942,9 @@ module HDLRuby::Low
|
|
935
942
|
end
|
936
943
|
|
937
944
|
|
938
|
-
## Extends the SystemI class with generation of
|
945
|
+
## Extends the SystemI class with generation of C text.
|
939
946
|
class Code
|
940
|
-
# Generates the text of the equivalent HDLRuby
|
947
|
+
# Generates the C text of the equivalent HDLRuby code.
|
941
948
|
# +level+ is the hierachical level of the object.
|
942
949
|
def to_c(level = 0)
|
943
950
|
# puts "For behavior: #{self}"
|
@@ -1042,10 +1049,10 @@ module HDLRuby::Low
|
|
1042
1049
|
end
|
1043
1050
|
|
1044
1051
|
|
1045
|
-
## Extends the Statement class with generation of
|
1052
|
+
## Extends the Statement class with generation of C text.
|
1046
1053
|
class Statement
|
1047
1054
|
|
1048
|
-
# Generates the C text of the equivalent HDLRuby
|
1055
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1049
1056
|
# +level+ is the hierachical level of the object.
|
1050
1057
|
def to_c(level = 0)
|
1051
1058
|
# Should never be here.
|
@@ -1081,10 +1088,10 @@ module HDLRuby::Low
|
|
1081
1088
|
end
|
1082
1089
|
end
|
1083
1090
|
|
1084
|
-
## Extends the Transmit class with generation of
|
1091
|
+
## Extends the Transmit class with generation of C text.
|
1085
1092
|
class Transmit
|
1086
1093
|
|
1087
|
-
# Generates the C text of the equivalent HDLRuby
|
1094
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1088
1095
|
# +level+ is the hierachical level of the object.
|
1089
1096
|
def to_c(level = 0)
|
1090
1097
|
# Save the state of the value pool.
|
@@ -1116,11 +1123,48 @@ module HDLRuby::Low
|
|
1116
1123
|
end
|
1117
1124
|
end
|
1118
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
|
+
|
1119
1163
|
|
1120
|
-
## Extends the If class with generation of
|
1164
|
+
## Extends the If class with generation of C text.
|
1121
1165
|
class If
|
1122
1166
|
|
1123
|
-
# Generates the C text of the equivalent HDLRuby
|
1167
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1124
1168
|
# +level+ is the hierachical level of the object.
|
1125
1169
|
def to_c(level = 0)
|
1126
1170
|
# The result string.
|
@@ -1176,10 +1220,10 @@ module HDLRuby::Low
|
|
1176
1220
|
end
|
1177
1221
|
end
|
1178
1222
|
|
1179
|
-
## Extends the When class with generation of
|
1223
|
+
## Extends the When class with generation of C text.
|
1180
1224
|
class When
|
1181
1225
|
|
1182
|
-
# Generates the C text of the equivalent HDLRuby
|
1226
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1183
1227
|
# +level+ is the hierachical level of the object.
|
1184
1228
|
def to_c(level = 0)
|
1185
1229
|
# The result string.
|
@@ -1211,10 +1255,10 @@ module HDLRuby::Low
|
|
1211
1255
|
end
|
1212
1256
|
end
|
1213
1257
|
|
1214
|
-
## Extends the Case class with generation of
|
1258
|
+
## Extends the Case class with generation of C text.
|
1215
1259
|
class Case
|
1216
1260
|
|
1217
|
-
# Generates the text of the equivalent HDLRuby
|
1261
|
+
# Generates the text of the equivalent HDLRuby code.
|
1218
1262
|
# +level+ is the hierachical level of the object.
|
1219
1263
|
def to_c(level = 0)
|
1220
1264
|
res = ""
|
@@ -1269,10 +1313,10 @@ module HDLRuby::Low
|
|
1269
1313
|
end
|
1270
1314
|
|
1271
1315
|
|
1272
|
-
## Extends the Delay class with generation of
|
1316
|
+
## Extends the Delay class with generation of C text.
|
1273
1317
|
class Delay
|
1274
1318
|
|
1275
|
-
# Generates the C text of the equivalent HDLRuby
|
1319
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1276
1320
|
# +level+ is the hierachical level of the object.
|
1277
1321
|
def to_c(level = 0)
|
1278
1322
|
return "make_delay(#{self.value.to_s}," +
|
@@ -1281,10 +1325,10 @@ module HDLRuby::Low
|
|
1281
1325
|
end
|
1282
1326
|
|
1283
1327
|
|
1284
|
-
## Extends the TimeWait class with generation of
|
1328
|
+
## Extends the TimeWait class with generation of C text.
|
1285
1329
|
class TimeWait
|
1286
1330
|
|
1287
|
-
# Generates the C text of the equivalent HDLRuby
|
1331
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1288
1332
|
# +level+ is the hierachical level of the object.
|
1289
1333
|
def to_c(level = 0)
|
1290
1334
|
# The resulting string.
|
@@ -1297,10 +1341,10 @@ module HDLRuby::Low
|
|
1297
1341
|
end
|
1298
1342
|
end
|
1299
1343
|
|
1300
|
-
## Extends the TimeRepeat class with generation of
|
1344
|
+
## Extends the TimeRepeat class with generation of C text.
|
1301
1345
|
class TimeRepeat
|
1302
1346
|
|
1303
|
-
# Generates the C text of the equivalent HDLRuby
|
1347
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1304
1348
|
# +level+ is the hierachical level of the object.
|
1305
1349
|
def to_c(level = 0)
|
1306
1350
|
# The resulting string.
|
@@ -1315,7 +1359,7 @@ module HDLRuby::Low
|
|
1315
1359
|
end
|
1316
1360
|
end
|
1317
1361
|
|
1318
|
-
## Extends the Block class with generation of
|
1362
|
+
## Extends the Block class with generation of C text.
|
1319
1363
|
class Block
|
1320
1364
|
|
1321
1365
|
# Adds the c code of the blocks to +res+ at +level+
|
@@ -1329,7 +1373,7 @@ module HDLRuby::Low
|
|
1329
1373
|
res << "#{Low2C.make_name(self)}();\n"
|
1330
1374
|
end
|
1331
1375
|
|
1332
|
-
# Generates the C text of the equivalent HDLRuby
|
1376
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1333
1377
|
# +level+ is the hierachical level of the object.
|
1334
1378
|
def to_c_code(level = 0)
|
1335
1379
|
# The resulting string.
|
@@ -1425,7 +1469,7 @@ module HDLRuby::Low
|
|
1425
1469
|
end
|
1426
1470
|
|
1427
1471
|
# Generates the execution of the block C text of the equivalent
|
1428
|
-
# HDLRuby
|
1472
|
+
# HDLRuby code.
|
1429
1473
|
# +level+ is the hierachical level of the object.
|
1430
1474
|
def to_c(level = 0)
|
1431
1475
|
res = " " * (level)
|
@@ -1455,22 +1499,22 @@ module HDLRuby::Low
|
|
1455
1499
|
end
|
1456
1500
|
|
1457
1501
|
|
1458
|
-
## Extends the Block class with generation of
|
1502
|
+
## Extends the Block class with generation of C text.
|
1459
1503
|
class TimeBlock
|
1460
1504
|
# TimeBlock is identical to Block in C
|
1461
1505
|
end
|
1462
1506
|
|
1463
1507
|
|
1464
|
-
## Extends the Connection class with generation of
|
1508
|
+
## Extends the Connection class with generation of C text.
|
1465
1509
|
class Connection
|
1466
1510
|
# Nothing required, Transmit is generated identically.
|
1467
1511
|
end
|
1468
1512
|
|
1469
1513
|
|
1470
|
-
## Extends the Expression class with generation of
|
1514
|
+
## Extends the Expression class with generation of C text.
|
1471
1515
|
class Expression
|
1472
1516
|
|
1473
|
-
# Generates the C text of the equivalent HDLRuby
|
1517
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1474
1518
|
# +level+ is the hierachical level of the object.
|
1475
1519
|
def to_c(level = 0)
|
1476
1520
|
# Should never be here.
|
@@ -1479,7 +1523,7 @@ module HDLRuby::Low
|
|
1479
1523
|
end
|
1480
1524
|
|
1481
1525
|
|
1482
|
-
## Extends the Value class with generation of
|
1526
|
+
## Extends the Value class with generation of C text.
|
1483
1527
|
class Value
|
1484
1528
|
|
1485
1529
|
## Generates the C text for an access to the value.
|
@@ -1558,10 +1602,10 @@ module HDLRuby::Low
|
|
1558
1602
|
end
|
1559
1603
|
end
|
1560
1604
|
|
1561
|
-
## Extends the Cast class with generation of
|
1605
|
+
## Extends the Cast class with generation of C text.
|
1562
1606
|
class Cast
|
1563
1607
|
|
1564
|
-
# Generates the C text of the equivalent HDLRuby
|
1608
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1565
1609
|
# +level+ is the hierachical level of the object.
|
1566
1610
|
def to_c(level = 0)
|
1567
1611
|
res = "({\n"
|
@@ -1589,10 +1633,10 @@ module HDLRuby::Low
|
|
1589
1633
|
end
|
1590
1634
|
|
1591
1635
|
|
1592
|
-
## Extends the Operation class with generation of
|
1636
|
+
## Extends the Operation class with generation of C text.
|
1593
1637
|
class Operation
|
1594
1638
|
|
1595
|
-
# Generates the C text of the equivalent HDLRuby
|
1639
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1596
1640
|
# +level+ is the hierachical level of the object.
|
1597
1641
|
def to_c(level = 0)
|
1598
1642
|
# Should never be here.
|
@@ -1600,10 +1644,10 @@ module HDLRuby::Low
|
|
1600
1644
|
end
|
1601
1645
|
end
|
1602
1646
|
|
1603
|
-
## Extends the Unary class with generation of
|
1647
|
+
## Extends the Unary class with generation of C text.
|
1604
1648
|
class Unary
|
1605
1649
|
|
1606
|
-
# Generates the C text of the equivalent HDLRuby
|
1650
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1607
1651
|
# +level+ is the hierachical level of the object.
|
1608
1652
|
def to_c(level = 0)
|
1609
1653
|
res = "({\n"
|
@@ -1645,80 +1689,10 @@ module HDLRuby::Low
|
|
1645
1689
|
end
|
1646
1690
|
|
1647
1691
|
|
1648
|
-
## Extends the Binary class with generation of
|
1692
|
+
## Extends the Binary class with generation of C text.
|
1649
1693
|
class Binary
|
1650
1694
|
|
1651
|
-
#
|
1652
|
-
# # +level+ is the hierachical level of the object.
|
1653
|
-
# def to_c(level = 0)
|
1654
|
-
# res = ""
|
1655
|
-
# case self.operator
|
1656
|
-
# when :+ then
|
1657
|
-
# return "add_value(#{self.left.to_c(level)}," +
|
1658
|
-
# "#{self.right.to_c(level)})"
|
1659
|
-
# when :- then
|
1660
|
-
# return "sub_value(#{self.left.to_c(level)}," +
|
1661
|
-
# "#{self.right.to_c(level)})"
|
1662
|
-
# when :* then
|
1663
|
-
# return "mul_value(#{self.left.to_c(level)}," +
|
1664
|
-
# "#{self.right.to_c(level)})"
|
1665
|
-
# when :/ then
|
1666
|
-
# return "div_value(#{self.left.to_c(level)}," +
|
1667
|
-
# "#{self.right.to_c(level)})"
|
1668
|
-
# when :% then
|
1669
|
-
# return "mod_value(#{self.left.to_c(level)}," +
|
1670
|
-
# "#{self.right.to_c(level)})"
|
1671
|
-
# when :** then
|
1672
|
-
# return "pow_value(#{self.left.to_c(level)}," +
|
1673
|
-
# "#{self.right.to_c(level)})"
|
1674
|
-
# when :& then
|
1675
|
-
# return "and_value(#{self.left.to_c(level)}," +
|
1676
|
-
# "#{self.right.to_c(level)})"
|
1677
|
-
# when :| then
|
1678
|
-
# return "or_value(#{self.left.to_c(level)}," +
|
1679
|
-
# "#{self.right.to_c(level)})"
|
1680
|
-
# when :^ then
|
1681
|
-
# return "xor_value(#{self.left.to_c(level)}," +
|
1682
|
-
# "#{self.right.to_c(level)})"
|
1683
|
-
# when :<<,:ls then
|
1684
|
-
# return "shift_left_value(#{self.left.to_c(level)}," +
|
1685
|
-
# "#{self.right.to_c(level)})"
|
1686
|
-
# when :>>,:rs then
|
1687
|
-
# return "shift_right_value(#{self.left.to_c(level)}," +
|
1688
|
-
# "#{self.right.to_c(level)})"
|
1689
|
-
# when :lr then
|
1690
|
-
# return "rotate_left_value(#{self.left.to_c(level)}," +
|
1691
|
-
# "#{self.right.to_c(level)})"
|
1692
|
-
# when :rr then
|
1693
|
-
# return "rotate_right_value(#{self.left.to_c(level)}," +
|
1694
|
-
# "#{self.right.to_c(level)})"
|
1695
|
-
# when :== then
|
1696
|
-
# return "equal_value(#{self.left.to_c(level)}," +
|
1697
|
-
# "#{self.right.to_c(level)})"
|
1698
|
-
# when :!= then
|
1699
|
-
# # return "not_equal_value(#{self.left.to_c(level)}," +
|
1700
|
-
# # "#{self.right.to_c(level)})"
|
1701
|
-
# return "xor_value(#{self.left.to_c(level)}," +
|
1702
|
-
# "#{self.right.to_c(level)})"
|
1703
|
-
# when :> then
|
1704
|
-
# return "greater_value(#{self.left.to_c(level)}," +
|
1705
|
-
# "#{self.right.to_c(level)})"
|
1706
|
-
# when :< then
|
1707
|
-
# return "lesser_value(#{self.left.to_c(level)}," +
|
1708
|
-
# "#{self.right.to_c(level)})"
|
1709
|
-
# when :>= then
|
1710
|
-
# return "greater_equal_value(#{self.left.to_c(level)}," +
|
1711
|
-
# "#{self.right.to_c(level)})"
|
1712
|
-
# when :<= then
|
1713
|
-
# return "lesser_equal_value(#{self.left.to_c(level)}," +
|
1714
|
-
# "#{self.right.to_c(level)})"
|
1715
|
-
# else
|
1716
|
-
# raise "Invalid binary operator: #{self.operator}."
|
1717
|
-
# end
|
1718
|
-
# return res
|
1719
|
-
# end
|
1720
|
-
|
1721
|
-
# Generates the C text of the equivalent HDLRuby::High code.
|
1695
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1722
1696
|
# +level+ is the hierachical level of the object.
|
1723
1697
|
def to_c(level = 0)
|
1724
1698
|
# res = " " * (level*3)
|
@@ -1795,17 +1769,12 @@ module HDLRuby::Low
|
|
1795
1769
|
end
|
1796
1770
|
end
|
1797
1771
|
|
1798
|
-
## Extends the Select class with generation of
|
1772
|
+
## Extends the Select class with generation of C text.
|
1799
1773
|
class Select
|
1800
1774
|
|
1801
|
-
# Generates the C text of the equivalent HDLRuby
|
1775
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1802
1776
|
# +level+ is the hierachical level of the object.
|
1803
1777
|
def to_c(level = 0)
|
1804
|
-
# res = "select_value(#{self.select.to_c(level)}," +
|
1805
|
-
# "#{self.each_choice.to_a.size}"
|
1806
|
-
# self.each_choice { |choice| res << ",#{choice.to_c(level)}" }
|
1807
|
-
# res << ")"
|
1808
|
-
# return res
|
1809
1778
|
# Gather the possible selection choices.
|
1810
1779
|
expressions = self.each_choice.to_a
|
1811
1780
|
# Create the resulting string.
|
@@ -1846,10 +1815,10 @@ module HDLRuby::Low
|
|
1846
1815
|
end
|
1847
1816
|
end
|
1848
1817
|
|
1849
|
-
## Extends the Concat class with generation of
|
1818
|
+
## Extends the Concat class with generation of C text.
|
1850
1819
|
class Concat
|
1851
1820
|
|
1852
|
-
# Generates the C text of the equivalent HDLRuby
|
1821
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1853
1822
|
# +level+ is the hierachical level of the object.
|
1854
1823
|
def to_c(level = 0)
|
1855
1824
|
# Gather the content to concat.
|
@@ -1893,10 +1862,10 @@ module HDLRuby::Low
|
|
1893
1862
|
end
|
1894
1863
|
|
1895
1864
|
|
1896
|
-
## Extends the Ref class with generation of
|
1865
|
+
## Extends the Ref class with generation of C text.
|
1897
1866
|
class Ref
|
1898
1867
|
|
1899
|
-
# Generates the C text of the equivalent HDLRuby
|
1868
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1900
1869
|
# +level+ is the hierachical level of the object and
|
1901
1870
|
# +left+ tells if it is a left value or not.
|
1902
1871
|
def to_c(level = 0, left = false)
|
@@ -1905,10 +1874,11 @@ module HDLRuby::Low
|
|
1905
1874
|
end
|
1906
1875
|
end
|
1907
1876
|
|
1908
|
-
|
1877
|
+
|
1878
|
+
## Extends the RefConcat class with generation of C text.
|
1909
1879
|
class RefConcat
|
1910
1880
|
|
1911
|
-
# Generates the C text of the equivalent HDLRuby
|
1881
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1912
1882
|
# +level+ is the hierachical level of the object and
|
1913
1883
|
# +left+ tells if it is a left value or not.
|
1914
1884
|
def to_c(level = 0, left = false)
|
@@ -1937,10 +1907,10 @@ module HDLRuby::Low
|
|
1937
1907
|
end
|
1938
1908
|
|
1939
1909
|
|
1940
|
-
## Extends the RefIndex class with generation of
|
1910
|
+
## Extends the RefIndex class with generation of C text.
|
1941
1911
|
class RefIndex
|
1942
1912
|
|
1943
|
-
# Generates the C text of the equivalent HDLRuby
|
1913
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1944
1914
|
# +level+ is thehierachical level of the object and
|
1945
1915
|
# +left+ tells if it is a left value or not.
|
1946
1916
|
def to_c(level = 0, left = false)
|
@@ -1981,22 +1951,13 @@ module HDLRuby::Low
|
|
1981
1951
|
end
|
1982
1952
|
|
1983
1953
|
|
1984
|
-
## Extends the RefRange class with generation of
|
1954
|
+
## Extends the RefRange class with generation of C text.
|
1985
1955
|
class RefRange
|
1986
1956
|
|
1987
|
-
# Generates the C text of the equivalent HDLRuby
|
1957
|
+
# Generates the C text of the equivalent HDLRuby code.
|
1988
1958
|
# +level+ is the hierachical level of the object and
|
1989
1959
|
# +left+ tells if it is a left value or not.
|
1990
1960
|
def to_c(level = 0, left = false)
|
1991
|
-
# if left then
|
1992
|
-
# res = "write_range(#{self.ref.to_c(level,left)},"
|
1993
|
-
# else
|
1994
|
-
# res = "read_range(#{self.ref.to_c(level,left)},"
|
1995
|
-
# end
|
1996
|
-
# res << "read64(#{self.range.first.to_c(level)})," +
|
1997
|
-
# "read64(#{self.range.last.to_c(level)})," +
|
1998
|
-
# "#{self.type.base.to_c(level)})"
|
1999
|
-
# return res
|
2000
1961
|
# Decide if it is a read or a write
|
2001
1962
|
command = left ? "write" : "read"
|
2002
1963
|
res = "({\n"
|
@@ -2041,10 +2002,11 @@ module HDLRuby::Low
|
|
2041
2002
|
end
|
2042
2003
|
end
|
2043
2004
|
|
2044
|
-
|
2005
|
+
|
2006
|
+
## Extends the RefName class with generation of C text.
|
2045
2007
|
class RefName
|
2046
2008
|
|
2047
|
-
# Generates the C text of the equivalent HDLRuby
|
2009
|
+
# Generates the C text of the equivalent HDLRuby code.
|
2048
2010
|
# +level+ is the hierachical level of the object and
|
2049
2011
|
# +left+ tells if it is a left value or not.
|
2050
2012
|
def to_c(level = 0, left = false)
|
@@ -2061,9 +2023,10 @@ module HDLRuby::Low
|
|
2061
2023
|
end
|
2062
2024
|
end
|
2063
2025
|
|
2064
|
-
|
2026
|
+
|
2027
|
+
## Extends the RefThis class with generation of C text.
|
2065
2028
|
class RefThis
|
2066
|
-
# Generates the C text of the equivalent HDLRuby
|
2029
|
+
# Generates the C text of the equivalent HDLRuby code.
|
2067
2030
|
# +level+ is the hierachical level of the object and
|
2068
2031
|
# +left+ tells if it is a left value or not.
|
2069
2032
|
def to_c(level = 0, left = false)
|
@@ -2077,14 +2040,5 @@ module HDLRuby::Low
|
|
2077
2040
|
end
|
2078
2041
|
end
|
2079
2042
|
|
2080
|
-
# ## Extends the Numeric class with generation of HDLRuby::High text.
|
2081
|
-
# class ::Numeric
|
2082
|
-
|
2083
|
-
# # Generates the text of the equivalent HDLRuby::High code.
|
2084
|
-
# # +level+ is the hierachical level of the object.
|
2085
|
-
# def to_c(level = 0)
|
2086
|
-
# return self.to_s
|
2087
|
-
# end
|
2088
|
-
# end
|
2089
2043
|
|
2090
2044
|
end
|