Esempio n. 1
0
    def __init__(self, switchOn):
        switchOn = _intfToSig(switchOn)
        if not isinstance(switchOn, RtlSignalBase):
            raise HwtSyntaxError("Select is not signal, it is not certain"
                                 " if this an error or desire")
        if arr_any(discoverEventDependency(switchOn), lambda x: True):
            raise HwtSyntaxError("Can not switch on result of event operator")

        super(Switch, self).__init__(switchOn, [])
        switchOn.ctx.statements.add(self)
Esempio n. 2
0
    def __init__(self, cond, *statements):
        """
        :param cond: condition in if
        :param statements: list of statements which should be active if condition is met
        """
        self.cond = _intfToSig(cond)
        assert isinstance(self.cond, RtlSignalBase)

        self.nowIsEventDependent = bool(list(discoverEventDependency(cond)))
        self.elifConds = []

        c = AndReducedContainer()
        c.add(self.cond)
        self._appendStatements(c, statements)
Esempio n. 3
0
    def Elif(self, cond, *statements):
        cond = _intfToSig(cond)
        self.nowIsEventDependent = self.nowIsEventDependent or\
                                   arr_any(discoverEventDependency(cond), lambda x: True)
        thisCond = AndReducedContainer()
        thisCond.add(cond)
        for c in reversed(self.elifConds):
            thisCond.add(~c)
        thisCond.add(~self.cond)

        self._appendStatements(thisCond, statements)

        self.elifConds.append(cond)

        return self
Esempio n. 4
0
    def Elif(self, cond, *statements):
        assert self.parentStm is None
        self.rank += 1
        cond_sig = _intfToSig(cond)

        self._now_is_event_dependent = arr_any(
            discoverEventDependency(cond_sig), lambda x: True)

        self._inputs.append(cond_sig)
        cond_sig.endpoints.append(self)

        case = []
        self.elIfs.append((cond_sig, case))
        self._register_stements(statements, case)

        return self
Esempio n. 5
0
File: code.py Progetto: arnabd88/hwt
    def __init__(self, cond, *statements):
        """
        :param cond: condition in if statement
        :param statements: list of statements which should be active
            if condition is met
        """
        cond_sig = _intfToSig(cond)
        if not isinstance(cond_sig, RtlSignalBase):
            raise IntfLvlConfErr("Condition is not signal, it is not certain"
                                 " if this is an error or desire ", cond_sig)

        super(If, self).__init__(cond_sig)
        self.rank = 1
        self._inputs.append(cond_sig)
        cond_sig.endpoints.append(self)

        ev_dep = arr_any(discoverEventDependency(cond_sig), lambda x: True)
        self._event_dependent_from_branch = 0 if ev_dep else None

        self._register_stements(statements, self.ifTrue)
        self._get_rtl_context().statements.add(self)