cjdrake / pyeda

Python EDA
BSD 2-Clause "Simplified" License
305 stars 55 forks source link

Design Hierarchy #103

Closed cjdrake closed 7 years ago

cjdrake commented 10 years ago

Currently, all Boolean variables are stored in the pyeda.boolalg.boolfunc.VARIABLES dict. The idea is to make interactive usage easy by globally returning the same variable instance given an identical name and index. For example: id(exprvar('x', 0)) == id(exprvar('x', 0)).

In order to support a modular design style, we need the ability to bind the dict of variable instances to a single module instance in a larger design.

First requirement is a Module base class. Define a new module by extending this class:

class Module:
    def __init__(self, name, **params):
        self.name = name
        self.params = params

class RippleCarryAdder(Module):
    def __init__(self, width=8):
        ...

    # TODO: define inputs, outputs, submodules
    # TODO: define elaborate protocol

To instantiate: rca = RippleCarryAdder('rca0', width=8). This performs elaboration without any additional steps.