HDLRuby 2.10.5 → 2.11.0

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/HDLRuby.gemspec +1 -0
  3. data/README.md +8 -4
  4. data/Rakefile +8 -0
  5. data/{lib/HDLRuby/sim/Makefile → ext/hruby_sim/Makefile_csim} +0 -0
  6. data/ext/hruby_sim/extconf.rb +13 -0
  7. data/ext/hruby_sim/hruby_rcsim_build.c +1188 -0
  8. data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim.h +255 -16
  9. data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_calc.c +310 -181
  10. data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_core.c +34 -17
  11. data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_list.c +0 -0
  12. data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_stack_calc.c +4 -1
  13. data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_stack_calc.c.sav +0 -0
  14. data/ext/hruby_sim/hruby_sim_tree_calc.c +375 -0
  15. data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_vcd.c +5 -5
  16. data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_sim_vizualize.c +2 -2
  17. data/{lib/HDLRuby/sim → ext/hruby_sim}/hruby_value_pool.c +4 -1
  18. data/lib/HDLRuby/hdr_samples/bstr_bench.rb +2 -0
  19. data/lib/HDLRuby/hdr_samples/case_bench.rb +2 -2
  20. data/lib/HDLRuby/hdr_samples/counter_bench.rb +0 -1
  21. data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +46 -0
  22. data/lib/HDLRuby/hdr_samples/dff_bench.rb +1 -1
  23. data/lib/HDLRuby/hdr_samples/print_bench.rb +62 -0
  24. data/lib/HDLRuby/hdr_samples/rom.rb +5 -3
  25. data/lib/HDLRuby/hdr_samples/simple_counter_bench.rb +43 -0
  26. data/lib/HDLRuby/hdrcc.rb +54 -8
  27. data/lib/HDLRuby/hruby_bstr.rb +1175 -917
  28. data/lib/HDLRuby/hruby_high.rb +200 -90
  29. data/lib/HDLRuby/hruby_high_fullname.rb +82 -0
  30. data/lib/HDLRuby/hruby_low.rb +41 -23
  31. data/lib/HDLRuby/hruby_low2c.rb +7 -0
  32. data/lib/HDLRuby/hruby_rcsim.rb +978 -0
  33. data/lib/HDLRuby/hruby_rsim.rb +1134 -0
  34. data/lib/HDLRuby/hruby_rsim_vcd.rb +322 -0
  35. data/lib/HDLRuby/hruby_values.rb +362 -18
  36. data/lib/HDLRuby/hruby_verilog.rb +21 -3
  37. data/lib/HDLRuby/version.rb +1 -1
  38. metadata +24 -13
@@ -225,7 +225,7 @@ Value make_value(Type type, int numeric) {
225
225
  * @note do not change the type of the value, only its capacity.
226
226
  * @praam value the value to change
227
227
  * @param size the size to match */
228
- void resize_value(Value value, int size) {
228
+ void resize_value(Value value, unsigned long long size) {
229
229
  if (value->capacity < size) {
230
230
  /* Resizing required, to limit frequent resize, double the
231
231
  * required new capacity. */
@@ -303,6 +303,9 @@ fix_numeric_type(Type type, unsigned long long val);
303
303
  * @param dst the destination value
304
304
  * @return dst */
305
305
  Value copy_value(Value src, Value dst) {
306
+ // printf("copy_value with src=%p and dst=%p\n",src,dst);
307
+ // printf("src->type=%p dst->type=%p\n",src->type,dst->type);
308
+ // printf("src->numeric=%i dst->numeric=%i\n",src->numeric,dst->numeric);
306
309
  /* set the status of the destination from the source. */
307
310
  if (dst->type == NULL)
308
311
  dst->type = src->type;
@@ -696,27 +699,42 @@ static Value greater_value_defined_bitstring(Value src0, Value src1, Value dst)
696
699
  dst->type = src0->type;
697
700
  dst->numeric = 1;
698
701
 
702
+ // /* Perform the comparison. */
703
+ // if (src0->type->flags.sign) {
704
+ // if (src1->type->flags.sign) {
705
+ // dst->data_int =
706
+ // ((signed long long)value2integer(src0) >
707
+ // (signed long long)value2integer(src1));
708
+ // } else {
709
+ // dst->data_int =
710
+ // ((signed long long)value2integer(src0) >
711
+ // (unsigned long long)value2integer(src1));
712
+ // }
713
+ // } else {
714
+ // if (src1->type->flags.sign) {
715
+ // dst->data_int =
716
+ // ((unsigned long long)value2integer(src0) >
717
+ // (signed long long)value2integer(src1));
718
+ // } else {
719
+ // dst->data_int =
720
+ // ((unsigned long long)value2integer(src0) >
721
+ // (unsigned long long)value2integer(src1));
722
+ // }
723
+ // }
724
+ /* Converts the values to integers. */
725
+ unsigned long long src0i = value2integer(src0);
726
+ unsigned long long src1i = value2integer(src1);
699
727
  /* Perform the comparison. */
700
728
  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
- }
729
+ if (src1->type->flags.sign)
730
+ dst->data_int = (signed long long)src0i > (signed long long)src1i;
731
+ else
732
+ dst->data_int = (signed long long)src0i >= 0 ? src0i > src1i : 0;
710
733
  } 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
- }
734
+ if (src1->type->flags.sign)
735
+ dst->data_int = (signed long long)src1i >= 0 ? src0i > src1i : 1;
736
+ else
737
+ dst->data_int = src0i > src1i;
720
738
  }
721
739
  return dst;
722
740
  }
