HDLRuby 2.6.5 → 2.6.16

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.
@@ -686,6 +686,41 @@ static Value mod_value_defined_bitstring(Value src0, Value src1, Value dst) {
686
686
  }
687
687
 
688
688
 
689
+ /** Computes the greater comparision of two defined bitstring values.
690
+ * @param src0 the first source value of the addition
691
+ * @param src1 the second source value of the addition
692
+ * @param dst the destination value
693
+ * @return dst */
694
+ static Value greater_value_defined_bitstring(Value src0, Value src1, Value dst) {
695
+ /* Sets state of the destination using the first source. */
696
+ dst->type = src0->type;
697
+ dst->numeric = 1;
698
+
699
+ /* Perform the comparison. */
700
+ if (src0->type->flags.sign) {
701
+ if (src1->type->flags.sign) {
702
+ dst->data_int =
703
+ ((signed long long)value2integer(src0) >
704
+ (signed long long)value2integer(src1));
705
+ } else {
706
+ dst->data_int =
707
+ ((signed long long)value2integer(src0) >
708
+ (unsigned long long)value2integer(src1));
709
+ }
710
+ } else {
711
+ if (src1->type->flags.sign) {
712
+ dst->data_int =
713
+ ((unsigned long long)value2integer(src0) >
714
+ (signed long long)value2integer(src1));
715
+ } else {
716
+ dst->data_int =
717
+ ((unsigned long long)value2integer(src0) >
718
+ (unsigned long long)value2integer(src1));
719
+ }
720
+ }
721
+ return dst;
722
+ }
723
+
689
724
  /** Computes the lesser comparision of two defined bitstring values.
690
725
  * @param src0 the first source value of the addition
691
726
  * @param src1 the second source value of the addition
@@ -697,23 +732,97 @@ static Value lesser_value_defined_bitstring(Value src0, Value src1, Value dst) {
697
732
  dst->numeric = 1;
698
733
 
699
734
  /* Perform the comparison. */
700
- dst->data_int = (value2integer(src0) < value2integer(src1));
735
+ if (src0->type->flags.sign) {
736
+ if (src1->type->flags.sign) {
737
+ dst->data_int =
738
+ ((signed long long)value2integer(src0) <
739
+ (signed long long)value2integer(src1));
740
+ } else {
741
+ dst->data_int =
742
+ ((signed long long)value2integer(src0) <
743
+ (unsigned long long)value2integer(src1));
744
+ }
745
+ } else {
746
+ if (src1->type->flags.sign) {
747
+ dst->data_int =
748
+ ((unsigned long long)value2integer(src0) <
749
+ (signed long long)value2integer(src1));
750
+ } else {
751
+ dst->data_int =
752
+ ((unsigned long long)value2integer(src0) <
753
+ (unsigned long long)value2integer(src1));
754
+ }
755
+ }
701
756
  return dst;
702
757
  }
703
758
 
759
+ /** Computes the greater or equal comparision of two defined bitstring values.
760
+ * @param src0 the first source value of the addition
761
+ * @param src1 the second source value of the addition
762
+ * @param dst the destination value
763
+ * @return dst */
764
+ static Value greater_equal_value_defined_bitstring(Value src0, Value src1, Value dst) {
765
+ /* Sets state of the destination using the first source. */
766
+ dst->type = src0->type;
767
+ dst->numeric = 1;
704
768
 
705
- /** Computes the greater comparision of two defined bitstring values.
769
+ /* Perform the comparison. */
770
+ if (src0->type->flags.sign) {
771
+ if (src1->type->flags.sign) {
772
+ dst->data_int =
773
+ ((signed long long)value2integer(src0) >=
774
+ (signed long long)value2integer(src1));
775
+ } else {
776
+ dst->data_int =
777
+ ((signed long long)value2integer(src0) >=
778
+ (unsigned long long)value2integer(src1));
779
+ }
780
+ } else {
781
+ if (src1->type->flags.sign) {
782
+ dst->data_int =
783
+ ((unsigned long long)value2integer(src0) >=
784
+ (signed long long)value2integer(src1));
785
+ } else {
786
+ dst->data_int =
787
+ ((unsigned long long)value2integer(src0) >=
788
+ (unsigned long long)value2integer(src1));
789
+ }
790
+ }
791
+ return dst;
792
+ }
793
+
794
+ /** Computes the lesser or equal comparision of two defined bitstring values.
706
795
  * @param src0 the first source value of the addition
707
796
  * @param src1 the second source value of the addition
708
797
  * @param dst the destination value
709
798
  * @return dst */
