Skip to content

How "fsm" should work #6

@tcr

Description

@tcr

The current "sequence" blocks are designed to convert sequential code into a state machine. This makes state machines easy to write, but hard to leverage their full expressive power.

A complementary "fsm" block may make it easy to author states:

fsm my_state {
    IDLE => {
        led <= 0;
        if start_condition {
            my_state <= ACTIVE;
        }
    }
    ACTIVE => {
        led <= 1;
        if some_condition {
            my_state <= IDLE; // maybe "next IDLE;" or "fsm <= IDLE;" for anonymous
        }
    }
}

Some questions:

  1. Can we elide my_state in most cases?
  2. Can we reference my_state outside of the fsm? Can we change (or check) its value from other blocks?
  3. Is an explicit my_state <= {value} allowed inside the fsm?
  4. How do you declare the initial state; is it just the first state?
  5. How does scoping of states work inside of fsm?
  6. Can we nest fsms?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions