Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(3)  |  Call(2)  |  Derive(0)  |  Import(1)
Decrementer module.

width -- bitwidth of input and output
speed -- SLOW, MEDIUM, or FAST performance
A -- input
Z -- output
architecture -- BEHAVIOR or STRUCTURE architecture selection

        def Dec(width, speed, A, Z, architecture=BEHAVIOR):
    
    """ Decrementer module.

    width -- bitwidth of input and output
    speed -- SLOW, MEDIUM, or FAST performance
    A -- input
    Z -- output
    architecture -- BEHAVIOR or STRUCTURE architecture selection

    """

    @instance
    def Behavioral():
        while 1:
            yield A
            Z.next = A - 1

    def Structural():
        AI = Signal(intbv(0))
        PO = Signal(intbv(0))
        prefix = PrefixAnd(width, speed, AI, PO)
        @instance
        def logic():
            while 1:
                yield A, PO
                AI.next = ~A
                Z.next = A ^ concat(PO[width-1:], '1')
        return [prefix, logic]

    if architecture == BEHAVIOR:
        return Behavioral
    else:
        return Structural()
        


src/m/y/myhdl-0.8/example/arith_lib/test_Dec.py   myhdl(Download)
from arith_utils import BEHAVIOR, STRUCTURE
from arith_utils import SLOW, FAST
from Dec import Dec
 
import random
        ZB = Signal(intbv(0))
 
        beh = Dec(width, speed, A, ZB, architecture=BEHAVIOR)
        str = Dec(width, speed, A, ZS, architecture=STRUCTURE)