710
- static Value greater_value_defined_bitstring(Value src0, Value src1, Value dst) {
799
+ static Value lesser_equal_value_defined_bitstring(Value src0, Value src1, Value dst) {
711
800
  /* Sets state of the destination using the first source. */
712
801
  dst->type = src0->type;
713
802
  dst->numeric = 1;
714
803
 
715
804
  /* Perform the comparison. */
716
- dst->data_int = (value2integer(src0) > value2integer(src1));
805
+ if (src0->type->flags.sign) {
806
+ if (src1->type->flags.sign) {
807
+ dst->data_int =
808
+ ((signed long long)value2integer(src0) <=
809
+ (signed long long)value2integer(src1));
810
+ } else {
811
+ dst->data_int =
812
+ ((signed long long)value2integer(src0) <=
813
+ (unsigned long long)value2integer(src1));
814
+ }
815
+ } else {
816
+ if (src1->type->flags.sign) {
817
+ dst->data_int =
818
+ ((unsigned long long)value2integer(src0) <=
819
+ (signed long long)value2integer(src1));
820
+ } else {
821
+ dst->data_int =
822
+ ((unsigned long long)value2integer(src0) <=
823
+ (unsigned long long)value2integer(src1));
824
+ }
825
+ }
717
826
  return dst;
718
827
  }
719
828
 
@@ -1762,13 +1871,49 @@ static Value equal_value_numeric(Value src0, Value src1, Value dst) {
1762
1871
  dst->type = src0->type;
1763
1872
  dst->numeric = 1;
1764
1873
 
1765
- /* Perform the !XOR. */
1766
- // dst->data_int = (src0->data_int == src1->data_int);
1767
- dst->data_int = ~(src0->data_int ^ src1->data_int);
1874
+ // /* Perform the !XOR. */
1875
+ // dst->data_int = ~(src0->data_int ^ src1->data_int);
1876
+ /* Perform the comparison. */
1877
+ dst->data_int = (src0->data_int == src1->data_int) ? 1 : 0;
1768
1878
  return dst;
1769
1879
  }
1770
1880
 
1771
1881
 
1882
+ /** Computes the greater comparision of two numeric values.
1883
+ * @param src0 the first source value of the addition
1884
+ * @param src1 the second source value of the addition
1885
+ * @param dst the destination value
1886
+ * @return the destination value */
1887
+ static Value greater_value_numeric(Value src0, Value src1, Value dst) {
1888
+ /* Sets state of the destination using the first source. */
1889
+ dst->type = src0->type;
1890
+ dst->numeric = 1;
1891
+
1892
+ /* Perform the greater. */
1893
+ if (src0->type->flags.sign) {
1894
+ if (src1->type->flags.sign) {
1895
+ dst->data_int =
1896
+ ((signed long long)src0->data_int >
1897
+ (signed long long)src1->data_int);
1898
+ } else {
1899
+ dst->data_int =
1900
+ ((signed long long)src0->data_int >
1901
+ (unsigned long long)src1->data_int);
1902
+ }
1903
+ } else {
1904
+ if (src1->type->flags.sign) {
1905
+ dst->data_int =
1906
+ ((unsigned long long)src0->data_int >
1907
+ (signed long long)src1->data_int);
1908
+ } else {
1909
+ dst->data_int =
1910
+ ((unsigned long long)src0->data_int >
1911
+ (unsigned long long)src1->data_int);
1912
+ }
1913
+ }
1914
+ return dst;
1915
+ }
1916
+
1772
1917
  /** Computes the lesser comparision of two numeric values.
1773
1918
  * @param src0 the first source value of the addition
1774
1919
  * @param src1 the second source value of the addition
@@ -1780,22 +1925,97 @@ static Value lesser_value_numeric(Value src0, Value src1, Value dst) {
1780
1925
  dst->numeric = 1;
1781
1926
 
1782
1927
  /* Perform the lesser. */
1783
- dst->data_int = (src0->data_int < src1->data_int);
1928
+ if (src0->type->flags.sign) {
1929
+ if (src1->type->flags.sign) {
1930
+ dst->data_int =
1931
+ ((signed long long)src0->data_int <
1932
+ (signed long long)src1->data_int);
1933
+ } else {
1934
+ dst->data_int =
1935
+ ((signed long long)src0->data_int <
1936
+ (unsigned long long)src1->data_int);
1937
+ }
1938
+ } else {
1939
+ if (src1->type->flags.sign) {
1940
+ dst->data_int =
1941
+ ((unsigned long long)src0->data_int <
1942
+ (signed long long)src1->data_int);
1943
+ } else {
1944
+ dst->data_int =
1945
+ ((unsigned long long)src0->data_int <
1946
+ (unsigned long long)src1->data_int);
1947
+ }
1948
+ }
1784
1949
  return dst;
1785
1950
  }
