HDLRuby 3.7.4 → 3.7.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.md +4 -0
- data/ext/hruby_sim/hruby_sim_calc.c +236 -126
- data/ext/hruby_sim/hruby_sim_tree_calc.c +5 -1
- data/ext/hruby_sim/hruby_value_pool.c +2 -0
- data/lib/HDLRuby/hdr_samples/comparison_bench.rb +36 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_leak_check.rb +46 -0
- data/lib/HDLRuby/std/sequencer_sw.rb +4 -4
- data/lib/HDLRuby/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af734e680200b79bc927ebf845cf13e712f5614a6f2188f23385f53f059442d1
|
4
|
+
data.tar.gz: be3d20a777119fd87686749b798df6a9f27ac9a0e7101821b1ab5a64d186a3c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14dd0ec35076907dddb6448965c6ce6a9ffc5e00d229760a0f3d2a30d0c8f3cf60b27567cac50abfe6c321db6e86a86ef3961c166372283eef55e273c8c85279
|
7
|
+
data.tar.gz: c63ef648b2782b10b02afba2247ba782bc34e83617a5d5b1bb11524844f2036e6cf47f6c435159f505ce2ee99201bb7c2663d39a04c76dd654e411249593d485
|
data/README.md
CHANGED
@@ -17,6 +17,10 @@ hdrcc --get-tuto
|
|
17
17
|
|
18
18
|
__What's new__
|
19
19
|
|
20
|
+
For HDLRuby version 3.7.4/3.7.5:
|
21
|
+
|
22
|
+
* Various bug fixes.
|
23
|
+
|
20
24
|
For HDLRuby version 3.7.3:
|
21
25
|
|
22
26
|
* Added the possibility to use software sequencers inside HDLRuby's program construct, and use within them program ports like they were input or output signals.
|
@@ -593,6 +593,7 @@ static Value sub_value_bitstring(Value src0, Value src1, Value dst) {
|
|
593
593
|
/* Compute the width of sources in bits. */
|
594
594
|
unsigned long long width0 = type_width(src0->type);
|
595
595
|
unsigned long long width1 = type_width(src1->type);
|
596
|
+
// printf("sub_value_bitstring, width0=%llu width1=%llu\n",width0,width1);
|
596
597
|
|
597
598
|
/* Update the destination capacity if required. */
|
598
599
|
resize_value(dst,width0);
|
@@ -605,6 +606,8 @@ static Value sub_value_bitstring(Value src0, Value src1, Value dst) {
|
|
605
606
|
char *src1_data = src1->data_str;
|
606
607
|
/* Get access to the data of the destination. */
|
607
608
|
char *dst_data = dst->data_str;
|
609
|
+
// printf("src0_data=%s\n",src0_data);
|
610
|
+
// printf("src1_data=%s\n",src1_data);
|
608
611
|
|
609
612
|
/* Get the sign extension character of source 1 and convert it to a bit.*/
|
610
613
|
// int ext = src1->type->flags.sign ? src1_data[width1-1] - '0' : 0;
|
@@ -620,10 +623,12 @@ static Value sub_value_bitstring(Value src0, Value src1, Value dst) {
|
|
620
623
|
if (count < width1) {
|
621
624
|
char d1 = src1_data[count] - '0';/* Get and convert to bit. */
|
622
625
|
if ((d0 == (d0&1)) && (d1 == (d1&1))) {
|
623
|
-
d1 = !d1; /* For the subtraction: a + ~b + 1 */
|
626
|
+
// d1 = !d1; /* For the subtraction: a + ~b + 1 */
|
627
|
+
d1 = d1 ^ 1; /* For the subtraction: a + ~b + 1 */
|
624
628
|
/* d0 and d1 are defined. */
|
625
629
|
res = d0 ^ (d1) ^ carry;
|
626
630
|
carry = (d0&d1) | (d0&carry) | (d1&carry);
|
631
|
+
//printf("d0=%d d1=%d res=%d carry=%d\n",d0,d1,res,carry);
|
627
632
|
} else {
|
628
633
|
/* Either input bit is undefined, end here. */
|
629
634
|
break;
|
@@ -650,6 +655,7 @@ static Value sub_value_bitstring(Value src0, Value src1, Value dst) {
|
|
650
655
|
for(;count < width0; ++count) {
|
651
656
|
dst_data[count] = 'x';
|
652
657
|
}
|
658
|
+
// printf("dst_data=%s\n",dst_data);
|
653
659
|
/* Return the destination. */
|
654
660
|
return dst;
|
655
661
|
}
|
@@ -777,47 +783,72 @@ static Value mod_value_defined_bitstring(Value src0, Value src1, Value dst) {
|
|
777
783
|
* @param dst the destination value
|
778
784
|
* @return dst */
|
779
785
|
static Value greater_value_defined_bitstring(Value src0, Value src1, Value dst) {
|
786
|
+
// printf("greater_value_defined_bitstring.\n");
|
780
787
|
/* Sets state of the destination using the first source. */
|
781
788
|
dst->type = src0->type;
|
782
789
|
dst->numeric = 1;
|
783
790
|
|
791
|
+
// /* Converts the values to integers. */
|
792
|
+
// unsigned long long src0i = value2integer(src0);
|
793
|
+
// unsigned long long src1i = value2integer(src1);
|
784
794
|
// /* Perform the comparison. */
|
785
795
|
// if (src0->type->flags.sign) {
|
786
|
-
// if (src1->type->flags.sign)
|
787
|
-
// dst->data_int =
|
788
|
-
//
|
789
|
-
//
|
790
|
-
// } else {
|
791
|
-
// dst->data_int =
|
792
|
-
// ((signed long long)value2integer(src0) >
|
793
|
-
// (unsigned long long)value2integer(src1));
|
794
|
-
// }
|
796
|
+
// if (src1->type->flags.sign)
|
797
|
+
// dst->data_int = (signed long long)src0i > (signed long long)src1i;
|
798
|
+
// else
|
799
|
+
// dst->data_int = (signed long long)src0i >= 0 ? src0i > src1i : 0;
|
795
800
|
// } else {
|
796
|
-
// if (src1->type->flags.sign)
|
797
|
-
// dst->data_int =
|
798
|
-
//
|
799
|
-
//
|
800
|
-
// } else {
|
801
|
-
// dst->data_int =
|
802
|
-
// ((unsigned long long)value2integer(src0) >
|
803
|
-
// (unsigned long long)value2integer(src1));
|
804
|
-
// }
|
801
|
+
// if (src1->type->flags.sign)
|
802
|
+
// dst->data_int = (signed long long)src1i >= 0 ? src0i > src1i : 1;
|
803
|
+
// else
|
804
|
+
// dst->data_int = src0i > src1i;
|
805
805
|
// }
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
806
|
+
char* src0_data = src0->data_str;
|
807
|
+
char* src1_data = src1->data_str;
|
808
|
+
long long width0 = type_width(src0->type);
|
809
|
+
long long width1 = type_width(src1->type);
|
810
|
+
long long width = width0>width1 ? width0 : width1;
|
811
|
+
if (src0->type->flags.sign && src0_data[width0-1] == '1') {
|
812
|
+
if(src1->type->flags.sign && src1_data[width1-1] == '1') {
|
813
|
+
/* Negative-negative comparison. */
|
814
|
+
for(long long i=width-1; i >= 0; --i) {
|
815
|
+
char d0 = i >= width0 ? '1' : src0_data[i];
|
816
|
+
char d1 = i >= width1 ? '1' : src1_data[i];
|
817
|
+
if (d0 < d1) {
|
818
|
+
dst->data_int = 0;
|
819
|
+
return dst;
|
820
|
+
} else if (d0 > d1) {
|
821
|
+
dst->data_int = 1;
|
822
|
+
return dst;
|
823
|
+
}
|
824
|
+
}
|
825
|
+
} else {
|
826
|
+
/* Negative positive comparison, src0 is smaller. */
|
827
|
+
dst->data_int = 0;
|
828
|
+
return dst;
|
829
|
+
}
|
815
830
|
} else {
|
816
|
-
if
|
817
|
-
|
818
|
-
|
819
|
-
dst
|
831
|
+
if(src1->type->flags.sign && src1_data[width1-1] == '1') {
|
832
|
+
/* Positive-negative comparison, src0 is greater. */
|
833
|
+
dst->data_int = 1;
|
834
|
+
return dst;
|
835
|
+
} else {
|
836
|
+
/* Positive-positive comparison. */
|
837
|
+
for(long long i=width-1; i >= 0; --i) {
|
838
|
+
char d0 = i >= width0 ? '0' : src0_data[i];
|
839
|
+
char d1 = i >= width1 ? '0' : src1_data[i];
|
840
|
+
if (d0 < d1) {
|
841
|
+
dst->data_int = 0;
|
842
|
+
return dst;
|
843
|
+
} else if (d0 > d1) {
|
844
|
+
dst->data_int = 1;
|
845
|
+
return dst;
|
846
|
+
}
|
847
|
+
}
|
848
|
+
}
|
820
849
|
}
|
850
|
+
/* Equality. */
|
851
|
+
dst->data_int = 0;
|
821
852
|
return dst;
|
822
853
|
}
|
823
854
|
|
@@ -827,47 +858,72 @@ static Value greater_value_defined_bitstring(Value src0, Value src1, Value dst)
|
|
827
858
|
* @param dst the destination value
|
828
859
|
* @return dst */
|
829
860
|
static Value lesser_value_defined_bitstring(Value src0, Value src1, Value dst) {
|
861
|
+
// printf("lesser_value_defined_bitstring.\n");
|
830
862
|
/* Sets state of the destination using the first source. */
|
831
863
|
dst->type = src0->type;
|
832
864
|
dst->numeric = 1;
|
833
865
|
|
866
|
+
// /* Converts the values to integers. */
|
867
|
+
// unsigned long long src0i = value2integer(src0);
|
868
|
+
// unsigned long long src1i = value2integer(src1);
|
834
869
|
// /* Perform the comparison. */
|
835
870
|
// if (src0->type->flags.sign) {
|
836
|
-
// if (src1->type->flags.sign)
|
837
|
-
// dst->data_int =
|
838
|
-
//
|
839
|
-
//
|
840
|
-
// } else {
|
841
|
-
// dst->data_int =
|
842
|
-
// ((signed long long)value2integer(src0) <
|
843
|
-
// (unsigned long long)value2integer(src1));
|
844
|
-
// }
|
871
|
+
// if (src1->type->flags.sign)
|
872
|
+
// dst->data_int = (signed long long)src0i < (signed long long)src1i;
|
873
|
+
// else
|
874
|
+
// dst->data_int = (signed long long)src0i >= 0 ? src0i < src1i : 1;
|
845
875
|
// } else {
|
846
|
-
// if (src1->type->flags.sign)
|
847
|
-
// dst->data_int =
|
848
|
-
//
|
849
|
-
//
|
850
|
-
// } else {
|
851
|
-
// dst->data_int =
|
852
|
-
// ((unsigned long long)value2integer(src0) <
|
853
|
-
// (unsigned long long)value2integer(src1));
|
854
|
-
// }
|
876
|
+
// if (src1->type->flags.sign)
|
877
|
+
// dst->data_int = (signed long long)src1i >= 0 ? src0i < src1i : 0;
|
878
|
+
// else
|
879
|
+
// dst->data_int = src0i < src1i;
|
855
880
|
// }
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
881
|
+
char* src0_data = src0->data_str;
|
882
|
+
char* src1_data = src1->data_str;
|
883
|
+
long long width0 = type_width(src0->type);
|
884
|
+
long long width1 = type_width(src1->type);
|
885
|
+
long long width = width0>width1 ? width0 : width1;
|
886
|
+
if (src0->type->flags.sign && src0_data[width0-1] == '1') {
|
887
|
+
if(src1->type->flags.sign && src1_data[width1-1] == '1') {
|
888
|
+
/* Negative-negative comparison. */
|
889
|
+
for(long long i=width-1; i >= 0; --i) {
|
890
|
+
char d0 = i >= width0 ? '1' : src0_data[i];
|
891
|
+
char d1 = i >= width1 ? '1' : src1_data[i];
|
892
|
+
if (d0 < d1) {
|
893
|
+
dst->data_int = 1;
|
894
|
+
return dst;
|
895
|
+
} else if (d0 > d1) {
|
896
|
+
dst->data_int = 0;
|
897
|
+
return dst;
|
898
|
+
}
|
899
|
+
}
|
900
|
+
} else {
|
901
|
+
/* Negative positive comparison, src0 is smaller. */
|
902
|
+
dst->data_int = 1;
|
903
|
+
return dst;
|
904
|
+
}
|
865
905
|
} else {
|
866
|
-
if
|
867
|
-
|
868
|
-
|
869
|
-
dst
|
906
|
+
if(src1->type->flags.sign && src1_data[width1-1] == '1') {
|
907
|
+
/* Positive-negative comparison, src0 is greater. */
|
908
|
+
dst->data_int = 0;
|
909
|
+
return dst;
|
910
|
+
} else {
|
911
|
+
/* Positive-positive comparison. */
|
912
|
+
for(long long i=width-1; i >= 0; --i) {
|
913
|
+
char d0 = i >= width0 ? '0' : src0_data[i];
|
914
|
+
char d1 = i >= width1 ? '0' : src1_data[i];
|
915
|
+
if (d0 < d1) {
|
916
|
+
dst->data_int = 1;
|
917
|
+
return dst;
|
918
|
+
} else if (d0 > d1) {
|
919
|
+
dst->data_int = 0;
|
920
|
+
return dst;
|
921
|
+
}
|
922
|
+
}
|
923
|
+
}
|
870
924
|
}
|
925
|
+
/* Equality. */
|
926
|
+
dst->data_int = 0;
|
871
927
|
return dst;
|
872
928
|
}
|
873
929
|
|
@@ -881,44 +937,68 @@ static Value greater_equal_value_defined_bitstring(Value src0, Value src1, Value
|
|
881
937
|
dst->type = src0->type;
|
882
938
|
dst->numeric = 1;
|
883
939
|
|
940
|
+
// /* Converts the values to integers. */
|
941
|
+
// unsigned long long src0i = value2integer(src0);
|
942
|
+
// unsigned long long src1i = value2integer(src1);
|
943
|
+
// // printf("src0i=%lld src1i=%lld, src0i.sign=%d src0i.width=%d, src1i.sign=%d src1i.width=%d\n",src0i,src1i,src0->type->flags.sign,type_width(src0->type),src1->type->flags.sign,type_width(src1->type));
|
884
944
|
// /* Perform the comparison. */
|
885
945
|
// if (src0->type->flags.sign) {
|
886
|
-
// if (src1->type->flags.sign)
|
887
|
-
// dst->data_int =
|
888
|
-
//
|
889
|
-
//
|
890
|
-
// } else {
|
891
|
-
// dst->data_int =
|
892
|
-
// ((signed long long)value2integer(src0) >=
|
893
|
-
// (unsigned long long)value2integer(src1));
|
894
|
-
// }
|
946
|
+
// if (src1->type->flags.sign)
|
947
|
+
// dst->data_int = (signed long long)src0i >= (signed long long)src1i;
|
948
|
+
// else
|
949
|
+
// dst->data_int = (signed long long)src0i >= 0 ? src0i >= src1i : 0;
|
895
950
|
// } else {
|
896
|
-
// if (src1->type->flags.sign)
|
897
|
-
// dst->data_int =
|
898
|
-
//
|
899
|
-
//
|
900
|
-
// } else {
|
901
|
-
// dst->data_int =
|
902
|
-
// ((unsigned long long)value2integer(src0) >=
|
903
|
-
// (unsigned long long)value2integer(src1));
|
904
|
-
// }
|
951
|
+
// if (src1->type->flags.sign)
|
952
|
+
// dst->data_int = (signed long long)src1i >= 0 ? src0i >= src1i : 1;
|
953
|
+
// else
|
954
|
+
// dst->data_int = src0i >= src1i;
|
905
955
|
// }
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
if (src0->type->flags.sign) {
|
912
|
-
if
|
913
|
-
|
914
|
-
|
915
|
-
|
956
|
+
char* src0_data = src0->data_str;
|
957
|
+
char* src1_data = src1->data_str;
|
958
|
+
long long width0 = type_width(src0->type);
|
959
|
+
long long width1 = type_width(src1->type);
|
960
|
+
long long width = width0>width1 ? width0 : width1;
|
961
|
+
if (src0->type->flags.sign && src0_data[width0-1] == '1') {
|
962
|
+
if(src1->type->flags.sign && src1_data[width1-1] == '1') {
|
963
|
+
/* Negative-negative comparison. */
|
964
|
+
for(long long i=width-1; i >= 0; --i) {
|
965
|
+
char d0 = i >= width0 ? '1' : src0_data[i];
|
966
|
+
char d1 = i >= width1 ? '1' : src1_data[i];
|
967
|
+
if (d0 < d1) {
|
968
|
+
dst->data_int = 0;
|
969
|
+
return dst;
|
970
|
+
} else if (d0 > d1) {
|
971
|
+
dst->data_int = 1;
|
972
|
+
return dst;
|
973
|
+
}
|
974
|
+
}
|
975
|
+
} else {
|
976
|
+
/* Negative positive comparison, src0 is smaller. */
|
977
|
+
dst->data_int = 0;
|
978
|
+
return dst;
|
979
|
+
}
|
916
980
|
} else {
|
917
|
-
if
|
918
|
-
|
919
|
-
|
920
|
-
dst
|
981
|
+
if(src1->type->flags.sign && src1_data[width1-1] == '1') {
|
982
|
+
/* Positive-negative comparison, src0 is greater. */
|
983
|
+
dst->data_int = 1;
|
984
|
+
return dst;
|
985
|
+
} else {
|
986
|
+
/* Positive-positive comparison. */
|
987
|
+
for(long long i=width-1; i >= 0; --i) {
|
988
|
+
char d0 = i >= width0 ? '0' : src0_data[i];
|
989
|
+
char d1 = i >= width1 ? '0' : src1_data[i];
|
990
|
+
if (d0 < d1) {
|
991
|
+
dst->data_int = 0;
|
992
|
+
return dst;
|
993
|
+
} else if (d0 > d1) {
|
994
|
+
dst->data_int = 1;
|
995
|
+
return dst;
|
996
|
+
}
|
997
|
+
}
|
998
|
+
}
|
921
999
|
}
|
1000
|
+
/* Equality. */
|
1001
|
+
dst->data_int = 1;
|
922
1002
|
return dst;
|
923
1003
|
}
|
924
1004
|
|
@@ -932,43 +1012,67 @@ static Value lesser_equal_value_defined_bitstring(Value src0, Value src1, Value
|
|
932
1012
|
dst->type = src0->type;
|
933
1013
|
dst->numeric = 1;
|
934
1014
|
|
1015
|
+
// /* Converts the values to integers. */
|
1016
|
+
// unsigned long long src0i = value2integer(src0);
|
1017
|
+
// unsigned long long src1i = value2integer(src1);
|
935
1018
|
// /* Perform the comparison. */
|
936
1019
|
// if (src0->type->flags.sign) {
|
937
|
-
// if (src1->type->flags.sign)
|
938
|
-
// dst->data_int =
|
939
|
-
//
|
940
|
-
//
|
941
|
-
// } else {
|
942
|
-
// dst->data_int =
|
943
|
-
// ((signed long long)value2integer(src0) <=
|
944
|
-
// (unsigned long long)value2integer(src1));
|
945
|
-
// }
|
1020
|
+
// if (src1->type->flags.sign)
|
1021
|
+
// dst->data_int = (signed long long)src0i <= (signed long long)src1i;
|
1022
|
+
// else
|
1023
|
+
// dst->data_int = (signed long long)src0i >= 0 ? src0i <= src1i : 1;
|
946
1024
|
// } else {
|
947
|
-
// if (src1->type->flags.sign)
|
948
|
-
// dst->data_int =
|
949
|
-
//
|
950
|
-
//
|
951
|
-
// } else {
|
952
|
-
// dst->data_int =
|
953
|
-
// ((unsigned long long)value2integer(src0) <=
|
954
|
-
// (unsigned long long)value2integer(src1));
|
955
|
-
// }
|
1025
|
+
// if (src1->type->flags.sign)
|
1026
|
+
// dst->data_int = (signed long long)src1i >= 0 ? src0i <= src1i : 0;
|
1027
|
+
// else
|
1028
|
+
// dst->data_int = src0i <= src1i;
|
956
1029
|
// }
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
1030
|
+
char* src0_data = src0->data_str;
|
1031
|
+
char* src1_data = src1->data_str;
|
1032
|
+
long long width0 = type_width(src0->type);
|
1033
|
+
long long width1 = type_width(src1->type);
|
1034
|
+
long long width = width0>width1 ? width0 : width1;
|
1035
|
+
if (src0->type->flags.sign && src0_data[width0-1] == '1') {
|
1036
|
+
if(src1->type->flags.sign && src1_data[width1-1] == '1') {
|
1037
|
+
/* Negative-negative comparison. */
|
1038
|
+
for(long long i=width-1; i >= 0; --i) {
|
1039
|
+
char d0 = i >= width0 ? '1' : src0_data[i];
|
1040
|
+
char d1 = i >= width1 ? '1' : src1_data[i];
|
1041
|
+
if (d0 < d1) {
|
1042
|
+
dst->data_int = 1;
|
1043
|
+
return dst;
|
1044
|
+
} else if (d0 > d1) {
|
1045
|
+
dst->data_int = 0;
|
1046
|
+
return dst;
|
1047
|
+
}
|
1048
|
+
}
|
1049
|
+
} else {
|
1050
|
+
/* Negative positive comparison, src0 is smaller. */
|
1051
|
+
dst->data_int = 1;
|
1052
|
+
return dst;
|
1053
|
+
}
|
966
1054
|
} else {
|
967
|
-
if
|
968
|
-
|
969
|
-
|
970
|
-
dst
|
1055
|
+
if(src1->type->flags.sign && src1_data[width1-1] == '1') {
|
1056
|
+
/* Positive-negative comparison, src0 is greater. */
|
1057
|
+
dst->data_int = 0;
|
1058
|
+
return dst;
|
1059
|
+
} else {
|
1060
|
+
/* Positive-positive comparison. */
|
1061
|
+
for(long long i=width-1; i >= 0; --i) {
|
1062
|
+
char d0 = i >= width0 ? '0' : src0_data[i];
|
1063
|
+
char d1 = i >= width1 ? '0' : src1_data[i];
|
1064
|
+
if (d0 < d1) {
|
1065
|
+
dst->data_int = 1;
|
1066
|
+
return dst;
|
1067
|
+
} else if (d0 > d1) {
|
1068
|
+
dst->data_int = 0;
|
1069
|
+
return dst;
|
1070
|
+
}
|
1071
|
+
}
|
1072
|
+
}
|
971
1073
|
}
|
1074
|
+
/* Equality. */
|
1075
|
+
dst->data_int = 1;
|
972
1076
|
return dst;
|
973
1077
|
}
|
974
1078
|
|
@@ -1193,6 +1297,7 @@ static Value or_value_bitstring(Value src0, Value src1, Value dst) {
|
|
1193
1297
|
* @param dst the destination value
|
1194
1298
|
* @return dst */
|
1195
1299
|
static Value xor_value_bitstring(Value src0, Value src1, Value dst) {
|
1300
|
+
// printf("xor_value_bitstring.\n");
|
1196
1301
|
/* Compute the width of sources in bits. */
|
1197
1302
|
unsigned long long width0 = type_width(src0->type);
|
1198
1303
|
unsigned long long width1 = type_width(src1->type);
|
@@ -1399,6 +1504,7 @@ static Value shift_right_value_bitstring(Value src0, Value src1, Value dst) {
|
|
1399
1504
|
* @param dst the destination value
|
1400
1505
|
* @return dst */
|
1401
1506
|
static Value equal_value_bitstring(Value src0, Value src1, Value dst) {
|
1507
|
+
// printf("equal_value_bitstring.\n");
|
1402
1508
|
/* Compute the width of sources in bits. */
|
1403
1509
|
unsigned long long width0 = type_width(src0->type);
|
1404
1510
|
unsigned long long width1 = type_width(src1->type);
|
@@ -2936,21 +3042,25 @@ Value shift_right_value(Value src0, Value src1, Value dst) {
|
|
2936
3042
|
* @param dst the destination value
|
2937
3043
|
* @return the destination value */
|
2938
3044
|
Value equal_value(Value src0, Value src1, Value dst) {
|
3045
|
+
// printf("equal_value.\n");
|
2939
3046
|
/* Might allocate a new value so save the current pool state. */
|
2940
3047
|
unsigned int pos = get_value_pos();
|
2941
3048
|
/* Do a numeric computation if possible, otherwise fallback to bitstring
|
2942
3049
|
* computation. */
|
2943
3050
|
if (src0->numeric) {
|
2944
3051
|
if (src1->numeric) {
|
3052
|
+
// printf("numeric numeric\n");
|
2945
3053
|
/* Both sources are numeric. */
|
2946
3054
|
return equal_value_numeric(src0,src1,dst);
|
2947
3055
|
} else {
|
3056
|
+
// printf("numeric bitstring\n");
|
2948
3057
|
/* src1 is not numeric, convert src0 to bitstring. */
|
2949
3058
|
src0 = set_bitstring_value(src0,get_value());
|
2950
3059
|
}
|
2951
3060
|
} else {
|
2952
3061
|
/* src0 is not numeric, what about src1. */
|
2953
3062
|
if (src1->numeric) {
|
3063
|
+
// printf("bitstring numeric\n");
|
2954
3064
|
/* src1 is numeric, convert it to bitstring. */
|
2955
3065
|
src1 = set_bitstring_value(src1,get_value());
|
2956
3066
|
}
|
@@ -367,6 +367,7 @@ void execute_statement(Statement stmnt, int mode, Behavior behavior) {
|
|
367
367
|
default:
|
368
368
|
perror("Invalid kind for a reference.");
|
369
369
|
}
|
370
|
+
free_value();
|
370
371
|
break;
|
371
372
|
}
|
372
373
|
case PRINT:
|
@@ -401,10 +402,13 @@ void execute_statement(Statement stmnt, int mode, Behavior behavior) {
|
|
401
402
|
Value condition = get_value();
|
402
403
|
condition = calc_expression(hif->condition,condition);
|
403
404
|
/* Is it true? */
|
404
|
-
if (is_defined_value(condition) && value2integer(condition)) {
|
405
|
+
// if (is_defined_value(condition) && value2integer(condition)) {
|
406
|
+
if (is_defined_value(condition) && !zero_value(condition)) {
|
407
|
+
// printf("Taken\n");
|
405
408
|
/* Yes, execute the yes branch. */
|
406
409
|
execute_statement(hif->yes,mode,behavior);
|
407
410
|
} else {
|
411
|
+
// printf("Not Taken\n");
|
408
412
|
/* No, maybe an alternate condition is met. */
|
409
413
|
int met = 0;/* Tell if an alternate condition has been met.*/
|
410
414
|
for(int i=0; i<hif->num_noifs; ++i) {
|
@@ -17,6 +17,7 @@ static unsigned int pool_pos = 0; /* The position in the pool. */
|
|
17
17
|
|
18
18
|
/** Get a fresh value. */
|
19
19
|
Value get_value() {
|
20
|
+
// printf("get_value, pool_cap=%d\n",pool_cap);
|
20
21
|
if (pool_cap == 0) {
|
21
22
|
/* First allocation. */
|
22
23
|
pool_cap = 16;
|
@@ -67,6 +68,7 @@ Value get_top_value() {
|
|
67
68
|
|
68
69
|
/** Frees the last value of the pool. */
|
69
70
|
void free_value() {
|
71
|
+
// printf("free_value\n");
|
70
72
|
if (pool_pos <= 0) { printf("Pool error!\n");exit(1);}
|
71
73
|
if (pool_pos > 0) pool_pos--;
|
72
74
|
}
|
@@ -21,20 +21,56 @@ system :comparison_bench do
|
|
21
21
|
sge <= (u >= v)
|
22
22
|
end
|
23
23
|
|
24
|
+
[128].inner :xL
|
25
|
+
[96].inner :yL
|
26
|
+
signed[128].inner :uL
|
27
|
+
signed[96].inner :vL
|
28
|
+
inner :ueL, :ultL, :uleL, :ugtL, :ugeL
|
29
|
+
inner :seL, :sltL, :sleL, :sgtL, :sgeL
|
30
|
+
|
31
|
+
par do
|
32
|
+
ueL <= (xL == yL)
|
33
|
+
ultL <= (xL < yL)
|
34
|
+
uleL <= (xL <= yL)
|
35
|
+
ugtL <= (xL > yL)
|
36
|
+
ugeL <= (xL >= yL)
|
37
|
+
|
38
|
+
seL <= (uL == vL)
|
39
|
+
sltL <= (uL < vL)
|
40
|
+
sleL <= (uL <= vL)
|
41
|
+
sgtL <= (uL > vL)
|
42
|
+
sgeL <= (uL >= vL)
|
43
|
+
end
|
44
|
+
|
24
45
|
timed do
|
25
46
|
x <= 0
|
26
47
|
y <= 0
|
27
48
|
u <= 0
|
28
49
|
v <= 0
|
50
|
+
xL <= 0
|
51
|
+
yL <= 0
|
52
|
+
uL <= 0
|
53
|
+
vL <= 0
|
29
54
|
!10.ns
|
30
55
|
x <= 1
|
31
56
|
u <= 1
|
57
|
+
xL <= 2**80 - 1
|
58
|
+
uL <= 2**80 - 1
|
32
59
|
!10.ns
|
33
60
|
y <= 2
|
34
61
|
v <= 2
|
62
|
+
yL <= 2**81 - 1
|
63
|
+
vL <= 2**81 - 1
|
64
|
+
!10.ns
|
65
|
+
x <= 3
|
66
|
+
u <= 3
|
67
|
+
xL <= 2**81 + 2**80 - 1
|
68
|
+
uL <= 2**81 + 2**80 - 1
|
35
69
|
!10.ns
|
36
70
|
x <= 2
|
37
71
|
u <= -2
|
72
|
+
xL <= 2**81 - 1
|
73
|
+
uL <= -2**81 + 1
|
38
74
|
!10.ns
|
39
75
|
end
|
40
76
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'std/sequencer.rb'
|
2
|
+
|
3
|
+
include HDLRuby::High::Std
|
4
|
+
|
5
|
+
# Checking for siulation leaks when using a sequencer.
|
6
|
+
system :my_seqencer do
|
7
|
+
|
8
|
+
inner :clk,:rst
|
9
|
+
[65536].inner :count
|
10
|
+
|
11
|
+
# sequencer(clk.posedge,rst) do
|
12
|
+
# sloop do
|
13
|
+
# # count <= count + 1
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
timed do
|
20
|
+
clk <= 0
|
21
|
+
rst <= 0
|
22
|
+
count <= 0
|
23
|
+
!10.ns
|
24
|
+
clk <= 1
|
25
|
+
!10.ns
|
26
|
+
clk <= 0
|
27
|
+
rst <= 1
|
28
|
+
!10.ns
|
29
|
+
clk <= 1
|
30
|
+
!10.ns
|
31
|
+
clk <= 0
|
32
|
+
rst <= 0
|
33
|
+
!10.ns
|
34
|
+
clk <= 1
|
35
|
+
repeat do
|
36
|
+
!10.ns
|
37
|
+
clk <= ~clk
|
38
|
+
hif(count == 0) { count <= 1 }
|
39
|
+
hcase(count)
|
40
|
+
hwhen(1) { count <= 2 }
|
41
|
+
hwhen(2) { count <= 3 }
|
42
|
+
hwhen(3) { count <= 4 }
|
43
|
+
helse { count <= 5 }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -222,7 +222,7 @@ module RubyHDL::High
|
|
222
222
|
:"^" => "(%{l})^(%{r})",
|
223
223
|
:"<<" => "(%{l})<<(%{r})", :">>" => "(%{l})>>(%{r})",
|
224
224
|
:"==" => "((%{l}) & %{m}==(%{r}) & %{m}) ? 1:0",
|
225
|
-
:"!=" => "((%{l}) & %{m}!=(%{r}) %{m}) ? 1:0",
|
225
|
+
:"!=" => "((%{l}) & %{m}!=(%{r}) & %{m}) ? 1:0",
|
226
226
|
:"<" => "((%{l}) & %{m}%{s} < (%{r}) & %{m}%{s}) ? 1:0",
|
227
227
|
:">" => "((%{l}) & %{m}%{s} > (%{r}) & %{m}%{s}) ? 1:0",
|
228
228
|
:"<=" => "((%{l}) & %{m}%{s} <=(%{r}) & %{m}%{s}) ? 1:0",
|
@@ -2309,9 +2309,9 @@ module RubyHDL::High
|
|
2309
2309
|
|
2310
2310
|
# Convert to Ruby code.
|
2311
2311
|
def to_ruby
|
2312
|
-
res = @sequencer.clk_up + "\nif(#{@condition.to_ruby} != 0)\n#{@yes_blk.to_ruby}\n"
|
2312
|
+
res = @sequencer.clk_up + "\nif((#{@condition.to_ruby}) != 0)\n#{@yes_blk.to_ruby}\n"
|
2313
2313
|
@elsifs.each do |(cond,blk)|
|
2314
|
-
res << "elsif(#{cond.to_ruby})\n#{blk.to_ruby}\n"
|
2314
|
+
res << "elsif((#{cond.to_ruby}) != 0)\n#{blk.to_ruby}\n"
|
2315
2315
|
end
|
2316
2316
|
if @else_blk then
|
2317
2317
|
res << "else\n#{@else_blk.to_ruby}\n"
|
@@ -2398,7 +2398,7 @@ module RubyHDL::High
|
|
2398
2398
|
# Convert to Ruby code.
|
2399
2399
|
def to_ruby
|
2400
2400
|
return @sequencer.clk_up +
|
2401
|
-
"\nwhile(#{@condition.to_ruby}) do\n#{@yes_blk.to_ruby}\n#{@sequencer.clk_up}\nend"
|
2401
|
+
"\nwhile((#{@condition.to_ruby}) != 0) do\n#{@yes_blk.to_ruby}\n#{@sequencer.clk_up}\nend"
|
2402
2402
|
end
|
2403
2403
|
|
2404
2404
|
# Convert to C code.
|
data/lib/HDLRuby/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: HDLRuby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.7.
|
4
|
+
version: 3.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lovic Gauthier
|
@@ -246,6 +246,7 @@ files:
|
|
246
246
|
- lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb
|
247
247
|
- lib/HDLRuby/hdr_samples/with_sequencer_enumerator.rb
|
248
248
|
- lib/HDLRuby/hdr_samples/with_sequencer_func.rb
|
249
|
+
- lib/HDLRuby/hdr_samples/with_sequencer_leak_check.rb
|
249
250
|
- lib/HDLRuby/hdr_samples/with_sequencer_sync.rb
|
250
251
|
- lib/HDLRuby/hdr_samples/with_str2value.rb
|
251
252
|
- lib/HDLRuby/hdr_samples/with_subsums.rb
|