예제 #1
0
 def _discover_sensitivity_sig(self, signal: RtlSignalBase, seen: set,
                               ctx: SensitivityCtx):
     casualSensitivity = set()
     signal._walk_sensitivity(casualSensitivity, seen, ctx)
     if not ctx.contains_ev_dependency:
         # if event dependent sensitivity found do not add other sensitivity
         ctx.extend(casualSensitivity)
예제 #2
0
파일: operator.py 프로젝트: nilintxc/hwt
    def _walk_sensitivity(self, casualSensitivity: set, seen: set,
                          ctx: SensitivityCtx):
        seen.add(self)

        if isEventDependentOp(self.operator):
            if ctx.contains_ev_dependency:
                assert self in ctx, "has to have only one clock one clock"
            ctx.contains_ev_dependency = True
            ctx.append(self)
        else:
            # walk source of signal
            for operand in self.operands:
                if operand not in seen:
                    operand._walk_sensitivity(casualSensitivity, seen, ctx)
예제 #3
0
    def _discover_sensitivity_seq(self,
                                  signals: List[RtlSignalBase],
                                  seen: set, ctx: SensitivityCtx)\
            -> None:
        """
        Discover sensitivity for list of signals

        """
        casualSensitivity = set()
        for s in signals:
            s._walk_sensitivity(casualSensitivity, seen, ctx)
            if ctx.contains_ev_dependency:
                break

        # if event dependent sensitivity found do not add other sensitivity
        if not ctx.contains_ev_dependency:
            ctx.extend(casualSensitivity)
예제 #4
0
    def _discover_sensitivity(self, seen: set) -> None:
        assert self._sensitivity is None
        ctx = self._sensitivity = SensitivityCtx()

        casualSensitivity = set()
        for inp in self._inputs:
            if inp not in seen:
                seen.add(inp)
                inp._walk_sensitivity(casualSensitivity, seen, ctx)
        ctx.extend(casualSensitivity)
예제 #5
0
    def _discover_sensitivity(self, seen) -> None:
        """
        Doc on parent class :meth:`HdlStatement._discover_sensitivity`
        """
        assert self._sensitivity is None, self
        ctx = self._sensitivity = SensitivityCtx()

        casual_sensitivity = set()
        self.switchOn._walk_sensitivity(casual_sensitivity, seen, ctx)
        if ctx.contains_ev_dependency:
            raise HwtSyntaxError("Can not switch on event operator result",
                                 self.switchOn)
        ctx.extend(casual_sensitivity)

        for stm in self._iter_stms():
            stm._discover_sensitivity(seen)
            ctx.extend(stm._sensitivity)
예제 #6
0
파일: ifContainter.py 프로젝트: Ben-401/hwt
    def _discover_sensitivity(self, seen: set) -> None:
        """
        Doc on parent class :meth:`HdlStatement._discover_sensitivity`
        """
        assert self._sensitivity is None, self
        ctx = self._sensitivity = SensitivityCtx()

        self._discover_sensitivity_sig(self.cond, seen, ctx)
        if ctx.contains_ev_dependency:
            return

        for stm in self.ifTrue:
            stm._discover_sensitivity(seen)
            ctx.extend(stm._sensitivity)

        # elifs
        for cond, stms in self.elIfs:
            if ctx.contains_ev_dependency:
                break

            self._discover_sensitivity_sig(cond, seen, ctx)
            if ctx.contains_ev_dependency:
                break

            for stm in stms:
                if ctx.contains_ev_dependency:
                    break

                stm._discover_sensitivity(seen)
                ctx.extend(stm._sensitivity)

        if not ctx.contains_ev_dependency and self.ifFalse:
            # else
            for stm in self.ifFalse:
                stm._discover_sensitivity(seen)
                ctx.extend(stm._sensitivity)

        else:
            assert not self.ifFalse, "can not negate event"
예제 #7
0
파일: __init__.py 프로젝트: saislam/hwt
def collect_comb_drivers(path_prefix: Tuple[Unit, ...], stm: iHdlStatement,
                         comb_connection_matrix: dict, comb_inputs: tuple):
    if isinstance(stm, Assignment):
        ctx = SensitivityCtx()
        seen = set()
        # merge condition inputs to current_comb_inputs
        current_comb_inputs = set(comb_inputs)
        for inp in stm._inputs:
            collect_comb_inputs(ctx, seen, inp, current_comb_inputs)

        for o in stm._outputs:
            o_key = path_prefix / o
            for i in current_comb_inputs:
                con = comb_connection_matrix.setdefault(path_prefix / i, set())
                con.add(o_key)

    elif isinstance(stm, IfContainer):
        current_comb_inputs = set(comb_inputs)  # intended copy
        elifs = ((stm.cond, stm.ifTrue), *stm.elIfs)
        ev_dep_branch = stm._event_dependent_from_branch
        ctx = SensitivityCtx()
        seen = set()
        found_event_dep = False
        for branch_i, (cond, stms) in enumerate(elifs):
            # [TODO] check if this works for clock gating
            if ev_dep_branch is not None and ev_dep_branch == branch_i:
                found_event_dep = True
                break

            collect_comb_inputs(ctx, seen, cond, current_comb_inputs)

            for sub_stm in stms:
                collect_comb_drivers(path_prefix, sub_stm,
                                     comb_connection_matrix,
                                     current_comb_inputs)

        if not found_event_dep and stm.ifFalse is not None:
            for sub_stm in stms:
                collect_comb_drivers(path_prefix, sub_stm,
                                     comb_connection_matrix,
                                     current_comb_inputs)

    elif isinstance(stm, HdlStatementBlock):
        for sub_stm in stm.statements:
            collect_comb_drivers(path_prefix, sub_stm, comb_connection_matrix,
                                 comb_inputs)

    elif isinstance(stm, SwitchContainer):
        current_comb_inputs = set(comb_inputs)
        ctx = SensitivityCtx()
        seen = set()
        collect_comb_inputs(ctx, seen, stm.switchOn, current_comb_inputs)
        cases = stm.cases
        if stm.default is not None:
            cases = chain(cases, ((None, stm.default), ))

        for (_, case_stms) in cases:
            for sub_stm in case_stms:
                collect_comb_drivers(path_prefix, sub_stm,
                                     comb_connection_matrix,
                                     current_comb_inputs)

    else:
        raise NotImplementedError(stm)