1786
1951
 
1787
- /** Computes the greater comparision of two numeric values.
1952
+ /** Computes the greater or equal comparision of two numeric values.
1788
1953
  * @param src0 the first source value of the addition
1789
1954
  * @param src1 the second source value of the addition
1790
1955
  * @param dst the destination value
1791
1956
  * @return the destination value */
1792
- static Value greater_value_numeric(Value src0, Value src1, Value dst) {
1957
+ static Value greater_equal_value_numeric(Value src0, Value src1, Value dst) {
1793
1958
  /* Sets state of the destination using the first source. */
1794
1959
  dst->type = src0->type;
1795
1960
  dst->numeric = 1;
1796
1961
 
1797
- /* Perform the lesser. */
1798
- dst->data_int = (src0->data_int > src1->data_int);
1962
+ /* Perform the greater or equal. */
1963
+ if (src0->type->flags.sign) {
1964
+ if (src1->type->flags.sign) {
1965
+ dst->data_int =
1966
+ ((signed long long)src0->data_int >=
1967
+ (signed long long)src1->data_int);
1968
+ } else {
1969
+ dst->data_int =
1970
+ ((signed long long)src0->data_int >=
1971
+ (unsigned long long)src1->data_int);
1972
+ }
1973
+ } else {
1974
+ if (src1->type->flags.sign) {
1975
+ dst->data_int =
1976
+ ((unsigned long long)src0->data_int >=
1977
+ (signed long long)src1->data_int);
1978
+ } else {
1979
+ dst->data_int =
1980
+ ((unsigned long long)src0->data_int >=
1981
+ (unsigned long long)src1->data_int);
1982
+ }
1983
+ }
1984
+ return dst;
1985
+ }
1986
+
1987
+ /** Computes the lesser or equal comparision of two numeric values.
1988
+ * @param src0 the first source value of the addition
1989
+ * @param src1 the second source value of the addition
1990
+ * @param dst the destination value
1991
+ * @return the destination value */
1992
+ static Value lesser_equal_value_numeric(Value src0, Value src1, Value dst) {
1993
+ /* Sets state of the destination using the first source. */
1994
+ dst->type = src0->type;
1995
+ dst->numeric = 1;
1996
+
1997
+ /* Perform the lesser or equal. */
1998
+ if (src0->type->flags.sign) {
1999
+ if (src1->type->flags.sign) {
2000
+ dst->data_int =
2001
+ ((signed long long)src0->data_int <=
2002
+ (signed long long)src1->data_int);
2003
+ } else {
2004
+ dst->data_int =
2005
+ ((signed long long)src0->data_int <=
2006
+ (unsigned long long)src1->data_int);
2007
+ }
2008
+ } else {
2009
+ if (src1->type->flags.sign) {
2010
+ dst->data_int =
2011
+ ((unsigned long long)src0->data_int <=
2012
+ (signed long long)src1->data_int);
2013
+ } else {
2014
+ dst->data_int =
2015
+ ((unsigned long long)src0->data_int <=
2016
+ (unsigned long long)src1->data_int);
2017
+ }
2018
+ }
1799
2019
  return dst;
1800
2020
  }
1801
2021
 
@@ -2434,6 +2654,34 @@ Value equal_value(Value src0, Value src1, Value dst) {
2434
2654
  }
2435
2655
 
2436
2656
 
2657
+
2658
+ /** Computes the greater comparision of two general values.
2659
+ * @param src0 the first source value of the addition
2660
+ * @param src1 the second source value of the addition
2661
+ * @param dst the destination value
2662
+ * @return dst */
2663
+ Value greater_value(Value src0, Value src1, Value dst) {
2664
+ /* Might allocate a new value so save the current pool state. */
2665
+ unsigned int pos = get_value_pos();
2666
+ /* Do a numeric computation if possible, otherwise fallback to bitstring
2667
+ * computation. */
2668
+ if (src0->numeric && src1->numeric) {
2669
+ /* Both sources are numeric. */
2670
+ return greater_value_numeric(src0,src1,dst);
2671
+ } else if (is_defined_value(src0) && is_defined_value(src1)) {
2672
+ /* Both sources can be converted to numeric values. */
2673
+ return greater_value_defined_bitstring(src0,src1,dst);
2674
+ } else {
2675
+ /* Cannot compute (for now), simply undefines the destination. */
2676
+ /* First ensure dst has the right shape. */
2677
+ copy_value(src0,dst);
2678
+ /* Then make it undefined. */
2679
+ set_undefined_bitstring(dst);
2680
+ }
2681
+ return dst;
2682
+ }
2683
+
2684
+
2437
2685
  /** Computes the lesser comparision of two general values.
2438
2686
  * @param src0 the first source value of the addition
2439
2687
  * @param src1 the second source value of the addition
@@ -2461,22 +2709,22 @@ Value lesser_value(Value src0, Value src1, Value dst) {
2461
2709
  }
2462
2710
 
2463
2711
 
2464
- /** Computes the greater comparision of two general values.
2465
- * @param src0 the first source value of the addition
2466
- * @param src1 the second source value of the addition
2712
+ /** Computes the greater or equal comparision of two values.
2713
+ * @param src0 the first source value of the comparison
2714
+ * @param src1 the second source value of the comparison
2467
2715
  * @param dst the destination value
2468
2716
  * @return dst */
2469
- Value greater_value(Value src0, Value src1, Value dst) {
2717
+ Value greater_equal_value(Value src0, Value src1, Value dst) {
2470
2718
  /* Might allocate a new value so save the current pool state. */
2471
2719
  unsigned int pos = get_value_pos();
2472
2720
  /* Do a numeric computation if possible, otherwise fallback to bitstring
2473
2721
  * computation. */
2474
2722
  if (src0->numeric && src1->numeric) {
2475
2723
  /* Both sources are numeric. */
2476
- return greater_value_numeric(src0,src1,dst);
2724
+ return greater_equal_value_numeric(src0,src1,dst);
2477
2725
  } else if (is_defined_value(src0) && is_defined_value(src1)) {
2478
2726
  /* Both sources can be converted to numeric values. */
2479
- return greater_value_defined_bitstring(src0,src1,dst);
2727
+ return greater_equal_value_defined_bitstring(src0,src1,dst);
2480
2728
  } else {
2481
2729
  /* Cannot compute (for now), simply undefines the destination. */
2482
2730
  /* First ensure dst has the right shape. */
@@ -2487,6 +2735,33 @@ Value greater_value(Value src0, Value src1, Value dst) {
2487
2735
  return dst;
2488
2736
  }
2489
2737
 
2738
+ /** Computes the lesser or equal comparision of two values.
2739
+ * @param src0 the first source value of the comparison
2740
+ * @param src1 the second source value of the comparison
2741
+ * @param dst the destination value
2742
+ * @return dst */
2743
+ Value lesser_equal_value(Value src0, Value src1, Value dst) {
2744
+ /* Might allocate a new value so save the current pool state. */
2745
+ unsigned int pos = get_value_pos();
2746
+ /* Do a numeric computation if possible, otherwise fallback to bitstring
2747
+ * computation. */
2748
+ if (src0->numeric && src1->numeric) {
2749
+ /* Both sources are numeric. */
2750
+ return lesser_equal_value_numeric(src0,src1,dst);
2751
+ } else if (is_defined_value(src0) && is_defined_value(src1)) {
2752
+ /* Both sources can be converted to numeric values. */
2753
+ return lesser_equal_value_defined_bitstring(src0,src1,dst);
2754
+ } else {
2755
+ /* Cannot compute (for now), simply undefines the destination. */
2756
+ /* First ensure dst has the right shape. */
2757
+ copy_value(src0,dst);
2758
+ /* Then make it undefined. */
2759
+ set_undefined_bitstring(dst);
2760
+ }
2761
+ return dst;
2762
+ }
2763
+
2764
+
2490
2765
 
2491
2766
  /** Selects a value depending on a general condition.
2492
2767
  * @param cond the condition to use for selecting a value
@@ -107,13 +107,15 @@ module HDLRuby::High::Std
107
107
  end
108
108
 
109
109
  # Make the interpolation.
110
- diff <= (next_data-base).as(diff.type) * remaining
111
- if(otyp.signed?) then
112
- interpolated_value <= base +
113
- ([[diff[diff.type.width-1]]*shift_bits,
114
- diff[diff.type.width-1..shift_bits]]).to_expr
115
- else
116
- interpolated_value <= base + (diff >> shift_bits)
110
+ par do
111
+ diff <= (next_data-base).as(diff.type) * remaining
112
+ if(otyp.signed?) then
113
+ interpolated_value <= base +
114
+ ([[diff[diff.type.width-1]]*shift_bits,
115
+ diff[diff.type.width-1..shift_bits]]).to_expr
116
+ else
117
+ interpolated_value <= base + (diff >> shift_bits)
118
+ end
117
119
  end
118
120
  end
119
121
 
@@ -1,3 +1,3 @@
1
1
  module HDLRuby
2
- VERSION = "2.6.5"
2
+ VERSION = "2.6.16"
3
3
  end
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.6.5
4
+ version: 2.6.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lovic Gauthier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-09 00:00:00.000000000 Z
11
+ date: 2021-09-20 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/comparison_bench.rb
86
87
  - lib/HDLRuby/hdr_samples/constant_in_function.rb
87
88
  - lib/HDLRuby/hdr_samples/counter_bench.rb
88
89
  - lib/HDLRuby/hdr_samples/dff.rb
@@ -134,6 +135,7 @@ files:
134
135
  - lib/HDLRuby/hdr_samples/sw_encrypt_cpusim_bench.rb
135
136
  - lib/HDLRuby/hdr_samples/system_open.rb
136
137
  - lib/HDLRuby/hdr_samples/tuple.rb
138
+ - lib/HDLRuby/hdr_samples/type_minmax_bench.rb
137
139
  - lib/HDLRuby/hdr_samples/with_channel.rb
138
140
  - lib/HDLRuby/hdr_samples/with_class.rb
139
141
  - lib/HDLRuby/hdr_samples/with_connector.rb
@@ -148,6 +150,7 @@ files:
148
150
  - lib/HDLRuby/hdr_samples/with_memory_rom.rb
149
151
  - lib/HDLRuby/hdr_samples/with_multi_channels.rb
150
152
  - lib/HDLRuby/hdr_samples/with_reconf.rb
153
+ - lib/HDLRuby/hdr_samples/with_to_array.rb
151
154
  - lib/HDLRuby/hdrcc.rb
152
155
  - lib/HDLRuby/high_samples/_adder_fault.rb
153
156
  - lib/HDLRuby/high_samples/_generic_transmission2.rb