@@ -731,27 +749,42 @@ static Value lesser_value_defined_bitstring(Value src0, Value src1, Value dst) {
731
749
  dst->type = src0->type;
732
750
  dst->numeric = 1;
733
751
 
752
+ // /* Perform the comparison. */
753
+ // if (src0->type->flags.sign) {
754
+ // if (src1->type->flags.sign) {
755
+ // dst->data_int =
756
+ // ((signed long long)value2integer(src0) <
757
+ // (signed long long)value2integer(src1));
758
+ // } else {
759
+ // dst->data_int =
760
+ // ((signed long long)value2integer(src0) <
761
+ // (unsigned long long)value2integer(src1));
762
+ // }
763
+ // } else {
764
+ // if (src1->type->flags.sign) {
765
+ // dst->data_int =
766
+ // ((unsigned long long)value2integer(src0) <
767
+ // (signed long long)value2integer(src1));
768
+ // } else {
769
+ // dst->data_int =
770
+ // ((unsigned long long)value2integer(src0) <
771
+ // (unsigned long long)value2integer(src1));
772
+ // }
773
+ // }
774
+ /* Converts the values to integers. */
775
+ unsigned long long src0i = value2integer(src0);
776
+ unsigned long long src1i = value2integer(src1);
734
777
  /* Perform the comparison. */
735
778
  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
- }
779
+ if (src1->type->flags.sign)
780
+ dst->data_int = (signed long long)src0i < (signed long long)src1i;
781
+ else
782
+ dst->data_int = (signed long long)src0i >= 0 ? src0i < src1i : 1;
745
783
  } 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
- }
784
+ if (src1->type->flags.sign)
785
+ dst->data_int = (signed long long)src1i >= 0 ? src0i < src1i : 0;
786
+ else
787
+ dst->data_int = src0i < src1i;
755
788
  }
756
789
  return dst;
757
790
  }
@@ -766,27 +799,42 @@ static Value greater_equal_value_defined_bitstring(Value src0, Value src1, Value
766
799
  dst->type = src0->type;
767
800
  dst->numeric = 1;
768
801
 
802
+ // /* Perform the comparison. */
803
+ // if (src0->type->flags.sign) {
804
+ // if (src1->type->flags.sign) {
805
+ // dst->data_int =
806
+ // ((signed long long)value2integer(src0) >=
807
+ // (signed long long)value2integer(src1));
808
+ // } else {
809
+ // dst->data_int =
810
+ // ((signed long long)value2integer(src0) >=
811
+ // (unsigned long long)value2integer(src1));
812
+ // }
813
+ // } else {
814
+ // if (src1->type->flags.sign) {
815
+ // dst->data_int =
816
+ // ((unsigned long long)value2integer(src0) >=
817
+ // (signed long long)value2integer(src1));
818
+ // } else {
819
+ // dst->data_int =
820
+ // ((unsigned long long)value2integer(src0) >=
821
+ // (unsigned long long)value2integer(src1));
822
+ // }
823
+ // }
824
+ /* Converts the values to integers. */
825
+ unsigned long long src0i = value2integer(src0);
826
+ unsigned long long src1i = value2integer(src1);
769
827
  /* Perform the comparison. */
770
828
  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
- }
829
+ if (src1->type->flags.sign)
830
+ dst->data_int = (signed long long)src0i >= (signed long long)src1i;
831
+ else
832
+ dst->data_int = (signed long long)src0i >= 0 ? src0i >= src1i : 0;
780
833
  } 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
- }
834
+ if (src1->type->flags.sign)
835
+ dst->data_int = (signed long long)src1i >= 0 ? src0i >= src1i : 1;
836
+ else
837
+ dst->data_int = src0i >= src1i;
790
838
  }
791
839
  return dst;
792
840
  }
@@ -801,27 +849,42 @@ static Value lesser_equal_value_defined_bitstring(Value src0, Value src1, Value
801
849
  dst->type = src0->type;
802
850
  dst->numeric = 1;
803
851
 
852
+ // /* Perform the comparison. */
853
+ // if (src0->type->flags.sign) {
854
+ // if (src1->type->flags.sign) {
855
+ // dst->data_int =
856
+ // ((signed long long)value2integer(src0) <=
857
+ // (signed long long)value2integer(src1));
858
+ // } else {
859
+ // dst->data_int =
860
+ // ((signed long long)value2integer(src0) <=
861
+ // (unsigned long long)value2integer(src1));
862
+ // }
863
+ // } else {
864
+ // if (src1->type->flags.sign) {
865
+ // dst->data_int =
866
+ // ((unsigned long long)value2integer(src0) <=
867
+ // (signed long long)value2integer(src1));
868
+ // } else {
869
+ // dst->data_int =
870
+ // ((unsigned long long)value2integer(src0) <=
871
+ // (unsigned long long)value2integer(src1));
872
+ // }
873
+ // }
874
+ /* Converts the values to integers. */
875
+ unsigned long long src0i = value2integer(src0);
876
+ unsigned long long src1i = value2integer(src1);
804
877
  /* Perform the comparison. */
805
878
  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
- }
879
+ if (src1->type->flags.sign)
880
+ dst->data_int = (signed long long)src0i <= (signed long long)src1i;
881
+ else
882
+ dst->data_int = (signed long long)src0i >= 0 ? src0i <= src1i : 1;
815
883
  } 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
- }
884
+ if (src1->type->flags.sign)
885
+ dst->data_int = (signed long long)src1i >= 0 ? src0i <= src1i : 0;
886
+ else
887
+ dst->data_int = src0i <= src1i;
825
888
  }
826
889
  return dst;
827
890
  }
@@ -1351,10 +1414,10 @@ static Value select_value_bitstring(Value cond, Value dst, unsigned int num,
1351
1414
  * @param dst the destination value
1352
1415
  * @param args the values to concat
1353
1416
  * @return dst */
1354
- static Value concat_value_bitstring_array(int num, int dir,
1417
+ static Value concat_value_bitstring_array(unsigned int num, int dir,
1355
1418
  Value dst, Value* args) {
1356
1419
  unsigned long long pos = 0; /* Current position in the resulting value.*/
1357
- unsigned long long i;
1420
+ unsigned int i;
1358
1421
  // printf("concat_value_bitstring with dir=%d\n",dir);
1359
1422
 
1360
1423
  /* Compute the size of the destination. */
@@ -1508,7 +1571,8 @@ static int same_content_value_range_bitstring(Value value0,
1508
1571
  * @param base the type of the elements
1509
1572
  * @param dst the destination value
1510
1573
  * @return dst */
1511
- Value read_range_bitstring(Value src, long long first, long long last,
1574
+ Value read_range_bitstring(Value src,
1575
+ unsigned long long first, unsigned long long last,
1512
1576
  Type base, Value dst) {
1513
1577
  // printf("read_range_bitstring with first=%lld last=%lld src=%s\n",first,last,src->data_str);
1514
1578
  /* Ensure first is the smaller. */
@@ -1547,7 +1611,8 @@ Value read_range_bitstring(Value src, long long first, long long last,
1547
1611
  * @param base the type of the elements
1548
1612
  * @param dst the destination value
1549
1613
  * @return dst */
1550
- Value write_range_bitstring(Value src, long long first, long long last,
1614
+ Value write_range_bitstring(Value src,
1615
+ unsigned long long first, unsigned long long last,
1551
1616
  Type base, Value dst) {
1552
1617
  unsigned long long i;
1553
1618
  /* Ensure first is the smaller. */
@@ -1586,7 +1651,8 @@ Value write_range_bitstring(Value src, long long first, long long last,
1586
1651
  * @param base the type of the elements
1587
1652
  * @param dst the destination value
1588
1653
  * @return dst */
1589
- Value write_range_bitstring_no_z(Value src, long long first, long long last,
1654
+ Value write_range_bitstring_no_z(Value src,
1655
+ unsigned long long first, unsigned long long last,
1590
1656
  Type base, Value dst) {
1591
1657
  unsigned long long i;
1592
1658
  /* Ensure first is the smaller. */
@@ -1627,7 +1693,7 @@ Value write_range_bitstring_no_z(Value src, long long first, long long last,
1627
1693
  static unsigned long long
1628
1694
  fix_numeric_type(Type type, unsigned long long val) {
1629
1695
  /* Get the width of the type. */
1630
- int width = type_width(type);
1696
+ unsigned long long width = type_width(type);
1631
1697
  /* Compute the base mask. */
1632
1698
  // unsigned long long mask = ((unsigned long long)(-1)) << width;
1633
1699
  /* NOTE: (ull)-1 << 64 becomes (ull)-1 on Intel processors, this is
@@ -1873,9 +1939,9 @@ static Value equal_value_numeric(Value src0, Value src1, Value dst) {
1873
1939
 
1874
1940
  /* Perform the comparison. */
1875
1941
  dst->data_int = (src0->data_int == src1->data_int) ? 1 : 0;
1876
- printf("scr0->data_int=%lld\n",src0->data_int);
1877
- printf("scr1->data_int=%lld\n",src1->data_int);
1878
- printf("dst->data_int=%lld\n",dst->data_int);
1942
+ // printf("scr0->data_int=%lld\n",src0->data_int);
1943
+ // printf("scr1->data_int=%lld\n",src1->data_int);
1944
+ // printf("dst->data_int=%lld\n",dst->data_int);
1879
1945
  return dst;
1880
1946
  }
1881
1947
 
@@ -1890,27 +1956,41 @@ static Value greater_value_numeric(Value src0, Value src1, Value dst) {
1890
1956
  dst->type = src0->type;
1891
1957
  dst->numeric = 1;
1892
1958
 
1893
- /* Perform the greater. */
1959
+ // /* Perform the greater. */
1960
+ // if (src0->type->flags.sign) {
1961
+ // if (src1->type->flags.sign) {
1962
+ // dst->data_int =
1963
+ // ((signed long long)src0->data_int >
1964
+ // (signed long long)src1->data_int);
1965
+ // } else {
1966
+ // dst->data_int =
1967
+ // ((signed long long)src0->data_int >
1968
+ // (unsigned long long)src1->data_int);
1969
+ // }
1970
+ // } else {
1971
+ // if (src1->type->flags.sign) {
1972
+ // dst->data_int =
1973
+ // ((unsigned long long)src0->data_int >
1974
+ // (signed long long)src1->data_int);
1975
+ // } else {
1976
+ // dst->data_int =
1977
+ // ((unsigned long long)src0->data_int >
1978
+ // (unsigned long long)src1->data_int);
1979
+ // }
1980
+ // }
1981
+ unsigned long long src0i = src0->data_int;
1982
+ unsigned long long src1i = src1->data_int;
1983
+ /* Perform the comparison. */
1894
1984
  if (src0->type->flags.sign) {
1895
- if (src1->type->flags.sign) {
1896
- dst->data_int =
1897
- ((signed long long)src0->data_int >
1898
- (signed long long)src1->data_int);
1899
- } else {
1900
- dst->data_int =
1901
- ((signed long long)src0->data_int >
1902
- (unsigned long long)src1->data_int);
1903
- }
1985
+ if (src1->type->flags.sign)
1986
+ dst->data_int = (signed long long)src0i > (signed long long)src1i;
1987
+ else
1988
+ dst->data_int = (signed long long)src0i >= 0 ? src0i > src1i : 0;
1904
1989
  } else {
1905
- if (src1->type->flags.sign) {
1906
- dst->data_int =
1907
- ((unsigned long long)src0->data_int >
1908
- (signed long long)src1->data_int);
1909
- } else {
1910
- dst->data_int =
1911
- ((unsigned long long)src0->data_int >
1912
- (unsigned long long)src1->data_int);
1913
- }
1990
+ if (src1->type->flags.sign)
1991
+ dst->data_int = (signed long long)src1i >= 0 ? src0i > src1i : 1;
1992
+ else
1993
+ dst->data_int = src0i > src1i;
1914
1994
  }
1915
1995
  return dst;
1916
1996
  }
@@ -1925,27 +2005,41 @@ static Value lesser_value_numeric(Value src0, Value src1, Value dst) {
1925
2005
  dst->type = src0->type;
1926
2006
  dst->numeric = 1;
1927
2007
 
1928
- /* Perform the lesser. */
2008
+ // /* Perform the lesser. */
2009
+ // if (src0->type->flags.sign) {
2010
+ // if (src1->type->flags.sign) {
2011
+ // dst->data_int =
2012
+ // ((signed long long)src0->data_int <
2013
+ // (signed long long)src1->data_int);
2014
+ // } else {
2015
+ // dst->data_int =
2016
+ // ((signed long long)src0->data_int <
2017
+ // (unsigned long long)src1->data_int);
2018
+ // }
2019
+ // } else {
2020
+ // if (src1->type->flags.sign) {
2021
+ // dst->data_int =
2022
+ // ((unsigned long long)src0->data_int <
2023
+ // (signed long long)src1->data_int);
2024
+ // } else {
2025
+ // dst->data_int =
2026
+ // ((unsigned long long)src0->data_int <
2027
+ // (unsigned long long)src1->data_int);
2028
+ // }
2029
+ // }
2030
+ unsigned long long src0i = src0->data_int;
2031
+ unsigned long long src1i = src1->data_int;
2032
+ /* Perform the comparison. */
1929
2033
  if (src0->type->flags.sign) {
1930
- if (src1->type->flags.sign) {
1931
- dst->data_int =
1932
- ((signed long long)src0->data_int <
1933
- (signed long long)src1->data_int);
1934
- } else {
1935
- dst->data_int =
1936
- ((signed long long)src0->data_int <
1937
- (unsigned long long)src1->data_int);
1938
- }
2034
+ if (src1->type->flags.sign)
2035
+ dst->data_int = (signed long long)src0i < (signed long long)src1i;
2036
+ else
2037
+ dst->data_int = (signed long long)src0i >= 0 ? src0i < src1i : 1;
1939
2038
  } else {
1940
- if (src1->type->flags.sign) {
1941
- dst->data_int =
1942
- ((unsigned long long)src0->data_int <
1943
- (signed long long)src1->data_int);
1944
- } else {
1945
- dst->data_int =
1946
- ((unsigned long long)src0->data_int <
1947
- (unsigned long long)src1->data_int);
1948
- }
2039
+ if (src1->type->flags.sign)
2040
+ dst->data_int = (signed long long)src1i >= 0 ? src0i < src1i : 0;
2041
+ else
2042
+ dst->data_int = src0i < src1i;
1949
2043
  }
1950
2044
  return dst;
1951
2045
  }
@@ -1960,27 +2054,41 @@ static Value greater_equal_value_numeric(Value src0, Value src1, Value dst) {
1960
2054
  dst->type = src0->type;
1961
2055
  dst->numeric = 1;
1962
2056
 
1963
- /* Perform the greater or equal. */
2057
+ // /* Perform the greater or equal. */
2058
+ // if (src0->type->flags.sign) {
2059
+ // if (src1->type->flags.sign) {
2060
+ // dst->data_int =
2061
+ // ((signed long long)src0->data_int >=
2062
+ // (signed long long)src1->data_int);
2063
+ // } else {
2064
+ // dst->data_int =
2065
+ // ((signed long long)src0->data_int >=
2066
+ // (unsigned long long)src1->data_int);
2067
+ // }
2068
+ // } else {
2069
+ // if (src1->type->flags.sign) {
2070
+ // dst->data_int =
2071
+ // ((unsigned long long)src0->data_int >=
2072
+ // (signed long long)src1->data_int);
2073
+ // } else {
2074
+ // dst->data_int =
2075
+ // ((unsigned long long)src0->data_int >=
2076
+ // (unsigned long long)src1->data_int);
2077
+ // }
2078
+ // }
2079
+ unsigned long long src0i = src0->data_int;
2080
+ unsigned long long src1i = src1->data_int;
2081
+ /* Perform the comparison. */
1964
2082
  if (src0->type->flags.sign) {
1965
- if (src1->type->flags.sign) {
1966
- dst->data_int =
1967
- ((signed long long)src0->data_int >=
1968
- (signed long long)src1->data_int);
1969
- } else {
1970
- dst->data_int =
1971
- ((signed long long)src0->data_int >=
1972
- (unsigned long long)src1->data_int);
1973
- }
2083
+ if (src1->type->flags.sign)
2084
+ dst->data_int = (signed long long)src0i >= (signed long long)src1i;
2085
+ else
2086
+ dst->data_int = (signed long long)src0i >= 0 ? src0i >= src1i : 0;
1974
2087
  } else {
1975
- if (src1->type->flags.sign) {
1976
- dst->data_int =
1977
- ((unsigned long long)src0->data_int >=
1978
- (signed long long)src1->data_int);
1979
- } else {
1980
- dst->data_int =
1981
- ((unsigned long long)src0->data_int >=
1982
- (unsigned long long)src1->data_int);
1983
- }
2088
+ if (src1->type->flags.sign)
2089
+ dst->data_int = (signed long long)src1i >= 0 ? src0i >= src1i : 1;
2090
+ else
2091
+ dst->data_int = src0i >= src1i;
1984
2092
  }
1985
2093
  return dst;
1986
2094
  }
@@ -1995,27 +2103,41 @@ static Value lesser_equal_value_numeric(Value src0, Value src1, Value dst) {
1995
2103
  dst->type = src0->type;
1996
2104
  dst->numeric = 1;
1997
2105
 
1998
- /* Perform the lesser or equal. */
2106
+ // /* Perform the lesser or equal. */
2107
+ // if (src0->type->flags.sign) {
2108
+ // if (src1->type->flags.sign) {
2109
+ // dst->data_int =
2110
+ // ((signed long long)src0->data_int <=
2111
+ // (signed long long)src1->data_int);
2112
+ // } else {
2113
+ // dst->data_int =
2114
+ // ((signed long long)src0->data_int <=
2115
+ // (unsigned long long)src1->data_int);
2116
+ // }
2117
+ // } else {
2118
+ // if (src1->type->flags.sign) {
2119
+ // dst->data_int =
2120
+ // ((unsigned long long)src0->data_int <=
2121
+ // (signed long long)src1->data_int);
2122
+ // } else {
2123
+ // dst->data_int =
2124
+ // ((unsigned long long)src0->data_int <=
2125
+ // (unsigned long long)src1->data_int);
2126
+ // }
2127
+ // }
2128
+ unsigned long long src0i = src0->data_int;
2129
+ unsigned long long src1i = src1->data_int;
2130
+ /* Perform the comparison. */
1999
2131
  if (src0->type->flags.sign) {
2000
- if (src1->type->flags.sign) {
2001
- dst->data_int =
2002
- ((signed long long)src0->data_int <=
2003
- (signed long long)src1->data_int);
2004
- } else {
2005
- dst->data_int =
2006
- ((signed long long)src0->data_int <=
2007
- (unsigned long long)src1->data_int);
2008
- }
2132
+ if (src1->type->flags.sign)
2133
+ dst->data_int = (signed long long)src0i <= (signed long long)src1i;
2134
+ else
2135
+ dst->data_int = (signed long long)src0i >= 0 ? src0i <= src1i : 1;
2009
2136
  } else {
2010
- if (src1->type->flags.sign) {
2011
- dst->data_int =
2012
- ((unsigned long long)src0->data_int <=
2013
- (signed long long)src1->data_int);
2014
- } else {
2015
- dst->data_int =
2016
- ((unsigned long long)src0->data_int <=
2017
- (unsigned long long)src1->data_int);
2018
- }
2137
+ if (src1->type->flags.sign)
2138
+ dst->data_int = (signed long long)src1i >= 0 ? src0i <= src1i : 0;
2139
+ else
2140
+ dst->data_int = src0i <= src1i;
2019
2141
  }
2020
2142
  return dst;
2021
2143
  }
@@ -2048,7 +2170,7 @@ static Value select_value_numeric(Value cond, Value dst, unsigned int num,
2048
2170
  * @param dir the direction of the concatenation.
2049
2171
  * @param dst the destination value
2050
2172
  * @return dst */
2051
- static Value concat_value_numeric_array(int num, int dir,
2173
+ static Value concat_value_numeric_array(unsigned int num, int dir,
2052
2174
  Value dst, Value* args) {
2053
2175
  unsigned int i,pos;
2054
2176
  /* Compute the bit width of the destination. */
@@ -2146,7 +2268,8 @@ static int same_content_value_range_numeric(Value value0,
2146
2268
  * @param base the type of the elements
2147
2269
  * @param dst the destination value
2148
2270
  * @return dst */
2149
- Value read_range_numeric(Value value, long long first, long long last,
2271
+ Value read_range_numeric(Value value,
2272
+ unsigned long long first, unsigned long long last,
2150
2273
  Type base, Value dst) {
2151
2274
  /* printf("read_range_numeric with value=%llx and first=%llu and last=%llu\n",value->data_int,first,last); */
2152
2275
  /* Ensure first is the smaller. */
@@ -2159,6 +2282,7 @@ Value read_range_numeric(Value value, long long first, long long last,
2159
2282
  long long length = last-first+1;
2160
2283
  /* Compute the elements size. */
2161
2284
  unsigned long long bw = type_width(base);
2285
+ // printf("bw=%llu\n",bw);
2162
2286
  /* Scale the range according to the base type. */
2163
2287
  first *= bw;
2164
2288
  last *= bw;
@@ -2191,7 +2315,8 @@ Value read_range_numeric(Value value, long long first, long long last,
2191
2315
  * @param base the type of the elements
2192
2316
  * @param dst the destination value
2193
2317
  * @return dst */
2194
- Value write_range_numeric(Value src, long long first, long long last,
2318
+ Value write_range_numeric(Value src,
2319
+ unsigned long long first, unsigned long long last,
2195
2320
  Type base, Value dst) {
2196
2321
  // printf("write_range_numeric\n");
2197
2322
  /* Ensure first is the smaller. */
@@ -2329,7 +2454,7 @@ Value mul_value(Value src0, Value src1, Value dst) {
2329
2454
  // printf("src0->numeric=%d src1->numeric=%d\n",src0->numeric,src1->numeric);
2330
2455
  // printf("is_defined_value(src0)=%d is_defined_value(src1)=%d\n",is_defined_value(src0),is_defined_value(src1));
2331
2456
  /* Might allocate a new value so save the current pool state. */
2332
- unsigned int pos = get_value_pos();
2457
+ // unsigned int pos = get_value_pos();
2333
2458
  /* Do a numeric computation if possible, otherwise fallback to bitstring
2334
2459
  * computation. */
2335
2460
  if (src0->numeric) {
@@ -2377,7 +2502,7 @@ Value mul_value(Value src0, Value src1, Value dst) {
2377
2502
  * @return dst */
2378
2503
  Value div_value(Value src0, Value src1, Value dst) {
2379
2504
  /* Might allocate a new value so save the current pool state. */
2380
- unsigned int pos = get_value_pos();
2505
+ // unsigned int pos = get_value_pos();
2381
2506
  /* Do a numeric computation if possible, otherwise fallback to bitstring
2382
2507
  * computation. */
2383
2508
  if (src0->numeric && src1->numeric) {
@@ -2404,7 +2529,7 @@ Value div_value(Value src0, Value src1, Value dst) {
2404
2529
  * @return dst */
2405
2530
  Value mod_value(Value src0, Value src1, Value dst) {
2406
2531
  /* Might allocate a new value so save the current pool state. */
2407
- unsigned int pos = get_value_pos();
2532
+ // unsigned int pos = get_value_pos();
2408
2533
  /* Do a numeric computation if possible, otherwise fallback to bitstring
2409
2534
  * computation. */
2410
2535
  if (src0->numeric && src1->numeric) {
@@ -2688,7 +2813,7 @@ Value not_equal_value_c(Value src0, Value src1, Value dst) {
2688
2813
  * @return dst */
2689
2814
  Value greater_value(Value src0, Value src1, Value dst) {
2690
2815
  /* Might allocate a new value so save the current pool state. */
2691
- unsigned int pos = get_value_pos();
2816
+ // unsigned int pos = get_value_pos();
2692
2817
  /* Do a numeric computation if possible, otherwise fallback to bitstring
2693
2818
  * computation. */
2694
2819
  if (src0->numeric && src1->numeric) {
@@ -2715,7 +2840,7 @@ Value greater_value(Value src0, Value src1, Value dst) {
2715
2840
  * @return dst */
2716
2841
  Value lesser_value(Value src0, Value src1, Value dst) {
2717
2842
  /* Might allocate a new value so save the current pool state. */
2718
- unsigned int pos = get_value_pos();
2843
+ // unsigned int pos = get_value_pos();
2719
2844
  /* Do a numeric computation if possible, otherwise fallback to bitstring
2720
2845
  * computation. */
2721
2846
  if (src0->numeric && src1->numeric) {
@@ -2742,7 +2867,7 @@ Value lesser_value(Value src0, Value src1, Value dst) {
2742
2867
  * @return dst */
2743
2868
  Value greater_equal_value(Value src0, Value src1, Value dst) {
2744
2869
  /* Might allocate a new value so save the current pool state. */
2745
- unsigned int pos = get_value_pos();
2870
+ // unsigned int pos = get_value_pos();
2746
2871
  /* Do a numeric computation if possible, otherwise fallback to bitstring
2747
2872
  * computation. */
2748
2873
  if (src0->numeric && src1->numeric) {
@@ -2768,7 +2893,7 @@ Value greater_equal_value(Value src0, Value src1, Value dst) {
2768
2893
  * @return dst */
2769
2894
  Value lesser_equal_value(Value src0, Value src1, Value dst) {
2770
2895
  /* Might allocate a new value so save the current pool state. */
2771
- unsigned int pos = get_value_pos();
2896
+ // unsigned int pos = get_value_pos();
2772
2897
  /* Do a numeric computation if possible, otherwise fallback to bitstring
2773
2898
  * computation. */
2774
2899
  if (src0->numeric && src1->numeric) {
@@ -2813,9 +2938,10 @@ Value select_value(Value cond, Value dst, unsigned int num, ...) {
2813
2938
  * @param num the number of values to concat
2814
2939
  * @param dst the destination value
2815
2940
  * @return dst */
2816
- Value concat_valueP(int num, int dir, Value dst, Value* values) {
2941
+ Value concat_valueP(unsigned int num, int dir, Value dst, Value* values) {
2817
2942
  unsigned long long width = 0;
2818
- int numeric = 1, i;
2943
+ int numeric = 1;
2944
+ unsigned int i;
2819
2945
  /* check if all the sub values are numeric. */
2820
2946
  for(i=0; i<num; ++i) {
2821
2947
  if (!values[i]->numeric) {
@@ -2849,8 +2975,8 @@ Value concat_valueP(int num, int dir, Value dst, Value* values) {
2849
2975
  }
2850
2976
  return dst;
2851
2977
  }
2852
- Value concat_valueV(int num, int dir, Value dst, va_list args) {
2853
- int i;
2978
+ Value concat_valueV(unsigned int num, int dir, Value dst, va_list args) {
2979
+ unsigned int i;
2854
2980
  Value* values = alloca(num*sizeof(Value)); /* The values to concatenate. */
2855
2981
  /* Copy the arguments to values for easier processing. */
2856
2982
  for(i=0; i<num; ++i) {
@@ -2858,7 +2984,7 @@ Value concat_valueV(int num, int dir, Value dst, va_list args) {
2858
2984
  }
2859
2985
  return concat_valueP(num,dir,dst,values);
2860
2986
  }
2861
- Value concat_value(int num, int dir, Value dst, ...) {
2987
+ Value concat_value(unsigned int num, int dir, Value dst, ...) {
2862
2988
  va_list args;
2863
2989
  va_start(args,dst);
2864
2990
  dst = concat_valueV(num,dir,dst,args);
@@ -2984,8 +3110,8 @@ int same_content_value_range(Value value0,
2984
3110
  * @param first the start index of the range
2985
3111
  * @param last the end index of the range
2986
3112
  * @return the resulting reference */
2987
- RefRangeS make_ref_rangeS(SignalI signal, Type typ, unsigned long long first,
2988
- unsigned long long last) {
3113
+ RefRangeS make_ref_rangeS(SignalI signal, Type typ,
3114
+ unsigned long long first, unsigned long long last) {
2989
3115
  RefRangeS result = { signal, typ, first, last };
2990
3116
  return result;
2991
3117
  }
@@ -3075,8 +3201,9 @@ unsigned long long value2integer(Value value) {
3075
3201
  * @param base the type of the elements
3076
3202
  * @param dst the destination value
3077
3203
  * @return dst */
3078
- Value read_range(Value value, long long first, long long last, Type base,
3079
- Value dst) {
3204
+ Value read_range(Value value,
3205
+ unsigned long long first, unsigned long long last,
3206
+ Type base, Value dst) {
3080
3207
  /* Is the value numeric? */
3081
3208
  if (value->numeric) {
3082
3209
  /* Yes, do a numeric range read. */
@@ -3152,8 +3279,9 @@ Value read_range(Value value, long long first, long long last, Type base,
3152
3279
  * @param base the type of the elements
3153
3280
  * @param dst the destination value
3154
3281
  * @return dst */
3155
- Value write_range(Value src, long long first, long long last, Type base,
3156
- Value dst) {
3282
+ Value write_range(Value src,
3283
+ unsigned long long first, unsigned long long last,
3284
+ Type base, Value dst) {
3157
3285
  // printf("write_range\n");
3158
3286
  /* Is the value numeric? */
3159
3287
  if ((src->numeric) && (dst->numeric)) {
@@ -3182,8 +3310,9 @@ Value write_range(Value src, long long first, long long last, Type base,
3182
3310
  * @param base the type of the elements
3183
3311
  * @param dst the destination value
3184
3312
  * @return dst */
3185
- Value write_range_no_z(Value src, long long first, long long last, Type base,
3186
- Value dst) {
3313
+ Value write_range_no_z(Value src,
3314
+ unsigned long long first, unsigned long long last,
3315
+ Type base, Value dst) {
3187
3316
  // printf("write_range_no_z\n");
3188
3317
  /* Is the value numeric? */
3189
3318
  if ((src->numeric) && (dst->numeric)) {