HDLRuby 3.9.1 → 3.9.5
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.html +4121 -4648
- data/README.md +16 -1
- data/ext/hruby_sim/hruby_rcsim_build.c +26 -0
- data/ext/hruby_sim/hruby_sim.h +6 -0
- data/ext/hruby_sim/hruby_sim_calc.c +68 -1
- data/lib/HDLRuby/hdr_samples/constant_prop_bench.rb +2 -2
- data/lib/HDLRuby/hdr_samples/with_henumerable.rb +281 -258
- data/lib/HDLRuby/hdr_samples/with_to_svg.rb +37 -0
- data/lib/HDLRuby/hdr_samples/with_unary_reduction.rb +23 -0
- data/lib/HDLRuby/hdr_samples/with_values.rb +4 -0
- data/lib/HDLRuby/hdrcc.rb +3 -0
- data/lib/HDLRuby/hruby_bstr.rb +2 -1
- data/lib/HDLRuby/hruby_high.rb +36 -8
- data/lib/HDLRuby/hruby_low.rb +52 -87
- data/lib/HDLRuby/hruby_low_split_signals.rb +213 -0
- data/lib/HDLRuby/hruby_rcsim.rb +6 -1
- data/lib/HDLRuby/hruby_types.rb +6 -2
- data/lib/HDLRuby/hruby_viz.rb +1099 -792
- data/lib/HDLRuby/std/hruby_enum.rb +104 -28
- data/lib/HDLRuby/std/sequencer.rb +23 -10
- data/lib/HDLRuby/verilog_hruby.rb +70 -28
- data/lib/HDLRuby/verilog_parser.rb +38 -18
- data/lib/HDLRuby/version.rb +1 -1
- metadata +5 -2
data/README.md
CHANGED
|
@@ -71,7 +71,18 @@ hdrcc --get-tuto
|
|
|
71
71
|
|
|
72
72
|
__What's New__
|
|
73
73
|
|
|
74
|
-
For HDLRuby version 3.9.
|
|
74
|
+
For HDLRuby version 3.9.3/3.9.4/3.9.5:
|
|
75
|
+
|
|
76
|
+
* Improved the graphical representation of the RTL code in SVG format for faster generation and better rendering. The tool is still experimental though.
|
|
77
|
+
|
|
78
|
+
* Fixed various bugs.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
For HDLRuby version 3.9.2:
|
|
82
|
+
|
|
83
|
+
* Added the `hbreak` command for exiting parallel enumerator loops.
|
|
84
|
+
|
|
85
|
+
For HDLRuby version 3.9.0/3.9.1:
|
|
75
86
|
|
|
76
87
|
* Added the parallel enumerators to the software sequencers.
|
|
77
88
|
|
|
@@ -3981,6 +3992,10 @@ Parallel enumerators provide several control methods:
|
|
|
3981
3992
|
|
|
3982
3993
|
* `+`: Concatenates two enumerators.
|
|
3983
3994
|
|
|
3995
|
+
Additionaly, it is possible to exit an enumeration loop using the following command:
|
|
3996
|
+
|
|
3997
|
+
* `hbreak`: Exits the current enumeration loop.
|
|
3998
|
+
|
|
3984
3999
|
__Hardware Implementations of Enumerable Methods__
|
|
3985
4000
|
|
|
3986
4001
|
Using parallel enumerators, HDLRuby provides hardware implementations of many Ruby Enumerable methods. These are available for any enumerable object and can be used inside or outside processes.
|
|
@@ -688,6 +688,7 @@ VALUE rcsim_make_value_numeric(VALUE mod, VALUE typeV, VALUE contentV) {
|
|
|
688
688
|
/* Get the type. */
|
|
689
689
|
Type type;
|
|
690
690
|
value_to_rcsim(TypeS,typeV,type);
|
|
691
|
+
// printf("type=%llu\n",type_width(type));
|
|
691
692
|
/* Create the value. */
|
|
692
693
|
Value value = make_value(type,0);
|
|
693
694
|
// printf("value=%p\n",value);
|
|
@@ -703,6 +704,28 @@ VALUE rcsim_make_value_numeric(VALUE mod, VALUE typeV, VALUE contentV) {
|
|
|
703
704
|
return res;
|
|
704
705
|
}
|
|
705
706
|
|
|
707
|
+
/* Creating a numeric value C object forcing bit 63 to one. */
|
|
708
|
+
VALUE rcsim_make_value_numeric_63one(VALUE mod, VALUE typeV, VALUE contentV) {
|
|
709
|
+
// printf("rcsim_make_value_numeric_63one\n");
|
|
710
|
+
/* Get the type. */
|
|
711
|
+
Type type;
|
|
712
|
+
value_to_rcsim(TypeS,typeV,type);
|
|
713
|
+
// printf("type=%llu\n",type_width(type));
|
|
714
|
+
/* Create the value. */
|
|
715
|
+
Value value = make_value(type,0);
|
|
716
|
+
// printf("value=%p\n",value);
|
|
717
|
+
/* Set it to numeric. */
|
|
718
|
+
value->numeric = 1;
|
|
719
|
+
value->capacity = 0;
|
|
720
|
+
value->data_str = NULL;
|
|
721
|
+
value->data_int = NUM2LL(contentV) | 0x8000000000000000ULL;
|
|
722
|
+
// printf("value->data_int=%lld\n",value->data_int);
|
|
723
|
+
/* Returns the C value embedded into a ruby VALUE. */
|
|
724
|
+
VALUE res;
|
|
725
|
+
rcsim_to_value(ValueS,value,res);
|
|
726
|
+
return res;
|
|
727
|
+
}
|
|
728
|
+
|
|
706
729
|
|
|
707
730
|
/* Creating a bitstring value C object. */
|
|
708
731
|
VALUE rcsim_make_value_bitstring(VALUE mod, VALUE typeV, VALUE contentV) {
|
|
@@ -760,6 +783,8 @@ VALUE rcsim_make_unary(VALUE mod, VALUE type, VALUE operator, VALUE child) {
|
|
|
760
783
|
switch(sym_to_char(operator)) {
|
|
761
784
|
case (unsigned char)'~': unary->oper = not_value; break;
|
|
762
785
|
case (unsigned char)('-'+'@'*2): unary->oper = neg_value; break;
|
|
786
|
+
case (unsigned char)'|': unary->oper = reduce_or_value; break;
|
|
787
|
+
case (unsigned char)'&': unary->oper = reduce_and_value; break;
|
|
763
788
|
default: perror("Invalid operator for unary.");
|
|
764
789
|
}
|
|
765
790
|
value_to_rcsim(ExpressionS,child,unary->child);
|
|
@@ -1904,6 +1929,7 @@ void Init_hruby_sim() {
|
|
|
1904
1929
|
rb_define_singleton_method(mod,"rcsim_make_hcase",rcsim_make_hcase,2);
|
|
1905
1930
|
rb_define_singleton_method(mod,"rcsim_make_block",rcsim_make_block,1);
|
|
1906
1931
|
rb_define_singleton_method(mod,"rcsim_make_value_numeric",rcsim_make_value_numeric,2);
|
|
1932
|
+
rb_define_singleton_method(mod,"rcsim_make_value_numeric_63one",rcsim_make_value_numeric_63one,2);
|
|
1907
1933
|
rb_define_singleton_method(mod,"rcsim_make_value_bitstring",rcsim_make_value_bitstring,2);
|
|
1908
1934
|
rb_define_singleton_method(mod,"rcsim_make_cast",rcsim_make_cast,2);
|
|
1909
1935
|
rb_define_singleton_method(mod,"rcsim_make_unary",rcsim_make_unary,3);
|
data/ext/hruby_sim/hruby_sim.h
CHANGED
|
@@ -252,6 +252,12 @@ extern Value not_value(Value src, Value dst);
|
|
|
252
252
|
* @return dst */
|
|
253
253
|
extern Value reduce_or_value(Value src, Value dst);
|
|
254
254
|
|
|
255
|
+
/** Compute the and of the bits a a value.
|
|
256
|
+
* @param src the source value
|
|
257
|
+
* @param dst the destination value
|
|
258
|
+
* @return dst */
|
|
259
|
+
extern Value reduce_and_value(Value src, Value dst);
|
|
260
|
+
|
|
255
261
|
/** Computes the AND of two values.
|
|
256
262
|
* @param src0 the first source value of the and
|
|
257
263
|
* @param src1 the second source value of the and
|
|
@@ -327,6 +327,7 @@ Value copy_value(Value src, Value dst) {
|
|
|
327
327
|
/* Copy the data. */
|
|
328
328
|
if (src->numeric) {
|
|
329
329
|
/* Numeric copy. */
|
|
330
|
+
// printf("copy_value with data_in: %llu\n", src->data_int);
|
|
330
331
|
dst->data_int = fix_numeric_type(dst->type,src->data_int);
|
|
331
332
|
} else {
|
|
332
333
|
// printf("copy_value with bit string: %.*s\n",src->capacity,src->data_str);
|
|
@@ -1348,6 +1349,44 @@ Value reduce_or_value_bitstring(Value src, Value dst) {
|
|
|
1348
1349
|
return dst;
|
|
1349
1350
|
}
|
|
1350
1351
|
|
|
1352
|
+
/** Compute the and of the bits a bitstring value.
|
|
1353
|
+
* @param src the source value
|
|
1354
|
+
* @param dst the destination value
|
|
1355
|
+
* @return dst */
|
|
1356
|
+
Value reduce_and_value_bitstring(Value src, Value dst) {
|
|
1357
|
+
/* Compute the width of the result in bits. */
|
|
1358
|
+
unsigned long long width = type_width(src->type);
|
|
1359
|
+
|
|
1360
|
+
/* Update the destination capacity if required. */
|
|
1361
|
+
resize_value(dst,width);
|
|
1362
|
+
/* Set the type and size of the destination from the type of the source.*/
|
|
1363
|
+
dst->type = src->type;
|
|
1364
|
+
dst->numeric = 0;
|
|
1365
|
+
|
|
1366
|
+
/* Get access to the source and destination data. */
|
|
1367
|
+
char* src_data = src->data_str;
|
|
1368
|
+
char* dst_data = dst->data_str;
|
|
1369
|
+
|
|
1370
|
+
/* Performs the reduce or. */
|
|
1371
|
+
unsigned long long count;
|
|
1372
|
+
char res = 0;
|
|
1373
|
+
for(count = 0; count < width; ++count) {
|
|
1374
|
+
/* Performs the reduce and. */
|
|
1375
|
+
char d = src_data[count] - '0'; /* Get and convert to bit. */
|
|
1376
|
+
if ((d == (d&1)) && (res != 'x'-'0')) { /* d is defined. */
|
|
1377
|
+
res &= d;
|
|
1378
|
+
} else {
|
|
1379
|
+
/* res is undefined. */
|
|
1380
|
+
res = 'x' - '0';
|
|
1381
|
+
}
|
|
1382
|
+
/* Apart for the first bit, there are only 0, still we are in
|
|
1383
|
+
* the loop, set it. */
|
|
1384
|
+
dst_data[count] = '0';
|
|
1385
|
+
}
|
|
1386
|
+
dst_data[0] = res + '0';
|
|
1387
|
+
/* Return the destination. */
|
|
1388
|
+
return dst;
|
|
1389
|
+
}
|
|
1351
1390
|
|
|
1352
1391
|
/** Computes the and of two bitstring values.
|
|
1353
1392
|
* @param src0 the first source value of the and
|
|
@@ -2128,7 +2167,6 @@ fix_numeric_type(Type type, unsigned long long val) {
|
|
|
2128
2167
|
if (type->flags.sign) {
|
|
2129
2168
|
/* Yes, perform sign extension. */
|
|
2130
2169
|
int is_neg = (val >> (width-1)) & 1;
|
|
2131
|
-
// printf("is_neg=%i\n",is_neg);
|
|
2132
2170
|
if (is_neg) {
|
|
2133
2171
|
/* Negative sign extension. */
|
|
2134
2172
|
return val | mask;
|
|
@@ -2280,6 +2318,21 @@ Value reduce_or_value_numeric(Value src, Value dst) {
|
|
|
2280
2318
|
return dst;
|
|
2281
2319
|
}
|
|
2282
2320
|
|
|
2321
|
+
/** Compute the and of the bits a numeric value.
|
|
2322
|
+
* @param src the source value
|
|
2323
|
+
* @param dst the destination value
|
|
2324
|
+
* @return dst */
|
|
2325
|
+
Value reduce_and_value_numeric(Value src, Value dst) {
|
|
2326
|
+
/* Sets state of the destination using the first source. */
|
|
2327
|
+
dst->type = src->type;
|
|
2328
|
+
dst->numeric = 1;
|
|
2329
|
+
|
|
2330
|
+
/* Perform the reduce and. */
|
|
2331
|
+
unsigned long long mask = ~(-1LL << type_width(src->type));
|
|
2332
|
+
dst->data_int = fix_numeric_type(dst->type, (~src->data_int & mask) == 0);
|
|
2333
|
+
return dst;
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2283
2336
|
|
|
2284
2337
|
/** Computes the AND of two numeric values.
|
|
2285
2338
|
* @param src0 the first source value of the addition
|
|
@@ -3061,6 +3114,20 @@ Value reduce_or_value(Value src, Value dst) {
|
|
|
3061
3114
|
}
|
|
3062
3115
|
}
|
|
3063
3116
|
|
|
3117
|
+
/** Compute the and of the bits a value.
|
|
3118
|
+
* @param src the source value
|
|
3119
|
+
* @param dst the destination value
|
|
3120
|
+
* @return dst */
|
|
3121
|
+
Value reduce_and_value(Value src, Value dst) {
|
|
3122
|
+
if (src->numeric) {
|
|
3123
|
+
/* The source is numeric. */
|
|
3124
|
+
return reduce_and_value_numeric(src,dst);
|
|
3125
|
+
} else {
|
|
3126
|
+
/* The source cannot be numeric, compute bitsitrings. */
|
|
3127
|
+
return reduce_and_value_bitstring(src,dst);
|
|
3128
|
+
}
|
|
3129
|
+
}
|
|
3130
|
+
|
|
3064
3131
|
|
|
3065
3132
|
/** Computes the AND of two general values.
|
|
3066
3133
|
* @param src0 the first source value of the addition
|
|
@@ -16,8 +16,8 @@ system :dff_bench do
|
|
|
16
16
|
[8].inner :count
|
|
17
17
|
[8].constant inc: 5
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
counter(:my_counter).(clk,rst,5,count)
|
|
19
|
+
counter(:my_counter).(clk,rst,inc,count)
|
|
20
|
+
# counter(:my_counter).(clk,rst,5,count)
|
|
21
21
|
|
|
22
22
|
# par do
|
|
23
23
|
# my_counter.inc <= 5
|