Skip to content

When method chaining syntax for updating registers #97

Description

@leonardt

Similar to chisel's when construct, we can add a method chaining implementation.

reg = Register()
reg.when(io.RESET, init)
      .when(io.LOAD, io.I)
      .else(4)

If no else case is provided, it could by default wire up the output of the register to the input (so the value doesn't change).

The ordering of the when statements indicate a precedence, so if io.RESET is true, the new value will be init regardless of the value of io.LOAD. This should match the semantics of a simple mux chain implementation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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