HDLRuby 3.8.2 → 3.9.0
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.
- checksums.yaml +4 -4
- data/README.md +2229 -1314
- data/ext/hruby_sim/hruby_sim_calc.c +23 -16
- data/lib/HDLRuby/hdr_samples/comparison_bench.rb +36 -0
- data/lib/HDLRuby/hdr_samples/with_henumerable.rb +5 -1
- data/lib/HDLRuby/hdr_samples/with_reduce.rb +10 -10
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +4 -1
- data/lib/HDLRuby/hdrlib.rb +291 -209
- data/lib/HDLRuby/hruby_high.rb +51 -32
- data/lib/HDLRuby/hruby_low2hdr.rb +9 -8
- data/lib/HDLRuby/hruby_low2vhd.rb +1 -1
- data/lib/HDLRuby/std/hruby_enum.rb +26 -5
- data/lib/HDLRuby/std/sequencer.rb +12 -2
- data/lib/HDLRuby/std/sequencer_sw.rb +812 -72
- data/lib/HDLRuby/version.rb +1 -1
- metadata +1 -1
@@ -854,12 +854,12 @@ static Value greater_value_numeric_defined_bitstring(Value src0, Value src1, Val
|
|
854
854
|
long long width0 = type_width(src0->type);
|
855
855
|
long long width1 = type_width(src1->type);
|
856
856
|
long long width = width0>width1 ? width0 : width1;
|
857
|
-
if (src0->type->flags.sign && (src0_int & (
|
857
|
+
if (src0->type->flags.sign && (src0_int & (1LL << (width0-1)))) {
|
858
858
|
if(src1->type->flags.sign && (src1_data[width1-1] == '1')) {
|
859
859
|
/* Negative-negative comparison. */
|
860
860
|
for(long long i=width-1; i >= 0; --i) {
|
861
861
|
char d0 = i >= width0 ? '1' :
|
862
|
-
((src0_int & (
|
862
|
+
((src0_int & (1LL << i)) ? '1' : '0');
|
863
863
|
char d1 = i >= width1 ? '1' : src1_data[i];
|
864
864
|
if (d0 < d1) {
|
865
865
|
dst->data_int = 0;
|
@@ -883,7 +883,7 @@ static Value greater_value_numeric_defined_bitstring(Value src0, Value src1, Val
|
|
883
883
|
/* Positive-positive comparison. */
|
884
884
|
for(long long i=width-1; i >= 0; --i) {
|
885
885
|
char d0 = i >= width0 ? '0' :
|
886
|
-
((src0_int & (
|
886
|
+
((src0_int & (1LL << i)) ? '1' : '0');
|
887
887
|
char d1 = i >= width1 ? '0' : src1_data[i];
|
888
888
|
if (d0 < d1) {
|
889
889
|
dst->data_int = 0;
|
@@ -974,15 +974,16 @@ static Value lesser_value_numeric_defined_bitstring(Value src0, Value src1, Valu
|
|
974
974
|
|
975
975
|
unsigned long long src0_int = src0->data_int;
|
976
976
|
char* src1_data = src1->data_str;
|
977
|
+
// printf("src1_data=%s\n",src1_data);
|
977
978
|
long long width0 = type_width(src0->type);
|
978
979
|
long long width1 = type_width(src1->type);
|
979
980
|
long long width = width0>width1 ? width0 : width1;
|
980
|
-
if (src0->type->flags.sign && (src0_int & (
|
981
|
+
if (src0->type->flags.sign && (src0_int & (1LL << (width0-1)))) {
|
981
982
|
if(src1->type->flags.sign && src1_data[width1-1] == '1') {
|
982
983
|
/* Negative-negative comparison. */
|
983
984
|
for(long long i=width-1; i >= 0; --i) {
|
984
985
|
char d0 = i >= width0 ? '1' :
|
985
|
-
((src0_int & (
|
986
|
+
((src0_int & (1LL << i)) ? '1' : '0');
|
986
987
|
char d1 = i >= width1 ? '1' : src1_data[i];
|
987
988
|
if (d0 < d1) {
|
988
989
|
dst->data_int = 1;
|
@@ -1006,8 +1007,9 @@ static Value lesser_value_numeric_defined_bitstring(Value src0, Value src1, Valu
|
|
1006
1007
|
/* Positive-positive comparison. */
|
1007
1008
|
for(long long i=width-1; i >= 0; --i) {
|
1008
1009
|
char d0 = i >= width0 ? '0' :
|
1009
|
-
((src0_int & (
|
1010
|
+
((src0_int & (1LL << i)) ? '1' : '0');
|
1010
1011
|
char d1 = i >= width1 ? '0' : src1_data[i];
|
1012
|
+
// printf("%d: d0=%d d1=%d\n",i,d0,d1);
|
1011
1013
|
if (d0 < d1) {
|
1012
1014
|
dst->data_int = 1;
|
1013
1015
|
return dst;
|
@@ -1100,12 +1102,12 @@ static Value greater_equal_value_numeric_defined_bitstring(Value src0, Value src
|
|
1100
1102
|
long long width0 = type_width(src0->type);
|
1101
1103
|
long long width1 = type_width(src1->type);
|
1102
1104
|
long long width = width0>width1 ? width0 : width1;
|
1103
|
-
if (src0->type->flags.sign && (src0_int & (
|
1105
|
+
if (src0->type->flags.sign && (src0_int & (1LL <<(width0-1)))) {
|
1104
1106
|
if(src1->type->flags.sign && src1_data[width1-1] == '1') {
|
1105
1107
|
/* Negative-negative comparison. */
|
1106
1108
|
for(long long i=width-1; i >= 0; --i) {
|
1107
1109
|
char d0 = i >= width0 ? '1' :
|
1108
|
-
((src0_int & (
|
1110
|
+
((src0_int & (1LL << i)) ? '1' : '0');
|
1109
1111
|
char d1 = i >= width1 ? '1' : src1_data[i];
|
1110
1112
|
if (d0 < d1) {
|
1111
1113
|
dst->data_int = 0;
|
@@ -1129,7 +1131,7 @@ static Value greater_equal_value_numeric_defined_bitstring(Value src0, Value src
|
|
1129
1131
|
/* Positive-positive comparison. */
|
1130
1132
|
for(long long i=width-1; i >= 0; --i) {
|
1131
1133
|
char d0 = i >= width0 ? '0' :
|
1132
|
-
((src0_int & (
|
1134
|
+
((src0_int & (1LL << i)) ? '1' : '0');
|
1133
1135
|
char d1 = i >= width1 ? '0' : src1_data[i];
|
1134
1136
|
if (d0 < d1) {
|
1135
1137
|
dst->data_int = 0;
|
@@ -1223,12 +1225,12 @@ static Value lesser_equal_value_numeric_defined_bitstring(Value src0, Value src1
|
|
1223
1225
|
long long width0 = type_width(src0->type);
|
1224
1226
|
long long width1 = type_width(src1->type);
|
1225
1227
|
long long width = width0>width1 ? width0 : width1;
|
1226
|
-
if (src0->type->flags.sign && (src0_int & (
|
1228
|
+
if (src0->type->flags.sign && (src0_int & (1LL << (width0-1)))) {
|
1227
1229
|
if(src1->type->flags.sign && src1_data[width1-1] == '1') {
|
1228
1230
|
/* Negative-negative comparison. */
|
1229
1231
|
for(long long i=width-1; i >= 0; --i) {
|
1230
1232
|
char d0 = i >= width0 ? '1' :
|
1231
|
-
((src0_int & (
|
1233
|
+
((src0_int & (1LL << i)) ? '1' : '0');
|
1232
1234
|
char d1 = i >= width1 ? '1' : src1_data[i];
|
1233
1235
|
if (d0 < d1) {
|
1234
1236
|
dst->data_int = 1;
|
@@ -1252,7 +1254,7 @@ static Value lesser_equal_value_numeric_defined_bitstring(Value src0, Value src1
|
|
1252
1254
|
/* Positive-positive comparison. */
|
1253
1255
|
for(long long i=width-1; i >= 0; --i) {
|
1254
1256
|
char d0 = i >= width0 ? '0' :
|
1255
|
-
((src0_int & (
|
1257
|
+
((src0_int & (1LL << i)) ? '1' : '0');
|
1256
1258
|
char d1 = i >= width1 ? '0' : src1_data[i];
|
1257
1259
|
// printf("d0=%c d1=%c\n",d0,d1);
|
1258
1260
|
if (d0 < d1) {
|
@@ -3297,6 +3299,7 @@ Value not_equal_value_c(Value src0, Value src1, Value dst) {
|
|
3297
3299
|
* @param dst the destination value
|
3298
3300
|
* @return dst */
|
3299
3301
|
Value greater_value(Value src0, Value src1, Value dst) {
|
3302
|
+
// printf("greater_value\n");
|
3300
3303
|
/* Might allocate a new value so save the current pool state. */
|
3301
3304
|
// unsigned int pos = get_value_pos();
|
3302
3305
|
/* Do a numeric computation if possible, otherwise fallback to bitstring
|
@@ -3308,7 +3311,8 @@ Value greater_value(Value src0, Value src1, Value dst) {
|
|
3308
3311
|
if (src0->numeric)
|
3309
3312
|
return greater_value_numeric_defined_bitstring(src0,src1,dst);
|
3310
3313
|
if (src1->numeric)
|
3311
|
-
return lesser_equal_value_numeric_defined_bitstring(src1,src0,dst);
|
3314
|
+
// return lesser_equal_value_numeric_defined_bitstring(src1,src0,dst);
|
3315
|
+
return lesser_value_numeric_defined_bitstring(src1,src0,dst);
|
3312
3316
|
/* Both sources can be converted to numeric values. */
|
3313
3317
|
return greater_value_defined_bitstring(src0,src1,dst);
|
3314
3318
|
} else {
|
@@ -3340,7 +3344,8 @@ Value lesser_value(Value src0, Value src1, Value dst) {
|
|
3340
3344
|
if (src0->numeric)
|
3341
3345
|
return lesser_value_numeric_defined_bitstring(src0,src1,dst);
|
3342
3346
|
if (src1->numeric)
|
3343
|
-
return greater_equal_value_numeric_defined_bitstring(src1,src0,dst);
|
3347
|
+
// return greater_equal_value_numeric_defined_bitstring(src1,src0,dst);
|
3348
|
+
return greater_value_numeric_defined_bitstring(src1,src0,dst);
|
3344
3349
|
return lesser_value_defined_bitstring(src0,src1,dst);
|
3345
3350
|
} else {
|
3346
3351
|
/* Cannot compute (for now), simply undefines the destination. */
|
@@ -3371,7 +3376,8 @@ Value greater_equal_value(Value src0, Value src1, Value dst) {
|
|
3371
3376
|
if (src0->numeric)
|
3372
3377
|
return greater_equal_value_numeric_defined_bitstring(src0,src1,dst);
|
3373
3378
|
if (src1->numeric)
|
3374
|
-
return lesser_value_numeric_defined_bitstring(src1,src0,dst);
|
3379
|
+
// return lesser_value_numeric_defined_bitstring(src1,src0,dst);
|
3380
|
+
return lesser_equal_value_numeric_defined_bitstring(src1,src0,dst);
|
3375
3381
|
return greater_equal_value_defined_bitstring(src0,src1,dst);
|
3376
3382
|
} else {
|
3377
3383
|
/* Cannot compute (for now), simply undefines the destination. */
|
@@ -3401,7 +3407,8 @@ Value lesser_equal_value(Value src0, Value src1, Value dst) {
|
|
3401
3407
|
if (src0->numeric)
|
3402
3408
|
return lesser_equal_value_numeric_defined_bitstring(src0,src1,dst);
|
3403
3409
|
if (src1->numeric)
|
3404
|
-
return greater_value_numeric_defined_bitstring(src1,src0,dst);
|
3410
|
+
// return greater_value_numeric_defined_bitstring(src1,src0,dst);
|
3411
|
+
return greater_equal_value_numeric_defined_bitstring(src1,src0,dst);
|
3405
3412
|
return lesser_equal_value_defined_bitstring(src0,src1,dst);
|
3406
3413
|
} else {
|
3407
3414
|
/* Cannot compute (for now), simply undefines the destination. */
|
@@ -2,6 +2,25 @@
|
|
2
2
|
|
3
3
|
# A benchmark for the comparators.
|
4
4
|
system :comparison_bench do
|
5
|
+
|
6
|
+
[8].inner truc: _h00
|
7
|
+
[8].inner :machin, :macheq
|
8
|
+
|
9
|
+
machin <= (truc > 0)
|
10
|
+
macheq <= (truc >= 0)
|
11
|
+
|
12
|
+
[8].inner bidule: _h00
|
13
|
+
[8].inner :chose, :choeq
|
14
|
+
|
15
|
+
chose <= (bidule < 0)
|
16
|
+
choeq <= (bidule <= 0)
|
17
|
+
|
18
|
+
[8].inner two: _h02
|
19
|
+
[8].inner :twoc, :twod
|
20
|
+
|
21
|
+
twoc <= (two > 1)
|
22
|
+
twod <= (two < 3)
|
23
|
+
|
5
24
|
[8].inner :x, :y
|
6
25
|
signed[8].inner :u,:v
|
7
26
|
inner :ue, :ult, :ule, :ugt, :uge
|
@@ -63,6 +82,23 @@ system :comparison_bench do
|
|
63
82
|
sgeND <= (uND >= vND)
|
64
83
|
end
|
65
84
|
|
85
|
+
inner :ueC, :ultC, :uleC, :ugtC, :ugeC
|
86
|
+
inner :seC, :sltC, :sleC, :sgtC, :sgeC
|
87
|
+
|
88
|
+
par do
|
89
|
+
ueC <= (x == 0)
|
90
|
+
ultC <= (x < 0)
|
91
|
+
uleC <= (x <= 0)
|
92
|
+
ugtC <= (x > 0)
|
93
|
+
ugeC <= (x >= 0)
|
94
|
+
|
95
|
+
seC <= (u == 0)
|
96
|
+
sltC <= (u < 0)
|
97
|
+
sleC <= (u <= 0)
|
98
|
+
sgtC <= (u > 0)
|
99
|
+
sgeC <= (u >= 0)
|
100
|
+
end
|
101
|
+
|
66
102
|
|
67
103
|
timed do
|
68
104
|
x <= 0
|
@@ -129,7 +129,7 @@ system :henmerable_checks do
|
|
129
129
|
|
130
130
|
[8].inner :res23, :res24
|
131
131
|
|
132
|
-
res23 <= vals.hfind(proc {-1}) { |elem| elem >
|
132
|
+
res23 <= vals.hfind(proc {-1}) { |elem| elem > 0 }
|
133
133
|
|
134
134
|
par(clk.posedge) do
|
135
135
|
# hprint("=0\n")
|
@@ -201,12 +201,16 @@ system :henmerable_checks do
|
|
201
201
|
end
|
202
202
|
|
203
203
|
[8].inner :res35, :res36
|
204
|
+
[7].inner :res35X, :res36X
|
204
205
|
|
205
206
|
res35 <= vals.hinject(_h01) { |a,b| a+b }
|
206
207
|
|
208
|
+
res35X <= vals.hinject(bit[4]) { |a,b| a+b }
|
209
|
+
|
207
210
|
par(clk.posedge) do
|
208
211
|
# hprint(":0\n")
|
209
212
|
res36 <= vals.(:+)
|
213
|
+
res36X <= vals.(bit[4],:+)
|
210
214
|
end
|
211
215
|
|
212
216
|
[8].inner :res37
|
@@ -1,38 +1,38 @@
|
|
1
1
|
|
2
2
|
|
3
|
-
# A benchmark for testing the enumarable properties of expression (
|
4
|
-
system :
|
3
|
+
# A benchmark for testing the enumarable properties of expression (hreduce).
|
4
|
+
system :with_hreduce_bench do
|
5
5
|
[8].inner :val,:res
|
6
6
|
[64].inner :val64
|
7
7
|
|
8
8
|
timed do
|
9
9
|
val <= _b01101010
|
10
|
-
res <= val.
|
10
|
+
res <= val.hreduce(_b00000000,:+)
|
11
11
|
!10.ns
|
12
12
|
val <= _01010010
|
13
|
-
res <= val.
|
13
|
+
res <= val.hreduce(_b00000000,:+)
|
14
14
|
!10.ns
|
15
15
|
val <= _01101111
|
16
|
-
res <= val.
|
16
|
+
res <= val.hreduce(_b00000000,:+)
|
17
17
|
!10.ns
|
18
18
|
val64 <= _b0110101001101010011010100110101001101010011010100110101001101010
|
19
|
-
res <= val64.
|
19
|
+
res <= val64.hreduce(_b00000000,:+)
|
20
20
|
!10.ns
|
21
21
|
res <= val64[7..0]
|
22
22
|
!10.ns
|
23
|
-
res <= res.
|
23
|
+
res <= res.hreduce(_b00000000,:+)
|
24
24
|
!10.ns
|
25
25
|
res <= val64[63..60]
|
26
26
|
!10.ns
|
27
|
-
res <= res.
|
27
|
+
res <= res.hreduce(_b00000000,:+)
|
28
28
|
!10.ns
|
29
29
|
val64 <= ~(val64 ^ val64)
|
30
|
-
res <= val64.
|
30
|
+
res <= val64.hreduce(_b00000000,:+)
|
31
31
|
!10.ns
|
32
32
|
val64[0] <= _b0
|
33
33
|
val64[3] <= _b0
|
34
34
|
val64[63] <= _b0
|
35
|
-
res <= val64.
|
35
|
+
res <= val64.hreduce(_b00000000,:+)
|
36
36
|
!10.ns
|
37
37
|
end
|
38
38
|
end
|
@@ -164,7 +164,7 @@ system :my_seqencer do
|
|
164
164
|
# hprint("=0\n")
|
165
165
|
res13 <= 0
|
166
166
|
res14 <= 0
|
167
|
-
res13 <= vals.sfind(-1) { |elem| elem >
|
167
|
+
res13 <= vals.sfind(-1) { |elem| elem > _h00 }
|
168
168
|
res14 <= vals.sfind(-1) { |elem| elem == _hAA }
|
169
169
|
# hprint("=1 res13=",res13," res14=",res14,"\n")
|
170
170
|
end
|
@@ -239,6 +239,7 @@ system :my_seqencer do
|
|
239
239
|
end
|
240
240
|
|
241
241
|
[8].inner :res26, :res27
|
242
|
+
[7].inner :res26X, :res27X
|
242
243
|
|
243
244
|
sequencer(clk.posedge,rst) do
|
244
245
|
# hprint(":0\n")
|
@@ -246,6 +247,8 @@ system :my_seqencer do
|
|
246
247
|
res27 <= 0
|
247
248
|
res26 <= vals.sinject(_h01) { |a,b| a+b }
|
248
249
|
res27 <= vals.sinject(:+)
|
250
|
+
res26X <= vals.sinject(bit[4]) { |a,b| a+b }
|
251
|
+
res27X <= vals.sinject(bit[4],:+)
|
249
252
|
# hprint(":1 res26=",res26," res27=",res27,"\n")
|
250
253
|
end
|
251
254
|
|