HDLRuby 2.6.22 → 2.7.1
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/lib/HDLRuby/hdr_samples/case_bench.rb +30 -0
- data/lib/HDLRuby/hdr_samples/constant_in_function.rb +1 -1
- data/lib/HDLRuby/hdr_samples/if_bench.rb +24 -0
- data/lib/HDLRuby/hdr_samples/index_bench.rb +37 -0
- data/lib/HDLRuby/hdr_samples/range_bench.rb +47 -0
- data/lib/HDLRuby/hdr_samples/with_casts.rb +30 -0
- data/lib/HDLRuby/hdr_samples/with_concat.rb +26 -0
- data/lib/HDLRuby/hdr_samples/with_ref_array.rb +26 -0
- data/lib/HDLRuby/hdr_samples/with_str2value.rb +14 -0
- data/lib/HDLRuby/hdr_samples/with_subsums.rb +33 -0
- data/lib/HDLRuby/hdr_samples/with_to_a.rb +90 -0
- data/lib/HDLRuby/hdr_samples/with_values.rb +58 -0
- data/lib/HDLRuby/hdrcc.rb +38 -25
- data/lib/HDLRuby/hruby_high.rb +11 -1
- data/lib/HDLRuby/hruby_low.rb +11 -0
- data/lib/HDLRuby/hruby_low2c.rb +1339 -550
- data/lib/HDLRuby/hruby_low_casts_without_expression.rb +78 -55
- data/lib/HDLRuby/hruby_low_mutable.rb +33 -0
- data/lib/HDLRuby/hruby_low_with_port.rb +21 -6
- data/lib/HDLRuby/hruby_low_without_namespace.rb +4 -2
- data/lib/HDLRuby/hruby_tools.rb +8 -1
- data/lib/HDLRuby/hruby_verilog.rb +218 -149
- data/lib/HDLRuby/sim/hruby_sim.h +114 -0
- data/lib/HDLRuby/sim/hruby_sim_calc.c +38 -9
- data/lib/HDLRuby/sim/hruby_sim_stack_calc.c +239 -0
- data/lib/HDLRuby/sim/hruby_sim_stack_calc.c.sav +100 -0
- data/lib/HDLRuby/sim/hruby_value_pool.c +36 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +15 -2
data/lib/HDLRuby/sim/hruby_sim.h
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
**/
|
5
5
|
|
6
6
|
#include <pthread.h>
|
7
|
+
#include <stdarg.h>
|
7
8
|
|
8
9
|
|
9
10
|
/* The interface to the HDLRuby objects C models. */
|
@@ -220,6 +221,20 @@ Value shift_right_value(Value src0, Value src1, Value dst);
|
|
220
221
|
* @return dst */
|
221
222
|
extern Value equal_value(Value src0, Value src1, Value dst);
|
222
223
|
|
224
|
+
/** Computes the C equal of two general values.
|
225
|
+
* @param src0 the first source value of the addition
|
226
|
+
* @param src1 the second source value of the addition
|
227
|
+
* @param dst the destination value
|
228
|
+
* @return the destination value */
|
229
|
+
extern Value equal_value_c(Value src0, Value src1, Value dst);
|
230
|
+
|
231
|
+
/** Computes the C not equal of two general values.
|
232
|
+
* @param src0 the first source value of the addition
|
233
|
+
* @param src1 the second source value of the addition
|
234
|
+
* @param dst the destination value
|
235
|
+
* @return the destination value */
|
236
|
+
extern Value not_equal_value_c(Value src0, Value src1, Value dst);
|
237
|
+
|
223
238
|
/** Computes the greater comparision of two values.
|
224
239
|
* @param src0 the first source value of the comparison
|
225
240
|
* @param src1 the second source value of the comparison
|
@@ -261,6 +276,8 @@ extern Value select_value(Value cond, Value dst, unsigned int num, ...);
|
|
261
276
|
* @param dst the destination value
|
262
277
|
* @return dst */
|
263
278
|
extern Value concat_value(int num, int dir, Value dst, ...);
|
279
|
+
extern Value concat_valueV(int num, int dir, Value dst, va_list args);
|
280
|
+
extern Value concat_valueP(int num, int dir, Value dst, Value* args);
|
264
281
|
|
265
282
|
/** Casts a value to another type.
|
266
283
|
* @param src the source value
|
@@ -373,6 +390,9 @@ extern Elem remove_list(List list);
|
|
373
390
|
/** Get a fresh value. */
|
374
391
|
extern Value get_value();
|
375
392
|
|
393
|
+
/** Get the current top value. */
|
394
|
+
Value get_top_value();
|
395
|
+
|
376
396
|
/** Frees the last value of the pool. */
|
377
397
|
extern void free_value();
|
378
398
|
|
@@ -383,6 +403,20 @@ extern unsigned int get_value_pos();
|
|
383
403
|
* @param pos the new position in the pool */
|
384
404
|
extern void set_value_pos(unsigned int pos);
|
385
405
|
|
406
|
+
/** Saves the current state+1 of the value pool to the pool state stack. */
|
407
|
+
extern void save_value_pos();
|
408
|
+
|
409
|
+
/** Restores the state of the value pool from the state stack. */
|
410
|
+
extern void restore_value_pos();
|
411
|
+
|
412
|
+
/** Macros for short control of the pool of values. */
|
413
|
+
#define SV save_value_pos();
|
414
|
+
#define PV push(get_value());save_value_pos();
|
415
|
+
#define RV restore_value_pos();
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
|
386
420
|
/** An HDLRuby object. */
|
387
421
|
typedef struct ObjectS_ {
|
388
422
|
Kind kind; /* The kind of object. */
|
@@ -712,3 +746,83 @@ extern Value write_range(Value src, long long first, long long last,
|
|
712
746
|
* @return dst */
|
713
747
|
extern Value write_range_no_z(Value src, long long first, long long last,
|
714
748
|
Type base, Value dst);
|
749
|
+
|
750
|
+
|
751
|
+
/** Stack-based computations. */
|
752
|
+
|
753
|
+
/** Push a value.
|
754
|
+
* @param val the value to push. */
|
755
|
+
extern void push(Value val);
|
756
|
+
|
757
|
+
/** Pops a value.
|
758
|
+
* @return the value. */
|
759
|
+
extern Value pop();
|
760
|
+
|
761
|
+
/** Access the top value of the stack without removing it.
|
762
|
+
* @return the value. */
|
763
|
+
extern Value peek();
|
764
|
+
|
765
|
+
/** Unary calculation.
|
766
|
+
* @param oper the operator function
|
767
|
+
* @return the destination
|
768
|
+
**/
|
769
|
+
extern Value unary(Value (*oper)(Value,Value));
|
770
|
+
|
771
|
+
/** Binary calculation.
|
772
|
+
* @param oper the operator function
|
773
|
+
* @return the destination
|
774
|
+
**/
|
775
|
+
extern Value binary(Value (*oper)(Value,Value,Value));
|
776
|
+
|
777
|
+
/** Cast calculation.
|
778
|
+
* @param typ the type to cast to.
|
779
|
+
* @return the destination.
|
780
|
+
**/
|
781
|
+
extern Value cast(Type typ);
|
782
|
+
|
783
|
+
/* Concat values.
|
784
|
+
* @param num the number of values to concat.
|
785
|
+
* @param dir the direction. */
|
786
|
+
extern Value sconcat(int num, int dir);
|
787
|
+
|
788
|
+
/* Index read calculation.
|
789
|
+
* @param typ the data type of the access. */
|
790
|
+
extern Value sreadI(Type typ);
|
791
|
+
|
792
|
+
/* Index write calculation.
|
793
|
+
* @param typ the data type of the access. */
|
794
|
+
extern Value swriteI(Type typ);
|
795
|
+
|
796
|
+
/* Range read calculation.
|
797
|
+
* @param typ the data type of the access. */
|
798
|
+
extern Value sreadR(Type typ);
|
799
|
+
|
800
|
+
/* Range write calculation.
|
801
|
+
* @param typ the data type of the access. */
|
802
|
+
extern Value swriteR(Type typ);
|
803
|
+
|
804
|
+
/** Check if the top value is defined. */
|
805
|
+
extern int is_defined();
|
806
|
+
|
807
|
+
/** Convert the top value to an integer. */
|
808
|
+
extern unsigned long long to_integer();
|
809
|
+
|
810
|
+
/** Check if a value is true.
|
811
|
+
* Actually check if it is defined and convert it to integer. */
|
812
|
+
extern unsigned long long is_true();
|
813
|
+
|
814
|
+
/* Transmit the top value to a signal in parallel.
|
815
|
+
* @param sig the signal to transmit to. */
|
816
|
+
extern void transmit(SignalI sig);
|
817
|
+
|
818
|
+
/* Transmit the top value to a signal in sequence.
|
819
|
+
* @param sig the signal to transmit to. */
|
820
|
+
extern void transmit_seq(SignalI sig);
|
821
|
+
|
822
|
+
/* Transmit the top value to a range in a signal in parallel.
|
823
|
+
* @param ref the ref to the range of the signal to transmit to. */
|
824
|
+
extern void transmitR(RefRangeS ref);
|
825
|
+
|
826
|
+
/* Transmit the top value to a range in a signal in sequence.
|
827
|
+
* @param ref the ref to the range of the signal to transmit to. */
|
828
|
+
extern void transmitR_seq(RefRangeS ref);
|
@@ -2657,6 +2657,28 @@ Value equal_value(Value src0, Value src1, Value dst) {
|
|
2657
2657
|
}
|
2658
2658
|
|
2659
2659
|
|
2660
|
+
/** Computes the C equal of two general values.
|
2661
|
+
* @param src0 the first source value of the addition
|
2662
|
+
* @param src1 the second source value of the addition
|
2663
|
+
* @param dst the destination value
|
2664
|
+
* @return the destination value */
|
2665
|
+
Value equal_value_c(Value src0, Value src1, Value dst) {
|
2666
|
+
dst = equal_value(src0,src1,dst);
|
2667
|
+
return reduce_or_value(dst,dst);
|
2668
|
+
}
|
2669
|
+
|
2670
|
+
|
2671
|
+
/** Computes the C not equal of two general values.
|
2672
|
+
* @param src0 the first source value of the addition
|
2673
|
+
* @param src1 the second source value of the addition
|
2674
|
+
* @param dst the destination value
|
2675
|
+
* @return the destination value */
|
2676
|
+
Value not_equal_value_c(Value src0, Value src1, Value dst) {
|
2677
|
+
dst = xor_value(src0,src1,dst);
|
2678
|
+
return reduce_or_value(dst,dst);
|
2679
|
+
}
|
2680
|
+
|
2681
|
+
|
2660
2682
|
|
2661
2683
|
/** Computes the greater comparision of two general values.
|
2662
2684
|
* @param src0 the first source value of the addition
|
@@ -2790,16 +2812,9 @@ Value select_value(Value cond, Value dst, unsigned int num, ...) {
|
|
2790
2812
|
* @param num the number of values to concat
|
2791
2813
|
* @param dst the destination value
|
2792
2814
|
* @return dst */
|
2793
|
-
Value
|
2815
|
+
Value concat_valueP(int num, int dir, Value dst, Value* values) {
|
2794
2816
|
unsigned long long width = 0;
|
2795
2817
|
int numeric = 1, i;
|
2796
|
-
va_list args;
|
2797
|
-
Value* values = alloca(num*sizeof(Value)); /* The values to concatenate. */
|
2798
|
-
va_start(args,dst);
|
2799
|
-
/* Copy the arguments to values for easier processing. */
|
2800
|
-
for(i=0; i<num; ++i) {
|
2801
|
-
values[i] = va_arg(args,Value);
|
2802
|
-
}
|
2803
2818
|
/* check if all the sub values are numeric. */
|
2804
2819
|
for(i=0; i<num; ++i) {
|
2805
2820
|
if (!values[i]->numeric) {
|
@@ -2831,11 +2846,25 @@ Value concat_value(int num, int dir, Value dst, ...) {
|
|
2831
2846
|
/* The sub values are now all bitstrings. */
|
2832
2847
|
concat_value_bitstring_array(num,dir,dst,values);
|
2833
2848
|
}
|
2849
|
+
return dst;
|
2850
|
+
}
|
2851
|
+
Value concat_valueV(int num, int dir, Value dst, va_list args) {
|
2852
|
+
int i;
|
2853
|
+
Value* values = alloca(num*sizeof(Value)); /* The values to concatenate. */
|
2854
|
+
/* Copy the arguments to values for easier processing. */
|
2855
|
+
for(i=0; i<num; ++i) {
|
2856
|
+
values[i] = va_arg(args,Value);
|
2857
|
+
}
|
2858
|
+
return concat_valueP(num,dir,dst,values);
|
2859
|
+
}
|
2860
|
+
Value concat_value(int num, int dir, Value dst, ...) {
|
2861
|
+
va_list args;
|
2862
|
+
va_start(args,dst);
|
2863
|
+
dst = concat_valueV(num,dir,dst,args);
|
2834
2864
|
va_end(args);
|
2835
2865
|
return dst;
|
2836
2866
|
}
|
2837
2867
|
|
2838
|
-
|
2839
2868
|
/** Casts a value to another type.
|
2840
2869
|
* @param src the source value
|
2841
2870
|
* @param type the type to cast to
|
@@ -0,0 +1,239 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <stdarg.h>
|
3
|
+
#include <stdlib.h>
|
4
|
+
#include <string.h>
|
5
|
+
#include <limits.h>
|
6
|
+
#include "hruby_sim.h"
|
7
|
+
|
8
|
+
|
9
|
+
/**
|
10
|
+
* The HDLRuby simulation stack calculation engine, to be used with C code
|
11
|
+
* generated by hruby_low2c.
|
12
|
+
**/
|
13
|
+
|
14
|
+
/* The stack variables. */
|
15
|
+
#define STACK_SIZE 0x10000
|
16
|
+
static Value stack[STACK_SIZE];
|
17
|
+
static int head = STACK_SIZE;
|
18
|
+
|
19
|
+
/** Push a value.
|
20
|
+
* @param val the value to push. */
|
21
|
+
void push(Value val) {
|
22
|
+
if (head > 0) {
|
23
|
+
stack[--head] = val;
|
24
|
+
} else {
|
25
|
+
perror("Computation stack full.\n");
|
26
|
+
exit(1);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
/** Pops a value.
|
31
|
+
* @return the value. */
|
32
|
+
Value pop() {
|
33
|
+
if (head < STACK_SIZE) {
|
34
|
+
return stack[head++];
|
35
|
+
} else {
|
36
|
+
perror("Computation stack empty.\n");
|
37
|
+
exit(1);
|
38
|
+
}
|
39
|
+
}
|
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
|
+
|
52
|
+
/** Pops multiple values.
|
53
|
+
* @param num the number of values to pop.
|
54
|
+
* @return a pointer on the first value (in heap order!). */
|
55
|
+
static Value* popn(int num) {
|
56
|
+
if (head+num <= STACK_SIZE) {
|
57
|
+
head += num;
|
58
|
+
return &stack[head-num];
|
59
|
+
} else {
|
60
|
+
perror("Not enough values in computation stack.\n");
|
61
|
+
exit(1);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
/** Unary calculation.
|
67
|
+
* @param oper the operator function
|
68
|
+
* @return the destination
|
69
|
+
**/
|
70
|
+
Value unary(Value (*oper)(Value,Value)) {
|
71
|
+
// printf("unary\n");
|
72
|
+
// Value dst = get_top_value();
|
73
|
+
// dst = oper(pop(),dst);
|
74
|
+
// push(dst);
|
75
|
+
// return dst;
|
76
|
+
return oper(pop(),peek());
|
77
|
+
}
|
78
|
+
|
79
|
+
/** Binary calculation.
|
80
|
+
* @param oper the operator function
|
81
|
+
* @return the destination
|
82
|
+
**/
|
83
|
+
Value binary(Value (*oper)(Value,Value,Value)) {
|
84
|
+
// printf("binary\n");
|
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;
|
91
|
+
Value r = pop();
|
92
|
+
Value l = pop();
|
93
|
+
return oper(l,r,peek());
|
94
|
+
}
|
95
|
+
|
96
|
+
/** Cast calculation.
|
97
|
+
* @param typ the type to cast to.
|
98
|
+
* @return the destination.
|
99
|
+
**/
|
100
|
+
Value cast(Type typ) {
|
101
|
+
// printf("cast\n");
|
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());
|
108
|
+
}
|
109
|
+
|
110
|
+
/* Concat values.
|
111
|
+
* @param num the number of values to concat.
|
112
|
+
* @param dir the direction. */
|
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;
|
123
|
+
Value* vals = alloca(num*sizeof(Value));
|
124
|
+
int i;
|
125
|
+
// printf("sconcat\n");
|
126
|
+
/* Get the values to concat from the stack. */
|
127
|
+
for(i=1;i<=num;++i) vals[num-i] = pop();
|
128
|
+
return concat_valueP(num,dir,peek(),vals);
|
129
|
+
}
|
130
|
+
|
131
|
+
/* Index read calculation.
|
132
|
+
* @param typ the data type of the access. */
|
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;
|
140
|
+
// printf("sreadI\n");
|
141
|
+
unsigned long long idx = value2integer(pop());
|
142
|
+
return read_range(pop(),idx,idx,typ,peek());
|
143
|
+
}
|
144
|
+
|
145
|
+
/* Index write calculation.
|
146
|
+
* @param typ the data type of the access. */
|
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;
|
154
|
+
// printf("swriteI\n");
|
155
|
+
unsigned long long idx = value2integer(pop());
|
156
|
+
return write_range(pop(),idx,idx,typ,peek());
|
157
|
+
}
|
158
|
+
|
159
|
+
/* Range read calculation.
|
160
|
+
* @param typ the data type of the access. */
|
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;
|
169
|
+
// printf("sreadR\n");
|
170
|
+
unsigned long long last = value2integer(pop());
|
171
|
+
unsigned long long first = value2integer(pop());
|
172
|
+
return read_range(pop(),first,last,typ,peek());
|
173
|
+
}
|
174
|
+
|
175
|
+
/* Range write calculation.
|
176
|
+
* @param typ the data type of the access. */
|
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;
|
185
|
+
// printf("swriteR\n");
|
186
|
+
unsigned long long last = value2integer(pop());
|
187
|
+
unsigned long long first = value2integer(pop());
|
188
|
+
return write_range(pop(),first,last,typ,peek());
|
189
|
+
}
|
190
|
+
|
191
|
+
/** Check if the top value is defined. */
|
192
|
+
int is_defined() {
|
193
|
+
return is_defined_value(pop());
|
194
|
+
}
|
195
|
+
|
196
|
+
/** Convert the top value to an integer. */
|
197
|
+
unsigned long long to_integer() {
|
198
|
+
return value2integer(pop());
|
199
|
+
}
|
200
|
+
|
201
|
+
/** Check if a value is true.
|
202
|
+
* Actually check if it is defined and convert it to integer. */
|
203
|
+
unsigned long long is_true() {
|
204
|
+
Value val = pop();
|
205
|
+
if (is_defined_value(val)) {
|
206
|
+
return value2integer(val);
|
207
|
+
} else {
|
208
|
+
return 0;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
/** Transmit the top value to a signal in parallel.
|
213
|
+
* @param sig the signal to transmit to. */
|
214
|
+
void transmit(SignalI sig) {
|
215
|
+
// printf("transmit\n");
|
216
|
+
transmit_to_signal(pop(),sig);
|
217
|
+
}
|
218
|
+
|
219
|
+
/** Transmit the top value to a signal in sequence.
|
220
|
+
* @param sig the signal to transmit to. */
|
221
|
+
void transmit_seq(SignalI sig) {
|
222
|
+
// printf("transmit_seq\n");
|
223
|
+
transmit_to_signal_seq(pop(),sig);
|
224
|
+
}
|
225
|
+
|
226
|
+
/** Transmit a value to a range in a signal in parallel.
|
227
|
+
* @param ref the ref to the range of the signal to transmit to. */
|
228
|
+
void transmitR(RefRangeS ref) {
|
229
|
+
// printf("transmitR\n");
|
230
|
+
transmit_to_signal_range(pop(),ref);
|
231
|
+
}
|
232
|
+
|
233
|
+
/** Transmit a value to a range in a signal in sequence.
|
234
|
+
* @param ref the ref to the range of the signal to transmit to. */
|
235
|
+
void transmitR_seq(RefRangeS ref) {
|
236
|
+
// printf("transmitR_seq\n");
|
237
|
+
transmit_to_signal_range_seq(pop(),ref);
|
238
|
+
}
|
239
|
+
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <stdarg.h>
|
3
|
+
#include <stdlib.h>
|
4
|
+
#include <string.h>
|
5
|
+
#include <limits.h>
|
6
|
+
#include "hruby_sim.h"
|
7
|
+
|
8
|
+
#ifndef alloca
|
9
|
+
#define alloca(x) __builtin_alloca(x)
|
10
|
+
#endif
|
11
|
+
|
12
|
+
|
13
|
+
/**
|
14
|
+
* The HDLRuby simulation stack calculation engine, to be used with C code
|
15
|
+
* generated by hruby_low2c.
|
16
|
+
**/
|
17
|
+
|
18
|
+
|
19
|
+
/** Unary calculation.
|
20
|
+
* @param src0 the left value
|
21
|
+
* @param oper the operator function
|
22
|
+
* @return the destination
|
23
|
+
**/
|
24
|
+
Value unary(Value src0, Value (*oper)(Value,Value)) {
|
25
|
+
Value dst = get_value();
|
26
|
+
unsigned int pool_state = get_value_pos();
|
27
|
+
dst = oper(src0,dst);
|
28
|
+
set_value_pos(pool_state);
|
29
|
+
return dst;
|
30
|
+
}
|
31
|
+
|
32
|
+
/** Binary calculation.
|
33
|
+
* @param src0 the left value
|
34
|
+
* @param src1 the right value
|
35
|
+
* @param oper the operator function
|
36
|
+
* @return the destination
|
37
|
+
**/
|
38
|
+
Value binary(Value src0, Value src1, Value (*oper)(Value,Value,Value)) {
|
39
|
+
Value dst = get_value();
|
40
|
+
unsigned int pool_state = get_value_pos();
|
41
|
+
dst = oper(src0,src1,dst);
|
42
|
+
set_value_pos(pool_state);
|
43
|
+
return dst;
|
44
|
+
}
|
45
|
+
|
46
|
+
/** Cast calculation.
|
47
|
+
* @param src0 the value to cast.
|
48
|
+
* @param typ the type to cast to.
|
49
|
+
* @return the destination.
|
50
|
+
**/
|
51
|
+
Value cast(Value src0, Type typ) {
|
52
|
+
Value dst = get_value();
|
53
|
+
unsigned int pool_state = get_value_pos();
|
54
|
+
dst = cast_value(src0,typ,dst);
|
55
|
+
set_value_pos(pool_state);
|
56
|
+
return dst;
|
57
|
+
}
|
58
|
+
|
59
|
+
/* Concat values.
|
60
|
+
* @param num the number of values to concat.
|
61
|
+
* @param dir the direction.
|
62
|
+
* @param vals the values to concat. */
|
63
|
+
Value sconcat(int num, int dir, ...) {
|
64
|
+
Value dst = get_value();
|
65
|
+
unsigned int pool_state = get_value_pos();
|
66
|
+
va_list args;
|
67
|
+
va_start(args,dir);
|
68
|
+
dst = concat_valueV(num,dir,dst,args);
|
69
|
+
va_end(args);
|
70
|
+
set_value_pos(pool_state);
|
71
|
+
return dst;
|
72
|
+
}
|
73
|
+
|
74
|
+
/* Read access calculation.
|
75
|
+
* @param src0 the value to access in.
|
76
|
+
* @param first the start index.
|
77
|
+
* @param last the end index.
|
78
|
+
* @param typ the data type of the access. */
|
79
|
+
Value sread(Value src0, unsigned long long first,
|
80
|
+
unsigned long long last, Type typ) {
|
81
|
+
Value dst = get_value();
|
82
|
+
unsigned int pool_state = get_value_pos();
|
83
|
+
dst = read_range(src0,first,last,typ,dst);
|
84
|
+
set_value_pos(pool_state);
|
85
|
+
return dst;
|
86
|
+
}
|
87
|
+
|
88
|
+
/* Write access calculation.
|
89
|
+
* @param src0 the value to access in.
|
90
|
+
* @param first the start index.
|
91
|
+
* @param last the end index.
|
92
|
+
* @param typ the data type of the access. */
|
93
|
+
Value swrite(Value src0, unsigned long long first,
|
94
|
+
unsigned long long last, Type typ) {
|
95
|
+
Value dst = get_value();
|
96
|
+
unsigned int pool_state = get_value_pos();
|
97
|
+
dst = write_range(src0,first,last,typ,dst);
|
98
|
+
set_value_pos(pool_state);
|
99
|
+
return dst;
|
100
|
+
}
|
@@ -47,6 +47,16 @@ Value get_value() {
|
|
47
47
|
return pool_values[pool_pos++];
|
48
48
|
}
|
49
49
|
|
50
|
+
/** Get the current top value. */
|
51
|
+
Value get_top_value() {
|
52
|
+
if (pool_pos > 0)
|
53
|
+
return pool_values[pool_pos-1];
|
54
|
+
else {
|
55
|
+
perror("Pool of values is empty.");
|
56
|
+
exit(1);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
50
60
|
/** Frees the last value of the pool. */
|
51
61
|
void free_value() {
|
52
62
|
if (pool_pos > 0) pool_pos--;
|
@@ -62,3 +72,29 @@ unsigned int get_value_pos() {
|
|
62
72
|
void set_value_pos(unsigned int pos) {
|
63
73
|
pool_pos = pos;
|
64
74
|
}
|
75
|
+
|
76
|
+
|
77
|
+
#define POOL_STATE_STACK_SIZE 0x10000
|
78
|
+
/* The stack of pool states. */
|
79
|
+
static unsigned int pool_state_stack[POOL_STATE_STACK_SIZE];
|
80
|
+
static int pool_state_head = POOL_STATE_STACK_SIZE;
|
81
|
+
|
82
|
+
/** Saves to current state of the value pool to the pool state stack. */
|
83
|
+
extern void save_value_pos() {
|
84
|
+
if (pool_state_head > 0) {
|
85
|
+
pool_state_stack[--pool_state_head] = get_value_pos();
|
86
|
+
} else {
|
87
|
+
perror("Pool state stack full.");
|
88
|
+
exit(1);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
/** Restores the state of the value pool from the state stack. */
|
93
|
+
extern void restore_value_pos() {
|
94
|
+
if (pool_state_head < POOL_STATE_STACK_SIZE) {
|
95
|
+
set_value_pos(pool_state_stack[pool_state_head++]);
|
96
|
+
} else {
|
97
|
+
perror("Pool state stack empty.");
|
98
|
+
exit(1);
|
99
|
+
}
|
100
|
+
}
|
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:
|
11
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/HDLRuby/hdr_samples/alu.rb
|
84
84
|
- lib/HDLRuby/hdr_samples/bstr_bench.rb
|
85
85
|
- lib/HDLRuby/hdr_samples/calculator.rb
|
86
|
+
- lib/HDLRuby/hdr_samples/case_bench.rb
|
86
87
|
- lib/HDLRuby/hdr_samples/comparison_bench.rb
|
87
88
|
- lib/HDLRuby/hdr_samples/constant_in_function.rb
|
88
89
|
- lib/HDLRuby/hdr_samples/counter_bench.rb
|
@@ -92,7 +93,9 @@ files:
|
|
92
93
|
- lib/HDLRuby/hdr_samples/dff_properties.rb
|
93
94
|
- lib/HDLRuby/hdr_samples/dff_unit.rb
|
94
95
|
- lib/HDLRuby/hdr_samples/huge_rom.rb
|
96
|
+
- lib/HDLRuby/hdr_samples/if_bench.rb
|
95
97
|
- lib/HDLRuby/hdr_samples/include.rb
|
98
|
+
- lib/HDLRuby/hdr_samples/index_bench.rb
|
96
99
|
- lib/HDLRuby/hdr_samples/instance_open.rb
|
97
100
|
- lib/HDLRuby/hdr_samples/linear_test.rb
|
98
101
|
- lib/HDLRuby/hdr_samples/logic_bench.rb
|
@@ -124,6 +127,7 @@ files:
|
|
124
127
|
- lib/HDLRuby/hdr_samples/neural/z.rb
|
125
128
|
- lib/HDLRuby/hdr_samples/prog.obj
|
126
129
|
- lib/HDLRuby/hdr_samples/ram.rb
|
130
|
+
- lib/HDLRuby/hdr_samples/range_bench.rb
|
127
131
|
- lib/HDLRuby/hdr_samples/register_with_code_bench.rb
|
128
132
|
- lib/HDLRuby/hdr_samples/rom.rb
|
129
133
|
- lib/HDLRuby/hdr_samples/ruby_fir_hw.rb
|
@@ -136,8 +140,10 @@ files:
|
|
136
140
|
- lib/HDLRuby/hdr_samples/system_open.rb
|
137
141
|
- lib/HDLRuby/hdr_samples/tuple.rb
|
138
142
|
- lib/HDLRuby/hdr_samples/type_minmax_bench.rb
|
143
|
+
- lib/HDLRuby/hdr_samples/with_casts.rb
|
139
144
|
- lib/HDLRuby/hdr_samples/with_channel.rb
|
140
145
|
- lib/HDLRuby/hdr_samples/with_class.rb
|
146
|
+
- lib/HDLRuby/hdr_samples/with_concat.rb
|
141
147
|
- lib/HDLRuby/hdr_samples/with_connector.rb
|
142
148
|
- lib/HDLRuby/hdr_samples/with_connector_memory.rb
|
143
149
|
- lib/HDLRuby/hdr_samples/with_decoder.rb
|
@@ -151,7 +157,12 @@ files:
|
|
151
157
|
- lib/HDLRuby/hdr_samples/with_multi_channels.rb
|
152
158
|
- lib/HDLRuby/hdr_samples/with_reconf.rb
|
153
159
|
- lib/HDLRuby/hdr_samples/with_reduce.rb
|
160
|
+
- lib/HDLRuby/hdr_samples/with_ref_array.rb
|
161
|
+
- lib/HDLRuby/hdr_samples/with_str2value.rb
|
162
|
+
- lib/HDLRuby/hdr_samples/with_subsums.rb
|
163
|
+
- lib/HDLRuby/hdr_samples/with_to_a.rb
|
154
164
|
- lib/HDLRuby/hdr_samples/with_to_array.rb
|
165
|
+
- lib/HDLRuby/hdr_samples/with_values.rb
|
155
166
|
- lib/HDLRuby/hdrcc.rb
|
156
167
|
- lib/HDLRuby/high_samples/_adder_fault.rb
|
157
168
|
- lib/HDLRuby/high_samples/_generic_transmission2.rb
|
@@ -294,6 +305,8 @@ files:
|
|
294
305
|
- lib/HDLRuby/sim/hruby_sim_calc.c
|
295
306
|
- lib/HDLRuby/sim/hruby_sim_core.c
|
296
307
|
- lib/HDLRuby/sim/hruby_sim_list.c
|
308
|
+
- lib/HDLRuby/sim/hruby_sim_stack_calc.c
|
309
|
+
- lib/HDLRuby/sim/hruby_sim_stack_calc.c.sav
|
297
310
|
- lib/HDLRuby/sim/hruby_sim_vcd.c
|
298
311
|
- lib/HDLRuby/sim/hruby_sim_vizualize.c
|
299
312
|
- lib/HDLRuby/sim/hruby_value_pool.c
|