Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed flow and replaced with source/sink and relative alignment #139

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

azidar
Copy link
Collaborator

@azidar azidar commented Nov 3, 2023

This PR is my first attempt to remove the concept of "flow" from the FIRRTL spec. Instead, I've replaced it with source/sink expressions and relative alignment.

Note that this is to clarify the underlying concepts which can be used to reason about FIRRTL semantics, but the actual semantics should remain unchanged.

Feedback welcome.

Motivation

"Flow" as a concept to describe FIRRTL connection semantics has (in my opinion) always been a bit lacking in clarity. I would often get confused myself about how it actually worked, even though I first proposed the idea..

As I implemented the connectable operators in Chisel, I was able to revisit this concept and made some headway in my own understanding of how to describe connection semantics. As a result, I've been wanted to remove "flow" entirely from the FIRRTL spec and introduce a new concept of "relative alignment" and "source/sink" expressions (or "lref"s, I'm totally open to using more standardized terms).

@azidar azidar marked this pull request as draft November 3, 2023 18:15
@mmaloney-sf
Copy link
Collaborator

Cool. Let me take some time to look this over.

As an initial thought: You're using the term "subcomponent". Could we wait until we have the term subcomponent formally defined before merging this in?

@sequencer
Copy link
Member

sequencer commented Nov 4, 2023 via email

Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High level:

  1. Flipped/Aligned matters narrowly for connection semantics. Can these changes be sunk into the Connection Algorithm section and then used to rewrite that section? The motivation for this is that Flipped/Aligned are concepts which are only relevant to dealing with connects. We can keep the spec tighter by only introducing these concepts there.
  2. Can the discussion of relative alignment be simplified to only discuss parent/child alignment once this is sunk? My reasoning here is that relative alignment of siblings I don't think is used and it would be terser to not mention it.

Pulling on (2), I think the essence of the concept is as follows:

A connection sets two things: (a) a base alignment of "aligned" and (b) a base component with a base type specified by the type of either the source or sink expression (choice of source or sink doesn't matter as the types must be equivalent). All leaf sub-components of the source and sink are then connected. Leaf sub-components are connected source-to-sink if the relative alignment of the leaf sub-component and the base component/type are aligned. Leaf sub-components are connected sink-to-source if the relative alignment of the leaf sub-component and base component/type are flipped.

When described as such the notion of sibling alignment doesn't arise.

WDYT?

spec.md Outdated Show resolved Hide resolved
spec.md Outdated
Comment on lines 2921 to 2924
With the following exceptions, all other hardware components/subcomponents can be referenced with a sink expression:
- input ports (or subcomponents which are input ports)
- data field of memory read ports
- rdata field of memory read-write ports
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, no primitive operations may be used as sink expressions. Given @mmaloney-sf's new grammar, it should be safe to say that only references are legal sink expressions. Then introduce the restrictions on what references are not legal as sinks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, I'll revisit this when I bump.

azidar and others added 2 commits November 6, 2023 09:22
Clarify working on source expressions

Co-authored-by: Schuyler Eldridge <[email protected]>
Comment on lines +672 to +673
- `p` is aligned w.r.t `p.alignedChild`
- `p` is flipped w.r.t `p.flippedChild`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is sort of weirdly written. I know it is a symmetrical relationship, but wouldn't it be more intuitive to write it as

p.aligned child is aligned w.r.t. p

Every sink-flow probe must be the target of exactly one of these statements.
Every sink probe expression must be the target of exactly one of these statements.

The define statement takes a sink static reference target and sets it to the specified reference, which must either be a compatible probe expression or static reference source.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The define statement takes a sink static reference target and sets it to the specified reference, which must either be a compatible probe expression or static reference source.
The `define`{.firrtl} statement takes a sink static reference target and sets it to the specified reference, which must either be a compatible probe expression or static reference source.

The flow of all other expressions are source.
- input ports (or subcomponents which are input ports)
- data field of memory read ports
- rdata field of memory read-write ports
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we use the nomenclature "ports" (as seen from within a module) and "pins" (as seen from outside a module) shouldn't an output pin not be allowed to be referenced with a sink expression?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants