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

[major] Layer-associated probe semantics and ABI #160

Merged
merged 4 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/firrtl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<item>intrinsic</item>
<item>propassign</item>
<item>public</item>
<item>enablelayer</item>
</list>
<list name="types">
<item>UInt</item>
Expand Down
1 change: 1 addition & 0 deletions revision-history.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ revisionHistory:
- Change the minimum width of the result of "Shift Right" on UInt to 0-bit.
- Allow assert and assume statements to have a format string
- Add Property primitive operations, starting with integer addition
- Define/clarify layer-colored probe semantics.
abi:
- Add ABI for public modules and filelist output.
- Changed ABI for group and ref generated files.
Expand Down
57 changes: 31 additions & 26 deletions spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ The types of intrinsic module parameters may only be literal integers or string
## Layers

Layers are collections of functionality which will not be present in all executions of a circuit.
When a layer is enabled, the FIRRTL circuit behaves *as-if* all the optional functionality of that layer was executed.
Layers are intended to be used to keep verification, debugging, or other collateral, not relevant to the operation of the circuit, in a separate area.
Each layer can then be optionally included in the resulting design.

Expand Down Expand Up @@ -260,6 +261,26 @@ circuit Foo :
Functionality enabled by a layer is put in one or more layer blocks inside modules.
For more information on layer blocks see [@sec:layer-blocks].

Probe types may be colored with a layer.
Layer coloring indicates which layers must be enabled for a probe to be used.
For more information on layer-colored probes see [@sec:probe-types] and [@sec:layer-coloring].

### Modules with Enabled Layers

Modules may be declared with enabled layers.
A module with enabled layers colors the body of the module with the color of all enabled layers.
This affects the legality of operations which use probes.
See [@sec:layer-coloring] for more information on layer coloring.

To declare a module with layers enabled, use the `enablelayer`{.firrtl} keyword.
The circuit below shows a module with one layer enabled:

``` firrtl
circuit Foo :
layer A, bind :
module Foo enablelayer A :
```

# Circuit Components

Circuit components are the named parts of a module corresponding to hardware.
Expand Down Expand Up @@ -687,8 +708,9 @@ Probe<UInt<8>>
RWProbe<UInt<8>>
```

`Probe`{.firrtl} and `RWProbe`{.firrtl} types may be associated with a layer (see [@sec:layers]).
When associated with a layer, the reference type may only be driven from layer blocks associated with the same layer.
`Probe`{.firrtl} and `RWProbe`{.firrtl} types may be *colored* with a layer (see [@sec:layers]).
When *layer-colored*, there are restrictions placed on the use of the probe.
See [@sec:layer-coloring] for a description of these restrictions.

For example:

Expand Down Expand Up @@ -2027,19 +2049,16 @@ Since they are intended for verification, ports with a probe type do not necessa
## Types

There are two probe types, `Probe<T>`{.firrtl} is a read-only variant and `RWProbe<T>`{.firrtl} is a read-write variant.
(See [@sec:probe-types]).
Probes may be layer-colored.
See [@sec:probe-types] for more information.

Examples:
## Layer Coloring

``` firrtl
Probe<UInt<8>>
RWProbe<UInt<8>>
```

A `RWProbe<T>`{.firrtl} will be implicitly cast to a `Probe<T>`{.firrtl} whenever an expression of type `RWProbe<T>`{.firrtl} is assigned to a port with type `Probe<T>`{.firrtl}.
Probe types may be colored with a layer (see [@sec:layers]).
A layer-colored probe type places restrictions on the operations which use it.

While `RWProbe<T>`{.firrtl} is strictly more powerful, `Probe<T>`{.firrtl} allows for more aggressive optimization.
You should consider using `Probe`{.firrtl} whenever you know you don't need to ability to force (see [@sec:forcing]).
An operation may only "read" from a probe whose layer color is enabled when the operation is enabled.
An operation that "writes" to a probe must be in a region whose layer color is enabled when the probe's layer color is enabled.
Comment on lines -2041 to +2061
Copy link
Member Author

Choose a reason for hiding this comment

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

These are the two most important sentences in this PR.

Give these a lot of scrutiny @mmaloney-sf.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a meaningful difference between a layer and a layer color?

My impression is the term "color" is just a colorful way to speak of the association between a probe and the layer it works against.

Both of these sentences also confuse me a bit, trying to interpret them. Trying to dig into why:

  • What does it mean for "the operation [to be] enabled"?
  • The quotes around "read" and "write" make me wonder if these are formal statements or if they should be taken intuitively.
  • You use the word "region" -- Should this be "layer" instead? Eg, "must be in a layer whose color is enabled".
  • The phrase "whose color is enabled" is also weird. Intuitively, colors can be mixed, but not enabled or disabled.
  • I feel like there's some subtle compound condition in the "write" restriction.


## The `probe`{.firrtl} and `rwprobe`{.firrtl} Expressions

Expand Down Expand Up @@ -2254,20 +2273,6 @@ module DUT :
connect y, p
```

## Probes and Layers

`Probe`{.firrtl} and `RWProbe`{.firrtl} types may be associated with a layer (see [@sec:layers]).
When associated with a layer, the probe type may only be driven from that layer.

For example:

``` firrtl
Probe<UInt<8>, A.B> ; A.B is a layer
RWProbe<UInt<8>, A.B>
```

For details on how probes are lowered, see the FIRRTL ABI Specification.

## External Modules

Ports with probe types may be specified on the interface of an external module (see [@sec:externally-defined-modules]).
Expand Down
Loading