@@ -2664,6 +2664,14 @@ class Choice(ModelEntity):
2664
2664
"""
2665
2665
2666
2666
2667
+ @export
2668
+ class ConcurrentChoice (Choice ):
2669
+ """
2670
+ A ``ConcurrentChoice`` is a base-class for all concurrent choices
2671
+ (in for...generate statements).
2672
+ """
2673
+
2674
+
2667
2675
@export
2668
2676
class Case (ModelEntity ):
2669
2677
"""
@@ -2673,18 +2681,35 @@ class Case(ModelEntity):
2673
2681
2674
2682
@export
2675
2683
class ConcurrentCase (Case , LabeledEntity , ConcurrentDeclarations , ConcurrentStatements ):
2676
- _choices : List
2677
-
2678
- def __init__ (self , label : str = None ):
2684
+ def __init__ (self , declaredItems : Iterable = None , statements : Iterable [ConcurrentStatement ] = None , alternativeLabel : str = None ):
2679
2685
super ().__init__ ()
2680
- LabeledEntity .__init__ (self , label )
2681
- ConcurrentDeclarations .__init__ (self )
2682
- ConcurrentStatements .__init__ (self )
2686
+ LabeledEntity .__init__ (self , alternativeLabel )
2687
+ ConcurrentDeclarations .__init__ (self , declaredItems )
2688
+ ConcurrentStatements .__init__ (self , statements )
2689
+
2690
+
2691
+ @export
2692
+ class GenerateCase (ConcurrentCase ):
2693
+ _choices : List [ConcurrentChoice ]
2694
+
2695
+ def __init__ (self , choices : Iterable [ConcurrentChoice ], declaredItems : Iterable = None , statements : Iterable [ConcurrentStatement ] = None , alternativeLabel : str = None ):
2696
+ super ().__init__ (declaredItems , statements , alternativeLabel )
2697
+
2698
+ self ._choices = [c for c in choices ]
2683
2699
2684
2700
@property
2685
- def Choises (self ) -> List [Choice ]:
2701
+ def Choises (self ) -> List [ConcurrentChoice ]:
2686
2702
return self ._choices
2687
2703
2704
+ def __str__ (self ) -> str :
2705
+ return "when {choices} =>" .format (choices = " | " .join ([str (c ) for c in self ._choices ]))
2706
+
2707
+
2708
+ @export
2709
+ class OthersGenerateCase (ConcurrentCase ):
2710
+ def __str__ (self ) -> str :
2711
+ return "when others =>"
2712
+
2688
2713
2689
2714
@export
2690
2715
class SequentialCase (Case , SequentialStatements ):
@@ -2699,17 +2724,57 @@ def Choises(self) -> List[Choice]:
2699
2724
return self ._choices
2700
2725
2701
2726
2727
+ @export
2728
+ class IndexedGenerateChoice (ConcurrentChoice ):
2729
+ _expression : Expression
2730
+
2731
+ def __init__ (self , expression : Expression ):
2732
+ super ().__init__ ()
2733
+
2734
+ self ._expression = expression
2735
+
2736
+ @property
2737
+ def Expression (self ) -> Expression :
2738
+ return self ._expression
2739
+
2740
+ def __str__ (self ) -> str :
2741
+ return "{expression!s}" .format (expression = self ._expression )
2742
+
2743
+
2744
+ @export
2745
+ class RangedGenerateChoice (ConcurrentChoice ):
2746
+ _range : 'Range'
2747
+
2748
+ def __init__ (self , rng : 'Range' ):
2749
+ super ().__init__ ()
2750
+
2751
+ self ._range = rng
2752
+
2753
+ @property
2754
+ def Range (self ) -> 'Range' :
2755
+ return self ._range
2756
+
2757
+ def __str__ (self ) -> str :
2758
+ return "{range!s}" .format (range = self ._range )
2759
+
2760
+
2702
2761
@export
2703
2762
class CaseGenerateStatement (GenerateStatement ):
2704
- _selectExpression : Expression
2705
- _cases : List [ConcurrentCase ]
2763
+ _expression : Expression
2764
+ _cases : List [GenerateCase ]
2765
+
2766
+ def __init__ (self , label : str , expression : Expression , cases : Iterable [GenerateCase ]):
2767
+ super ().__init__ (label )
2768
+
2769
+ self ._expression = expression
2770
+ self ._cases = [] if cases is None else [c for c in cases ]
2706
2771
2707
2772
@property
2708
2773
def SelectExpression (self ) -> Expression :
2709
- return self ._selectExpression
2774
+ return self ._expression
2710
2775
2711
2776
@property
2712
- def Cases (self ) -> List [ConcurrentCase ]:
2777
+ def Cases (self ) -> List [GenerateCase ]:
2713
2778
return self ._cases
2714
2779
2715
2780
0 commit comments