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

[minor] Add ABI to public module, extmodule #202

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions abi.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ This is done to avoid name collisions with the private modules produced by other

There are two supported port lowering ABIs.
These ABIs are applicable to public modules or external modules only.
These ABIs can be specified on each public module or external module using the following syntax:

``` {.firrtl .notest}
FIRRTL version 4.0.0
circuit Foo :
;; snippetbegin
public module<v1> Foo:
extmodule<v2> Bar:
;; snippetend
```

*Port Lowering ABIv1 is the default lowering for public modules if no port lowering is specified.*

#### Port Lowering ABIv1

Expand Down Expand Up @@ -117,6 +129,8 @@ This ABI does not specify whether the original aggregate referent is scalarized

All other port types shall lower according ot the type lowering in section ["On Types"](@sec:On-Types).

Port lowering ABIv1 uses the identifier `v1` when explicitly specified on a public module or external module.

#### Port Lowering ABIv2

Ports are lowered per the v1 ABI above, except for aggregate types.
Expand All @@ -129,6 +143,8 @@ Passive bundles shall be lowered to Verilog packed structs.

Reference types in ports shall be logically split out from aggregates and named as though "Aggregate Type Lowering" was used.

Port lowering ABIv2 uses the identifier `v2` when explicitly specified on a public module or external module.

## On Layers

The lowering convention of a declared layer specifies how a layer and all its associated layer blocks will be lowered.
Expand Down
3 changes: 3 additions & 0 deletions revision-history.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ revisionHistory:
- Restore id and info in printf grammar, add to verif commands.
- Add intrinsic expressions and statements.
- Remove intrinsic modules.
- Add ABI to public module and external module.
abi:
- Add ABI for public modules and filelist output.
- Changed ABI for group and ref generated files.
These now use the public module and not the circuit.
- Use EBNF to describe probe port macros and filename.
- Correct mistakes in code examples.
- Clarify that ABI v1 is the default ABI if unspecified on a public module
or external module.
# Information about the old versions. This should be static.
oldVersions:
- version: 3.2.0
Expand Down
35 changes: 33 additions & 2 deletions spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ A public module has a number of restrictions:
3. A `RWProbe`{.firrtl} may not be used to access a public module's ports.
4. A public module may be instantiated by other modules within a circuit, but the behavior of the module must not be affected by these instantiations.

A public module may specify which ABI a compiler must use for a specific public module.
This can be specified with the syntax below:

``` {.firrtl .notest}
FIRRTL version 4.0.0
circuit Foo:
;; snippetbegin
public module<v1> Foo:
;; snippetend
```

If the ABI is unspecified, the ABI for that public module uses the default ABI version as defined in the FIRRTL ABI Specification.

For more information on the lowering of public modules, see the FIRRTL ABI Specification.

### Private Modules
Expand Down Expand Up @@ -225,6 +238,21 @@ Foo #(
endmodule
```

Externally defined modules may specify an explicit lowering ABI using the same syntax as public modules:

``` {.firrtl .notest}
FIRRTL version 4.0.0
circuit Foo:
public module Foo:
;; snippetbegin
extmodule<v2> Bar:
;; snippetend
```

If the ABI is unspecified, the ABI for that public module uses the default ABI version as defined in the FIRRTL ABI Specification.

For more information on the lowering of public modules, see the FIRRTL ABI Specification.

## Layers

Layers are collections of functionality which will not be present in all executions of a circuit.
Expand Down Expand Up @@ -4169,15 +4197,18 @@ decl =
| decl_layer
| decl_type_alias ;

abi =
"<" , id , ">" ;

decl_module =
[ "public" ], "module" , id , { enablelayer } , ":" , [ info ] ,
[ "public" ], "module" , [ abi ] , id , { enablelayer } , ":" , [ info ] ,
newline , indent ,
{ port , newline } ,
{ statement , newline } ,
dedent ;

decl_extmodule =
"extmodule" , id , ":" , [ info ] , newline , indent ,
"extmodule" , [ abi ] , id , ":" , [ info ] , newline , indent ,
{ port , newline } ,
[ "defname" , "=" , id , newline ] ,
{ "parameter" , id , "=" , type_param , newline } ,
Expand Down
Loading