Commit Graph

7419 Commits

Author SHA1 Message Date
John Demme 77ab38628c
[ESI] Start of system manifest: types (#6290)
An ESI system manifest is intended to describe the parts of a particular
accelerator which may be relevant to software.  It will eventually
replace the services metadata json.

This first PR only outputs types on cosim ports.
2023-10-17 13:27:45 -07:00
John Demme 285980c15d
[PyCDE] Support ESI bundles (#6288) 2023-10-17 13:27:12 -07:00
Morten Borup Petersen c26204ac84
[MSFT] Add multicycle path op (#6262)
Adds a new operation to the MSFT dialect which specifies a multicycle path constraint in between two symbols.

This implementation does not opt in to the whole dynamic instance hierarchy specification of MSFT; do we want to do that? Would have to require some thinking about what it means that a PD constraint refrences two dynamic instances, wherein `msft.instance.dynamic` currently expects all nested pd constraints to reference the parent instance exclusively.
To this, i don't think it will be needed in our immediate usecase, anyways (assuming we're going to use `hw.path.to_this` which itself will generate the `hw.hierpath` and _not_ use the dynamic instance hierarchy support in MSFT).

Also splits `DynInstDataOpInterface` into a two interfaces; one base interface (anything that pertains to dynamic instance data) and the `UnaryDynInstDataOpInterface` which refers to all data ops which access a single location - some additional boilerplate is introduced since the current implementation of OpInterface's doesn't seem to support inheriting interfaces implementing parent interfaces (everything is expected to be defined by the implementing op).

Exported TCL example:
```tcl
proc reg_0_multicycle_config { parent } {
  set_multicycle_path -hold 1 -setup 2 -from [get_registers {$parent|reg_0}] -to [get_registers {$parent|reg2}]
}
```
2023-10-17 09:46:25 +02:00
Andrew Lenharth b4a09b7476 [NFC] Add a comment on a test 2023-10-16 11:50:10 -05:00
Andrew Lenharth fa69518fd7 [NFC] Fix getReferencedModule and add test locking in correct symbol resolution behavior 2023-10-16 11:38:28 -05:00
Andrew Lenharth 475d4e9bc7
Fix performance regression in verifiers by using the required symbol table collection to resolve the module name. The symbol table collection is required for this function explicitly for this lookup, it just wasn't being used (#6293) 2023-10-16 10:57:47 -05:00
Andrew Lenharth 786a31d679 [NFC] LLVM bump 2023-10-16 10:07:04 -05:00
Andrew Lenharth 3734470f37 [NFC] preallocate vector in Instance getPorts 2023-10-15 23:19:17 -05:00
John Demme b5e633f1dd [ESI] Fix bug in lowering bundles
Mustn't insert things after the terminator!
2023-10-14 03:23:14 +00:00
John Demme 82504d0ffb [ESI][Python] Use ODS enum in Python bindings
This is safe since it's just an enum from a header. Better since it
avoids duplication.
2023-10-14 03:19:57 +00:00
Andrew Lenharth 12d168633c
[HW] round trip ModuleType non-ssa values (#6287)
Treat blockargs like other values and let the asm name hint interface compute names for them. If the port name is a legal ssa name, it will be used, otherwise the legalization will compute a new name based on the port name. This has stable round-tripping after the first round, which is consistent with other ops which provide ssa name hints.
2023-10-13 14:25:00 -07:00
Hideto Ueno e83993015c
[FIRRTL] [FIRRTLFolds] Remove RecursiveMemoryEffects and RecursivelySpeculatable from When op, add canonicalizers (#6236)
RecursiveMemoryEffects and RecursivelySpeculatable traits provides automatic derivation of side-effects of operations but these effects are computed by recursive IR walk. This is problematic for firrtl.when since when operations are often deeply nested, which prevents us from running canonicalizers before ExpandWhens. This PR just removes these traits and add canonicalizers for whens manually.
2023-10-13 18:29:32 +09:00
John Demme f9841b31e3 [PyCDE] Fix test
seq.compreg asm syntax change
2023-10-12 23:44:02 +00:00
Rachit Nigam 8765933dc7
Add emission for calyx std_signext (#6285)
* add emission for Calyx std_signext

* fix tests
2023-10-12 12:17:44 -04:00
Nandor Licker 3c42434a3e [NFC][GranCentral] Allow probe outputs from companions 2023-10-12 08:36:40 -07:00
Prithayan Barua cbe82b9674
[ExtractTestCode] Use non-empty unqiue port names (#6283)
Update ETC to add non-empty and unique port names.

---------

Co-authored-by: Nandor Licker <n@ndor.email>
2023-10-12 07:21:03 -07:00
Hideto Ueno c247ea94fe
[LowerToHW] Fix symbol creation for empty names (#6282)
firrtl.instance with lowerToBind is lowered into bound instance and symbols are created for the instances. There was a bug that symbols were generated by instance names, not by an appropriate helper so there could have been name collisions. This commit fixes the issue by using inner symbol generation helper.

This also fixes symbol creation for empty port names as well.
2023-10-12 19:27:21 +09:00
Hideto Ueno 74e9f45378
[FIRRTL] Add strip option to DropName (#6281)
This commit adds strip option to drop name pass. Even though there is none option but none option does keep existing names. strip explicitly strips all names to remove variable names form Chisel.
2023-10-12 19:26:20 +09:00
Daniel Resnick b895069d55
[NFC] LLVM Bump (#6280) 2023-10-11 14:26:22 -06:00
Hideto Ueno 080f275376
[Namespace] Return an empty string for empty string. (#6284)
Previously Namespace::newName could return empty string for empty string.
This is a problematic behaivor since primary use cases of Namespace is
symbol generation but empty string cannot be used a symbol.

For example HWExportModuleHierarchy crashed with an instance with an
empty name.

This commit fixes the issue by pre-registering empty string in a constructor of
Namespace.
2023-10-12 05:25:56 +09:00
Andrew Young 8e4992be35
[OM] Overhaul of path operations (#6253)
This PR does an overhaul of how path related operations work in the OM dialect.

When OM classes are created from FIRRTL, a base path is now fed through the
class hieararchy.  All paths to hardware objects are now created relative to
the base path.  The `path` op has been renamed to `path_create`, and now takes
a basepath SSA parameter, which means that it is impossible to create a path
which is not relative to some base.

A second set of operations to create "frozen paths" have been added.  In
FreezePaths, we lower all path operations to hard-coded strings, which allows
us to remove the hardware from the OM IR and still be valid.  These operations
have been changed to return `FrozenPathType`, which is to make sure that people
don't try to inter-mix the two kinds of path types.  The intention is that the
evaluator will only understand frozen paths.

The PathAttr in OM no longer represents the entire target path, but just the
list of instances which lead up to it.

This also adds an OM utility for parsing FIRRTL style target strings, which is
used in the `frozenpath_create` MLIR assembly format.  The existing APIs
contained in FIRRTL were not suitable since these new strings do not include
the circuit name, and we need some restrictions for parsing base paths, which
can not target components. The new parser is a bit more resilient to badly
formed path strings. In the future it may be possible to reunite these two
bodies of code.

The existing python support for paths had to be removed.
2023-10-11 12:33:10 -07:00
Hideto Ueno 0518211c34 [CI] Remove a backslash
This fixes a windows build failure
2023-10-11 07:26:37 -07:00
Hideto Ueno 6d37163e7c
[CI] Install LLVM utils (#6279)
The default `install` command doesn't install LLVM utils Filecheck/not/count. Downstream users of CIRCT might want to use FileCheck directly so this PR adds `-DLLVM_INSTALL_UTILS=On` to cmake options. It increase 1MB of release artifacts (85MB->86MB) so I believe that's ok.

Tested by https://github.com/llvm/circt/actions/runs/6483396914.
2023-10-11 23:17:54 +09:00
Hideto Ueno 694f03773c
[circt-opt] Export symbols for MLIR plugins (#6278)
This commit adds pupport for MLIR plugins for circt-opt
2023-10-11 20:47:26 +09:00
Nandor Licker dadf87b742 [NFC][firtool] Fix CAPI 2023-10-11 04:24:33 -07:00
Nandor Licker 4d87c19d4a
[FIRRTL][GrandCentral] Add a mode to drop companion modules (#6268)
Instead of the `--instantiate-companion-only` flag, Grand Central now takes a `--companion-mode` flag which specifies the handling of companion objects. The modes are:

* `bind`, the original behaviour
* `instantiate`, which creates explicit instances
* `drop` which removes companions and companion-only sub-hierarchies from the design
2023-10-10 22:32:08 +03:00
Prithayan Barua cbc8c39613
[OM] Add location info to EvaluatorValue (#6240)
Add the debug locations to the evaluator value, which will be used to generate info fields
 of the object model output json.
2023-10-10 10:06:38 -07:00
Nandor Licker 225e26e439
[Seq] Fix the canonicalization of seq registers with a clock type (#6274) 2023-10-10 19:45:04 +03:00
Morten Borup Petersen 0d7cd67f57
[PipelineToHW] Add optional power-on values to control registers (#6269)
Resulting generated .sv:
```mlir
hw.module @testPowerOn(in %arg0: i32, in %arg1: i32, in %go: i1, in %clk: !seq.clock, in %rst: i1, out out0: i32, out out1: i1) {
  %0:2 = pipeline.scheduled(%a0 : i32 = %arg0, %a1 : i32 = %arg1) clock(%clk) reset(%rst) go(%go) entryEn(%s0_enable) -> (out: i32){
    %1 = comb.sub %a0,%a1 : i32
    pipeline.stage ^bb1 regs(%1 : i32, %a0 : i32)
  ^bb1(%6: i32, %7: i32, %s1_enable : i1):  // pred: ^bb1
    %8 = comb.add %6, %7 : i32
    pipeline.return %8 : i32
  }
  hw.output %0#0, %0#1 : i32, i1
}
```
->
```sv
module testPowerOn(
  input  [31:0] arg0,
                arg1,
  input         go,
                clk,
                rst,
  output [31:0] out0,
  output        out1
);

  reg [31:0] p0_stage0_reg0;
  reg [31:0] p0_stage0_reg1;
  always_ff @(posedge clk) begin
    p0_stage0_reg0 <= arg0 - arg1;
    p0_stage0_reg1 <= arg0;
  end
  reg        p0_stage1_enable = 1'h0;
  always_ff @(posedge clk) begin
    if (rst)
      p0_stage1_enable <= 1'h0;
    else
      p0_stage1_enable <= go;
  end
  assign out0 = p0_stage0_reg0 + p0_stage0_reg1;
  assign out1 = p0_stage1_enable;
endmodule
```
2023-10-10 11:10:16 +02:00
Morten Borup Petersen c9aa79bd27
[Seq] Remove custom printer/parser for `seq.compreg(.ce)` ops (#6267)
Removed in favor of using a generated parser + a couple of custom directives to resolve the optional name and types of the implicit operands.
2023-10-09 19:53:54 +02:00
Hideto Ueno 2f4af25eac
[firtool] Add infra for pass plugins (#6254)
This PR ads MLIR pass plugin functionality to firtool pipeline to dynamically load pass plugins and execute passes. 
`*.so` file is load with`--load-pass-plugin` option. Currently we can insert passes to 4 places in the pipeline: (1) after FIRRTL parsing (2) before LowerToHW (3) after HW lowering (4) after SV lowering.
2023-10-10 00:06:47 +09:00
Nandor Licker aefe8280c3 [Seq][NFC] Remove Twine constructor 2023-10-09 06:37:17 -07:00
Nandor Licker a124061765 [Seq][NFC] Add a builder for seq.compreg using Twine 2023-10-09 06:34:11 -07:00
Nandor Licker 4607cb868a
[Seq][NFC] More flexible builders for compregs (#6270) 2023-10-09 16:33:45 +03:00
Morten Borup Petersen 2ec4cd0921
[Seq] Add optional power-on value to `compreg` ops (#6255)
In doing so, also opt to move to a keyword style assembly format, rather than a flat list of operands. This is needed to resolve the now three different, optional, operands that can occur in the assembly format (reset operands, clock-enable, and the power-on operand).
To avoid making things too complicated, a keyword is required for either group, e.g.
> `seq.compreg %in %clk reset %rst, %rstValue ce %ce powerOn %po`

+ some related cleanups in places where the default generated builder was being used (without good reason).
2023-10-09 11:11:15 +02:00
Andrew Lenharth a5de7a2bf5 [NFC] Don't compute portlist every name lookup 2023-10-06 17:03:21 -05:00
Andrew Lenharth b5a9b9d4d4 [NFC] don't recompute port list every name query 2023-10-06 16:48:00 -05:00
Will Dietz 15cc6fe9e1
[FIRRTL][NFC] Move FieldRef -> InnerSymTarget to utility. (#6265)
Keep FIRRTL-only for now due to dependence on dialect-specific
mechanism to get port number from block argument.
(HW has this but don't want FModuleLike dep in HW)
2023-10-06 14:24:04 -05:00
Will Dietz aeb6f0fe59
[FIRRTL][MergeConnections] Reject non-passive aggregates. (#6264)
Previously: #5780.

Fixes #6259.

(along with #5835 for the specific FIRRTL input)
2023-10-06 13:52:56 -05:00
Will Dietz 7165cd92ff
[FIRRTL][FIRParser] Prefer RWProbe op as much as possible. (#5835)
Keep forceable for now-- it's needed for uninferred resets presently,
and has slightly better (if not ideal) behavior when attempting
to rwprobe a non-passive aggregate.

Accordingly the spec test `force_nonpassive.fir` now fails.

We can't rwprobe() an aggregate that /must/ be lowered.  Forceable
tries to allow this, but when using symbols this is just rejected.

Force of non-passive will soon be unsupported and spec updated to make illegal.
2023-10-06 12:52:59 -05:00
Will Dietz 8fcb732efa [FIRRTL] Add OpenAgg support to getFieldName, fix diagnostic.
These disappear early but some diagnostics, such as flow checking,
use this method so implement it.

This shouldn't be "unreachable", but that's a different fix.
2023-10-05 20:27:45 -05:00
Fabian Schuiki 71a78d6128
[SV] Mark sv.xmr.ref op as pure (#6260)
Having an `sv.xmr.ref` op inside a procedural block such as
`sv.alwayscomb` triggers an assertion in `PrepareForEmission`. The pass
would identify the ref op as having side-effects and then go ahead and
try to pull it outside the procedural block. Doing so would create a
`sv.reg` op with multiple nested inout types, which breaks.

Fix the issue by marking the `sv.xmr.ref` op as pure. Taking a reference
to something does not have a side-effect. It's accessing what's behind
the reference that has side-effects.
2023-10-05 14:55:21 -07:00
Hideto Ueno 5508c1e42a
[OM] Evaluator: Support graph regions (#6249)
This commit adds support for graph regions for evaluator.

`ReferenceValue`, a new subclass of `EvaluatorValue`, is added to behave as pointers. `ReferenceValue` can be used as alias to different values and is created for `class.object.field` operation because `class.object.field` can access fields across class hierarchies and the fields might not be initilized yet. `RefenceValue` is not exposed to outside of evaluator implemenation. `EvaluatorValue::finalize` shrinks intermidiate `RefenceValue` in the evaluator value.

Evaluation algorithm is changed to worklist-based iteration. `instantiae` method first traverses the whole IR including sub-class, and create partially evaluaed values for all values and add these values to the worklist. After that we evaluate values until there is no partially evaluaed value.

Fix https://github.com/llvm/circt/issues/5834
2023-10-06 03:24:38 +09:00
Andrew Young 307fb5874b
[OM] Add more path types (#6250)
This adds more path types which will be used for greater safety in OMIR. This
change splits regular paths in to BasePathType and PathType, where the
BasePathType is only capable of representing paths through the instance
hierarchy, without being able to target hardware components such as wires and
registers. In the future, all paths can only be created relative to some base
path. This also adds a FrozenBasePathType and FrozenPathType, which will be
used to represent lowered paths which no longer depend on the hardware hiearchy
being present in the IR.
2023-10-04 17:49:09 -07:00
Will Dietz 885499f424 [Debug] Fix HGLDD test on Windows. 2023-10-04 17:59:11 -05:00
John Demme d85dcf02b8
[PyCDE] Fixing tests (#6252)
Mostly broken due to hw.module asm format change. Also, the cocotb tests
have been broken for some time.
2023-10-04 14:30:24 -07:00
Fabian Schuiki 39bd9f535f
[Debug] Fix windows path separator in HGLDD test 2023-10-04 14:10:20 -07:00
Fabian Schuiki 5cb43e185d
[Debug] Add basic DebugInfo analysis and emission (#6148)
CIRCT will eventually want to be able to emit debugging information
alongside its Verilog and other outputs. This commit adds a basic
`DebugInfo` analysis that traverses the IR, collects information in
whichever format we chose to annotate it in the IR, and forms a separate
graph of DI nodes that can be inspected easily.

The rationale behind a separate DI graph is to decouple debug info
formats from in-IR storage. For example, we may want to emit the DI into
a JSON file (which is what the experimental HGLDD does), or dump the DI
in a human-readable form for testing. In the IR, it is not yet clear if
we respresent DI as separate ops, attributes on existing ops, and how
attributes express the DI graph. For example, do modules list their
variables, which makes removal hard, or do variables point to their
parent modules? The `DebugInfo` analysis abstracts over this IR encoding
matter and presents the DI in a format that is easily emitted. (Modules
list their contained variables.)

This commit also adds a `DebugInfo` MLIR translation library to CIRCT.
It implements DI emission as straightforward translations, allowing for
DI to be emitted as:

- `circt-translate --dump-di` for human-readable testing; and
- `circt-translate --emit-hgldd` and
  `circt-translate --emit-split-hgldd` for an experimental JSON format

When compiling a design with firtool, the `--emit-hgldd` option can be
used to generate `*.dd` companion files alongside its SV output. This
relies on Verilog emission locations to be annotated in the IR, which
is done separately in PR #6092.
2023-10-04 12:51:05 -07:00
Andrew Lenharth 0eaf230847 [NFC] Good by HWTestModule. You were a good demonstration, but now the real modules can do all the things 2023-10-04 14:48:52 -05:00
Mike Urbach 0ea677dc15
[OM] Update FreezePaths to root paths at the nearest public module. (#6244)
The current logic doesn't support freezing paths with multiple public
modules. In the current setup, multiple public modules are allowed, so
this updates the instance graph traversal to allow rooting paths at
the nearest public module.
2023-10-04 13:05:52 -06:00