HDLRuby 2.3.8 → 2.4.10

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.
@@ -7,26 +7,51 @@
7
7
  * generated by hruby_low2c.
8
8
  **/
9
9
 
10
+ /* The print function pointers. */
11
+
12
+ PrinterS printer;
13
+
14
+
15
+ /** Initializes the visualization printer engine.
16
+ * @param print_time the time printer
17
+ * @param print_name the name printer
18
+ * @param print_value the value printer
19
+ * @param print_signal the signal state printer. */
20
+ void init_visualizer(void (*print_time)(unsigned long long),
21
+ void (*print_name)(Object),
22
+ void (*print_value)(Value),
23
+ void (*print_signal)(SignalI)) {
24
+ printer.print_time = print_time;
25
+ printer.print_name = print_name;
26
+ printer.print_value = print_value;
27
+ printer.print_signal = print_signal;
28
+ }
29
+
30
+
31
+
32
+
33
+ /* The default printing functions. */
34
+
10
35
  /** Prints the time.
11
36
  * @param time the time to show. */
12
- void print_time(unsigned long long time) {
37
+ static void default_print_time(unsigned long long time) {
13
38
  printf("# %llups",time);
14
39
  }
15
40
 
16
41
  /** Prints the time and goes to the next line.
17
- * @param time the time to show. */
18
- void println_time(unsigned long long time) {
19
- print_time(time);
42
+ * @par1am time the time to show. */
43
+ static void default_println_time(unsigned long long time) {
44
+ default_print_time(time);
20
45
  printf("\n");
21
46
  }
22
47
 
23
48
  /** Prints the name of an object.
24
49
  * @param object the object to print the name. */
25
- void print_name(Object object) {
50
+ static void default_print_name(Object object) {
26
51
  /* Recurse on the owner if any. */
27
52
  // printf("owner=%p\n",object->owner);
28
53
  if (object->owner != NULL) {
29
- print_name(object->owner);
54
+ default_print_name(object->owner);
30
55
  printf("::");
31
56
  }
32
57
  /* Depending on the kind of object. */
@@ -48,7 +73,7 @@ void print_name(Object object) {
48
73
 
49
74
  /** Prints a value.
50
75
  * @param value the value to print */
51
- void print_value(Value value) {
76
+ static void default_print_value(Value value) {
52
77
  if (value->numeric) {
53
78
  unsigned long long width = type_width(value->type);
54
79
  unsigned long long mask = 1ULL << (width-1);
@@ -77,15 +102,29 @@ void print_value(Value value) {
77
102
 
78
103
  /** Prints a signal.
79
104
  * @param signal the signal to show */
80
- void print_signal(SignalI signal) {
81
- print_name((Object)signal);
105
+ static void default_print_signal(SignalI signal) {
106
+ default_print_name((Object)signal);
82
107
  printf(": ");
83
- print_value(signal->f_value);
108
+ default_print_value(signal->f_value);
84
109
  }
85
110
 
86
111
  /** Prints a signal and goes to the next line.
87
112
  * @param signal the signal to show */
88
- void println_signal(SignalI signal) {
89
- print_signal(signal);
113
+ static void default_println_signal(SignalI signal) {
114
+ default_print_signal(signal);
90
115
  printf("\n");
91
116
  }
117
+
118
+
119
+
120
+ /* Set up the visualizer. */
121
+
122
+ /** Set up the default vizualization engine.
123
+ * @param name the name of the vizualization. */
124
+ void init_default_visualizer(char* name) {
125
+ /* Initialize the vizualizer printer engine. */
126
+ init_visualizer(&default_println_time,
127
+ &default_print_name,
128
+ &default_print_value,
129
+ &default_println_signal);
130
+ }
@@ -52,10 +52,18 @@ module HDLRuby::High::Std
52
52
  end
53
53
  # Redefine the multiplication and division for fixed point.
54
54
  typ.define_operator(:*) do |left,right|
55
- (left.as([isize+fsize*2])*right) >> fsize
55
+ if (typ.signed?) then
56
+ (left.as(signed[isize+fsize*2])*right) >> fsize
57
+ else
58
+ (left.as([isize+fsize*2])*right) >> fsize
59
+ end
56
60
  end
57
61
  typ.define_operator(:/) do |left,right|
58
- (left.as([isize+fsize*2]) << fsize) / right
62
+ if (typ.signed?) then
63
+ (left.as(signed[isize+fsize*2]) << fsize) / right
64
+ else
65
+ (left.as([isize+fsize*2]) << fsize) / right
66
+ end
59
67
  end
60
68
  typ
61
69
  end
@@ -209,6 +209,7 @@ module HDLRuby::High::Std
209
209
  # lv and rv are valid.
210
210
  lvoks = lefts.each_with_index.map { |left,i| inner :"lvok#{i}" }
211
211
  inner :rvok
212
+ woks = lefts.each_with_index.map { |left,i| inner :"wok#{i}" }
212
213
  # Run flag
213
214
  inner :run
214
215
  par(ev) do
@@ -218,28 +219,39 @@ module HDLRuby::High::Std
218
219
  rvok <= 0
219
220
  lefts.each_with_index do |left,i|
220
221
  lvoks[i] <= 0
221
- # accs[i].write(0)
222
- avs[i] <= 0
222
+ # avs[i] <= 0
223
+ woks[i] <= 0
223
224
  end
224
225
  end
225
226
  hif(req | run) do
226
227
  run <= 1
227
228
  # Computation request.
228
- right.read(rv) { rvok <= 1 }
229
+ hif(~rvok) { right.read(rv) { rvok <= 1 } }
229
230
  lefts.each_with_index do |left,i|
230
- left.read(lvs[i]) { lvoks[i] <= 1 }
231
+ hif(~lvoks[i]) { left.read(lvs[i]) { lvoks[i] <= 1 } }
231
232
  # accs[i].read(avs[i])
232
- hif(lvoks[i] & rvok) do
233
+ hif(lvoks[i] & rvok & ~woks[i]) do
233
234
  ack <= 1
234
235
  run <= 0
235
- # accs[i].write(add.(avs[i],mul.(lvs[i],rv)))
236
236
  seq do
237
237
  avs[i] <= add.(avs[i],mul.(lvs[i],rv))
238
- accs[i].write(avs[i])
238
+ accs[i].write(avs[i]) do
239
+ woks[i] <= 1
240
+ # seq do
241
+ # lvoks[i] <= 0
242
+ # rvok <= lvoks.reduce(:|)
243
+ # end
244
+ end
239
245
  end
240
246
  end
247
+ hif (woks.reduce(:&)) do
248
+ woks.each { |wok| wok <= 0 }
249
+ lvoks.each { | lvok| lvok <=0 }
250
+ rvok <= 0
251
+ end
241
252
  end
242
253
  end
254
+ helse { avs.each {|av| av <= 0 } }
243
255
  # helse do
244
256
  # rvok <= 0
245
257
  # lefts.each_with_index do |left,i|
@@ -34,6 +34,7 @@ HDLRuby::High::Std.channel(:mem_sync) do |n,typ,size,clk_e,rst,br_rsts = []|
34
34
  size = size.to_i
35
35
  # Compute the address bus width from the size.
36
36
  awidth = (size-1).width
37
+ awidth = 1 if awidth == 0
37
38
  # Ensure clk_e is an event, if not set it to a positive edge.
38
39
  clk_e = clk_e.posedge unless clk_e.is_a?(Event)
39
40
 
@@ -209,6 +210,7 @@ HDLRuby::High::Std.channel(:mem_rom) do |typ,size,clk,rst,content,
209
210
  size = size.to_i
210
211
  # Compute the address bus width from the size.
211
212
  awidth = (size-1).width
213
+ awidth = 1 if awidth == 0
212
214
  # Process the table of reset mapping for the branches.
213
215
  # Ensures br_srts is a hash.
214
216
  br_rsts = br_rsts.to_hash
@@ -292,17 +294,43 @@ HDLRuby::High::Std.channel(:mem_rom) do |typ,size,clk,rst,content,
292
294
  trig_r <= 0
293
295
  end
294
296
  # The read procedure.
297
+ # par do
298
+ # hif(rst == 0) do
299
+ # # No reset, so can perform the read.
300
+ # hif(trig_r == 1) do
301
+ # # The trigger was previously set, read ok.
302
+ # target <= dbus_r
303
+ # blk.call if blk
304
+ # end
305
+ # # Prepare the read.
306
+ # abus_r <= abus_r + 1
307
+ # trig_r <= 1
308
+ # end
309
+ # end
310
+ # The read procedure.
295
311
  par do
296
312
  hif(rst == 0) do
297
313
  # No reset, so can perform the read.
298
314
  hif(trig_r == 1) do
299
315
  # The trigger was previously set, read ok.
300
- target <= dbus_r
301
- blk.call if blk
316
+ # target <= dbus_r
317
+ # blk.call if blk
318
+ seq do
319
+ # abus_r <= abus_r + 1
320
+ target <= dbus_r
321
+ blk.call if blk
322
+ end
323
+ end
324
+ helse do
325
+ # Prepare the read.
326
+ # abus_r <= abus_r + 1
327
+ if 2**size.width != size then
328
+ abus_r <= mux((abus_r + 1) == size, abus_r + 1, 0)
329
+ else
330
+ abus_r <= abus_r + 1
331
+ end
332
+ trig_r <= 1
302
333
  end
303
- # Prepare the read.
304
- abus_r <= abus_r + 1
305
- trig_r <= 1
306
334
  end
307
335
  end
308
336
  end
@@ -331,18 +359,44 @@ HDLRuby::High::Std.channel(:mem_rom) do |typ,size,clk,rst,content,
331
359
  # Reset so switch of the access trigger.
332
360
  trig_r <= 0
333
361
  end
362
+ # # The read procedure.
363
+ # par do
364
+ # hif(rst == 0) do
365
+ # # No reset, so can perform the read.
366
+ # hif(trig_r == 1) do
367
+ # # The trigger was previously set, read ok.
368
+ # target <= dbus_r
369
+ # blk.call if blk
370
+ # end
371
+ # # Prepare the read.
372
+ # abus_r <= abus_r - 1
373
+ # trig_r <= 1
374
+ # end
375
+ # end
334
376
  # The read procedure.
335
377
  par do
336
378
  hif(rst == 0) do
337
379
  # No reset, so can perform the read.
338
380
  hif(trig_r == 1) do
339
381
  # The trigger was previously set, read ok.
340
- target <= dbus_r
341
- blk.call if blk
382
+ # target <= dbus_r
383
+ # blk.call if blk
384
+ seq do
385
+ # abus_r <= abus_r - 1
386
+ target <= dbus_r
387
+ blk.call if blk
388
+ end
389
+ end
390
+ helse do
391
+ # Prepare the read.
392
+ # abus_r <= abus_r - 1
393
+ if 2**size.width != size then
394
+ abus_r <= mux(abus_r == 0, abus_r - 1, size - 1)
395
+ else
396
+ abus_r <= abus_r - 1
397
+ end
398
+ trig_r <= 1
342
399
  end
343
- # Prepare the read.
344
- abus_r <= abus_r - 1
345
- trig_r <= 1
346
400
  end
347
401
  end
348
402
  end
@@ -392,6 +446,7 @@ HDLRuby::High::Std.channel(:mem_dual) do |typ,size,clk,rst,br_rsts = {}|
392
446
  size = size.to_i
393
447
  # Compute the address bus width from the size.
394
448
  awidth = (size-1).width
449
+ awidth = 1 if awidth == 0
395
450
  # Process the table of reset mapping for the branches.
396
451
  # puts "first br_rsts=#{br_rsts}"
397
452
  # if br_rsts.is_a?(Array) then
@@ -541,12 +596,24 @@ HDLRuby::High::Std.channel(:mem_dual) do |typ,size,clk,rst,br_rsts = {}|
541
596
  # No reset, so can perform the read.
542
597
  hif(trig_r == 1) do
543
598
  # The trigger was previously set, read ok.
544
- target <= dbus_r
545
- blk.call if blk
599
+ # target <= dbus_r
600
+ # blk.call if blk
601
+ seq do
602
+ # abus_r <= abus_r + 1
603
+ target <= dbus_r
604
+ blk.call if blk
605
+ end
606
+ end
607
+ helse do
608
+ # Prepare the read.
609
+ # abus_r <= abus_r + 1
610
+ if 2**size.width != size then
611
+ abus_r <= mux((abus_r + 1) == size, abus_r + 1, 0)
612
+ else
613
+ abus_r <= abus_r + 1
614
+ end
615
+ trig_r <= 1
546
616
  end
547
- # Prepare the read.
548
- abus_r <= abus_r + 1
549
- trig_r <= 1
550
617
  end
551
618
  end
552
619
  end
@@ -581,7 +648,12 @@ HDLRuby::High::Std.channel(:mem_dual) do |typ,size,clk,rst,br_rsts = {}|
581
648
  # No reset, so can perform the write.
582
649
  blk.call if blk
583
650
  # Prepare the write.
584
- abus_w <= abus_w + 1
651
+ # abus_w <= abus_w + 1
652
+ if 2**size.width != size then
653
+ abus_w <= mux((abus_w + 1) == size, abus_w + 1, 0)
654
+ else
655
+ abus_w <= abus_w + 1
656
+ end
585
657
  trig_w <= 1
586
658
  dbus_w <= target
587
659
  end
@@ -613,18 +685,44 @@ HDLRuby::High::Std.channel(:mem_dual) do |typ,size,clk,rst,br_rsts = {}|
613
685
  # Reset so switch of the access trigger.
614
686
  trig_r <= 0
615
687
  end
688
+ # # The read procedure.
689
+ # par do
690
+ # hif(rst == 0) do
691
+ # # No reset, so can perform the read.
692
+ # hif(trig_r == 1) do
693
+ # # The trigger was previously set, read ok.
694
+ # target <= dbus_r
695
+ # blk.call if blk
696
+ # end
697
+ # # Prepare the read.
698
+ # abus_r <= abus_r - 1
699
+ # trig_r <= 1
700
+ # end
701
+ # end
616
702
  # The read procedure.
617
703
  par do
618
704
  hif(rst == 0) do
619
705
  # No reset, so can perform the read.
620
706
  hif(trig_r == 1) do
621
707
  # The trigger was previously set, read ok.
622
- target <= dbus_r
623
- blk.call if blk
708
+ # target <= dbus_r
709
+ # blk.call if blk
710
+ seq do
711
+ # abus_r <= abus_r - 1
712
+ target <= dbus_r
713
+ blk.call if blk
714
+ end
715
+ end
716
+ helse do
717
+ # Prepare the read.
718
+ # abus_r <= abus_r - 1
719
+ if 2**size.width != size then
720
+ abus_r <= mux(abus_r == 0, abus_r - 1, size - 1)
721
+ else
722
+ abus_r <= abus_r - 1
723
+ end
724
+ trig_r <= 1
624
725
  end
625
- # Prepare the read.
626
- abus_r <= abus_r - 1
627
- trig_r <= 1
628
726
  end
629
727
  end
630
728
  end
@@ -659,7 +757,12 @@ HDLRuby::High::Std.channel(:mem_dual) do |typ,size,clk,rst,br_rsts = {}|
659
757
  # No reset, so can perform the write.
660
758
  blk.call if blk
661
759
  # Prepare the write.
662
- abus_w <= abus_w - 1
760
+ # abus_w <= abus_w - 1
761
+ if 2**size.width != size then
762
+ abus_w <= mux(abus_w == 0, abus_w - 1, size - 1)
763
+ else
764
+ abus_w <= abus_w - 1
765
+ end
663
766
  trig_w <= 1
664
767
  dbus_w <= target
665
768
  end
@@ -853,6 +956,8 @@ HDLRuby::High::Std.channel(:mem_file) do |typ,size,clk,rst,br_rsts = {}|
853
956
  reader_input rst_name
854
957
  end
855
958
  # Declares the address counter.
959
+ awidth = size.width-1
960
+ awidth = 1 if awidth == 0
856
961
  [size.width-1].inner :abus_r
857
962
  reader_inout :abus_r
858
963
 
@@ -876,7 +981,12 @@ HDLRuby::High::Std.channel(:mem_file) do |typ,size,clk,rst,br_rsts = {}|
876
981
  end
877
982
  blk.call if blk
878
983
  # Prepare the next read.
879
- abus_r <= abus_r + 1
984
+ # abus_r <= abus_r + 1
985
+ if 2**size.width != size then
986
+ abus_r <= mux((abus_r + 1) == size, abus_r + 1, 0)
987
+ else
988
+ abus_r <= abus_r + 1
989
+ end
880
990
  end
881
991
  end
882
992
  end
@@ -915,7 +1025,12 @@ HDLRuby::High::Std.channel(:mem_file) do |typ,size,clk,rst,br_rsts = {}|
915
1025
  end
916
1026
  blk.call if blk
917
1027
  # Prepare the next write.
918
- abus_w <= abus_w + 1
1028
+ # abus_w <= abus_w + 1
1029
+ if 2**size.width != size then
1030
+ abus_w <= mux((abus_w + 1) == size, abus_w + 1, 0)
1031
+ else
1032
+ abus_w <= abus_w + 1
1033
+ end
919
1034
  end
920
1035
  end
921
1036
  end
@@ -933,6 +1048,8 @@ HDLRuby::High::Std.channel(:mem_file) do |typ,size,clk,rst,br_rsts = {}|
933
1048
  reader_input rst_name
934
1049
  end
935
1050
  # Declares the address counter.
1051
+ awidth = size.width - 1
1052
+ awidth = 1 if awidth == 0
936
1053
  [size.width-1].inner :abus_r
937
1054
  reader_inout :abus_r
938
1055
 
@@ -956,7 +1073,12 @@ HDLRuby::High::Std.channel(:mem_file) do |typ,size,clk,rst,br_rsts = {}|
956
1073
  end
957
1074
  blk.call if blk
958
1075
  # Prepare the next read.
959
- abus_r <= abus_r - 1
1076
+ # abus_r <= abus_r - 1
1077
+ if 2**size.width != size then
1078
+ abus_r <= mux(abus_r == 0, abus_r - 1, size - 1)
1079
+ else
1080
+ abus_r <= abus_r - 1
1081
+ end
960
1082
  end
961
1083
  end
962
1084
  end
@@ -995,7 +1117,12 @@ HDLRuby::High::Std.channel(:mem_file) do |typ,size,clk,rst,br_rsts = {}|
995
1117
  end
996
1118
  blk.call if blk
997
1119
  # Prepare the next write.
998
- abus_w <= abus_w - 1
1120
+ # abus_w <= abus_w - 1
1121
+ if 2**size.width != size then
1122
+ abus_w <= mux(abus_w == 0, abus_w - 1, size - 1)
1123
+ else
1124
+ abus_w <= abus_w - 1
1125
+ end
999
1126
  end
1000
1127
  end
1001
1128
  end
@@ -1043,7 +1170,9 @@ HDLRuby::High::Std.channel(:mem_bank) do |typ,nbanks,size,clk,rst,br_rsts = {}|
1043
1170
  size = size.to_i
1044
1171
  # Compute the address bus width from the size.
1045
1172
  awidth = (size*nbanks-1).width
1173
+ awidth = 1 if awidth == 0
1046
1174
  awidth_b = (size-1).width # Bank width
1175
+ awidth_b = 1 if awidth_b == 0
1047
1176
  # Ensures br_srts is a hash.
1048
1177
  br_rsts = br_rsts.to_hash
1049
1178
 
@@ -1204,7 +1333,12 @@ HDLRuby::High::Std.channel(:mem_bank) do |typ,nbanks,size,clk,rst,br_rsts = {}|
1204
1333
  blk.call if blk
1205
1334
  end
1206
1335
  # Prepare the read.
1207
- abus_r <= abus_r + 1
1336
+ # abus_r <= abus_r + 1
1337
+ if 2**size.width != size then
1338
+ abus_r <= mux((abus_r + 1) == size, abus_r + 1, 0)
1339
+ else
1340
+ abus_r <= abus_r + 1
1341
+ end
1208
1342
  trig_r <= 1
1209
1343
  end
1210
1344
  end
@@ -1240,7 +1374,12 @@ HDLRuby::High::Std.channel(:mem_bank) do |typ,nbanks,size,clk,rst,br_rsts = {}|
1240
1374
  # No reset, so can perform the write.
1241
1375
  blk.call if blk
1242
1376
  # Prepare the write.
1243
- abus_w <= abus_w + 1
1377
+ # abus_w <= abus_w + 1
1378
+ if 2**size.width != size then
1379
+ abus_w <= mux((abus_w + 1) == size, abus_w + 1, 0)
1380
+ else
1381
+ abus_w <= abus_w + 1
1382
+ end
1244
1383
  trig_w <= 1
1245
1384
  dbus_w <= target
1246
1385
  end
@@ -1281,7 +1420,12 @@ HDLRuby::High::Std.channel(:mem_bank) do |typ,nbanks,size,clk,rst,br_rsts = {}|
1281
1420
  blk.call if blk
1282
1421
  end
1283
1422
  # Prepare the read.
1284
- abus_r <= abus_r - 1
1423
+ # abus_r <= abus_r - 1
1424
+ if 2**size.width != size then
1425
+ abus_r <= mux(abus_r == 0, abus_r - 1, size - 1)
1426
+ else
1427
+ abus_r <= abus_r - 1
1428
+ end
1285
1429
  trig_r <= 1
1286
1430
  end
1287
1431
  end
@@ -1318,6 +1462,11 @@ HDLRuby::High::Std.channel(:mem_bank) do |typ,nbanks,size,clk,rst,br_rsts = {}|
1318
1462
  blk.call if blk
1319
1463
  # Prepare the write.
1320
1464
  abus_w <= abus_w - 1
1465
+ if 2**size.width != size then
1466
+ abus_w <= mux(abus_w == 0, abus_w - 1, size - 1)
1467
+ else
1468
+ abus_w <= abus_w - 1
1469
+ end
1321
1470
  trig_w <= 1
1322
1471
  dbus_w <= target
1323
1472
  end