Skip to content

Feature Request: Assembling "external" functions #159

@rdaly525

Description

@rdaly525
def test_extern_function():

    class Op(Enum):
        And=1
        Or=2

    @family_closure
    def PE_fc(family):

        Bit = family.Bit

        @family.assemble_function(locals(), globals())
        def fun(op: Op, in0: Bit, in1: Bit) -> Bit:
            if op == Op.And:
                return in0 & in1
            else: #op == Op.Or
                return in0 | in1

        @family.assemble(locals(), globals())
        class PE_Extern(Peak):
            def __call__(self, op: Op, in0: Bit, in1: Bit) -> Bit:
                return fun(op, in0, in1)

        return PE_Extern

This is a proposal for a way to assemble user defined helper functions. Allows users to write more modular code and is conceptually similar to using magma's circuit.combinational on arbitrary functions. Initial implementation in branch 'extern'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions