HDLRuby 2.6.25 → 2.7.1
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/with_ref_array.rb +26 -0
- data/lib/HDLRuby/hdr_samples/with_subsums.rb +33 -0
- data/lib/HDLRuby/hdr_samples/with_values.rb +58 -0
- data/lib/HDLRuby/hruby_low2c.rb +9 -9
- data/lib/HDLRuby/sim/hruby_sim.h +6 -1
- data/lib/HDLRuby/sim/hruby_sim_stack_calc.c +69 -33
- data/lib/HDLRuby/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ca0e2aba73e7ceb55e145dd22286398ae7605d04d46212f870ba895d3f983d9
|
4
|
+
data.tar.gz: 434ae3eb4d974a00ea1510b0e23d66dc51d5f6ac5ef0e4b79af288b5d05f6985
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d097cbd7793ef60fd94c70f7a8acb2e49b13915fd799b7618523c1ba57300195a9ca8a7a61d6e50a8f89779ce6bf64a484bdf5267de93b3159f61186f40e6a82
|
7
|
+
data.tar.gz: 27db7c7e988abe14635a515572c2774e8a76d44e7f0e85bfb6ec8b1c9dfed85f61ef49e1f597c59fc9b725b6aacc53b976f73a3b49f816820c5ca9691e253559
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
# A benchmark for testing array references.
|
3
|
+
system :with_concat do
|
4
|
+
[8].inner :count
|
5
|
+
[8].inner :val0,:val1
|
6
|
+
[3].inner :val2
|
7
|
+
[8].inner :val3
|
8
|
+
|
9
|
+
val2 <= val0[4..2]
|
10
|
+
val3[6..3] <= val1[7..4]
|
11
|
+
|
12
|
+
timed do
|
13
|
+
val0 <= _00001111
|
14
|
+
val1 <= _11000011
|
15
|
+
count <= 0
|
16
|
+
!10.ns
|
17
|
+
val0 <= _11110000
|
18
|
+
val1 <= _00111100
|
19
|
+
count <= 1
|
20
|
+
!10.ns
|
21
|
+
val0 <= _10101010
|
22
|
+
val1 <= _01010101
|
23
|
+
count <= 2
|
24
|
+
!10.ns
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
# A benchmark for sum of sub parts of a vector.
|
3
|
+
system :with_concat do
|
4
|
+
[8].inner :count
|
5
|
+
[16].inner :val0, :val1, :val2, :val3, :val4, :val5, :val6
|
6
|
+
bs = []
|
7
|
+
10.times do |i|
|
8
|
+
bs << [16].inner(:"b#{i}")
|
9
|
+
end
|
10
|
+
|
11
|
+
vals = [val1,val2,val3,val4]
|
12
|
+
par do
|
13
|
+
vals.each.with_index { |val,i| val <= val0[(i*4+3)..i*4] }
|
14
|
+
end
|
15
|
+
val5 <= vals.reduce(:+)
|
16
|
+
|
17
|
+
par do
|
18
|
+
bs.each.with_index { |b,i| b <= val0[i..i] }
|
19
|
+
end
|
20
|
+
val6 <= bs.reduce(:+)
|
21
|
+
|
22
|
+
timed do
|
23
|
+
val0 <= _1111000011110000
|
24
|
+
count <= 0
|
25
|
+
!10.ns
|
26
|
+
val0 <= _0000111100001111
|
27
|
+
count <= 1
|
28
|
+
!10.ns
|
29
|
+
val0 <= _1010101010101010
|
30
|
+
count <= 2
|
31
|
+
!10.ns
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
|
2
|
+
# A benchmark for testing the literal values.
|
3
|
+
system :with_values do
|
4
|
+
inner :v1
|
5
|
+
[8].inner :v8
|
6
|
+
[16].inner :v16
|
7
|
+
[32].inner :v32
|
8
|
+
[56].inner :v56
|
9
|
+
[64].inner :v64
|
10
|
+
[96].inner :v96
|
11
|
+
|
12
|
+
|
13
|
+
timed do
|
14
|
+
v1 <= 0
|
15
|
+
v8 <= 0
|
16
|
+
v16 <= 0
|
17
|
+
v32 <= 0
|
18
|
+
v56 <= 0
|
19
|
+
v64 <= 0
|
20
|
+
v96 <= 0
|
21
|
+
!10.ns
|
22
|
+
v1 <= 1
|
23
|
+
v8 <= 1
|
24
|
+
v16 <= 1
|
25
|
+
v32 <= 1
|
26
|
+
v56 <= 1
|
27
|
+
v64 <= 1
|
28
|
+
v96 <= 1
|
29
|
+
!10.ns
|
30
|
+
v8 <= 128
|
31
|
+
v16 <= 128
|
32
|
+
v32 <= 128
|
33
|
+
v56 <= 128
|
34
|
+
v64 <= 128
|
35
|
+
v96 <= 128
|
36
|
+
!10.ns
|
37
|
+
v16 <= 0x1000
|
38
|
+
v32 <= 0x1000
|
39
|
+
v56 <= 0x1000
|
40
|
+
v64 <= 0x1000
|
41
|
+
v96 <= 0x1000
|
42
|
+
!10.ns
|
43
|
+
v32 <= 0x10000000
|
44
|
+
v56 <= 0x10000000
|
45
|
+
v64 <= 0x10000000
|
46
|
+
v96 <= 0x10000000
|
47
|
+
!10.ns
|
48
|
+
v56 <= 0x10000000000000
|
49
|
+
v64 <= 0x10000000000000
|
50
|
+
v96 <= 0x10000000000000
|
51
|
+
!10.ns
|
52
|
+
v64 <= 0x1000000000000000
|
53
|
+
v96 <= 0x1000000000000000
|
54
|
+
!10.ns
|
55
|
+
v96 <= 0x1000000000000000000
|
56
|
+
!10.ns
|
57
|
+
end
|
58
|
+
end
|
data/lib/HDLRuby/hruby_low2c.rb
CHANGED
@@ -1360,7 +1360,7 @@ module HDLRuby::Low
|
|
1360
1360
|
# def to_c(level = 0)
|
1361
1361
|
def to_c(res,level = 0)
|
1362
1362
|
# Save the value pool state.
|
1363
|
-
res << (" " * (level*3)) << "
|
1363
|
+
res << (" " * (level*3)) << "PV;\n"
|
1364
1364
|
# Generate the print for each argument.
|
1365
1365
|
self.each_arg do |arg|
|
1366
1366
|
if (arg.is_a?(StringE)) then
|
@@ -1981,7 +1981,7 @@ module HDLRuby::Low
|
|
1981
1981
|
res << " " * (level+1)*3
|
1982
1982
|
# res << "static unsigned long long data[] = { "
|
1983
1983
|
res << "static unsigned int data[] = { "
|
1984
|
-
res << str.scan(/.{1,#{Low2C.int_width}}/m).map do |sub|
|
1984
|
+
res << str.scan(/.{1,#{Low2C.int_width}}/m).reverse.map do |sub|
|
1985
1985
|
sub.to_i(2).to_s # + "ULL"
|
1986
1986
|
end.join(",")
|
1987
1987
|
res << " };\n"
|
@@ -2056,7 +2056,7 @@ module HDLRuby::Low
|
|
2056
2056
|
# def to_c(level = 0)
|
2057
2057
|
def to_c(res,level = 0)
|
2058
2058
|
# Save the value pool state.
|
2059
|
-
res << (" " * (level*3)) << "
|
2059
|
+
res << (" " * (level*3)) << "PV;\n"
|
2060
2060
|
# Generate the child.
|
2061
2061
|
self.child.to_c(res,level)
|
2062
2062
|
res << (" " * (level*3))
|
@@ -2144,7 +2144,7 @@ module HDLRuby::Low
|
|
2144
2144
|
end
|
2145
2145
|
# Some computation required.
|
2146
2146
|
# Save the value pool state.
|
2147
|
-
res << (" " * (level*3)) << "
|
2147
|
+
res << (" " * (level*3)) << "PV;\n"
|
2148
2148
|
# Generate the child.
|
2149
2149
|
self.child.to_c(res,level)
|
2150
2150
|
res << (" " * (level*3))
|
@@ -2256,7 +2256,7 @@ module HDLRuby::Low
|
|
2256
2256
|
# def to_c(level = 0)
|
2257
2257
|
def to_c(res, level = 0)
|
2258
2258
|
# Save the value pool state.
|
2259
|
-
res << (" " * (level*3)) << "
|
2259
|
+
res << (" " * (level*3)) << "PV;\n"
|
2260
2260
|
# Generate the left computation.
|
2261
2261
|
self.left.to_c(res,level)
|
2262
2262
|
# Generate the right computation.
|
@@ -2375,7 +2375,7 @@ module HDLRuby::Low
|
|
2375
2375
|
# +level+ is the hierachical level of the object.
|
2376
2376
|
def to_c(res,level = 0)
|
2377
2377
|
# Save the value pool state.
|
2378
|
-
res << (" " * (level*3)) << "
|
2378
|
+
res << (" " * (level*3)) << "PV;\n"
|
2379
2379
|
# Gather the possible selection choices.
|
2380
2380
|
expressions = self.each_choice.to_a
|
2381
2381
|
# Create the resulting string.
|
@@ -2444,7 +2444,7 @@ module HDLRuby::Low
|
|
2444
2444
|
# +level+ is the hierachical level of the object.
|
2445
2445
|
def to_c(res,level = 0)
|
2446
2446
|
# Save the value pool state.
|
2447
|
-
res << (" " * (level*3)) << "
|
2447
|
+
res << (" " * (level*3)) << "PV;\n"
|
2448
2448
|
# Gather the content to concat.
|
2449
2449
|
expressions = self.each_expression.to_a
|
2450
2450
|
# Compute each sub expression.
|
@@ -2604,7 +2604,7 @@ module HDLRuby::Low
|
|
2604
2604
|
# +left+ tells if it is a left value or not.
|
2605
2605
|
def to_c(res,level = 0, left = false)
|
2606
2606
|
# Save the value pool state.
|
2607
|
-
res << (" " * (level*3)) << "
|
2607
|
+
res << (" " * (level*3)) << "PV;\n"
|
2608
2608
|
# Compute the reference.
|
2609
2609
|
self.ref.to_c(res,level)
|
2610
2610
|
# Compute the index.
|
@@ -2718,7 +2718,7 @@ module HDLRuby::Low
|
|
2718
2718
|
# end
|
2719
2719
|
def to_c(res,level = 0, left = false)
|
2720
2720
|
# Save the value pool state.
|
2721
|
-
res << (" " * (level*3)) << "
|
2721
|
+
res << (" " * (level*3)) << "PV;\n"
|
2722
2722
|
# Compute the reference.
|
2723
2723
|
self.ref.to_c(res,level)
|
2724
2724
|
# res << (" " * (level*3))
|
data/lib/HDLRuby/sim/hruby_sim.h
CHANGED
@@ -410,7 +410,8 @@ extern void save_value_pos();
|
|
410
410
|
extern void restore_value_pos();
|
411
411
|
|
412
412
|
/** Macros for short control of the pool of values. */
|
413
|
-
#define SV
|
413
|
+
#define SV save_value_pos();
|
414
|
+
#define PV push(get_value());save_value_pos();
|
414
415
|
#define RV restore_value_pos();
|
415
416
|
|
416
417
|
|
@@ -757,6 +758,10 @@ extern void push(Value val);
|
|
757
758
|
* @return the value. */
|
758
759
|
extern Value pop();
|
759
760
|
|
761
|
+
/** Access the top value of the stack without removing it.
|
762
|
+
* @return the value. */
|
763
|
+
extern Value peek();
|
764
|
+
|
760
765
|
/** Unary calculation.
|
761
766
|
* @param oper the operator function
|
762
767
|
* @return the destination
|
@@ -38,6 +38,17 @@ Value pop() {
|
|
38
38
|
}
|
39
39
|
}
|
40
40
|
|
41
|
+
/** Access the top value of the stack without removing it.
|
42
|
+
* @return the value. */
|
43
|
+
Value peek() {
|
44
|
+
if (head < STACK_SIZE) {
|
45
|
+
return stack[head];
|
46
|
+
} else {
|
47
|
+
perror("Computation stack empty.\n");
|
48
|
+
exit(1);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
41
52
|
/** Pops multiple values.
|
42
53
|
* @param num the number of values to pop.
|
43
54
|
* @return a pointer on the first value (in heap order!). */
|
@@ -58,10 +69,11 @@ static Value* popn(int num) {
|
|
58
69
|
**/
|
59
70
|
Value unary(Value (*oper)(Value,Value)) {
|
60
71
|
// printf("unary\n");
|
61
|
-
Value dst = get_top_value();
|
62
|
-
dst = oper(pop(),dst);
|
63
|
-
push(dst);
|
64
|
-
return dst;
|
72
|
+
// Value dst = get_top_value();
|
73
|
+
// dst = oper(pop(),dst);
|
74
|
+
// push(dst);
|
75
|
+
// return dst;
|
76
|
+
return oper(pop(),peek());
|
65
77
|
}
|
66
78
|
|
67
79
|
/** Binary calculation.
|
@@ -70,12 +82,15 @@ Value unary(Value (*oper)(Value,Value)) {
|
|
70
82
|
**/
|
71
83
|
Value binary(Value (*oper)(Value,Value,Value)) {
|
72
84
|
// printf("binary\n");
|
73
|
-
Value dst = get_top_value();
|
85
|
+
// Value dst = get_top_value();
|
86
|
+
// Value r = pop();
|
87
|
+
// Value l = pop();
|
88
|
+
// dst = oper(l,r,dst);
|
89
|
+
// push(dst);
|
90
|
+
// return dst;
|
74
91
|
Value r = pop();
|
75
92
|
Value l = pop();
|
76
|
-
|
77
|
-
push(dst);
|
78
|
-
return dst;
|
93
|
+
return oper(l,r,peek());
|
79
94
|
}
|
80
95
|
|
81
96
|
/** Cast calculation.
|
@@ -84,72 +99,93 @@ Value binary(Value (*oper)(Value,Value,Value)) {
|
|
84
99
|
**/
|
85
100
|
Value cast(Type typ) {
|
86
101
|
// printf("cast\n");
|
87
|
-
Value dst = get_top_value();
|
88
|
-
Value src = pop();
|
89
|
-
dst = cast_value(src,typ,dst);
|
90
|
-
push(dst);
|
91
|
-
return dst;
|
102
|
+
// Value dst = get_top_value();
|
103
|
+
// Value src = pop();
|
104
|
+
// dst = cast_value(src,typ,dst);
|
105
|
+
// push(dst);
|
106
|
+
// return dst;
|
107
|
+
return cast_value(pop(),typ,peek());
|
92
108
|
}
|
93
109
|
|
94
110
|
/* Concat values.
|
95
111
|
* @param num the number of values to concat.
|
96
112
|
* @param dir the direction. */
|
97
113
|
Value sconcat(int num, int dir) {
|
114
|
+
// Value* vals = alloca(num*sizeof(Value));
|
115
|
+
// Value dst = get_top_value();
|
116
|
+
// int i;
|
117
|
+
// // printf("sconcat\n");
|
118
|
+
// /* Get the values to concat from the stack. */
|
119
|
+
// for(i=1;i<=num;++i) vals[num-i] = pop();
|
120
|
+
// dst = concat_valueP(num,dir,dst,vals);
|
121
|
+
// push(dst);
|
122
|
+
// return dst;
|
98
123
|
Value* vals = alloca(num*sizeof(Value));
|
99
|
-
Value dst = get_top_value();
|
100
124
|
int i;
|
101
125
|
// printf("sconcat\n");
|
102
126
|
/* Get the values to concat from the stack. */
|
103
127
|
for(i=1;i<=num;++i) vals[num-i] = pop();
|
104
|
-
|
105
|
-
push(dst);
|
106
|
-
return dst;
|
128
|
+
return concat_valueP(num,dir,peek(),vals);
|
107
129
|
}
|
108
130
|
|
109
131
|
/* Index read calculation.
|
110
132
|
* @param typ the data type of the access. */
|
111
133
|
Value sreadI(Type typ) {
|
134
|
+
// // printf("sreadI\n");
|
135
|
+
// Value dst = get_top_value();
|
136
|
+
// unsigned long long idx = value2integer(pop());
|
137
|
+
// dst = read_range(pop(),idx,idx,typ,dst);
|
138
|
+
// push(dst);
|
139
|
+
// return dst;
|
112
140
|
// printf("sreadI\n");
|
113
|
-
Value dst = get_top_value();
|
114
141
|
unsigned long long idx = value2integer(pop());
|
115
|
-
|
116
|
-
push(dst);
|
117
|
-
return dst;
|
142
|
+
return read_range(pop(),idx,idx,typ,peek());
|
118
143
|
}
|
119
144
|
|
120
145
|
/* Index write calculation.
|
121
146
|
* @param typ the data type of the access. */
|
122
147
|
Value swriteI(Type typ) {
|
148
|
+
// // printf("swriteI\n");
|
149
|
+
// Value dst = get_top_value();
|
150
|
+
// unsigned long long idx = value2integer(pop());
|
151
|
+
// dst = write_range(pop(),idx,idx,typ,dst);
|
152
|
+
// push(dst);
|
153
|
+
// return dst;
|
123
154
|
// printf("swriteI\n");
|
124
|
-
Value dst = get_top_value();
|
125
155
|
unsigned long long idx = value2integer(pop());
|
126
|
-
|
127
|
-
push(dst);
|
128
|
-
return dst;
|
156
|
+
return write_range(pop(),idx,idx,typ,peek());
|
129
157
|
}
|
130
158
|
|
131
159
|
/* Range read calculation.
|
132
160
|
* @param typ the data type of the access. */
|
133
161
|
Value sreadR(Type typ) {
|
162
|
+
// // printf("sreadR\n");
|
163
|
+
// Value dst = get_top_value();
|
164
|
+
// unsigned long long last = value2integer(pop());
|
165
|
+
// unsigned long long first = value2integer(pop());
|
166
|
+
// dst = read_range(pop(),first,last,typ,dst);
|
167
|
+
// push(dst);
|
168
|
+
// return dst;
|
134
169
|
// printf("sreadR\n");
|
135
|
-
Value dst = get_top_value();
|
136
170
|
unsigned long long last = value2integer(pop());
|
137
171
|
unsigned long long first = value2integer(pop());
|
138
|
-
|
139
|
-
push(dst);
|
140
|
-
return dst;
|
172
|
+
return read_range(pop(),first,last,typ,peek());
|
141
173
|
}
|
142
174
|
|
143
175
|
/* Range write calculation.
|
144
176
|
* @param typ the data type of the access. */
|
145
177
|
Value swriteR(Type typ) {
|
178
|
+
// // printf("swriteR\n");
|
179
|
+
// Value dst = get_top_value();
|
180
|
+
// unsigned long long last = value2integer(pop());
|
181
|
+
// unsigned long long first = value2integer(pop());
|
182
|
+
// dst = write_range(pop(),first,last,typ,dst);
|
183
|
+
// push(dst);
|
184
|
+
// return dst;
|
146
185
|
// printf("swriteR\n");
|
147
|
-
Value dst = get_top_value();
|
148
186
|
unsigned long long last = value2integer(pop());
|
149
187
|
unsigned long long first = value2integer(pop());
|
150
|
-
|
151
|
-
push(dst);
|
152
|
-
return dst;
|
188
|
+
return write_range(pop(),first,last,typ,peek());
|
153
189
|
}
|
154
190
|
|
155
191
|
/** Check if the top value is defined. */
|
data/lib/HDLRuby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: HDLRuby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lovic Gauthier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -157,9 +157,12 @@ files:
|
|
157
157
|
- lib/HDLRuby/hdr_samples/with_multi_channels.rb
|
158
158
|
- lib/HDLRuby/hdr_samples/with_reconf.rb
|
159
159
|
- lib/HDLRuby/hdr_samples/with_reduce.rb
|
160
|
+
- lib/HDLRuby/hdr_samples/with_ref_array.rb
|
160
161
|
- lib/HDLRuby/hdr_samples/with_str2value.rb
|
162
|
+
- lib/HDLRuby/hdr_samples/with_subsums.rb
|
161
163
|
- lib/HDLRuby/hdr_samples/with_to_a.rb
|
162
164
|
- lib/HDLRuby/hdr_samples/with_to_array.rb
|
165
|
+
- lib/HDLRuby/hdr_samples/with_values.rb
|
163
166
|
- lib/HDLRuby/hdrcc.rb
|
164
167
|
- lib/HDLRuby/high_samples/_adder_fault.rb
|
165
168
|
- lib/HDLRuby/high_samples/_generic_transmission2.rb
|