diff options
| -rw-r--r-- | pyGHDL/libghdl/vhdl/nodes.py | 280 | ||||
| -rw-r--r-- | src/synth/synth-vhdl_eval.adb | 4 | ||||
| -rw-r--r-- | src/synth/synth-vhdl_oper.adb | 7 | ||||
| -rw-r--r-- | src/synth/synth-vhdl_stmts.adb | 18 | ||||
| -rw-r--r-- | src/vhdl/translate/trans-chap1.adb | 2 | ||||
| -rw-r--r-- | src/vhdl/translate/trans-chap12.adb | 2 | ||||
| -rw-r--r-- | src/vhdl/translate/trans-chap2.adb | 661 | ||||
| -rw-r--r-- | src/vhdl/translate/trans-chap2.ads | 18 | ||||
| -rw-r--r-- | src/vhdl/translate/trans-chap4.adb | 60 | ||||
| -rw-r--r-- | src/vhdl/translate/trans-chap4.ads | 2 | ||||
| -rw-r--r-- | src/vhdl/translate/translation.adb | 12 | ||||
| -rw-r--r-- | src/vhdl/vhdl-ieee-std_logic_arith.adb | 8 | ||||
| -rw-r--r-- | src/vhdl/vhdl-nodes.ads | 5 | ||||
| -rw-r--r-- | testsuite/gna/issue2395/test.vhdl | 64 | ||||
| -rwxr-xr-x | testsuite/gna/issue2395/testsuite.sh | 11 | ||||
| -rw-r--r-- | testsuite/gna/issue2410/test.vhdl | 28 | ||||
| -rwxr-xr-x | testsuite/gna/issue2410/testsuite.sh | 11 | ||||
| -rw-r--r-- | testsuite/synth/issue2408/bug.vhdl | 39 | ||||
| -rwxr-xr-x | testsuite/synth/issue2408/testsuite.sh | 8 | ||||
| -rw-r--r-- | testsuite/synth/synth183/test.vhdl | 45 | ||||
| -rwxr-xr-x | testsuite/synth/synth183/testsuite.sh | 11 |
21 files changed, 910 insertions, 386 deletions
diff --git a/pyGHDL/libghdl/vhdl/nodes.py b/pyGHDL/libghdl/vhdl/nodes.py index 72c2c57f6..e91d44a81 100644 --- a/pyGHDL/libghdl/vhdl/nodes.py +++ b/pyGHDL/libghdl/vhdl/nodes.py @@ -1836,144 +1836,148 @@ class Iir_Predefined(IntEnum): Ieee_Std_Logic_Arith_Conv_Unsigned_Uns = 614 Ieee_Std_Logic_Arith_Conv_Unsigned_Sgn = 615 Ieee_Std_Logic_Arith_Conv_Unsigned_Log = 616 - Ieee_Std_Logic_Arith_Conv_Integer_Int = 617 - Ieee_Std_Logic_Arith_Conv_Integer_Uns = 618 - Ieee_Std_Logic_Arith_Conv_Integer_Sgn = 619 - Ieee_Std_Logic_Arith_Conv_Integer_Log = 620 - Ieee_Std_Logic_Arith_Conv_Vector_Int = 621 - Ieee_Std_Logic_Arith_Conv_Vector_Uns = 622 - Ieee_Std_Logic_Arith_Conv_Vector_Sgn = 623 - Ieee_Std_Logic_Arith_Conv_Vector_Log = 624 - Ieee_Std_Logic_Arith_Ext = 625 - Ieee_Std_Logic_Arith_Sxt = 626 - Ieee_Std_Logic_Arith_Id_Uns_Uns = 627 - Ieee_Std_Logic_Arith_Id_Sgn_Sgn = 628 - Ieee_Std_Logic_Arith_Neg_Sgn_Sgn = 629 - Ieee_Std_Logic_Arith_Abs_Sgn_Sgn = 630 - Ieee_Std_Logic_Arith_Shl_Uns = 631 - Ieee_Std_Logic_Arith_Shl_Sgn = 632 - Ieee_Std_Logic_Arith_Shr_Uns = 633 - Ieee_Std_Logic_Arith_Shr_Sgn = 634 - Ieee_Std_Logic_Arith_Id_Uns_Slv = 635 - Ieee_Std_Logic_Arith_Id_Sgn_Slv = 636 - Ieee_Std_Logic_Arith_Neg_Sgn_Slv = 637 - Ieee_Std_Logic_Arith_Abs_Sgn_Slv = 638 - Ieee_Std_Logic_Arith_Mul_Uns_Uns_Uns = 639 - Ieee_Std_Logic_Arith_Mul_Sgn_Sgn_Sgn = 640 - Ieee_Std_Logic_Arith_Mul_Sgn_Uns_Sgn = 641 - Ieee_Std_Logic_Arith_Mul_Uns_Sgn_Sgn = 642 - Ieee_Std_Logic_Arith_Mul_Uns_Uns_Slv = 643 - Ieee_Std_Logic_Arith_Mul_Sgn_Sgn_Slv = 644 - Ieee_Std_Logic_Arith_Mul_Sgn_Uns_Slv = 645 - Ieee_Std_Logic_Arith_Mul_Uns_Sgn_Slv = 646 - Ieee_Std_Logic_Arith_Add_Uns_Uns_Uns = 647 - Ieee_Std_Logic_Arith_Add_Sgn_Sgn_Sgn = 648 - Ieee_Std_Logic_Arith_Add_Uns_Sgn_Sgn = 649 - Ieee_Std_Logic_Arith_Add_Sgn_Uns_Sgn = 650 - Ieee_Std_Logic_Arith_Add_Uns_Int_Uns = 651 - Ieee_Std_Logic_Arith_Add_Int_Uns_Uns = 652 - Ieee_Std_Logic_Arith_Add_Sgn_Int_Sgn = 653 - Ieee_Std_Logic_Arith_Add_Int_Sgn_Sgn = 654 - Ieee_Std_Logic_Arith_Add_Uns_Log_Uns = 655 - Ieee_Std_Logic_Arith_Add_Log_Uns_Uns = 656 - Ieee_Std_Logic_Arith_Add_Sgn_Log_Sgn = 657 - Ieee_Std_Logic_Arith_Add_Log_Sgn_Sgn = 658 - Ieee_Std_Logic_Arith_Add_Uns_Uns_Slv = 659 - Ieee_Std_Logic_Arith_Add_Sgn_Sgn_Slv = 660 - Ieee_Std_Logic_Arith_Add_Uns_Sgn_Slv = 661 - Ieee_Std_Logic_Arith_Add_Sgn_Uns_Slv = 662 - Ieee_Std_Logic_Arith_Add_Uns_Int_Slv = 663 - Ieee_Std_Logic_Arith_Add_Int_Uns_Slv = 664 - Ieee_Std_Logic_Arith_Add_Sgn_Int_Slv = 665 - Ieee_Std_Logic_Arith_Add_Int_Sgn_Slv = 666 - Ieee_Std_Logic_Arith_Add_Uns_Log_Slv = 667 - Ieee_Std_Logic_Arith_Add_Log_Uns_Slv = 668 - Ieee_Std_Logic_Arith_Add_Sgn_Log_Slv = 669 - Ieee_Std_Logic_Arith_Add_Log_Sgn_Slv = 670 - Ieee_Std_Logic_Arith_Sub_Uns_Uns_Uns = 671 - Ieee_Std_Logic_Arith_Sub_Sgn_Sgn_Sgn = 672 - Ieee_Std_Logic_Arith_Sub_Uns_Sgn_Sgn = 673 - Ieee_Std_Logic_Arith_Sub_Sgn_Uns_Sgn = 674 - Ieee_Std_Logic_Arith_Sub_Uns_Int_Uns = 675 - Ieee_Std_Logic_Arith_Sub_Int_Uns_Uns = 676 - Ieee_Std_Logic_Arith_Sub_Sgn_Int_Sgn = 677 - Ieee_Std_Logic_Arith_Sub_Int_Sgn_Sgn = 678 - Ieee_Std_Logic_Arith_Sub_Uns_Log_Uns = 679 - Ieee_Std_Logic_Arith_Sub_Log_Uns_Uns = 680 - Ieee_Std_Logic_Arith_Sub_Sgn_Log_Sgn = 681 - Ieee_Std_Logic_Arith_Sub_Log_Sgn_Sgn = 682 - Ieee_Std_Logic_Arith_Sub_Uns_Uns_Slv = 683 - Ieee_Std_Logic_Arith_Sub_Sgn_Sgn_Slv = 684 - Ieee_Std_Logic_Arith_Sub_Uns_Sgn_Slv = 685 - Ieee_Std_Logic_Arith_Sub_Sgn_Uns_Slv = 686 - Ieee_Std_Logic_Arith_Sub_Uns_Int_Slv = 687 - Ieee_Std_Logic_Arith_Sub_Int_Uns_Slv = 688 - Ieee_Std_Logic_Arith_Sub_Sgn_Int_Slv = 689 - Ieee_Std_Logic_Arith_Sub_Int_Sgn_Slv = 690 - Ieee_Std_Logic_Arith_Sub_Uns_Log_Slv = 691 - Ieee_Std_Logic_Arith_Sub_Log_Uns_Slv = 692 - Ieee_Std_Logic_Arith_Sub_Sgn_Log_Slv = 693 - Ieee_Std_Logic_Arith_Sub_Log_Sgn_Slv = 694 - Ieee_Std_Logic_Arith_Lt_Uns_Uns = 695 - Ieee_Std_Logic_Arith_Lt_Sgn_Sgn = 696 - Ieee_Std_Logic_Arith_Lt_Uns_Sgn = 697 - Ieee_Std_Logic_Arith_Lt_Sgn_Uns = 698 - Ieee_Std_Logic_Arith_Lt_Uns_Int = 699 - Ieee_Std_Logic_Arith_Lt_Int_Uns = 700 - Ieee_Std_Logic_Arith_Lt_Sgn_Int = 701 - Ieee_Std_Logic_Arith_Lt_Int_Sgn = 702 - Ieee_Std_Logic_Arith_Le_Uns_Uns = 703 - Ieee_Std_Logic_Arith_Le_Sgn_Sgn = 704 - Ieee_Std_Logic_Arith_Le_Uns_Sgn = 705 - Ieee_Std_Logic_Arith_Le_Sgn_Uns = 706 - Ieee_Std_Logic_Arith_Le_Uns_Int = 707 - Ieee_Std_Logic_Arith_Le_Int_Uns = 708 - Ieee_Std_Logic_Arith_Le_Sgn_Int = 709 - Ieee_Std_Logic_Arith_Le_Int_Sgn = 710 - Ieee_Std_Logic_Arith_Gt_Uns_Uns = 711 - Ieee_Std_Logic_Arith_Gt_Sgn_Sgn = 712 - Ieee_Std_Logic_Arith_Gt_Uns_Sgn = 713 - Ieee_Std_Logic_Arith_Gt_Sgn_Uns = 714 - Ieee_Std_Logic_Arith_Gt_Uns_Int = 715 - Ieee_Std_Logic_Arith_Gt_Int_Uns = 716 - Ieee_Std_Logic_Arith_Gt_Sgn_Int = 717 - Ieee_Std_Logic_Arith_Gt_Int_Sgn = 718 - Ieee_Std_Logic_Arith_Ge_Uns_Uns = 719 - Ieee_Std_Logic_Arith_Ge_Sgn_Sgn = 720 - Ieee_Std_Logic_Arith_Ge_Uns_Sgn = 721 - Ieee_Std_Logic_Arith_Ge_Sgn_Uns = 722 - Ieee_Std_Logic_Arith_Ge_Uns_Int = 723 - Ieee_Std_Logic_Arith_Ge_Int_Uns = 724 - Ieee_Std_Logic_Arith_Ge_Sgn_Int = 725 - Ieee_Std_Logic_Arith_Ge_Int_Sgn = 726 - Ieee_Std_Logic_Arith_Eq_Uns_Uns = 727 - Ieee_Std_Logic_Arith_Eq_Sgn_Sgn = 728 - Ieee_Std_Logic_Arith_Eq_Uns_Sgn = 729 - Ieee_Std_Logic_Arith_Eq_Sgn_Uns = 730 - Ieee_Std_Logic_Arith_Eq_Uns_Int = 731 - Ieee_Std_Logic_Arith_Eq_Int_Uns = 732 - Ieee_Std_Logic_Arith_Eq_Sgn_Int = 733 - Ieee_Std_Logic_Arith_Eq_Int_Sgn = 734 - Ieee_Std_Logic_Arith_Ne_Uns_Uns = 735 - Ieee_Std_Logic_Arith_Ne_Sgn_Sgn = 736 - Ieee_Std_Logic_Arith_Ne_Uns_Sgn = 737 - Ieee_Std_Logic_Arith_Ne_Sgn_Uns = 738 - Ieee_Std_Logic_Arith_Ne_Uns_Int = 739 - Ieee_Std_Logic_Arith_Ne_Int_Uns = 740 - Ieee_Std_Logic_Arith_Ne_Sgn_Int = 741 - Ieee_Std_Logic_Arith_Ne_Int_Sgn = 742 - Ieee_Std_Logic_Misc_And_Reduce_Slv = 743 - Ieee_Std_Logic_Misc_And_Reduce_Suv = 744 - Ieee_Std_Logic_Misc_Nand_Reduce_Slv = 745 - Ieee_Std_Logic_Misc_Nand_Reduce_Suv = 746 - Ieee_Std_Logic_Misc_Or_Reduce_Slv = 747 - Ieee_Std_Logic_Misc_Or_Reduce_Suv = 748 - Ieee_Std_Logic_Misc_Nor_Reduce_Slv = 749 - Ieee_Std_Logic_Misc_Nor_Reduce_Suv = 750 - Ieee_Std_Logic_Misc_Xor_Reduce_Slv = 751 - Ieee_Std_Logic_Misc_Xor_Reduce_Suv = 752 - Ieee_Std_Logic_Misc_Xnor_Reduce_Slv = 753 - Ieee_Std_Logic_Misc_Xnor_Reduce_Suv = 754 + Ieee_Std_Logic_Arith_Conv_Signed_Int = 617 + Ieee_Std_Logic_Arith_Conv_Signed_Uns = 618 + Ieee_Std_Logic_Arith_Conv_Signed_Sgn = 619 + Ieee_Std_Logic_Arith_Conv_Signed_Log = 620 + Ieee_Std_Logic_Arith_Conv_Integer_Int = 621 + Ieee_Std_Logic_Arith_Conv_Integer_Uns = 622 + Ieee_Std_Logic_Arith_Conv_Integer_Sgn = 623 + Ieee_Std_Logic_Arith_Conv_Integer_Log = 624 + Ieee_Std_Logic_Arith_Conv_Vector_Int = 625 + Ieee_Std_Logic_Arith_Conv_Vector_Uns = 626 + Ieee_Std_Logic_Arith_Conv_Vector_Sgn = 627 + Ieee_Std_Logic_Arith_Conv_Vector_Log = 628 + Ieee_Std_Logic_Arith_Ext = 629 + Ieee_Std_Logic_Arith_Sxt = 630 + Ieee_Std_Logic_Arith_Id_Uns_Uns = 631 + Ieee_Std_Logic_Arith_Id_Sgn_Sgn = 632 + Ieee_Std_Logic_Arith_Neg_Sgn_Sgn = 633 + Ieee_Std_Logic_Arith_Abs_Sgn_Sgn = 634 + Ieee_Std_Logic_Arith_Shl_Uns = 635 + Ieee_Std_Logic_Arith_Shl_Sgn = 636 + Ieee_Std_Logic_Arith_Shr_Uns = 637 + Ieee_Std_Logic_Arith_Shr_Sgn = 638 + Ieee_Std_Logic_Arith_Id_Uns_Slv = 639 + Ieee_Std_Logic_Arith_Id_Sgn_Slv = 640 + Ieee_Std_Logic_Arith_Neg_Sgn_Slv = 641 + Ieee_Std_Logic_Arith_Abs_Sgn_Slv = 642 + Ieee_Std_Logic_Arith_Mul_Uns_Uns_Uns = 643 + Ieee_Std_Logic_Arith_Mul_Sgn_Sgn_Sgn = 644 + Ieee_Std_Logic_Arith_Mul_Sgn_Uns_Sgn = 645 + Ieee_Std_Logic_Arith_Mul_Uns_Sgn_Sgn = 646 + Ieee_Std_Logic_Arith_Mul_Uns_Uns_Slv = 647 + Ieee_Std_Logic_Arith_Mul_Sgn_Sgn_Slv = 648 + Ieee_Std_Logic_Arith_Mul_Sgn_Uns_Slv = 649 + Ieee_Std_Logic_Arith_Mul_Uns_Sgn_Slv = 650 + Ieee_Std_Logic_Arith_Add_Uns_Uns_Uns = 651 + Ieee_Std_Logic_Arith_Add_Sgn_Sgn_Sgn = 652 + Ieee_Std_Logic_Arith_Add_Uns_Sgn_Sgn = 653 + Ieee_Std_Logic_Arith_Add_Sgn_Uns_Sgn = 654 + Ieee_Std_Logic_Arith_Add_Uns_Int_Uns = 655 + Ieee_Std_Logic_Arith_Add_Int_Uns_Uns = 656 + Ieee_Std_Logic_Arith_Add_Sgn_Int_Sgn = 657 + Ieee_Std_Logic_Arith_Add_Int_Sgn_Sgn = 658 + Ieee_Std_Logic_Arith_Add_Uns_Log_Uns = 659 + Ieee_Std_Logic_Arith_Add_Log_Uns_Uns = 660 + Ieee_Std_Logic_Arith_Add_Sgn_Log_Sgn = 661 + Ieee_Std_Logic_Arith_Add_Log_Sgn_Sgn = 662 + Ieee_Std_Logic_Arith_Add_Uns_Uns_Slv = 663 + Ieee_Std_Logic_Arith_Add_Sgn_Sgn_Slv = 664 + Ieee_Std_Logic_Arith_Add_Uns_Sgn_Slv = 665 + Ieee_Std_Logic_Arith_Add_Sgn_Uns_Slv = 666 + Ieee_Std_Logic_Arith_Add_Uns_Int_Slv = 667 + Ieee_Std_Logic_Arith_Add_Int_Uns_Slv = 668 + Ieee_Std_Logic_Arith_Add_Sgn_Int_Slv = 669 + Ieee_Std_Logic_Arith_Add_Int_Sgn_Slv = 670 + Ieee_Std_Logic_Arith_Add_Uns_Log_Slv = 671 + Ieee_Std_Logic_Arith_Add_Log_Uns_Slv = 672 + Ieee_Std_Logic_Arith_Add_Sgn_Log_Slv = 673 + Ieee_Std_Logic_Arith_Add_Log_Sgn_Slv = 674 + Ieee_Std_Logic_Arith_Sub_Uns_Uns_Uns = 675 + Ieee_Std_Logic_Arith_Sub_Sgn_Sgn_Sgn = 676 + Ieee_Std_Logic_Arith_Sub_Uns_Sgn_Sgn = 677 + Ieee_Std_Logic_Arith_Sub_Sgn_Uns_Sgn = 678 + Ieee_Std_Logic_Arith_Sub_Uns_Int_Uns = 679 + Ieee_Std_Logic_Arith_Sub_Int_Uns_Uns = 680 + Ieee_Std_Logic_Arith_Sub_Sgn_Int_Sgn = 681 + Ieee_Std_Logic_Arith_Sub_Int_Sgn_Sgn = 682 + Ieee_Std_Logic_Arith_Sub_Uns_Log_Uns = 683 + Ieee_Std_Logic_Arith_Sub_Log_Uns_Uns = 684 + Ieee_Std_Logic_Arith_Sub_Sgn_Log_Sgn = 685 + Ieee_Std_Logic_Arith_Sub_Log_Sgn_Sgn = 686 + Ieee_Std_Logic_Arith_Sub_Uns_Uns_Slv = 687 + Ieee_Std_Logic_Arith_Sub_Sgn_Sgn_Slv = 688 + Ieee_Std_Logic_Arith_Sub_Uns_Sgn_Slv = 689 + Ieee_Std_Logic_Arith_Sub_Sgn_Uns_Slv = 690 + Ieee_Std_Logic_Arith_Sub_Uns_Int_Slv = 691 + Ieee_Std_Logic_Arith_Sub_Int_Uns_Slv = 692 + Ieee_Std_Logic_Arith_Sub_Sgn_Int_Slv = 693 + Ieee_Std_Logic_Arith_Sub_Int_Sgn_Slv = 694 + Ieee_Std_Logic_Arith_Sub_Uns_Log_Slv = 695 + Ieee_Std_Logic_Arith_Sub_Log_Uns_Slv = 696 + Ieee_Std_Logic_Arith_Sub_Sgn_Log_Slv = 697 + Ieee_Std_Logic_Arith_Sub_Log_Sgn_Slv = 698 + Ieee_Std_Logic_Arith_Lt_Uns_Uns = 699 + Ieee_Std_Logic_Arith_Lt_Sgn_Sgn = 700 + Ieee_Std_Logic_Arith_Lt_Uns_Sgn = 701 + Ieee_Std_Logic_Arith_Lt_Sgn_Uns = 702 + Ieee_Std_Logic_Arith_Lt_Uns_Int = 703 + Ieee_Std_Logic_Arith_Lt_Int_Uns = 704 + Ieee_Std_Logic_Arith_Lt_Sgn_Int = 705 + Ieee_Std_Logic_Arith_Lt_Int_Sgn = 706 + Ieee_Std_Logic_Arith_Le_Uns_Uns = 707 + Ieee_Std_Logic_Arith_Le_Sgn_Sgn = 708 + Ieee_Std_Logic_Arith_Le_Uns_Sgn = 709 + Ieee_Std_Logic_Arith_Le_Sgn_Uns = 710 + Ieee_Std_Logic_Arith_Le_Uns_Int = 711 + Ieee_Std_Logic_Arith_Le_Int_Uns = 712 + Ieee_Std_Logic_Arith_Le_Sgn_Int = 713 + Ieee_Std_Logic_Arith_Le_Int_Sgn = 714 + Ieee_Std_Logic_Arith_Gt_Uns_Uns = 715 + Ieee_Std_Logic_Arith_Gt_Sgn_Sgn = 716 + Ieee_Std_Logic_Arith_Gt_Uns_Sgn = 717 + Ieee_Std_Logic_Arith_Gt_Sgn_Uns = 718 + Ieee_Std_Logic_Arith_Gt_Uns_Int = 719 + Ieee_Std_Logic_Arith_Gt_Int_Uns = 720 + Ieee_Std_Logic_Arith_Gt_Sgn_Int = 721 + Ieee_Std_Logic_Arith_Gt_Int_Sgn = 722 + Ieee_Std_Logic_Arith_Ge_Uns_Uns = 723 + Ieee_Std_Logic_Arith_Ge_Sgn_Sgn = 724 + Ieee_Std_Logic_Arith_Ge_Uns_Sgn = 725 + Ieee_Std_Logic_Arith_Ge_Sgn_Uns = 726 + Ieee_Std_Logic_Arith_Ge_Uns_Int = 727 + Ieee_Std_Logic_Arith_Ge_Int_Uns = 728 + Ieee_Std_Logic_Arith_Ge_Sgn_Int = 729 + Ieee_Std_Logic_Arith_Ge_Int_Sgn = 730 + Ieee_Std_Logic_Arith_Eq_Uns_Uns = 731 + Ieee_Std_Logic_Arith_Eq_Sgn_Sgn = 732 + Ieee_Std_Logic_Arith_Eq_Uns_Sgn = 733 + Ieee_Std_Logic_Arith_Eq_Sgn_Uns = 734 + Ieee_Std_Logic_Arith_Eq_Uns_Int = 735 + Ieee_Std_Logic_Arith_Eq_Int_Uns = 736 + Ieee_Std_Logic_Arith_Eq_Sgn_Int = 737 + Ieee_Std_Logic_Arith_Eq_Int_Sgn = 738 + Ieee_Std_Logic_Arith_Ne_Uns_Uns = 739 + Ieee_Std_Logic_Arith_Ne_Sgn_Sgn = 740 + Ieee_Std_Logic_Arith_Ne_Uns_Sgn = 741 + Ieee_Std_Logic_Arith_Ne_Sgn_Uns = 742 + Ieee_Std_Logic_Arith_Ne_Uns_Int = 743 + Ieee_Std_Logic_Arith_Ne_Int_Uns = 744 + Ieee_Std_Logic_Arith_Ne_Sgn_Int = 745 + Ieee_Std_Logic_Arith_Ne_Int_Sgn = 746 + Ieee_Std_Logic_Misc_And_Reduce_Slv = 747 + Ieee_Std_Logic_Misc_And_Reduce_Suv = 748 + Ieee_Std_Logic_Misc_Nand_Reduce_Slv = 749 + Ieee_Std_Logic_Misc_Nand_Reduce_Suv = 750 + Ieee_Std_Logic_Misc_Or_Reduce_Slv = 751 + Ieee_Std_Logic_Misc_Or_Reduce_Suv = 752 + Ieee_Std_Logic_Misc_Nor_Reduce_Slv = 753 + Ieee_Std_Logic_Misc_Nor_Reduce_Suv = 754 + Ieee_Std_Logic_Misc_Xor_Reduce_Slv = 755 + Ieee_Std_Logic_Misc_Xor_Reduce_Suv = 756 + Ieee_Std_Logic_Misc_Xnor_Reduce_Slv = 757 + Ieee_Std_Logic_Misc_Xnor_Reduce_Suv = 758 @export diff --git a/src/synth/synth-vhdl_eval.adb b/src/synth/synth-vhdl_eval.adb index 020c67896..1913f349a 100644 --- a/src/synth/synth-vhdl_eval.adb +++ b/src/synth/synth-vhdl_eval.adb @@ -609,6 +609,7 @@ package body Synth.Vhdl_Eval is end case; end Eval_Vector_Minimum; + -- ARG to log-vector, sign extended. function Eval_To_Log_Vector (Arg : Uns64; Sz : Int64; Res_Type : Type_Acc) return Memtyp is @@ -2634,7 +2635,8 @@ package body Synth.Vhdl_Eval is (Uns64 (Read_Discrete (Param1)), Int64 (Param2.Typ.Abound.Len), Res_Typ); when Iir_Predefined_Ieee_Numeric_Std_Tosgn_Int_Nat_Sgn - | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Vector_Int => + | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Vector_Int + | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Signed_Int => return Eval_To_Log_Vector (To_Uns64 (Read_Discrete (Param1)), Read_Discrete (Param2), Res_Typ); diff --git a/src/synth/synth-vhdl_oper.adb b/src/synth/synth-vhdl_oper.adb index d9f1c694e..64d2deae3 100644 --- a/src/synth/synth-vhdl_oper.adb +++ b/src/synth/synth-vhdl_oper.adb @@ -2039,7 +2039,8 @@ package body Synth.Vhdl_Oper is return Synth_Resize (Ctxt, L, B.Len, False, Expr); end; when Iir_Predefined_Ieee_Numeric_Std_Tosgn_Int_Nat_Sgn - | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Vector_Int => + | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Vector_Int + | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Signed_Int => return Synth_Conv_Vector (True); when Iir_Predefined_Ieee_Numeric_Std_Toint_Uns_Nat | Iir_Predefined_Ieee_Numeric_Std_Unsigned_To_Integer_Slv_Nat @@ -2060,7 +2061,10 @@ package body Synth.Vhdl_Oper is | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Vector_Uns | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Unsigned_Uns | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Unsigned_Log + | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Signed_Log + | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Signed_Uns | Iir_Predefined_Ieee_Std_Logic_Arith_Ext => + -- Unsigned to unsigned (resize) declare W : Width; begin @@ -2090,6 +2094,7 @@ package body Synth.Vhdl_Oper is when Iir_Predefined_Ieee_Numeric_Std_Resize_Sgn_Nat | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Vector_Sgn | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Unsigned_Sgn + | Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Signed_Sgn | Iir_Predefined_Ieee_Std_Logic_Arith_Sxt => if not Is_Static (R.Val) then Error_Msg_Synth diff --git a/src/synth/synth-vhdl_stmts.adb b/src/synth/synth-vhdl_stmts.adb index 6a6285a96..6fb438356 100644 --- a/src/synth/synth-vhdl_stmts.adb +++ b/src/synth/synth-vhdl_stmts.adb @@ -990,10 +990,11 @@ package body Synth.Vhdl_Stmts is Mark_Expr_Pool (Marker); Targ := Synth_Target (Inst, Get_Target (Stmt)); Targ_Type := Targ.Targ_Type; + First := No_Valtyp; Last := No_Net; Ce := Get_Conditional_Expression_Chain (Stmt); - while Ce /= Null_Node loop + loop -- First, evaluate the condition. Cond := Get_Condition (Ce); if Cond /= Null_Node then @@ -1050,8 +1051,21 @@ package body Synth.Vhdl_Stmts is exit when Cond_Tri = True; Ce := Get_Chain (Ce); + exit when Ce = Null_Node; end loop; - Synth_Assignment (Inst, Targ, First, Stmt); + + if Last /= No_Net then + if Cond_Tri /= True then + -- There is at least one Mux2, and its input-1 is not connected. + -- Implement missing assignment as a self-assignment. + Val := Synth_Read (Inst, Targ, Stmt); + Connect (Get_Input (Get_Net_Parent (Last), 1), + Get_Net (Ctxt, Val)); + end if; + + Synth_Assignment (Inst, Targ, First, Stmt); + end if; + Release_Expr_Pool (Marker); end Synth_Conditional_Variable_Assignment; diff --git a/src/vhdl/translate/trans-chap1.adb b/src/vhdl/translate/trans-chap1.adb index f48695d95..8533e5483 100644 --- a/src/vhdl/translate/trans-chap1.adb +++ b/src/vhdl/translate/trans-chap1.adb @@ -172,7 +172,7 @@ package body Trans.Chap1 is -- Entity declaration subprograms as they can be called by the -- architectures. Chap4.Translate_Declaration_Chain_Subprograms - (Entity, Subprg_Translate_Spec_And_Body); + (Entity, Subprg_Translate_Only_Spec); else -- Entity declaration and process subprograms. Chap9.Translate_Block_Subprograms (Entity, Entity); diff --git a/src/vhdl/translate/trans-chap12.adb b/src/vhdl/translate/trans-chap12.adb index f3686ef9c..adabd133b 100644 --- a/src/vhdl/translate/trans-chap12.adb +++ b/src/vhdl/translate/trans-chap12.adb @@ -654,7 +654,7 @@ package body Trans.Chap12 is case Get_Kind (Lib_Unit) is when Iir_Kind_Package_Declaration => if not Get_Elab_Flag (Unit) then - Chap2.Elab_Package_Body (Lib_Unit, Null_Iir); + Chap2.Elab_Package_Unit_Without_Body (Lib_Unit); end if; when Iir_Kind_Entity_Declaration => Gen_Last_Arch (Lib_Unit); diff --git a/src/vhdl/translate/trans-chap2.adb b/src/vhdl/translate/trans-chap2.adb index e2a2cc398..4c5f15929 100644 --- a/src/vhdl/translate/trans-chap2.adb +++ b/src/vhdl/translate/trans-chap2.adb @@ -35,6 +35,8 @@ package body Trans.Chap2 is use Trans.Subprgs; use Trans.Helpers; + procedure Elab_Package_Internal (Spec : Iir; Header : Iir); + type Name_String_Xlat_Array is array (Name_Id range <>) of String (1 .. 4); -- Ortho function names are only composed of [A-Za-z0-9_]. For VHDL @@ -762,155 +764,298 @@ package body Trans.Chap2 is Pop_Instance_Factory (Info.Package_Body_Scope'Access); end Pop_Package_Instance_Factory; - -- Translate a package declaration or a macro-expanded package - -- instantiation. HEADER is the node containing generic and generic_map. - procedure Translate_Package (Decl : Iir; Header : Iir) + -- Declare elaboration routines for a package. + procedure Create_Package_Elaborator (Info : Ortho_Info_Acc) is - Is_Nested : constant Boolean := Is_Nested_Package (Decl); - Is_Uninstantiated : constant Boolean := - Get_Kind (Decl) = Iir_Kind_Package_Declaration - and then Is_Uninstantiated_Package (Decl); - Mark : Id_Mark_Type; - Info : Ortho_Info_Acc; - Interface_List : O_Inter_List; - Prev_Subprg_Instance : Subprgs.Subprg_Instance_Stack; + Interface_List : O_Inter_List; + begin + -- Declare elaborator for the spec. + Start_Procedure_Decl + (Interface_List, Create_Identifier ("ELAB_SPEC"), Global_Storage); + Subprgs.Add_Subprg_Instance_Interfaces + (Interface_List, Info.Package_Elab_Spec_Instance); + Finish_Subprogram_Decl + (Interface_List, Info.Package_Elab_Spec_Subprg); + + -- Declare elaborator for the body. + Start_Procedure_Decl + (Interface_List, Create_Identifier ("ELAB_BODY"), Global_Storage); + Subprgs.Add_Subprg_Instance_Interfaces + (Interface_List, Info.Package_Elab_Body_Instance); + Finish_Subprogram_Decl + (Interface_List, Info.Package_Elab_Body_Subprg); + end Create_Package_Elaborator; + + -- Translate a non-uninstantiated package declaration. + -- HEADER is the node containing generic and generic_map. + procedure Translate_Package_Concrete_Common (Decl : Iir; Header : Iir) + is + Info : Ortho_Info_Acc; begin Info := Add_Info (Decl, Kind_Package); - if Is_Nested then - Push_Identifier_Prefix (Mark, Get_Identifier (Decl)); + if Header /= Null_Iir then + Chap4.Translate_Generic_Association_Chain (Header); end if; - -- Translate declarations. - if Is_Uninstantiated then - -- Create an instance for the spec. - Push_Instance_Factory (Info.Package_Spec_Scope'Access); - Chap4.Translate_Generic_Chain (Header); - Chap4.Translate_Declaration_Chain (Decl); + Chap4.Translate_Declaration_Chain (Decl); + + Save_Local_Identifier (Info.Package_Local_Id); + end Translate_Package_Concrete_Common; + + procedure Translate_Package_Concrete_Unit (Decl : Iir; Header : Iir) + is + Info : constant Ortho_Info_Acc := Get_Info (Decl); + begin + Info.Package_Elab_Var := Create_Var + (Create_Var_Identifier ("ELABORATED"), Ghdl_Bool_Type); + + -- For nested package, this will be translated when translating + -- subprograms. + Chap4.Translate_Declaration_Chain_Subprograms_Spec_Body (Decl); + + Create_Package_Elaborator (Info); + + if Flag_Rti then + -- Generate RTI. + Rtis.Generate_Unit (Decl); + end if; + + if Global_Storage /= O_Storage_External then + -- Create elaboration procedure for the spec + Elab_Package_Internal (Decl, Header); + end if; + + -- Overwrite the value written by Translate_Package_Concrete_Common. + Save_Local_Identifier (Info.Package_Local_Id); + end Translate_Package_Concrete_Unit; + + -- Translate a package declaration or a macro-expanded package + -- instantiation. HEADER is the node containing generic and generic_map. + procedure Translate_Package_Uninst_Common (Decl : Iir; Header : Iir) + is + Add_Body : constant Boolean := + not Get_Need_Body (Decl) and then Get_Package_Body (Decl) = Null_Iir; + Info : Ortho_Info_Acc; + begin + Info := Add_Info (Decl, Kind_Package); + + -- Create an instance for the spec. + Push_Instance_Factory (Info.Package_Spec_Scope'Access); + Chap4.Translate_Generic_Chain (Header); + Chap4.Translate_Declaration_Chain (Decl); + if not Is_Nested_Package (Decl) then Info.Package_Elab_Var := Create_Var (Create_Var_Identifier ("ELABORATED"), Ghdl_Bool_Type); - Pop_Instance_Factory (Info.Package_Spec_Scope'Access); + end if; + Pop_Instance_Factory (Info.Package_Spec_Scope'Access); + + -- Name the spec instance and create a pointer. + New_Type_Decl (Create_Identifier ("SPECINSTTYPE"), + Get_Scope_Type (Info.Package_Spec_Scope)); + Declare_Scope_Acc (Info.Package_Spec_Scope, + Create_Identifier ("SPECINSTPTR"), + Info.Package_Spec_Ptr_Type); + + -- Create an instance and its pointer for the body. + Chap2.Declare_Inst_Type_And_Ptr + (Info.Package_Body_Scope'Access, Info.Package_Body_Ptr_Type); + + if Add_Body then + -- Generic package without a body. + -- Create an empty body instance. + Push_Package_Instance_Factory (Decl); + Pop_Package_Instance_Factory (Decl); + end if; + Save_Local_Identifier (Info.Package_Local_Id); + end Translate_Package_Uninst_Common; + + procedure Translate_Package_Uninst_Unit (Decl : Iir; Header : Iir) + is + Info : constant Ortho_Info_Acc := Get_Info (Decl); + Add_Body : constant Boolean := + not Get_Need_Body (Decl) and then Get_Package_Body (Decl) = Null_Iir; + Prev_Subprg_Instance : Subprgs.Subprg_Instance_Stack; + begin + -- Each subprogram has a body instance argument (because subprograms + -- body can access body declarations). + Subprgs.Push_Subprg_Instance + (Info.Package_Body_Scope'Access, Info.Package_Body_Ptr_Type, + Wki_Instance, Prev_Subprg_Instance); + + -- For nested package, this will be translated when translating + -- subprograms. + Chap4.Translate_Declaration_Chain_Subprograms + (Decl, Subprg_Translate_Only_Spec); + + Create_Package_Elaborator (Info); + + Subprgs.Pop_Subprg_Instance (Wki_Instance, Prev_Subprg_Instance); + + if Flag_Rti then + -- Generate RTI. + Rtis.Generate_Unit (Decl); + end if; + + if Add_Body and then Global_Storage /= O_Storage_External then + -- For nested package, this will be translated when translating + -- subprograms. + Set_Scope_Via_Field (Info.Package_Spec_Scope, + Info.Package_Spec_Field, + Info.Package_Body_Scope'Access); + + Chap4.Translate_Declaration_Chain_Subprograms + (Decl, Subprg_Translate_Only_Body); - -- Name the spec instance and create a pointer. - New_Type_Decl (Create_Identifier ("SPECINSTTYPE"), - Get_Scope_Type (Info.Package_Spec_Scope)); - Declare_Scope_Acc (Info.Package_Spec_Scope, - Create_Identifier ("SPECINSTPTR"), - Info.Package_Spec_Ptr_Type); + -- Create elaboration procedure for the spec + Elab_Package_Internal (Decl, Header); - -- Create an instance and its pointer for the body. - Chap2.Declare_Inst_Type_And_Ptr - (Info.Package_Body_Scope'Access, Info.Package_Body_Ptr_Type); + Clear_Scope (Info.Package_Spec_Scope); + end if; + + Save_Local_Identifier (Info.Package_Local_Id); + end Translate_Package_Uninst_Unit; - -- Each subprogram has a body instance argument (because subprogram - -- bodys can access to body declarations). + procedure Translate_Package_Declaration_Subprograms + (Decl : Iir_Package_Declaration; What : Subprg_Translate_Kind) + is + Info : constant Ortho_Info_Acc := Get_Info (Decl); + Is_Uninst : constant Boolean := Is_Uninstantiated_Package (Decl); + Prev_Subprg_Instance : Subprgs.Subprg_Instance_Stack; + Mark : Id_Mark_Type; + begin + if Is_Uninst and then Get_Macro_Expanded_Flag (Decl) then + -- Nothing to do for macro-expanded packages. + return; + end if; + + Push_Identifier_Prefix (Mark, Get_Identifier (Decl)); + + if Is_Uninst then + -- An extra parameter for the package instance needs to be added + -- to the subprograms. Subprgs.Push_Subprg_Instance (Info.Package_Body_Scope'Access, Info.Package_Body_Ptr_Type, Wki_Instance, Prev_Subprg_Instance); + end if; - if not Is_Nested then - -- For nested package, this will be translated when translating - -- subprograms. - Chap4.Translate_Declaration_Chain_Subprograms - (Decl, Subprg_Translate_Only_Spec); - end if; - else - if Header /= Null_Iir then - Chap4.Translate_Generic_Association_Chain (Header); - end if; - Chap4.Translate_Declaration_Chain (Decl); - if not Is_Nested then - Info.Package_Elab_Var := Create_Var - (Create_Var_Identifier ("ELABORATED"), Ghdl_Bool_Type); + Chap4.Translate_Declaration_Chain_Subprograms (Decl, What); + + if Is_Uninst then + if What in Subprg_Translate_Spec then + -- Also declare elaborator subprograms. + Create_Package_Elaborator (Info); end if; - -- Translate subprograms declarations. - if not Is_Nested then + Subprgs.Pop_Subprg_Instance (Wki_Instance, Prev_Subprg_Instance); + + if What in Subprg_Translate_Body then -- For nested package, this will be translated when translating -- subprograms. - Chap4.Translate_Declaration_Chain_Subprograms - (Decl, Subprg_Translate_Spec_And_Body); - end if; - end if; + Set_Scope_Via_Field (Info.Package_Spec_Scope, + Info.Package_Spec_Field, + Info.Package_Body_Scope'Access); - if not Is_Nested then - -- Declare elaborator for the spec. - Start_Procedure_Decl - (Interface_List, Create_Identifier ("ELAB_SPEC"), Global_Storage); - Subprgs.Add_Subprg_Instance_Interfaces - (Interface_List, Info.Package_Elab_Spec_Instance); - Finish_Subprogram_Decl - (Interface_List, Info.Package_Elab_Spec_Subprg); + Elab_Package_Internal (Decl, Get_Package_Header (Decl)); - -- Declare elaborator for the body. - Start_Procedure_Decl - (Interface_List, Create_Identifier ("ELAB_BODY"), Global_Storage); - Subprgs.Add_Subprg_Instance_Interfaces - (Interface_List, Info.Package_Elab_Body_Instance); - Finish_Subprogram_Decl - (Interface_List, Info.Package_Elab_Body_Subprg); + Clear_Scope (Info.Package_Spec_Scope); - if Flag_Rti then - -- Generate RTI. - Rtis.Generate_Unit (Decl); + if not Get_Need_Body (Decl) + and then Get_Package_Body (Decl) = Null_Iir + then + Elab_Package_Body (Decl, Null_Iir); + end if; end if; end if; - if Is_Uninstantiated then - if not Get_Need_Body (Decl) - and then Get_Package_Body (Decl) = Null_Iir - then - -- Generic package without a body. - -- Create an empty body instance. - Push_Package_Instance_Factory (Decl); - Pop_Package_Instance_Factory (Decl); + Pop_Identifier_Prefix (Mark); + end Translate_Package_Declaration_Subprograms; - if not Is_Nested - and then Global_Storage /= O_Storage_External - then - -- For nested package, this will be translated when translating - -- subprograms. - Set_Scope_Via_Field (Info.Package_Spec_Scope, - Info.Package_Spec_Field, - Info.Package_Body_Scope'Access); + procedure Translate_Package_Body_Subprograms + (Bod : Iir_Package_Body; What : Subprg_Translate_Kind) + is + Spec : constant Iir := Get_Package (Bod); + Is_Uninst : constant Boolean := Is_Uninstantiated_Package (Spec); + Info : constant Ortho_Info_Acc := Get_Info (Spec); + Prev_Subprg_Instance : Subprgs.Subprg_Instance_Stack; + Mark : Id_Mark_Type; + begin + if Is_Uninst and then Get_Macro_Expanded_Flag (Spec) then + -- Nothing to do for macro-expanded packages. + return; + end if; - Chap4.Translate_Declaration_Chain_Subprograms - (Decl, Subprg_Translate_Only_Body); + Push_Identifier_Prefix (Mark, Get_Identifier (Spec)); - -- Create elaboration procedure for the spec - Elab_Package (Decl, Header); + if Is_Uninst then + -- An extra parameter for the package instance needs to be added + -- to the subprograms. + Subprgs.Push_Subprg_Instance + (Info.Package_Body_Scope'Access, Info.Package_Body_Ptr_Type, + Wki_Instance, Prev_Subprg_Instance); - Clear_Scope (Info.Package_Spec_Scope); - end if; - end if; + -- For nested package, this will be translated when translating + -- subprograms. + Set_Scope_Via_Field (Info.Package_Spec_Scope, + Info.Package_Spec_Field, + Info.Package_Body_Scope'Access); + end if; + Chap4.Translate_Declaration_Chain_Subprograms (Bod, What); + + if Is_Uninst then + Clear_Scope (Info.Package_Spec_Scope); Subprgs.Pop_Subprg_Instance (Wki_Instance, Prev_Subprg_Instance); - else - if not Is_Nested - and then Global_Storage /= O_Storage_External - then - -- Create elaboration procedure for the spec - Elab_Package (Decl, Header); + + if What in Subprg_Translate_Body then + Elab_Package_Body (Spec, Bod); end if; end if; - Save_Local_Identifier (Info.Package_Local_Id); - if Is_Nested then - Pop_Identifier_Prefix (Mark); - end if; - end Translate_Package; + Pop_Identifier_Prefix (Mark); + end Translate_Package_Body_Subprograms; - procedure Translate_Package_Declaration (Decl : Iir_Package_Declaration) is + procedure Translate_Package_Declaration (Decl : Iir_Package_Declaration) + is + Mark : Id_Mark_Type; begin -- Skip uninstantiated package that have to be macro-expanded. if Get_Macro_Expanded_Flag (Decl) then return; end if; - Translate_Package (Decl, Get_Package_Header (Decl)); + Push_Identifier_Prefix (Mark, Get_Identifier (Decl)); + + if Is_Uninstantiated_Package (Decl) then + Translate_Package_Uninst_Common (Decl, Get_Package_Header (Decl)); + else + Translate_Package_Concrete_Common (Decl, Get_Package_Header (Decl)); + end if; + + Pop_Identifier_Prefix (Mark); end Translate_Package_Declaration; - procedure Translate_Package_Body (Bod : Iir_Package_Body) + procedure Translate_Package_Declaration_Unit + (Decl : Iir_Package_Declaration) + is + Header : Iir; + begin + -- Skip uninstantiated package that have to be macro-expanded. + if Get_Macro_Expanded_Flag (Decl) then + return; + end if; + + Header := Get_Package_Header (Decl); + if Is_Uninstantiated_Package (Decl) then + Translate_Package_Uninst_Common (Decl, Header); + Translate_Package_Uninst_Unit (Decl, Header); + else + Translate_Package_Concrete_Common (Decl, Header); + Translate_Package_Concrete_Unit (Decl, Header); + end if; + end Translate_Package_Declaration_Unit; + + procedure Translate_Package_Body_Internal (Bod : Iir_Package_Body) is Is_Nested : constant Boolean := Is_Nested_Package (Bod); Spec : constant Iir_Package_Declaration := Get_Package (Bod); @@ -923,16 +1068,11 @@ package body Trans.Chap2 is Info : constant Ortho_Info_Acc := Get_Info (Spec); Prev_Storage : constant O_Storage := Global_Storage; Prev_Subprg_Instance : Subprgs.Subprg_Instance_Stack; - Mark : Id_Mark_Type; begin if Is_Spec_Decl and then Get_Macro_Expanded_Flag (Spec) then return; end if; - if Is_Nested then - Push_Identifier_Prefix (Mark, Get_Identifier (Spec)); - end if; - -- Translate declarations. if Is_Spec_Decl and then Is_Uninstantiated_Package (Spec) then Push_Package_Instance_Factory (Spec); @@ -949,9 +1089,6 @@ package body Trans.Chap2 is -- May be called during elaboration to generate RTI. if Global_Storage = O_Storage_External then - if Is_Nested then - Pop_Identifier_Prefix (Mark); - end if; return; end if; @@ -985,26 +1122,47 @@ package body Trans.Chap2 is if not Is_Nested then Chap4.Translate_Declaration_Chain_Subprograms (Spec, Subprg_Translate_Only_Body); - Elab_Package (Spec, Get_Package_Header (Spec)); + Elab_Package_Internal (Spec, Get_Package_Header (Spec)); end if; Clear_Scope (Info.Package_Spec_Scope); end if; - if not Is_Nested then + if not Is_Nested and Flag_Elaboration then Elab_Package_Body (Spec, Bod); end if; Global_Storage := Prev_Storage; + end Translate_Package_Body_Internal; - if Is_Nested then - Pop_Identifier_Prefix (Mark); - end if; + -- For a nested package body or for a nested package instantiation body. + procedure Translate_Package_Body (Bod : Iir_Package_Body) + is + Spec : constant Iir_Package_Declaration := Get_Package (Bod); + Mark : Id_Mark_Type; + begin + Push_Identifier_Prefix (Mark, Get_Identifier (Spec)); + + Translate_Package_Body_Internal (Bod); + + Pop_Identifier_Prefix (Mark); end Translate_Package_Body; + procedure Translate_Package_Body_Unit (Bod : Iir_Package_Body) is + begin + if not Flag_Elaboration then + return; + end if; + + Translate_Package_Body_Internal (Bod); + end Translate_Package_Body_Unit; + -- Elaborate a package or a package instantiation. - procedure Elab_Package (Spec : Iir; Header : Iir) + procedure Elab_Package_Internal (Spec : Iir; Header : Iir) is Is_Nested : constant Boolean := Is_Nested_Package (Spec); + Is_Uninst : constant Boolean := + Get_Kind (Spec) = Iir_Kind_Package_Declaration + and then Is_Uninstantiated_Package (Spec); Info : constant Ortho_Info_Acc := Get_Info (Spec); Final : Boolean; Constr : O_Assoc_List; @@ -1013,16 +1171,16 @@ package body Trans.Chap2 is return; end if; - if not Is_Nested then + if (not Is_Nested) or else Is_Uninst then Start_Subprogram_Body (Info.Package_Elab_Spec_Subprg); Push_Local_Factory; Subprgs.Start_Subprg_Instance_Use (Info.Package_Elab_Spec_Instance); - Elab_Dependence (Get_Design_Unit (Spec)); + if not Is_Nested then + Elab_Dependence (Get_Design_Unit (Spec)); + end if; - if not (Get_Kind (Spec) = Iir_Kind_Package_Declaration - and then Is_Uninstantiated_Package (Spec)) - then + if not Is_Uninst then -- Register the top level package. This is done dynamically, as -- we know only during elaboration that the design depends on a -- package (a package maybe referenced by an entity which is never @@ -1046,34 +1204,43 @@ package body Trans.Chap2 is Chap4.Elab_Declaration_Chain (Spec, Final); pragma Unreferenced (Final); - if not Is_Nested and then Flag_Elaboration then + if (not Is_Nested) or else Is_Uninst then Close_Temp; Subprgs.Finish_Subprg_Instance_Use (Info.Package_Elab_Spec_Instance); Pop_Local_Factory; Finish_Subprogram_Body; end if; - end Elab_Package; + end Elab_Package_Internal; + + procedure Elab_Package_Declaration (Spec : Iir) is + begin + Elab_Package_Internal (Spec, Get_Package_Header (Spec)); + end Elab_Package_Declaration; procedure Elab_Package_Body (Spec : Iir_Package_Declaration; Bod : Iir) is + -- SPEC can be a package declaration or a package instantiation. Is_Spec_Decl : constant Boolean := Get_Kind (Spec) = Iir_Kind_Package_Declaration; + Is_Uninst : constant Boolean := + Is_Spec_Decl and then Is_Uninstantiated_Package (Spec); Info : constant Ortho_Info_Acc := Get_Info (Spec); If_Blk : O_If_Block; Constr : O_Assoc_List; Final : Boolean; begin - if Is_Spec_Decl and then Get_Macro_Expanded_Flag (Spec) then - return; - end if; + -- Macro-expanded packages are skipped. + pragma Assert + (not (Is_Spec_Decl and then Get_Macro_Expanded_Flag (Spec))); - if not Flag_Elaboration and not Is_Nested_Package (Spec) then - return; - end if; + -- No elaboration code generated, except for nested packages + -- (could be within a subprogram). + pragma Assert (Flag_Elaboration or else Is_Nested_Package (Spec)); - if Is_Spec_Decl and then Is_Uninstantiated_Package (Spec) then + if Is_Uninst then + -- Make spec reachable. Set_Scope_Via_Field (Info.Package_Spec_Scope, Info.Package_Spec_Field, Info.Package_Body_Scope'Access); @@ -1085,12 +1252,14 @@ package body Trans.Chap2 is -- If the package was already elaborated, return now, -- else mark the package as elaborated. - Start_If_Stmt (If_Blk, New_Value (Get_Var (Info.Package_Elab_Var))); - New_Return_Stmt; - New_Else_Stmt (If_Blk); - New_Assign_Stmt (Get_Var (Info.Package_Elab_Var), - New_Lit (Ghdl_Bool_True_Node)); - Finish_If_Stmt (If_Blk); + if Info.Package_Elab_Var /= Null_Var then + Start_If_Stmt (If_Blk, New_Value (Get_Var (Info.Package_Elab_Var))); + New_Return_Stmt; + New_Else_Stmt (If_Blk); + New_Assign_Stmt (Get_Var (Info.Package_Elab_Var), + New_Lit (Ghdl_Bool_True_Node)); + Finish_If_Stmt (If_Blk); + end if; -- Elab Spec. Start_Association (Constr, Info.Package_Elab_Spec_Subprg); @@ -1098,7 +1267,10 @@ package body Trans.Chap2 is New_Procedure_Call (Constr); if Bod /= Null_Iir then - Elab_Dependence (Get_Design_Unit (Bod)); + if not Is_Nested_Package (Bod) then + Elab_Dependence (Get_Design_Unit (Bod)); + end if; + Open_Temp; Chap4.Elab_Declaration_Chain (Bod, Final); Close_Temp; @@ -1108,11 +1280,20 @@ package body Trans.Chap2 is Pop_Local_Factory; Finish_Subprogram_Body; - if Is_Spec_Decl and then Is_Uninstantiated_Package (Spec) then + if Is_Uninst then Clear_Scope (Info.Package_Spec_Scope); end if; end Elab_Package_Body; + procedure Elab_Package_Unit_Without_Body (Spec : Iir) is + begin + if Get_Macro_Expanded_Flag (Spec) then + return; + end if; + + Elab_Package_Body (Spec, Null_Iir); + end Elab_Package_Unit_Without_Body; + procedure Instantiate_Iir_Info (N : Iir); procedure Instantiate_Iir_Chain_Info (Chain : Iir) @@ -1599,35 +1780,57 @@ package body Trans.Chap2 is (Info.Package_Instance_Spec_Scope'Access); end Instantiate_Info_Package; - procedure Translate_Package_Instantiation_Declaration (Inst : Iir) + procedure Update_Info_Package (Inst : Iir) is - Spec : constant Iir := Get_Uninstantiated_Package_Decl (Inst); - Pkg_Info : constant Ortho_Info_Acc := Get_Info (Spec); - Info : Ortho_Info_Acc; - Interface_List : O_Inter_List; + Spec : constant Iir := Get_Uninstantiated_Package_Decl (Inst); + Pkg_Info : constant Ortho_Info_Acc := Get_Info (Spec); + Info : constant Ortho_Info_Acc := Get_Info (Inst); + El : Iir; begin - if Get_Macro_Expanded_Flag (Spec) then - -- Macro-expanded instantiations are translated like a package. - Translate_Package (Inst, Inst); + -- Create the info instances. + Push_Instantiate_Var_Scope + (Info.Package_Instance_Spec_Scope'Access, + Pkg_Info.Package_Spec_Scope'Access); + Push_Instantiate_Var_Scope + (Info.Package_Instance_Body_Scope'Access, + Pkg_Info.Package_Body_Scope'Access); - -- Generate code for the body. - declare - Bod : constant Iir := Get_Instance_Package_Body (Inst); - begin - if Get_Immediate_Body_Flag (Inst) then - Translate_Package_Body (Bod); - elsif not Get_Need_Body (Spec) - and then not Is_Nested_Package (Inst) - and then Global_Storage /= O_Storage_External - then - -- As an elaboration subprogram for the body is always - -- needed, generate it. - Elab_Package_Body (Inst, Null_Iir); - end if; - end; - return; - end if; + El := Get_Declaration_Chain (Inst); + while El /= Null_Iir loop + case Get_Kind (El) is + when Iir_Kind_Function_Declaration + | Iir_Kind_Procedure_Declaration => + declare + Orig : constant Iir := + Vhdl.Sem_Inst.Get_Origin (El); + pragma Assert (Orig /= Null_Iir); + Orig_Info : constant Ortho_Info_Acc := + Get_Info (Orig); + Info : constant Ortho_Info_Acc := Get_Info (El); + begin + if Orig_Info /= null then + Copy_Info (Info, Orig_Info); + Clean_Copy_Info (Info); + end if; + end; + when others => + null; + end case; + El := Get_Chain (El); + end loop; + Pop_Instantiate_Var_Scope + (Info.Package_Instance_Body_Scope'Access); + Pop_Instantiate_Var_Scope + (Info.Package_Instance_Spec_Scope'Access); + end Update_Info_Package; + + procedure Translate_Package_Instantiation_Declaration_Internal (Inst : Iir) + is + Spec : constant Iir := Get_Uninstantiated_Package_Decl (Inst); + Pkg_Info : constant Ortho_Info_Acc := Get_Info (Spec); + Info : Ortho_Info_Acc; + begin Info := Add_Info (Inst, Kind_Package_Instance); -- Create the variable containing data for the package instance. @@ -1644,36 +1847,113 @@ package body Trans.Chap2 is Info.Package_Instance_Body_Scope'Access); Instantiate_Info_Package (Inst); + end Translate_Package_Instantiation_Declaration_Internal; - if Is_Nested_Package (Inst) or else not Flag_Elaboration then - return; + procedure Translate_Package_Instantiation_Declaration_Macro (Inst : Iir) is + begin + -- Generate code for the body. + if Get_Immediate_Body_Flag (Inst) then + Translate_Package_Body_Internal (Get_Instance_Package_Body (Inst)); + elsif not Get_Need_Body (Get_Uninstantiated_Package_Decl (Inst)) + and then not Is_Nested_Package (Inst) + and then Global_Storage /= O_Storage_External + then + -- As an elaboration subprogram for the body is always + -- needed, generate it. + Elab_Package_Body (Inst, Null_Iir); end if; + end Translate_Package_Instantiation_Declaration_Macro; - -- Declare elaboration procedure - Start_Procedure_Decl - (Interface_List, Create_Identifier ("ELAB"), Global_Storage); - -- Chap2.Add_Subprg_Instance_Interfaces - -- (Interface_List, Info.Package_Instance_Elab_Instance); - Finish_Subprogram_Decl - (Interface_List, Info.Package_Instance_Elab_Subprg); + procedure Translate_Package_Instantiation_Declaration (Inst : Iir) + is + Spec : constant Iir := Get_Uninstantiated_Package_Decl (Inst); + Mark : Id_Mark_Type; + begin + Push_Identifier_Prefix (Mark, Get_Identifier (Inst)); - if Global_Storage = O_Storage_External then - return; + if Get_Macro_Expanded_Flag (Spec) then + Translate_Package_Concrete_Common (Inst, Inst); + Translate_Package_Instantiation_Declaration_Macro (Inst); + else + Translate_Package_Instantiation_Declaration_Internal (Inst); end if; - -- Elaborator: - Start_Subprogram_Body (Info.Package_Instance_Elab_Subprg); - -- Chap2.Start_Subprg_Instance_Use - -- (Info.Package_Instance_Elab_Instance); + Pop_Identifier_Prefix (Mark); + end Translate_Package_Instantiation_Declaration; - Elab_Dependence (Get_Design_Unit (Inst)); + procedure Translate_Package_Instantiation_Declaration_Subprograms + (Inst : Iir; What : Subprg_Translate_Kind) is + begin + if Get_Macro_Expanded_Flag (Get_Uninstantiated_Package_Decl (Inst)) then + declare + Bod : constant Iir := Get_Instance_Package_Body (Inst); + Mark : Id_Mark_Type; + begin + Push_Identifier_Prefix (Mark, Get_Identifier (Inst)); + Chap4.Translate_Declaration_Chain_Subprograms (Inst, What); + if Is_Valid (Bod) + and then Global_Storage /= O_Storage_External + and then Get_Immediate_Body_Flag (Inst) + then + Chap4.Translate_Declaration_Chain_Subprograms (Bod, What); + end if; + Pop_Identifier_Prefix (Mark); + end; + else + if What in Subprg_Translate_Spec then + -- Update info for subprgs. + -- Info have been instantiated but may not be complete as the + -- ortho node may be created later. + Update_Info_Package (Inst); + end if; + end if; + end Translate_Package_Instantiation_Declaration_Subprograms; - Elab_Package_Instantiation_Declaration (Inst); + procedure Translate_Package_Instantiation_Declaration_Unit (Inst : Iir) + is + Spec : constant Iir := Get_Uninstantiated_Package_Decl (Inst); + Interface_List : O_Inter_List; + Info : Ortho_Info_Acc; + begin + if Get_Macro_Expanded_Flag (Spec) then + Translate_Package_Concrete_Common (Inst, Inst); + Translate_Package_Concrete_Unit (Inst, Inst); + Translate_Package_Instantiation_Declaration_Macro (Inst); + else + Translate_Package_Instantiation_Declaration_Internal (Inst); - -- Chap2.Finish_Subprg_Instance_Use - -- (Info.Package_Instance_Elab_Instance); - Finish_Subprogram_Body; - end Translate_Package_Instantiation_Declaration; + if not Flag_Elaboration then + return; + end if; + + Info := Get_Info (Inst); + + -- Declare elaboration procedure + Start_Procedure_Decl + (Interface_List, Create_Identifier ("ELAB"), Global_Storage); + -- Chap2.Add_Subprg_Instance_Interfaces + -- (Interface_List, Info.Package_Instance_Elab_Instance); + Finish_Subprogram_Decl + (Interface_List, Info.Package_Instance_Elab_Subprg); + + if Global_Storage = O_Storage_External then + return; + end if; + + -- Elaborator: + Start_Subprogram_Body (Info.Package_Instance_Elab_Subprg); + -- Chap2.Start_Subprg_Instance_Use + -- (Info.Package_Instance_Elab_Instance); + + Elab_Dependence (Get_Design_Unit (Inst)); + + Elab_Package_Instantiation_Declaration (Inst); + + -- Chap2.Finish_Subprg_Instance_Use + -- (Info.Package_Instance_Elab_Instance); + Finish_Subprogram_Body; + end if; + end Translate_Package_Instantiation_Declaration_Unit; procedure Elab_Package_Instantiation_Declaration (Inst : Iir) is @@ -1685,19 +1965,18 @@ package body Trans.Chap2 is -- Macro-expanded instances are handled like a regular package. if Get_Macro_Expanded_Flag (Spec) then declare - Spec_Parent : constant Iir := Get_Parent (Spec); Bod : constant Iir := Get_Package_Body (Spec); begin -- There are no routines generated to elaborate macro-expanded -- packages, but dependencies still need to be elaborated. - if Get_Kind (Spec_Parent) = Iir_Kind_Design_Unit then + if not Is_Nested_Package (Spec) then Elab_Dependence (Get_Design_Unit (Spec)); if Bod /= Null_Iir then Elab_Dependence (Get_Design_Unit (Bod)); end if; end if; - Elab_Package (Inst, Inst); + Elab_Package_Internal (Inst, Inst); if Get_Immediate_Body_Flag (Inst) then -- Humm, if BOD is present then INST_BOD should also be diff --git a/src/vhdl/translate/trans-chap2.ads b/src/vhdl/translate/trans-chap2.ads index a3c6189d9..155b91487 100644 --- a/src/vhdl/translate/trans-chap2.ads +++ b/src/vhdl/translate/trans-chap2.ads @@ -29,13 +29,25 @@ package Trans.Chap2 is -- overload number if any. procedure Push_Subprg_Identifier (Spec : Iir; Mark : out Id_Mark_Type); + -- Package declaration, body and instantiation when they are design units. + procedure Translate_Package_Declaration_Unit + (Decl : Iir_Package_Declaration); + procedure Translate_Package_Body_Unit (Bod : Iir_Package_Body); + procedure Translate_Package_Instantiation_Declaration_Unit (Inst : Iir); + procedure Elab_Package_Unit_Without_Body (Spec : Iir); + + -- For nested packages. procedure Translate_Package_Declaration (Decl : Iir_Package_Declaration); procedure Translate_Package_Body (Bod : Iir_Package_Body); procedure Translate_Package_Instantiation_Declaration (Inst : Iir); - - procedure Elab_Package (Spec : Iir; Header : Iir); + procedure Translate_Package_Declaration_Subprograms + (Decl : Iir_Package_Declaration; What : Subprg_Translate_Kind); + procedure Translate_Package_Body_Subprograms + (Bod : Iir_Package_Body; What : Subprg_Translate_Kind); + procedure Translate_Package_Instantiation_Declaration_Subprograms + (Inst : Iir; What : Subprg_Translate_Kind); + procedure Elab_Package_Declaration (Spec : Iir); procedure Elab_Package_Body (Spec : Iir_Package_Declaration; Bod : Iir); - procedure Elab_Package_Instantiation_Declaration (Inst : Iir); -- Add info for an interface_package_declaration or a diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb index 07e3f9030..2c33231c4 100644 --- a/src/vhdl/translate/trans-chap4.adb +++ b/src/vhdl/translate/trans-chap4.adb @@ -2598,22 +2598,18 @@ package body Trans.Chap4 is Create_Union_Scope (State_Scope.all, Scope_Type); end Translate_Statements_Chain_State_Declaration; - -- PKG is a nested package declaration or package body - -- Translate only if non-generic or non-macro expanded. - -- SPEC is the corresponding package declaration. - procedure Translate_Declaration_Chain_Subprograms_Package - (Pkg : Iir; Spec : Iir; What : Subprg_Translate_Kind) + procedure Translate_Declaration_Chain_Subprograms_Spec_Body (Parent : Iir) is - Mark : Id_Mark_Type; + What : Subprg_Translate_Kind; begin - if Get_Package_Header (Spec) = Null_Iir - or else not Get_Macro_Expanded_Flag (Spec) - then - Push_Identifier_Prefix (Mark, Get_Identifier (Pkg)); - Translate_Declaration_Chain_Subprograms (Pkg, What); - Pop_Identifier_Prefix (Mark); + if Global_Storage /= O_Storage_External then + What := Subprg_Translate_Spec_And_Body; + else + -- No need and incorrect to generate bodies when external storage. + What := Subprg_Translate_Only_Spec; end if; - end Translate_Declaration_Chain_Subprograms_Package; + Translate_Declaration_Chain_Subprograms (Parent, What); + end Translate_Declaration_Chain_Subprograms_Spec_Body; procedure Translate_Declaration_Chain_Subprograms (Parent : Iir; What : Subprg_Translate_Kind) @@ -2622,9 +2618,9 @@ package body Trans.Chap4 is Do_Specs : constant Boolean := What in Subprg_Translate_Spec; -- True iff bodies must be translated. - Do_Bodies : constant Boolean := - (What in Subprg_Translate_Body - and then Global_Storage /= O_Storage_External); + Do_Bodies : constant Boolean := What in Subprg_Translate_Body; + pragma Assert + (not (Do_Bodies and then Global_Storage = O_Storage_External)); El : Iir; Infos : Chap7.Implicit_Subprogram_Infos; @@ -2697,29 +2693,12 @@ package body Trans.Chap4 is Chap3.Translate_Protected_Type_Body_Subprograms_Body (El); end if; when Iir_Kind_Package_Declaration => - Translate_Declaration_Chain_Subprograms_Package (El, El, What); + Chap2.Translate_Package_Declaration_Subprograms (El, What); when Iir_Kind_Package_Body => - Translate_Declaration_Chain_Subprograms_Package - (El, Get_Package (El), What); + Chap2.Translate_Package_Body_Subprograms (El, What); when Iir_Kind_Package_Instantiation_Declaration => - if Get_Macro_Expanded_Flag - (Get_Uninstantiated_Package_Decl (El)) - then - declare - Bod : constant Iir := Get_Instance_Package_Body (El); - Mark : Id_Mark_Type; - begin - Push_Identifier_Prefix (Mark, Get_Identifier (El)); - Translate_Declaration_Chain_Subprograms (El, What); - if Is_Valid (Bod) - and then Global_Storage /= O_Storage_External - and then Get_Immediate_Body_Flag (El) - then - Translate_Declaration_Chain_Subprograms (Bod, What); - end if; - Pop_Identifier_Prefix (Mark); - end; - end if; + Chap2.Translate_Package_Instantiation_Declaration_Subprograms + (El, What); when Iir_Kind_Package_Instantiation_Body => declare Mark : Id_Mark_Type; @@ -2832,8 +2811,11 @@ package body Trans.Chap4 is null; when Iir_Kind_Package_Declaration => - Chap2.Elab_Package (Decl, Get_Package_Header (Decl)); - -- FIXME: finalizer + if not Is_Uninstantiated_Package (Decl) then + -- Elaborate nested package (unless it is uninstantiated). + Chap2.Elab_Package_Declaration (Decl); + -- FIXME: finalizer + end if; when Iir_Kind_Package_Body => declare Nested_Final : Boolean; diff --git a/src/vhdl/translate/trans-chap4.ads b/src/vhdl/translate/trans-chap4.ads index 02ff9a70e..cf4a6624b 100644 --- a/src/vhdl/translate/trans-chap4.ads +++ b/src/vhdl/translate/trans-chap4.ads @@ -57,6 +57,8 @@ package Trans.Chap4 is procedure Translate_Declaration_Chain_Subprograms (Parent : Iir; What : Subprg_Translate_Kind); + procedure Translate_Declaration_Chain_Subprograms_Spec_Body (Parent : Iir); + -- Create subprograms for type/function conversion of signal -- associations. -- ENTITY is the entity instantiated, which can be either diff --git a/src/vhdl/translate/translation.adb b/src/vhdl/translate/translation.adb index 76fa7a0b3..86a18e892 100644 --- a/src/vhdl/translate/translation.adb +++ b/src/vhdl/translate/translation.adb @@ -167,21 +167,15 @@ package body Translation is when Iir_Kind_Package_Declaration => New_Debug_Comment_Decl ("package declaration " & Image_Identifier (Lib_Unit)); - Chap2.Translate_Package_Declaration (Lib_Unit); - if Get_Package_Origin (Lib_Unit) /= Null_Iir - and then Get_Package_Body (Lib_Unit) /= Null_Iir - then - -- Corresponding body for package instantiation. - Chap2.Translate_Package_Body (Get_Package_Body (Lib_Unit)); - end if; + Chap2.Translate_Package_Declaration_Unit (Lib_Unit); when Iir_Kind_Package_Body => New_Debug_Comment_Decl ("package body " & Image_Identifier (Lib_Unit)); - Chap2.Translate_Package_Body (Lib_Unit); + Chap2.Translate_Package_Body_Unit (Lib_Unit); when Iir_Kind_Package_Instantiation_Declaration => New_Debug_Comment_Decl ("package instantiation " & Image_Identifier (Lib_Unit)); - Chap2.Translate_Package_Instantiation_Declaration (Lib_Unit); + Chap2.Translate_Package_Instantiation_Declaration_Unit (Lib_Unit); when Iir_Kind_Entity_Declaration => New_Debug_Comment_Decl ("entity " & Image_Identifier (Lib_Unit)); Chap1.Translate_Entity_Declaration (Lib_Unit); diff --git a/src/vhdl/vhdl-ieee-std_logic_arith.adb b/src/vhdl/vhdl-ieee-std_logic_arith.adb index 0786f753e..b3f6e9c81 100644 --- a/src/vhdl/vhdl-ieee-std_logic_arith.adb +++ b/src/vhdl/vhdl-ieee-std_logic_arith.adb @@ -50,6 +50,12 @@ package body Vhdl.Ieee.Std_Logic_Arith is Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Unsigned_Int, Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Unsigned_Log); + Conv_Sgn_Patterns : constant Conv_Pattern_Type := + (Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Signed_Sgn, + Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Signed_Uns, + Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Signed_Int, + Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Signed_Log); + Conv_Int_Patterns : constant Conv_Pattern_Type := (Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Integer_Sgn, Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Integer_Uns, @@ -521,6 +527,8 @@ package body Vhdl.Ieee.Std_Logic_Arith is Def := Handle_Bin (Mul_Patterns); when Name_Conv_Unsigned => Def := Handle_Conv (Conv_Uns_Patterns); + when Name_Conv_Signed => + Def := Handle_Conv (Conv_Sgn_Patterns); when Name_Conv_Std_Logic_Vector => Def := Handle_Conv (Conv_Vec_Patterns); when Name_Op_Less => diff --git a/src/vhdl/vhdl-nodes.ads b/src/vhdl/vhdl-nodes.ads index 3d9561662..95676af3e 100644 --- a/src/vhdl/vhdl-nodes.ads +++ b/src/vhdl/vhdl-nodes.ads @@ -6289,6 +6289,11 @@ package Vhdl.Nodes is Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Unsigned_Sgn, Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Unsigned_Log, + Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Signed_Int, + Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Signed_Uns, + Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Signed_Sgn, + Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Signed_Log, + Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Integer_Int, Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Integer_Uns, Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Integer_Sgn, diff --git a/testsuite/gna/issue2395/test.vhdl b/testsuite/gna/issue2395/test.vhdl new file mode 100644 index 000000000..7b467938e --- /dev/null +++ b/testsuite/gna/issue2395/test.vhdl @@ -0,0 +1,64 @@ +library ieee ; + use ieee.std_logic_1164.all ; + +package axi4s is + + type axis_t is record + data : std_ulogic_vector ; + dest : std_ulogic_vector ; + id : std_ulogic_vector ; + strb : std_ulogic_vector ; + keep : std_ulogic_vector ; + user : std_ulogic_vector ; + last : std_ulogic ; + valid : std_ulogic ; + ready : std_ulogic ; + end record ; + + type axis_array_t is array(natural range <>) of axis_t ; + + package make is + generic ( + DATA_BYTES : positive := 4 ; + DEST_WIDTH : natural := 0 ; + ID_WIDTH : natural := 0 ; + USER_WIDTH : natural := 0 + ) ; + + subtype DATA_RANGE is natural range DATA_BYTES*8-1 downto 0 ; + subtype DEST_RANGE is natural range DEST_WIDTH-1 downto 0 ; + subtype ID_RANGE is natural range ID_WIDTH-1 downto 0 ; + subtype KEEP_RANGE is natural range DATA_BYTES-1 downto 0 ; + subtype USER_RANGE is natural range USER_WIDTH-1 downto 0 ; + + subtype axis_t is axi4s.axis_t( + data(DATA_RANGE), + dest(DEST_RANGE), + id(ID_RANGE), + keep(KEEP_RANGE), + strb(KEEP_RANGE), + user(USER_RANGE) + ) ; + + end package ; + +end package ; + +package axis32 is new work.axi4s.make ; + +entity test is + port ( + clock : in bit ; + reset : in bit ; + rx : inout work.axis32.axis_t ; + tx : inout work.axi4s.axis_t(data(31 downto 0), dest(-1 downto 0), id(-1 downto 0), keep(3 downto 0), strb(-1 downto 0), user(-1 downto 0)) + ) ; +end entity ; + +architecture arch of test is + +begin + + -- do nothing for now + +end architecture ; diff --git a/testsuite/gna/issue2395/testsuite.sh b/testsuite/gna/issue2395/testsuite.sh new file mode 100755 index 000000000..1d84c0f57 --- /dev/null +++ b/testsuite/gna/issue2395/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../testenv.sh + +export GHDL_STD_FLAGS=--std=08 +analyze test.vhdl +elab_simulate test + +clean + +echo "Test successful" diff --git a/testsuite/gna/issue2410/test.vhdl b/testsuite/gna/issue2410/test.vhdl new file mode 100644 index 000000000..280452526 --- /dev/null +++ b/testsuite/gna/issue2410/test.vhdl @@ -0,0 +1,28 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity test is +end entity test; +architecture beh of test is + type t_slv_array is array (natural range <>) of std_logic_vector; + subtype t_word_array is t_slv_array(open)(15 downto 0); + + procedure test_proc( + variable sig : out t_word_array) + is + variable v_sig : t_word_array(0 to sig'length); + begin + v_sig := (others => x"AAAA"); + sig := v_sig(1 to sig'length); + end procedure; +begin + + process + variable v_sig : t_word_array(0 to 0); + begin + test_proc(v_sig); + wait; + end process; + +end architecture beh; diff --git a/testsuite/gna/issue2410/testsuite.sh b/testsuite/gna/issue2410/testsuite.sh new file mode 100755 index 000000000..1d84c0f57 --- /dev/null +++ b/testsuite/gna/issue2410/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../testenv.sh + +export GHDL_STD_FLAGS=--std=08 +analyze test.vhdl +elab_simulate test + +clean + +echo "Test successful" diff --git a/testsuite/synth/issue2408/bug.vhdl b/testsuite/synth/issue2408/bug.vhdl new file mode 100644 index 000000000..179b30298 --- /dev/null +++ b/testsuite/synth/issue2408/bug.vhdl @@ -0,0 +1,39 @@ +library IEEE; +use IEEE.std_logic_1164.all; +use IEEE.std_logic_arith.all; + +entity bug is + generic( + LEN : positive := 32; + POS : natural := 10 + ); + port( + output : out signed(LEN-1 downto 0) + ); + + function GET_NUM_FUNC(n : natural) return integer is + variable result :integer; + begin + case n is + when 0 => result := 16#010020#; + when 1 => result := 16#020D30#; + when 2 => result := 16#00FC1#; + when 3 => result := 16#05010#; + when 4 => result := 16#02800#; + when 5 => result := 16#01400#; + when 6 => result := 16#002F#; + when 7 => result := 16#0508#; + when 8 => result := 16#0200#; + when 9 => result := 16#0100#; + when 10 => result := 16#0A0#; + when others => result := 16#0#; + end case; + return result; + end GET_NUM_FUNC; + +end bug; + +architecture behav of bug is +begin + output <= conv_signed(GET_NUM_FUNC(POS), LEN); +end architecture; diff --git a/testsuite/synth/issue2408/testsuite.sh b/testsuite/synth/issue2408/testsuite.sh new file mode 100755 index 000000000..7de7b802c --- /dev/null +++ b/testsuite/synth/issue2408/testsuite.sh @@ -0,0 +1,8 @@ +#! /bin/sh + +. ../../testenv.sh + +GHDL_STD_FLAGS=-fsynopsys +synth_only bug + +echo "Test successful" diff --git a/testsuite/synth/synth183/test.vhdl b/testsuite/synth/synth183/test.vhdl new file mode 100644 index 000000000..84fc93639 --- /dev/null +++ b/testsuite/synth/synth183/test.vhdl @@ -0,0 +1,45 @@ +library ieee;
+ use ieee.std_logic_1164.all;
+
+entity test is
+ generic (
+ BAUD_MULT : positive := 16
+ );
+ port (
+ clk, rst : in std_logic;
+
+ brk : out std_logic;
+ rx : in std_logic
+ );
+end test;
+
+architecture behavioral of test is
+
+ signal rx_buf : std_logic := '1';
+ signal break : std_logic := '0';
+
+begin
+
+ BREAK_DETECTOR: process (clk, rst) is
+ constant BREAK_CNT : positive := BAUD_MULT * 11;
+ variable count : natural range 0 to BREAK_CNT + 1 := 0;
+ begin
+ if (rising_edge(clk)) then
+ rx_buf <= rx;
+ -- Add to counter if '0', but halt count when break detected
+ count := (count + 1) when not(rx_buf or break);
+ -- Reset counter if '1'
+ count := 0 when rx_buf;
+
+ break <= '0' when (count < BREAK_CNT) else '1';
+
+ if (rst = '1') then
+ count := 0;
+ break <= '0';
+ end if;
+ end if;
+ end process;
+
+ brk <= break;
+
+end behavioral;
\ No newline at end of file diff --git a/testsuite/synth/synth183/testsuite.sh b/testsuite/synth/synth183/testsuite.sh new file mode 100755 index 000000000..eb1ca0714 --- /dev/null +++ b/testsuite/synth/synth183/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../testenv.sh + +GHDL_STD_FLAGS=--std=08 + +synth_analyze test + +clean + +echo "Test successful" |
