Commit Graph

8761 Commits

Author SHA1 Message Date
cepheus c0a77be1f4
[MooreToCore] Support to lower unpackedStructType (#7565)
This is a simple way to map unpackedStructType (Moore type) to structType in hw dialect directly.
2024-09-04 11:16:16 +08:00
John Demme 7c9f8fbb71 [ESI][Runtime] Fixing Windows build and logging bug
- Fixed MSVC build warning.
- Fixed MSVC build errors.
- Respect minLevel.
2024-09-03 23:24:34 +00:00
John Demme 063f7449aa
[ESI][Runtime] Logging API (#7569)
The ESI logging API is intended to be agnostic of the application's logging framework. In other words, it can be adapted to the application's logging method with ease -- users must only extend one class. It also comes with a simple text logger.

It is also designed to enable debug logging in Release builds with (very) minimal performance overhead if the user does not set the log level to debug.

This PR introduces the API, but doesn't use it much. More plumbing will be required to actually use it. In the interest of keeping this PR small, this is left for future work.
2024-09-03 13:53:10 -07:00
John Demme b76cc0e54f
[ESI] Manifest: change the schema to be more rational (#7561)
Changes falling out of an audit conducted by Morten and myself.
2024-09-03 13:35:37 -07:00
Will Dietz bdb9b0edcf
[FIRRTL][GrandCentral] Don't crash on missing keys, getAs. (#7577)
Add missing getAs return value checking, emit diagnostics.

Found via fuzzing.
2024-09-03 15:34:46 -05:00
Will Dietz 546575da37
[FIRRTL][GrandCentral] Fix crashes on error re:tryGetAs. (#7576)
Check return values of parsing functions.

Found via fuzzing.
2024-09-03 15:34:35 -05:00
Martin Erhart c102ea8832
[MooreToCore] Separate conversion pattern for moore.output (#7573)
Don't convert the output op in the module pattern because the operands will be of the wrong type since the body has not been converted yet, so it need to apply the hw output pattern afterwards anyway. Instead of relying on that pattern we should have a separate one for moore.output to hw.output that is applied once the rest of the body was converted. The HW output pattern is unnecessary because in the IR before conversion, no hw.output operation should be present (at least none that has a moore typed operand), thus its presence is only the consequence of a bad conversion process (if a target operation is inserted of which the operands are still of the source type, conversion casts should be inserted).
2024-09-03 18:12:29 +01:00
Will Dietz 7ba7fc3051
[SV] Fix regop canonicalizer crashing. (#7564) 2024-09-03 11:30:03 -05:00
Hideto Ueno ac008b1c17
[FIRRTLUtils] Fix walkDrivers subfield id calculation (#7536)
This fixes an overflow in walkDrivers when field ID is zero.

Fix https://github.com/chipsalliance/chisel/issues/4354 and https://github.com/llvm/circt/issues/7423.
2024-09-04 00:50:16 +09:00
Morten Borup Petersen 1c5dfa4a27
[ESI] Don't assume `using namespace std` in Manifest.cpp (#7571)
* [ESI] Don't assume `using namespace std` in Manifest.cpp

* format

---------

Co-authored-by: Morten Borup Petersen <mpetersen@microsoft.com>
2024-09-03 13:07:07 +02:00
John Demme ec8e3642bc [ESI][Runtime] Fix integration test
Wrong module name in test. Not caught since none of the CI gates test
the runtime. We need to fix this.
2024-09-03 04:07:25 +00:00
John Demme 1df1ef4802
[ESI][Runtime] Address MMIO regions symbolically (#7568)
Access MMIO address regions by the AppID of the requestor. Also provide
access to the MMIO space descriptors.
2024-09-02 16:40:16 -07:00
Martin Erhart d88c535754 [NFC][Seq] Fully qualify Value 2024-09-02 10:39:32 +01:00
Mike Urbach c2c047359b
Bump LLVM to 10407be542aeb2b59477b167bbba3716538dc722. (#7550)
---------

Co-authored-by: Martin Erhart <maerhart@outlook.com>
2024-09-01 09:15:42 +01:00
John Demme ce6901d54f
[ESI][Runtime] Pretty printing of service ports (#7567)
esiquery now displays the function signatures instead of the consistuent
channels. More representative of the API which is exposed.
2024-08-31 14:12:55 -07:00
Will Dietz ce8c14f9aa [Verif][VerifyClockedAssertLike] Don't crash on blockarg operand. 2024-08-31 03:17:34 -05:00
Will Dietz 929ffc4001 [FIRRTL][CreateSiFiveMetadata] Diagnostic not assertion failure. 2024-08-31 03:07:36 -05:00
Morten Borup Petersen e5949967ef
[ESI] Add optional non-blocking write API to `WriteChannelPort` (#7555)
[ESI] Add optional non-blocking write API to `WriteChannelPort`
2024-08-30 11:42:00 +02:00
Hideto Ueno b937bcfab0
[Seq] Add initial value to compreg (#7553)
This PR extends compreg's powerOnValue operand to be able to capture more complicated initialization such as firreg's randomized initialization or DPI calls. This change should make register initialization more modular and a step forward towards https://github.com/llvm/circt/issues/7213. 

While ASICs might not have explicit initial values, they are crucial for simulation
and FPGA implementation. FPGA designs often require constant initial values, while
simulation allows for more complex initialization using expressions like function calls
`$random`, `$readmem`, and `$fopen`.

seq.compreg has a (optional) powerOn operand that is lowered into inlined assignment in SV which allows users to initialize registers with user-specified values. However this representation is not sufficient for initialization with function calls. 

In order to represent various kinds of initialization, `seq.initial` op and `!seq.immutable` type
are introduced. The `seq.initial` operation produces values with types wrapped in `!seq.immutable`.
The `!seq.immutable` type wrapper prevents initial values from depending on time-variant values.
Stateful operations typically require corresponding initial values with the `!seq.immutable` type.
This ensures that the initial state of the operation is well-defined and independent of time-variant factors.

Example Input:
```mlir
%r_init, %u_init = seq.initial {
  %rand = sv.macro.ref.se @RANDOM() : () -> i32
  %c0_i32 = hw.constant 0 : i32
  seq.yield %rand, %c0_i32 : i32, i32
} : !seq.immutable<i32>, !seq.immutable<i32>
%r = seq.compreg %i, %clk initial %r_init : i32
%u = seq.compreg %i, %clk initial %u_init : i32
```

Output Verilog:
```verilog
reg [31:0] r;
initial
  r = `RANDOM;
reg [31:0] u = 32'h0;
```
2024-08-30 14:08:34 +09:00
Schuyler Eldridge 79af01e0a1
fixup! [FIRRTL] Use new layer ABI 2024-08-29 17:13:42 -04:00
Schuyler Eldridge cff52574a2
[FIRRTL] Use new layer ABI
Align CIRCT with the finalized layer ABI [[1]].  This changes the file
name of the bind file used to enable a layer.  This specifically switches
from using underscore as a delimiter to a hyphen.  This avoids a problem
where a circuit that contained modules or layers whose names contained
underscores could result in multiple layer enable files that had, by the
ABI, the exact same name.

[1]: https://github.com/chipsalliance/firrtl-spec/pull/233

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-29 17:10:17 -04:00
Andrew Young 6dcdb59ce1 [firtool] Run the CheckLayers pass 2024-08-28 19:38:04 -07:00
Andrew Young 126c46ad93 [firrtl] Add CheckLayers diagnostics pass
This adds a pass to check for illegal instantiation of a module with
layers underneath a layer.  This is a situation that leads to
bind-unde-bind when emitted to Verilog, which is illegal.  This does not
differentiate between inline layers and bind layers, although
theoretically this is only a problem for bind layers. This does not
create errors on extmodules, as we have no way of knowing whether they
contain a layer or not, and we don't want false positives.
2024-08-28 19:38:04 -07:00
Schuyler Eldridge 1afd3a589c
[ExportVerilog] Drop external module emission (#7558)
Stop emitting external modules entirely in single file emission and drop
the creation of "extern_modules.sv" in split file emission.  This is done
because it creates problems/confusion for Verilog generation flows which
are trying to hide the existence of some modules.  E.g., the existence of
"extern_modules.sv" will leak what external modules were instantiated
under a FIRRTL layerblock.

Alternatively, this could be revived by creating these files by respecting
the output file attributes on external modules such that each significant
directory got such a file.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-28 10:56:55 -04:00
Prithayan Barua 33c35fff11
[FreezePaths] Add an optional argument, to get the operation name (#7549)
`FreezePaths` pass may sometimes need to be invoked before `ExportVerilog`. 
This change removes the dependency of the pass on the `hw.verilogName`
 attribute, and adds an optional get operation name function, that can be
 invoked if the verilog name is absent. 
This enables any tool to invoke it earlier by providing an appropriate 
name-getter function. 
But as is expected, the names used to freeze the paths, may not match the
 verilog names. This should be used with caution, only when the path will not
 be used and its okay to be incorrect.
2024-08-26 09:28:18 -07:00
Morten Borup Petersen 5a669dffa6
[ESI] Make AcceleratorConnection::disconnect virtual (#7554)
Currently, `AcceleratorConnection` implementations only have one "official" teardown entry point, being their destructors. However, this makes implementations susceptible to destructor race conditions, due to the various things that may be concurrently executing in implementation-owned resources.

To provide users with more control during teardown, mark `AcceleratorConnection::disconnect` as virtual, allowing implementations to tear things down before destruction.

Co-authored-by: Morten Borup Petersen <mpetersen@microsoft.com>
2024-08-26 17:40:04 +02:00
Schuyler Eldridge 66122ebbcf
[FIRRTL] Cleanup variable names in LayerMerge, NFC
Superficial cleanup of LayerMerge to make the variable names make more
sense.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-24 00:31:45 -04:00
Schuyler Eldridge d5bf8f8880
[FIRRTL] Improve Layer Merge Performance
Fix a performance issue in the `LayerMerge` pass.  Apparently, repeated
use of `inlineBlockBefore` with a forward walk can be a performance issue.
Fix this, by reversing the iteration order.

h/t @youngar for algorithmic suggestions.

Fixes #7551.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-24 00:30:59 -04:00
Schuyler Eldridge 6743073c37
[FIRRTL] Remove priority in BlackBoxReader, NFC
Remove vestigial code in BlackBoxReader related to tracking the "priority"
of different directories.  This was made unused in an earlier commit that
switched to an LCA computation for where black box files should be placed.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-23 17:07:15 -04:00
Schuyler Eldridge 70fbc30422
[FIRRTL] Compute LCA of BlackBoxDir output files
Change how the output directory is computed for external modules with
black box annotations.  Previously, this relied on a "precedence" of
predefined directories.  Now, this trivially computes the LCA of the
directories for all output directories for a black box annotation with the
same name field.

This _does not_ replicate the old behavior.  Instead, users are expected
to rework their output directory structure to align with this algorithm.
E.g., it is no longer possible to make the tesbench a sibling directory of
the main output directory and have blackboxes that are instantiated by
both the testbench and the design to be put in the design---instead a user
should nest the testbench directory _under_ the main output directory.

The omnibus test case has been necessarily updated to show how the above
nesting.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-23 17:07:01 -04:00
Schuyler Eldridge 53d96d712d
[FIRRTL] Add makeCommonPrefix utility
Add a utility, makeCommonPrefix, copied from AssignOutputDirs.  This is
useful for computing the LCA of two directories.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-23 17:06:42 -04:00
Schuyler Eldridge 822987c87f
[FIRRTL] Set output dirs on annotated blackboxes
Reorder the FIRRTL pass pipeline so that Chisel blackboxes (represented by
a `firrtl.extmodule` and one of two blackbox annotations) will be assigned
an output directory based on their instantiation location.

Fixes #7538.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-23 17:06:27 -04:00
Schuyler Eldridge bd7703d53b
[FIRRTL] Set output directories on extmodules
Change the `AssignOutputDirs` pass to add `hw::output_file` attributes on
external modules in the same way that these attributes are added to normal
modules.  While this has no effect on an external module which has no
implementation, this fixes a bug where the external module _does_ have an
implementation that the compiler will later resolve.

This is specifically done to make output directories compose correctly
with Chisel inline blackboxes where the body of the external module is in
an annotation and is supposed to be written to a file.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-23 17:06:11 -04:00
Will Dietz 062ea0331a
[FIRRTL][LowerLayers] Update rwprobe operations if possible. (#7369)
Fixes first example in #7365 .

Add error path to LowerLayers so anything that goes wrong
can fail the pass.
2024-08-22 08:37:01 -05:00
Schuyler Eldridge eef76ca7e3
[FIRRTL] Debug header/footer in BBoxReader, NFC
Add the standard debug header/footer to the `BlackBoxReader` pass.  This
is entirely cosmetic.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-21 20:03:33 -04:00
Schuyler Eldridge 82782363ae
[FIRRTL] Add debug prints to AssignOutputDirs, NFC
Add some basic debugging information to the AssignOutputDirs pass.  This
indicates that the pass is running and what modules are having their
output directories updated.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-21 20:03:30 -04:00
Fabian Schuiki aae37b7a5c
[MooreToCore] Ignore ConstantLike values in wait op (#7540)
Skip values defined by `ConstantLike` ops when collecting the list of
values to observe in `llhd.wait` ops. Constants will never cause an
`llhd.wait` to resume execution since they never change value.
2024-08-21 23:39:18 +02:00
Hideto Ueno 5d8cf69cf2
[CombFolds] Don't canonicalize extract(shl(1, x)) if shift is multiply used (#7527)
There is a canonicalization for `exract(c, shl(1, x))` to `x == c` but this
canonicalization introduces a bunch of comparision to constants. This harms
PPA when bitwidth is large (e.g. 16 bit shift introduce 2^16 icmp op). To prevent
such regressions this commit imposes restriction regarding the number of uses
for shift.
2024-08-21 12:25:13 +09:00
John Demme 29b1c1cc76
[ESI][Runtime] Generate C++ header files for constants (#7517)
Start of static C++ header file generation. Just integer constants for now. Can work off of any manifest and will even connect to a live accelerator and read the manifest from there.

Generates a `types.h` file and one per module listed in the manifest. Inside the module header file, generates one class per module and adds the constants to that class. Puts _everything_ in a namespace specified by the user as `system_name`.
2024-08-20 13:52:52 -07:00
Martin Erhart 898eb8b926
[MooreToCore] Add always_comb and always_latch lowering support (#7532) 2024-08-20 12:35:24 +01:00
Schuyler Eldridge fb052d901a
[FIRRTL] Fix comment placement in test, NFC
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-19 19:48:21 -04:00
Schuyler Eldridge a2eec9e062
[FIRRTL] Whitespace test cleanup, NFC
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-19 19:19:29 -04:00
Schuyler Eldridge 31ed547abb
[FIRRTL] Combine LowerLayers firtool tests, NFC
Combine two tests of LowerLayers end-to-end behavior into a single
`-split-input-file` test.  This is done to add more tests to this file in
the future.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-19 19:19:29 -04:00
Will Dietz fcbd718c43
[FIRRTL][FIRParser] Cache property constants. (#7530)
Greatly reduces IR size generated in presence of many repeat
constants as commonly occurs in practice due to the data-like
nature of classes / properties.

Same tricky as done for FIRRTL integer constants,
use single cache/code for both.
2024-08-19 12:26:53 -05:00
Martin Erhart 9efc2e7572
[LLHD] Let WaitOp observe plain values instead of signals (#7528)
This is necessary to lower the moore dialect's always_comb and always_latch without introducing helper signals. It also allows for more mem2reg at the LLHD level.
2024-08-19 17:36:10 +01:00
Hideto Ueno 246636cee1
[ExportVerilog] Don't inline unpacked array assignments (#4548)
This changes emission style for unpacked array declaration. Verilator doesn't support initialization assignments for unpacked arrays, e.g:
```verilog
wire w[1:0] = '{0, 0};
```
This PR checks the value type and prevents inlining. Ideally it is more desirable to improve verilator but for now I want to avoid inlining unpacked arrays to declaration since it's just a tiny readability optimization. 

Fix https://github.com/llvm/circt/issues/6363.
2024-08-19 18:04:38 +09:00
Schuyler Eldridge 209d9fb80e
[firrtl] Fix bug in sibling layer specialization
Fix a bug in the `SpecializeLayers` pass where sibling layers would not be
enabled/disabled correctly if an earlier sibling layer was also
enabled/disabled.

Fixes #7525.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-16 19:26:26 -04:00
Schuyler Eldridge 27d3965c59
[firrtl] Test whitespace cleanup, NFC
Cleanup trailing whitespace in a test.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-16 19:26:26 -04:00
Fabian Schuiki d71e6e30c3
[Moore] Improve WaitEventOp, lower to LLHD (#7518)
Rework the `moore.wait_event` op to be able to accurately model the
semantics of SystemVerilog's `@...` event control statements. The op now
has a body region which is executed to detect a relevant change in one
or more interesting values. A new `moore.detect_event` op serves as the
mechanism to encode whether a posedge, negedge, both, or any change at
all on a value should be detected as an event.

Based on this new `moore.wait_event` op we can properly convert most of
the event control statements in `ImportVerilog` to a corresponding MLIR
op. Delay control like `#1ns` is not handled yet.

In the MooreToCore conversion this new op allows us to properly generate
`llhd.wait` operations at the right place that suspend process execution
until an interesting event has occurred. This now also allows us to
support almost all SystemVerilog processes in the lowering. The only
missing ones are `always_comb` and `always_latch` which require an
implicit `llhd.wait` to be inserted. @maerhart has a version of that
lowering almost ready though.

This commit also adds an `llhd.final` op in order to be able to lower
`final` procedures.

Fixes #7482.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
2024-08-16 13:14:12 -07:00
Fabian Schuiki 4492392eab
[LLHD] Align signals with other wire/variable ops (#7523)
Make the `llhd.sig` op use the same naming pattern as HW wires, Moore
variables, Seq registers, and a handful of other operations in CIRCT.
These all use the `custom<ImplicitSSAName>` parser to provide uniform
handling of optional names.

Make the signal name optional to align with other ops.

Rename the class to `SignalOp` for clarity.
2024-08-15 18:15:07 -07:00