Skip to content

Commit 160bafe

Browse files
authored
[minor] Add optional circuit to target syntax (#294)
Change the target syntax to include an optional circuit. Note: this change is strange becauase the spec was _always_ incomplete in how it discussed targets. It never discussed the circuit, though it showed them in examples. Change this so that the circuit name is optional. This creates a somewhat funky syntax where targets, which never care about the circuit due to the co-location of annotation JSON in the circuit, will all be prefixed with `~|`. This, while it would be nice to remove, provides a sigil that avoids conflicts with a legacy, undocumented target format used by Chisel originally called "named". This would use the following: ``` ebnf circuit , [ '.' , module , ['.' , component ] ] ``` I originally wanted to dorp the `~|` and have all targets start with the module. However, this would create an ambiguity with a named circuit. E.g., a bare `Foo` could be "circuit Foo" or "module Foo". I am working to burn this down in Chisel and, after recent changes, Chisel will no longer emit this. However, I'd like to let that cook for a while. Hence, this is the new syntax. Conveniently, CIRCT will already parse this due to a pleasntly permissive (bugby) target parser. Signed-off-by: Schuyler Eldridge <[email protected]>
1 parent 7c92e63 commit 160bafe

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

revision-history.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ revisionHistory:
55
# additions to the specification should append entries here.
66
thisVersion:
77
spec:
8+
- Add optional circuit to target syntax.
89
abi:
910
# Information about the old versions. This should be static.
1011
oldVersions:

spec.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -3439,7 +3439,7 @@ A circuit is described, stored, and optimized in a folded representation.
34393439
For example, there may be multiple instances of a module which will eventually become multiple physical copies of that module on the die.
34403440

34413441
Targets are a mechanism to identify specific hardware in specific instances of modules in a FIRRTL circuit.
3442-
A target consists of a root module, an optional instance hierarchy, and an optional reference.
3442+
A target consists of an optional circuit, a mandatory root module, an optional instance hierarchy, and an optional reference.
34433443
A target can only identify hardware with a name, e.g., a module, instance, register, wire, or node.
34443444
References may further refer to specific fields or subindices in aggregates.
34453445
A target with no instance hierarchy is local.
@@ -3448,7 +3448,7 @@ A target with an instance hierarchy is non-local.
34483448
Targets use a shorthand syntax of the form:
34493449

34503450
``` ebnf
3451-
target = module , [ { “/” (instance) “:” (module) } , [ “>” , ref ] ]
3451+
target = "~" , [ circuit ] , "|" , module , [ { “/” (instance) “:” (module) } , [ “>” , ref ] ]
34523452
```
34533453

34543454
A reference is a name inside a module and one or more qualifying tokens that encode subfields (of a bundle) or subindices (of a vector):
@@ -3490,11 +3490,11 @@ Some examples include:
34903490

34913491
| Target | Description |
34923492
|-------------------------|-----------------------------------------------|
3493-
| `Foo` | refers to module `Foo`{.firrtl} (or the only instance of module `Foo`{.firrtl}) |
3494-
| `Bar` | refers to module `Bar`{.firrtl} (or both instances of module `Bar`{.firrtl}) |
3495-
| `Foo/a:Bar` | refers just to one instance of module `Bar`{.firrtl} |
3496-
| `Foo/b:Bar/c:Baz` | refers to one instance of module `Baz`{.firrtl} |
3497-
| `Bar/d:Baz` | refers to two instances of module `Baz`{.firrtl} |
3493+
| `~|Foo` | refers to module `Foo`{.firrtl} (or the only instance of module `Foo`{.firrtl}) |
3494+
| `~|Bar` | refers to module `Bar`{.firrtl} (or both instances of module `Bar`{.firrtl}) |
3495+
| `~|Foo/a:Bar` | refers just to one instance of module `Bar`{.firrtl} |
3496+
| `~|Foo/b:Bar/c:Baz` | refers to one instance of module `Baz`{.firrtl} |
3497+
| `~|Bar/d:Baz` | refers to two instances of module `Baz`{.firrtl} |
34983498

34993499
If a target does not contain an instance path, it is a *local* target.
35003500
A local target points to all instances of a module.
@@ -3511,11 +3511,11 @@ The following shows a valid annotation file containing two annotations:
35113511
[
35123512
{
35133513
"class":"hello",
3514-
"target":"~Foo|Bar"
3514+
"target":"~|Bar"
35153515
},
35163516
{
35173517
"class":"world",
3518-
"target":"~Foo|Baz"
3518+
"target":"~|Baz"
35193519
}
35203520
]
35213521
```
@@ -3529,11 +3529,11 @@ FIRRTL version 4.0.0
35293529
circuit Foo: %[[
35303530
{
35313531
"class":"hello",
3532-
"target":"~Foo|Bar"
3532+
"target":"~|Bar"
35333533
},
35343534
{
35353535
"class":"world",
3536-
"target":"~Foo|Baz"
3536+
"target":"~|Baz"
35373537
}
35383538
]]
35393539
module Baz :

0 commit comments

Comments
 (0)