HDLRuby 3.9.3 → 3.9.6
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 +34 -3
- data/ext/hruby_sim/hruby_rcsim_build.c +47 -0
- data/ext/hruby_sim/hruby_sim.h +29 -1
- data/ext/hruby_sim/hruby_sim_calc.c +142 -19
- data/ext/hruby_sim/hruby_sim_tree_calc.c +37 -0
- data/lib/HDLRuby/hdr_samples/case_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/constant_prop_bench.rb +2 -2
- data/lib/HDLRuby/hdr_samples/logic_bench.rb +12 -12
- data/lib/HDLRuby/hdr_samples/with_assign_to_slice.rb +19 -0
- data/lib/HDLRuby/hdr_samples/with_casez.rb +35 -0
- data/lib/HDLRuby/hdr_samples/with_henumerable.rb +1 -1
- data/lib/HDLRuby/hruby_high.rb +122 -13
- data/lib/HDLRuby/hruby_low.rb +50 -46
- data/lib/HDLRuby/hruby_low_split_signals.rb +2 -2
- data/lib/HDLRuby/hruby_rcsim.rb +13 -3
- data/lib/HDLRuby/hruby_verilog.rb +17 -6
- data/lib/HDLRuby/hruby_viz.rb +827 -713
- data/lib/HDLRuby/std/decoder.rb +2 -2
- data/lib/HDLRuby/std/sequencer.rb +6 -7
- data/lib/HDLRuby/verilog_hruby.rb +30 -0
- data/lib/HDLRuby/verilog_parser.rb +1 -1
- data/lib/HDLRuby/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 00a784914e79391b0aa065086641989892907de384b64b3b43b221587076fcf4
|
|
4
|
+
data.tar.gz: b53f9aa4f668cd8a736f476b4c8b86572ec8572f00f09ba85bfd484e67ff3fc6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0e35ec948e04837424e7a2992a9f06aa15d580305c68688bdf22270b73b762f759bb7c76785f3866dd2abc25a1eaf6835005e622467458e2b9ad04134839ab62
|
|
7
|
+
data.tar.gz: 3a3a557df353dff6b0203dcbc28fc3231d76fd6a7b7b29853061ac5451dc9a375f272f46adbb8b9ad4a838992f27097c443f0817c19d565103c2ffb0a0d343bf
|
data/README.md
CHANGED
|
@@ -71,7 +71,14 @@ hdrcc --get-tuto
|
|
|
71
71
|
|
|
72
72
|
__What's New__
|
|
73
73
|
|
|
74
|
-
For
|
|
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:
|
|
75
82
|
|
|
76
83
|
* Added the `hbreak` command for exiting parallel enumerator loops.
|
|
77
84
|
|
|
@@ -468,7 +475,7 @@ These include:
|
|
|
468
475
|
|
|
469
476
|
* `hif` / `helsif` / `helse` for `if`-like conditionals
|
|
470
477
|
|
|
471
|
-
* `hcase` / `hwhen` / `helse` for `case`-like conditionals
|
|
478
|
+
* `hcase` / `hcasez` / `hwhen` / `helse` for `case`-like conditionals
|
|
472
479
|
|
|
473
480
|
* `mux`, an expression-level construct for multiplexers, which supports multiple inputs, unlike the ?: ternary operator in Verilog, which only handles two
|
|
474
481
|
|
|
@@ -1786,7 +1793,7 @@ The behavior of an assignment statement depends on the execution mode of the enc
|
|
|
1786
1793
|
|
|
1787
1794
|
### Control Statements
|
|
1788
1795
|
|
|
1789
|
-
There are two types of control statements in HDLRuby: the hardware if (`hif`) and the hardware case (`
|
|
1796
|
+
There are two types of control statements in HDLRuby: the hardware if (`hif`) the hardware case (`hcase`), and the hardware case with wildcards (`hcasez`).
|
|
1790
1797
|
|
|
1791
1798
|
#### hif
|
|
1792
1799
|
|
|
@@ -1813,6 +1820,30 @@ end
|
|
|
1813
1820
|
...
|
|
1814
1821
|
```
|
|
1815
1822
|
|
|
1823
|
+
#### hcasez
|
|
1824
|
+
|
|
1825
|
+
The `hcasez` construct consists of an expression and a list of value-block pairs. A block is executed when its corresponding value matches the value of the `hcasez` expression. If the value contains wildcard digits represented by a `z` they match any corresponding digit. It is declared as follows:
|
|
1826
|
+
|
|
1827
|
+
```ruby
|
|
1828
|
+
hcasez <expression>
|
|
1829
|
+
hwhen <value 0> do
|
|
1830
|
+
<block contents 0>
|
|
1831
|
+
end
|
|
1832
|
+
hwhen <value 1> do
|
|
1833
|
+
<block contents 1>
|
|
1834
|
+
end
|
|
1835
|
+
...
|
|
1836
|
+
```
|
|
1837
|
+
|
|
1838
|
+
As an example of wildcard, the following statement will be executed if val is equal to 5 or 7:
|
|
1839
|
+
|
|
1840
|
+
```ruby
|
|
1841
|
+
hcasez val
|
|
1842
|
+
hwhen _b01z1 do
|
|
1843
|
+
<block contents 0>
|
|
1844
|
+
end
|
|
1845
|
+
```
|
|
1846
|
+
|
|
1816
1847
|
#### helse
|
|
1817
1848
|
|
|
1818
1849
|
You can add a block that is executed when the condition of an `hif` is not met, or when no case in an hcase matches, using the `helse` keyword:
|
|
@@ -659,6 +659,28 @@ VALUE rcsim_make_hcase(VALUE mod, VALUE valueV, VALUE defoltV) {
|
|
|
659
659
|
return res;
|
|
660
660
|
}
|
|
661
661
|
|
|
662
|
+
/* Creating a hardware casez C object. */
|
|
663
|
+
VALUE rcsim_make_hcasez(VALUE mod, VALUE valueV, VALUE defoltV) {
|
|
664
|
+
// printf("rcsim_make_hcasez\n");
|
|
665
|
+
/* Allocates the hardware case. */
|
|
666
|
+
HCaseZ hcasez = (HCaseZ)malloc(sizeof(HCaseZS));
|
|
667
|
+
// printf("hcasez=%p\n",hcasez);
|
|
668
|
+
/* Set it up. */
|
|
669
|
+
hcasez->kind = HCASEZ;
|
|
670
|
+
hcasez->owner = NULL;
|
|
671
|
+
value_to_rcsim(ExpressionS,valueV,hcasez->value);
|
|
672
|
+
hcasez->num_whens = 0;
|
|
673
|
+
hcasez->matches = NULL;
|
|
674
|
+
hcasez->stmnts = NULL;
|
|
675
|
+
if (TYPE(defoltV) == T_NIL)
|
|
676
|
+
hcasez->defolt = NULL;
|
|
677
|
+
else
|
|
678
|
+
value_to_rcsim(StatementS,defoltV,hcasez->defolt);
|
|
679
|
+
/* Returns the C hardware case embedded into a ruby VALUE. */
|
|
680
|
+
VALUE res;
|
|
681
|
+
rcsim_to_value(HCaseZS,hcasez,res);
|
|
682
|
+
return res;
|
|
683
|
+
}
|
|
662
684
|
|
|
663
685
|
/* Creating a block C object. */
|
|
664
686
|
VALUE rcsim_make_block(VALUE mod, VALUE modeV) {
|
|
@@ -688,6 +710,7 @@ VALUE rcsim_make_value_numeric(VALUE mod, VALUE typeV, VALUE contentV) {
|
|
|
688
710
|
/* Get the type. */
|
|
689
711
|
Type type;
|
|
690
712
|
value_to_rcsim(TypeS,typeV,type);
|
|
713
|
+
// printf("type=%llu\n",type_width(type));
|
|
691
714
|
/* Create the value. */
|
|
692
715
|
Value value = make_value(type,0);
|
|
693
716
|
// printf("value=%p\n",value);
|
|
@@ -703,6 +726,28 @@ VALUE rcsim_make_value_numeric(VALUE mod, VALUE typeV, VALUE contentV) {
|
|
|
703
726
|
return res;
|
|
704
727
|
}
|
|
705
728
|
|
|
729
|
+
/* Creating a numeric value C object forcing bit 63 to one. */
|
|
730
|
+
VALUE rcsim_make_value_numeric_63one(VALUE mod, VALUE typeV, VALUE contentV) {
|
|
731
|
+
// printf("rcsim_make_value_numeric_63one\n");
|
|
732
|
+
/* Get the type. */
|
|
733
|
+
Type type;
|
|
734
|
+
value_to_rcsim(TypeS,typeV,type);
|
|
735
|
+
// printf("type=%llu\n",type_width(type));
|
|
736
|
+
/* Create the value. */
|
|
737
|
+
Value value = make_value(type,0);
|
|
738
|
+
// printf("value=%p\n",value);
|
|
739
|
+
/* Set it to numeric. */
|
|
740
|
+
value->numeric = 1;
|
|
741
|
+
value->capacity = 0;
|
|
742
|
+
value->data_str = NULL;
|
|
743
|
+
value->data_int = NUM2LL(contentV) | 0x8000000000000000ULL;
|
|
744
|
+
// printf("value->data_int=%lld\n",value->data_int);
|
|
745
|
+
/* Returns the C value embedded into a ruby VALUE. */
|
|
746
|
+
VALUE res;
|
|
747
|
+
rcsim_to_value(ValueS,value,res);
|
|
748
|
+
return res;
|
|
749
|
+
}
|
|
750
|
+
|
|
706
751
|
|
|
707
752
|
/* Creating a bitstring value C object. */
|
|
708
753
|
VALUE rcsim_make_value_bitstring(VALUE mod, VALUE typeV, VALUE contentV) {
|
|
@@ -1904,8 +1949,10 @@ void Init_hruby_sim() {
|
|
|
1904
1949
|
rb_define_singleton_method(mod,"rcsim_make_timeTerminate",rcsim_make_timeTerminate,0);
|
|
1905
1950
|
rb_define_singleton_method(mod,"rcsim_make_hif",rcsim_make_hif,3);
|
|
1906
1951
|
rb_define_singleton_method(mod,"rcsim_make_hcase",rcsim_make_hcase,2);
|
|
1952
|
+
rb_define_singleton_method(mod,"rcsim_make_hcasez",rcsim_make_hcasez,2);
|
|
1907
1953
|
rb_define_singleton_method(mod,"rcsim_make_block",rcsim_make_block,1);
|
|
1908
1954
|
rb_define_singleton_method(mod,"rcsim_make_value_numeric",rcsim_make_value_numeric,2);
|
|
1955
|
+
rb_define_singleton_method(mod,"rcsim_make_value_numeric_63one",rcsim_make_value_numeric_63one,2);
|
|
1909
1956
|
rb_define_singleton_method(mod,"rcsim_make_value_bitstring",rcsim_make_value_bitstring,2);
|
|
1910
1957
|
rb_define_singleton_method(mod,"rcsim_make_cast",rcsim_make_cast,2);
|
|
1911
1958
|
rb_define_singleton_method(mod,"rcsim_make_unary",rcsim_make_unary,3);
|
data/ext/hruby_sim/hruby_sim.h
CHANGED
|
@@ -27,6 +27,7 @@ typedef struct TransmitS_ TransmitS;
|
|
|
27
27
|
typedef struct PrintS_ PrintS;
|
|
28
28
|
typedef struct HIfS_ HIfS;
|
|
29
29
|
typedef struct HCaseS_ HCaseS;
|
|
30
|
+
typedef struct HCaseZS_ HCaseZS;
|
|
30
31
|
typedef struct TimeWaitS_ TimeWaitS;
|
|
31
32
|
typedef struct TimeRepeatS_ TimeRepeatS;
|
|
32
33
|
typedef struct TimeTerminateS_ TimeTerminateS;
|
|
@@ -63,6 +64,7 @@ typedef struct TransmitS_* Transmit;
|
|
|
63
64
|
typedef struct PrintS_* Print;
|
|
64
65
|
typedef struct HIfS_* HIf;
|
|
65
66
|
typedef struct HCaseS_* HCase;
|
|
67
|
+
typedef struct HCaseZS_* HCaseZ;
|
|
66
68
|
typedef struct TimeWaitS_* TimeWait;
|
|
67
69
|
typedef struct TimeRepeatS_* TimeRepeat;
|
|
68
70
|
typedef struct TimeTerminateS_* TimeTerminate;
|
|
@@ -91,7 +93,7 @@ typedef enum {
|
|
|
91
93
|
#endif
|
|
92
94
|
OBJECT, SYSTEMT, SIGNALI, SCOPE, BEHAVIOR, SYSTEMI, CODE, BLOCK, EVENT,
|
|
93
95
|
#ifdef RCSIM
|
|
94
|
-
/* Statements */ TRANSMIT, PRINT, HIF, HCASE,
|
|
96
|
+
/* Statements */ TRANSMIT, PRINT, HIF, HCASE, HCASEZ,
|
|
95
97
|
TIME_WAIT, TIME_REPEAT, TIME_TERMINATE,
|
|
96
98
|
/* Expressions */ UNARY, BINARY, SELECT, CONCAT, CAST,
|
|
97
99
|
/* References */ REF_OBJECT, REF_INDEX, REF_RANGE, REF_CONCAT,
|
|
@@ -300,6 +302,13 @@ Value shift_right_value(Value src0, Value src1, Value dst);
|
|
|
300
302
|
* @return dst */
|
|
301
303
|
extern Value equal_value(Value src0, Value src1, Value dst);
|
|
302
304
|
|
|
305
|
+
/** Computes the equal (NXOR) of two values treating Z as wildcards.
|
|
306
|
+
* @param src0 the first source value of the comparison
|
|
307
|
+
* @param src1 the second source value of the comparison
|
|
308
|
+
* @param dst the destination value
|
|
309
|
+
* @return dst */
|
|
310
|
+
extern Value equal_value_z(Value src0, Value src1, Value dst);
|
|
311
|
+
|
|
303
312
|
/** Computes the C equal of two general values.
|
|
304
313
|
* @param src0 the first source value of the addition
|
|
305
314
|
* @param src1 the second source value of the addition
|
|
@@ -307,6 +316,13 @@ extern Value equal_value(Value src0, Value src1, Value dst);
|
|
|
307
316
|
* @return the destination value */
|
|
308
317
|
extern Value equal_value_c(Value src0, Value src1, Value dst);
|
|
309
318
|
|
|
319
|
+
/** Computes the C equal of two general values treating Z as wildcards.
|
|
320
|
+
* @param src0 the first source value of the addition
|
|
321
|
+
* @param src1 the second source value of the addition
|
|
322
|
+
* @param dst the destination value
|
|
323
|
+
* @return the destination value */
|
|
324
|
+
extern Value equal_value_z_c(Value src0, Value src1, Value dst);
|
|
325
|
+
|
|
310
326
|
/** Computes the C not equal of two general values.
|
|
311
327
|
* @param src0 the first source value of the addition
|
|
312
328
|
* @param src1 the second source value of the addition
|
|
@@ -701,6 +717,18 @@ typedef struct HCaseS_ {
|
|
|
701
717
|
Statement defolt; /* The default statement. */
|
|
702
718
|
} HCaseS;
|
|
703
719
|
|
|
720
|
+
/** The C model of a hardware casez statement. */
|
|
721
|
+
typedef struct HCaseZS_ {
|
|
722
|
+
Kind kind; /* The kind of object. */
|
|
723
|
+
Object owner; /* The owner of the object if any. */
|
|
724
|
+
|
|
725
|
+
Expression value; /* The value to match. */
|
|
726
|
+
int num_whens; /* The number of possible cases. */
|
|
727
|
+
Expression* matches;/* The cases matching values. */
|
|
728
|
+
Statement* stmnts; /* The corresponding statements. */
|
|
729
|
+
Statement defolt; /* The default statement. */
|
|
730
|
+
} HCaseZS;
|
|
731
|
+
|
|
704
732
|
/** The C model of a time wait statement. */
|
|
705
733
|
typedef struct TimeWaitS_ {
|
|
706
734
|
Kind kind; /* The kind of object. */
|
|
@@ -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);
|
|
@@ -1732,44 +1733,44 @@ static Value shift_right_value_bitstring(Value src0, Value src1, Value dst) {
|
|
|
1732
1733
|
}
|
|
1733
1734
|
|
|
1734
1735
|
|
|
1735
|
-
/**
|
|
1736
|
+
/** computes the equal (!xor) of two bitstring values.
|
|
1736
1737
|
* @param src0 the first source value of the and
|
|
1737
1738
|
* @param src1 the second source value of the and
|
|
1738
1739
|
* @param dst the destination value
|
|
1739
1740
|
* @return dst */
|
|
1740
1741
|
static Value equal_value_bitstring(Value src0, Value src1, Value dst) {
|
|
1741
1742
|
// printf("equal_value_bitstring.\n");
|
|
1742
|
-
/*
|
|
1743
|
+
/* compute the width of sources in bits. */
|
|
1743
1744
|
unsigned long long width0 = type_width(src0->type);
|
|
1744
1745
|
unsigned long long width1 = type_width(src1->type);
|
|
1745
1746
|
|
|
1746
|
-
/*
|
|
1747
|
+
/* update the destination capacity if required. */
|
|
1747
1748
|
resize_value(dst,width0);
|
|
1748
|
-
/*
|
|
1749
|
+
/* set the type and size of the destination from the type of the source.*/
|
|
1749
1750
|
dst->type = src0->type;
|
|
1750
1751
|
dst->numeric = 0;
|
|
1751
1752
|
|
|
1752
|
-
/*
|
|
1753
|
+
/* get access to the data of the sources. */
|
|
1753
1754
|
char *src0_data = src0->data_str;
|
|
1754
1755
|
char *src1_data = src1->data_str;
|
|
1755
|
-
/*
|
|
1756
|
+
/* get access to the data of the destination. */
|
|
1756
1757
|
char *dst_data = dst->data_str;
|
|
1757
1758
|
|
|
1758
|
-
/*
|
|
1759
|
+
/* get the sign extension character of source 1 and convert it to a bit.*/
|
|
1759
1760
|
int ext = bitstring_ext(src1);
|
|
1760
1761
|
|
|
1761
|
-
/*
|
|
1762
|
+
/* perform the !xor. */
|
|
1762
1763
|
unsigned long long count;
|
|
1763
|
-
/*
|
|
1764
|
+
/* check if values are the same. */
|
|
1764
1765
|
char same = '1';
|
|
1765
1766
|
for(count = 0; count < width0; ++count) {
|
|
1766
|
-
char d0 = src0_data[count] - '0'; /*
|
|
1767
|
+
char d0 = src0_data[count] - '0'; /* get and convert to bit. */
|
|
1767
1768
|
char d1;
|
|
1768
1769
|
if (count < width1) {
|
|
1769
|
-
/*
|
|
1770
|
-
d1 = src1_data[count] - '0';/*
|
|
1770
|
+
/* still within source 1. */
|
|
1771
|
+
d1 = src1_data[count] - '0';/* get and convert to bit. */
|
|
1771
1772
|
} else {
|
|
1772
|
-
/*
|
|
1773
|
+
/* outside source 1, use the sign extension. */
|
|
1773
1774
|
d1 = ext;
|
|
1774
1775
|
}
|
|
1775
1776
|
if (d0 == (d0&1)) {
|
|
@@ -1781,22 +1782,98 @@ static Value equal_value_bitstring(Value src0, Value src1, Value dst) {
|
|
|
1781
1782
|
break;
|
|
1782
1783
|
}
|
|
1783
1784
|
} else {
|
|
1784
|
-
/*
|
|
1785
|
+
/* undefined. */
|
|
1785
1786
|
same = 'x';
|
|
1786
1787
|
break;
|
|
1787
1788
|
}
|
|
1788
1789
|
} else {
|
|
1789
|
-
/*
|
|
1790
|
+
/* undefined. */
|
|
1790
1791
|
same = 'x';
|
|
1791
1792
|
break;
|
|
1792
1793
|
}
|
|
1793
1794
|
}
|
|
1794
|
-
/*
|
|
1795
|
+
/* set the destination to 0 or 1 depending of different. */
|
|
1795
1796
|
dst_data[0] = same;
|
|
1796
1797
|
for(count = 1; count < width0; ++count) {
|
|
1797
1798
|
dst_data[count] = '0';
|
|
1798
1799
|
}
|
|
1799
|
-
/*
|
|
1800
|
+
/* return the destination. */
|
|
1801
|
+
return dst;
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
/** computes the equal (!xor) of two bitstring values treating Z as wildcard.
|
|
1805
|
+
* @param src0 the first source value of the and
|
|
1806
|
+
* @param src1 the second source value of the and
|
|
1807
|
+
* @param dst the destination value
|
|
1808
|
+
* @return dst */
|
|
1809
|
+
static Value equal_value_z_bitstring(Value src0, Value src1, Value dst) {
|
|
1810
|
+
// printf("equal_value_bitstring.\n");
|
|
1811
|
+
/* compute the width of sources in bits. */
|
|
1812
|
+
unsigned long long width0 = type_width(src0->type);
|
|
1813
|
+
unsigned long long width1 = type_width(src1->type);
|
|
1814
|
+
|
|
1815
|
+
/* update the destination capacity if required. */
|
|
1816
|
+
resize_value(dst,width0);
|
|
1817
|
+
/* set the type and size of the destination from the type of the source.*/
|
|
1818
|
+
dst->type = src0->type;
|
|
1819
|
+
dst->numeric = 0;
|
|
1820
|
+
|
|
1821
|
+
/* get access to the data of the sources. */
|
|
1822
|
+
char *src0_data = src0->data_str;
|
|
1823
|
+
char *src1_data = src1->data_str;
|
|
1824
|
+
/* get access to the data of the destination. */
|
|
1825
|
+
char *dst_data = dst->data_str;
|
|
1826
|
+
|
|
1827
|
+
/* get the sign extension character of source 1 and convert it to a bit.*/
|
|
1828
|
+
int ext = bitstring_ext(src1);
|
|
1829
|
+
|
|
1830
|
+
/* perform the !xor. */
|
|
1831
|
+
unsigned long long count;
|
|
1832
|
+
/* check if values are the same. */
|
|
1833
|
+
char same = '1';
|
|
1834
|
+
for(count = 0; count < width0; ++count) {
|
|
1835
|
+
char d0 = src0_data[count] - '0'; /* get and convert to bit. */
|
|
1836
|
+
char d1;
|
|
1837
|
+
if (d0 == 'z' - '0' || d0 == 'Z' - '0') {
|
|
1838
|
+
/* Z is wildcard, so same. */
|
|
1839
|
+
continue;
|
|
1840
|
+
}
|
|
1841
|
+
if (count < width1) {
|
|
1842
|
+
/* still within source 1. */
|
|
1843
|
+
d1 = src1_data[count] - '0';/* get and convert to bit. */
|
|
1844
|
+
} else {
|
|
1845
|
+
/* outside source 1, use the sign extension. */
|
|
1846
|
+
d1 = ext;
|
|
1847
|
+
}
|
|
1848
|
+
if (d1 == 'z' - '0' || d1 == 'Z' - '0') {
|
|
1849
|
+
/* Z is wildcard, so same. */
|
|
1850
|
+
continue;
|
|
1851
|
+
}
|
|
1852
|
+
if (d0 == (d0&1)) {
|
|
1853
|
+
/* d0 is defined. */
|
|
1854
|
+
if (d1 == (d1&1)) {
|
|
1855
|
+
/* d1 is also defined. */
|
|
1856
|
+
if (d0 != d1) {
|
|
1857
|
+
same = '0';
|
|
1858
|
+
break;
|
|
1859
|
+
}
|
|
1860
|
+
} else {
|
|
1861
|
+
/* undefined. */
|
|
1862
|
+
same = 'x';
|
|
1863
|
+
break;
|
|
1864
|
+
}
|
|
1865
|
+
} else {
|
|
1866
|
+
/* undefined. */
|
|
1867
|
+
same = 'x';
|
|
1868
|
+
break;
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
/* set the destination to 0 or 1 depending of different. */
|
|
1872
|
+
dst_data[0] = same;
|
|
1873
|
+
for(count = 1; count < width0; ++count) {
|
|
1874
|
+
dst_data[count] = '0';
|
|
1875
|
+
}
|
|
1876
|
+
/* return the destination. */
|
|
1800
1877
|
return dst;
|
|
1801
1878
|
}
|
|
1802
1879
|
|
|
@@ -2166,7 +2243,6 @@ fix_numeric_type(Type type, unsigned long long val) {
|
|
|
2166
2243
|
if (type->flags.sign) {
|
|
2167
2244
|
/* Yes, perform sign extension. */
|
|
2168
2245
|
int is_neg = (val >> (width-1)) & 1;
|
|
2169
|
-
// printf("is_neg=%i\n",is_neg);
|
|
2170
2246
|
if (is_neg) {
|
|
2171
2247
|
/* Negative sign extension. */
|
|
2172
2248
|
return val | mask;
|
|
@@ -3299,7 +3375,7 @@ Value shift_right_value(Value src0, Value src1, Value dst) {
|
|
|
3299
3375
|
}
|
|
3300
3376
|
|
|
3301
3377
|
|
|
3302
|
-
/** Computes the equal (
|
|
3378
|
+
/** Computes the equal (NXOR) of two general values.
|
|
3303
3379
|
* @param src0 the first source value of the addition
|
|
3304
3380
|
* @param src1 the second source value of the addition
|
|
3305
3381
|
* @param dst the destination value
|
|
@@ -3336,6 +3412,43 @@ Value equal_value(Value src0, Value src1, Value dst) {
|
|
|
3336
3412
|
return dst;
|
|
3337
3413
|
}
|
|
3338
3414
|
|
|
3415
|
+
/** Computes the equal (NXOR) of two general values.
|
|
3416
|
+
* @param src0 the first source value of the addition
|
|
3417
|
+
* @param src1 the second source value of the addition
|
|
3418
|
+
* @param dst the destination value
|
|
3419
|
+
* @return the destination value */
|
|
3420
|
+
Value equal_value_z(Value src0, Value src1, Value dst) {
|
|
3421
|
+
// printf("equal_value.\n");
|
|
3422
|
+
/* Might allocate a new value so save the current pool state. */
|
|
3423
|
+
unsigned int pos = get_value_pos();
|
|
3424
|
+
/* Do a numeric computation if possible, otherwise fallback to bitstring
|
|
3425
|
+
* computation. */
|
|
3426
|
+
if (src0->numeric) {
|
|
3427
|
+
if (src1->numeric) {
|
|
3428
|
+
// printf("numeric numeric\n");
|
|
3429
|
+
/* Both sources are numeric. */
|
|
3430
|
+
return equal_value_numeric(src0,src1,dst);
|
|
3431
|
+
} else {
|
|
3432
|
+
// printf("numeric bitstring\n");
|
|
3433
|
+
/* src1 is not numeric, convert src0 to bitstring. */
|
|
3434
|
+
src0 = set_bitstring_value(src0,get_value());
|
|
3435
|
+
}
|
|
3436
|
+
} else {
|
|
3437
|
+
/* src0 is not numeric, what about src1. */
|
|
3438
|
+
if (src1->numeric) {
|
|
3439
|
+
// printf("bitstring numeric\n");
|
|
3440
|
+
/* src1 is numeric, convert it to bitstring. */
|
|
3441
|
+
src1 = set_bitstring_value(src1,get_value());
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
/* The sources cannot be numeric, compute bitsitrings. */
|
|
3445
|
+
dst = equal_value_z_bitstring(src0,src1,dst);
|
|
3446
|
+
/* Restores the pool of values. */
|
|
3447
|
+
set_value_pos(pos);
|
|
3448
|
+
/* Return the destination. */
|
|
3449
|
+
return dst;
|
|
3450
|
+
}
|
|
3451
|
+
|
|
3339
3452
|
|
|
3340
3453
|
/** Computes the C equal of two general values.
|
|
3341
3454
|
* @param src0 the first source value of the addition
|
|
@@ -3347,6 +3460,16 @@ Value equal_value_c(Value src0, Value src1, Value dst) {
|
|
|
3347
3460
|
return reduce_or_value(dst,dst);
|
|
3348
3461
|
}
|
|
3349
3462
|
|
|
3463
|
+
/** Computes the C equal of two general values treating Z as wildcards.
|
|
3464
|
+
* @param src0 the first source value of the addition
|
|
3465
|
+
* @param src1 the second source value of the addition
|
|
3466
|
+
* @param dst the destination value
|
|
3467
|
+
* @return the destination value */
|
|
3468
|
+
Value equal_value_z_c(Value src0, Value src1, Value dst) {
|
|
3469
|
+
dst = equal_value_z(src0,src1,dst);
|
|
3470
|
+
return reduce_or_value(dst,dst);
|
|
3471
|
+
}
|
|
3472
|
+
|
|
3350
3473
|
|
|
3351
3474
|
/** Computes the C not equal of two general values.
|
|
3352
3475
|
* @param src0 the first source value of the addition
|
|
@@ -471,6 +471,43 @@ void execute_statement(Statement stmnt, int mode, Behavior behavior) {
|
|
|
471
471
|
}
|
|
472
472
|
break;
|
|
473
473
|
}
|
|
474
|
+
case HCASEZ:
|
|
475
|
+
{
|
|
476
|
+
HCaseZ hcasez = (HCaseZ)stmnt;
|
|
477
|
+
/* Calculation the value to check. */
|
|
478
|
+
// Value value = calc_expression(hcasez->value);
|
|
479
|
+
Value value = get_value();
|
|
480
|
+
value = calc_expression(hcasez->value,value);
|
|
481
|
+
/* Tell if a casez if matched. */
|
|
482
|
+
int met = 0;
|
|
483
|
+
/* Check each case. */
|
|
484
|
+
Value cmp = get_value();
|
|
485
|
+
for(int i=0; i<hcasez->num_whens; ++i) {
|
|
486
|
+
// cmp = equal_value_z_c(value,calc_expression(hcasez->matches[i]),
|
|
487
|
+
// cmp);
|
|
488
|
+
Value match = get_value();
|
|
489
|
+
match = calc_expression(hcasez->matches[i],match);
|
|
490
|
+
cmp = equal_value_z_c(value,match,cmp);
|
|
491
|
+
if (is_defined_value(cmp) && value2integer(cmp)) {
|
|
492
|
+
/* Found the right case, execute the corresponding
|
|
493
|
+
* statement. */
|
|
494
|
+
execute_statement(hcasez->stmnts[i],mode,behavior);
|
|
495
|
+
/* And remeber it. */
|
|
496
|
+
met = 1;
|
|
497
|
+
free_value();
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
free_value();
|
|
501
|
+
}
|
|
502
|
+
free_value();
|
|
503
|
+
free_value();
|
|
504
|
+
/* Was no case found and is there a default statement? */
|
|
505
|
+
if (!met && hcasez->defolt) {
|
|
506
|
+
/* Yes, execute the default statement. */
|
|
507
|
+
execute_statement(hcasez->defolt,mode,behavior);
|
|
508
|
+
}
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
474
511
|
case TIME_WAIT:
|
|
475
512
|
{
|
|
476
513
|
/* Get the value of the delay. */
|
|
@@ -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
|
|
@@ -2,25 +2,25 @@
|
|
|
2
2
|
# A benchmark for the logic operations.
|
|
3
3
|
system :logic_bench do
|
|
4
4
|
[3].inner :x,:y
|
|
5
|
-
[3].inner :s_not, :s_and, :s_or, :s_xor, :
|
|
5
|
+
[3].inner :s_not, :s_and, :s_or, :s_xor, :s_eq
|
|
6
6
|
|
|
7
7
|
signed[16].inner :a,:b,:shl,:shr
|
|
8
8
|
|
|
9
9
|
timed do
|
|
10
10
|
8.times do |i|
|
|
11
11
|
8.times do |j|
|
|
12
|
-
x
|
|
13
|
-
y
|
|
14
|
-
s_not
|
|
15
|
-
s_and
|
|
16
|
-
s_or
|
|
17
|
-
s_xor
|
|
18
|
-
|
|
12
|
+
x <= i
|
|
13
|
+
y <= j
|
|
14
|
+
s_not <= ~x
|
|
15
|
+
s_and <= x & y
|
|
16
|
+
s_or <= x | y
|
|
17
|
+
s_xor <= x ^ y
|
|
18
|
+
s_eq <= (x == y)
|
|
19
19
|
!10.ns
|
|
20
|
-
a
|
|
21
|
-
b
|
|
22
|
-
shl
|
|
23
|
-
shr
|
|
20
|
+
a <= i
|
|
21
|
+
b <= j
|
|
22
|
+
shl <= (a << b)
|
|
23
|
+
shr <= (a >> b)
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
system :assign_to_slice do
|
|
2
|
+
[8].inner :reg
|
|
3
|
+
|
|
4
|
+
timed do
|
|
5
|
+
!10.ns
|
|
6
|
+
reg[1..0] <= _b00
|
|
7
|
+
!10.ns
|
|
8
|
+
reg[3..2] <= _b01
|
|
9
|
+
!10.ns
|
|
10
|
+
reg[5..4] <= _b10
|
|
11
|
+
!10.ns
|
|
12
|
+
reg[7..6] <= _b11
|
|
13
|
+
!10.ns
|
|
14
|
+
reg[3..0] <= _ha
|
|
15
|
+
!10.ns
|
|
16
|
+
reg[7..4] <= _h5
|
|
17
|
+
!10.ns
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Test the casez statement.
|
|
2
|
+
|
|
3
|
+
# A benchmark for the case statement.
|
|
4
|
+
system :case_bench do
|
|
5
|
+
[8].inner :x, :z
|
|
6
|
+
|
|
7
|
+
par do
|
|
8
|
+
hcasez(x)
|
|
9
|
+
hwhen(_b0000_0000) { z <= 0 }
|
|
10
|
+
hwhen(_b000z_0001) { z <= 1 }
|
|
11
|
+
hwhen(_b00z0_0010) { z <= 4 }
|
|
12
|
+
hwhen(_b00zz_0011) { z <= 9 }
|
|
13
|
+
hwhen(_b0z00_0100) { z <= 16 }
|
|
14
|
+
hwhen(_b0z0z_0101) { z <= 25 }
|
|
15
|
+
hwhen(_b0zz0_0110) { z <= 36 }
|
|
16
|
+
hwhen(_b0zzz_0111) { z <= 49 }
|
|
17
|
+
hwhen(_bz000_1000) { z <= 64 }
|
|
18
|
+
hwhen(_bz00z_1001) { z <= 81 }
|
|
19
|
+
hwhen(_bz0z0_1010) { z <= 100 }
|
|
20
|
+
hwhen(_bz0zz_1011) { z <= 121 }
|
|
21
|
+
hwhen(_bzz00_1100) { z <= 144 }
|
|
22
|
+
hwhen(_bzz0z_1101) { z <= 169 }
|
|
23
|
+
hwhen(_bzzz0_1110) { z <= 196 }
|
|
24
|
+
hwhen(_bzzzz_1111) { z <= 225 }
|
|
25
|
+
helse { z <= _zzzzzzzz }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
timed do
|
|
29
|
+
!10.ns
|
|
30
|
+
20.times do |i|
|
|
31
|
+
x <= i
|
|
32
|
+
!10.ns
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -344,7 +344,7 @@ system :henmerable_checks do
|
|
|
344
344
|
|
|
345
345
|
par(clk.posedge) do
|
|
346
346
|
# hprint("}0\n")
|
|
347
|
-
vals.hzip([_h12]*8).
|
|
347
|
+
vals.hzip([_h12]*8).heach_with_index { |(a,b),i| res62[i] <= a+b }
|
|
348
348
|
end
|
|
349
349
|
|
|
350
350
|
# Test enumerators of values.
|