Commit Graph

1685 Commits

Author SHA1 Message Date
Will Dietz 69a110f97f
Update LLVM (#3502)
In llvm submodule: set branch to main, so can just update with:

$ git submodule update --remote --merge

See PR for summary of significant upstream changes and details of how they were handled:
https://github.com/llvm/circt/pull/3502
2022-07-18 14:18:53 -05:00
Will Dietz 939a6aa68b
[FIRRTL] Add stats to various memory-related passses (#3521)
* AddSeqMemPorts: Add statistic for ports added.
* FlattenMemory: stat for memories flattened
* LowerMemory: stats for memories lowered and mem mods created.
* Dedup: nit, prefer preincrement
* LowerCHIRRTL: stats for mems lowered/created/portless (dropped)
* InferRW: stat counting memories inferred to rw port
* MemToRegOfVec: Add stat for mems converted.
2022-07-18 14:14:49 -05:00
Morten Borup Petersen d904317dd1
[HWArith, CAPI] Add CAPI boilerplate for HWArith (#3550) 2022-07-18 15:19:08 +02:00
Hideto Ueno 79f45c2b68
[LowerTypes] Add flags to refine aggregate preservation (#3490)
This PR modifies LowerTypes to specify types preserved by aggregate preservation, i.e. `-preserve-aggregate={none, 1d-vec, vec, all}`.
Implementation wise, `peelType` takes the enum and selectively lower types.
2022-07-18 19:14:50 +09:00
Hideto Ueno 893eccb2ad
[LowerToHW][FIRTOOL] Add an option to emit chisel asserts as sva (#3545)
This commit adds an option `emit-chisel-asserts-as-sva` to emit chisel
asserts as SVA assertions at LowerToHW. Users sometimes want to emit 
only SVA for verification purpose and therefore, this commit provides a
command line option to emit "ifElseFatal" style assertion as SVA.
2022-07-18 17:15:02 +09:00
7FM 655cb61abd
[HWArithToHW] Add lowering boilerplate (#3546) 2022-07-18 10:03:22 +02:00
Martin Erhart 4924dba5a2 [FIRRTL] Rename operation arguments to resolve ambiguities 2022-07-16 22:05:18 +02:00
Martin Erhart 41f0f93833 [SV] Rename operation arguments to resolve ambiguities 2022-07-16 22:05:18 +02:00
Martin Erhart 2b524a07d0 [HW] Rename operation arguments called 'operands' to resolve ambiguities 2022-07-16 22:05:18 +02:00
Martin Erhart c33340a839 [FIRRTL] Adopt prefixed accessors
Another step towards #2006
2022-07-16 22:05:18 +02:00
Morten Borup Petersen 56a260a1d4
[FSMToSV] Add FSM to SV conversion pass (#3483)
This commit introduces an FSM to SV lowering pass, as well as some small modifications to the FSM dialect to facilitate the conversion. This initial version of the pass does not support transition action regions and variables.

The lowering style is fairly straight forward; two processes are emitted, one `always_ff` for state register inference, one `always_comb` for next-state calculation and output assignments.

e.g.:
```mlir
fsm.machine @top(%a0: i1, %arg1: i1) -> (i8, i8) attributes {initialState = "A", argNames = ["a0", "a1"], resNames = ["r0", "r1"]} {
  %c_42 = hw.constant 42 : i8
  fsm.state @A output  {
    %c_0 = hw.constant 0 : i8
    fsm.output %c_0, %c_42 : i8, i8
  } transitions {
    fsm.transition @B
  }

  fsm.state @B output  {
    %c_1 = hw.constant 1 : i8
    fsm.output %c_1, %c_42 : i8, i8
  } transitions {
    fsm.transition @A guard {
      %g = comb.and %a0, %arg1 : i1
      fsm.return %g
    }
  }
}
```
emits as
```sv
typedef enum {A, B} top_state_t;
module top(
  input        a0,
               a1,
               clk,
               rst,
  output [7:0] r0,
               r1);

  reg  [7:0]       output_1;
  reg  [7:0]       output_0;
      top_state_t next_state;
  wire top_state_t to_A;
  wire top_state_t to_B;
      top_state_t state_reg;

  assign to_A = A;
  assign to_B = B;
  always_ff @(posedge clk) begin
    if (rst)
      state_reg <= to_A;
    else
      state_reg <= next_state;
  end
  always_comb begin
    case (state_reg)
      A: begin
        next_state = to_B;
        output_0 = 8'h0;
        output_1 = 8'h2A;
      end
      B: begin
        next_state = a0 & a1 ? to_A : to_B;
        output_0 = 8'h1;
        output_1 = 8'h2A;
      end
    endcase
  end
  assign r0 = output_0;
  assign r1 = output_1;
endmodule
```
2022-07-16 21:57:24 +02:00
John Demme f1ed562e0e [ESI] [NFC] Split out services pass into separate file
ESIPasses.cpp is getting sort of long and ESI Services is going to have
some non-pass code. So break it out into its own cpp file.
2022-07-15 15:29:43 -07:00
John Demme 00aeed9f2a
[MSFT] Implement `HWMutableModuleLike` in `msft.module` (#3542)
Allows ESI connect services pass to execute on msft modules.
2022-07-15 13:57:54 -07:00
John Demme a90f2466da
[HW] [ESI] Add module mutation interface, use it in ESI pass (#3532)
Adds a new `HWMutableModuleLike` op interface which exposes a bunch of methods which were all present in the `hw` operations which implemented `HWModuleLike`. This allows one of the ESI passes to not have knowledge of any `hw` module or instance ops -- it can operate on anything which has a module implementing `HWMutableModuleLike`. Paves the way to supporting `msft.module`.
2022-07-14 15:17:27 -07:00
Nandor Licker 8e7d82c04f
[SV][Seq] Introduced a FIR register (#2939)
Introduced a `seq.firreg` register
2022-07-14 22:33:21 +03:00
7FM dd8fc1fd47
[HWArith] Implement Constant,Add,Sub,Mul,Div (#3512)
First batch of bit-width-aware arithmetic operations.

Co-authored-by: Julian Oppermann <oppermann@esa.tu-darmstadt.de>
2022-07-14 15:29:47 +02:00
Will Dietz 9efb31b33b
Namespace: add underscore before the suffix (#3528)
Tweak behavior to match comment "2." (_<n>_<suffix>).

Insist on underscore separation instead of leaving up to caller.
2022-07-14 07:32:57 -05:00
Martin Erhart b5bf74863d [Comb] Adopt prefixed accessors
Another step towards #2006
2022-07-14 13:57:36 +02:00
Martin Erhart 8170526392 [SV] Adopt prefixed accessors 2022-07-14 12:12:44 +02:00
Martin Erhart a29e5848fb [Seq] Adopt prefixed accessors
Another step towards #2006
2022-07-14 11:19:55 +02:00
Martin Erhart 3ab2c5ad78
[HW] Adopt prefixed accessors (#3533)
We cannot directly switch to prefixed only because of the use of duck-typing in HWOpInterfaces.td and SVOps.cpp. This means we need to generate both the prefixed and non-prefixed accessors until all dialects that make use of HWInstanceLike have switched. This includes HW, SV, FIRRTL, MSFT.
2022-07-14 11:08:23 +02:00
Andrew Young 26226cb787
[FIRRTL] Add canonicalizers for verification ops (#3530)
This replicates some assertions implemented in the SV dialect.  We need
to move these into the FIRRTL dialect so that they may be removed before
`IMDeadCodeElim` runs.

Co-authored-by: Hideto Ueno <uenoku.tokotoko@gmail.com>
2022-07-14 00:59:59 -07:00
Martin Erhart 2612a4ad7f
[LLHD] Use prefixed accessors (#3527) 2022-07-14 08:38:13 +02:00
Andrew Young ce469bbf54
[FIRRTL][SV] Add comment attribute to GC interfaces and modules (#3529)
We need to add a comment `// VCS coverage exclude_file"` to all Grand
Central modules and interfaces.  When we needed something like this
previousl, it was previously handled by adding a `comment` attribute
onto `hw.module` and handled in lower to HW.

To support these new targets, we have to:

1. Add a comment attribute to SV interfaces.  To accomplish this, I used
   an optional string attribute.  I switched the printed format to print
   the attribute dictionary after the symbol name, which I think is more
   common across all our operations.
2. Update ExportVerilog to print this attribute.  The `emitComment`
   function can recognize null attributes and skip a comment.
3. Propagate a "comment" attribute on FIRRTL modules in LowerToHW to HW
   modules.  This was not added to the ODS arguments, similar to the
   `output_file` attribute.
4. Modify GrandCentral to attach these comments to generated modules and
   interfaces.

I tested this on a design and there were no more files in the `scope`
directory missing this attribute.

Co-authored-by: Hideto Ueno <uenoku.tokotoko@gmail.com>
2022-07-13 23:35:06 -07:00
John Demme 47683ac1d2
[ESI] Global services connection pass (#3496)
Implements a pass to connect up ESI services clients to the nearest server instantiation. Wires up the ports and generates a generation request to call a user-specified generator.
2022-07-13 18:41:04 -07:00
Will Dietz 81e31a80b3
[FIRRTL][IMDCE] Add stat for number operations erased (#3519) 2022-07-13 08:36:56 -05:00
Andrew Young 4ce39c63fd
[FIRRTL] Use more anno class strings from AnnotationDetails.h (#3517) 2022-07-12 14:43:24 -07:00
Will Dietz f6f2492e3c [FIRRTL] AnnoDetails: be consistent about strings, fix warnings (NFC)
Most of these are 'constexpr const char *', use this for all.
The 'static const char *' generate warnings in files where they're not
used.
2022-07-12 13:09:49 -05:00
Will Dietz 129a694a8f [FIRRTL] Passes.td: doc touchups, NFC. 2022-07-12 11:00:59 -05:00
Andrew Young fb6e84222b
[FIRRTL] Add AddSeqMemPorts Anno to LowerAnnotations (#3508) 2022-07-12 10:55:26 -04:00
Schuyler Eldridge cd138aba3b
[FIRRTL] Add, use FullAsyncReset Anno Defs
Add Annotation class names associated with the "Full Async Reset
Transform" (which is implemented by the InferResets pass) to the global
AnnotationDetails.h definitions file.  Use these definitions in place of
strings in InferResets.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-07-12 10:53:47 -04:00
Schuyler Eldridge 9dc60f11e0
[FIRRTL] Add MustDedup Anno to defs, NFC
Add MustDeduplicateAnnotation to Annotation definitions and use it in
place of a string in the Dedup pass.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-07-11 23:50:28 -04:00
Schuyler Eldridge aa630e3059
[FIRRTL] Add RunFirrtlTransformAnnotation handling
Drop RunFirrtlTransformAnnotations in the LowerAnnotations pass.  This
is an Annotation that is used to add passes to the Scala FIRRTL
Compiler (SFC) pass pipeline and has no use in CIRCT.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-07-11 23:31:51 -04:00
John Demme 39ad137916
[ESI] Global services model (#3468)
ESI global services provide connectivity to chip-level stuff like PCIe, DRAM, Ethernet, etc. Additionally, services are completely user-defined and can be used recursively, so a user could define a telemetry service which is backed by PCIe (for instance). Users need to implement the services themselves, but ESI will plumb through the connection requests and provide users with a list of pre-connected ESI ports. ESI could also provide several standard multiplexing components.

Implements roughly the model in #2811. A lowering pass as described in the op documentation will be in a subsequent PR.
2022-07-11 20:21:38 -07:00
Schuyler Eldridge 4a77e7ee21 [FIRRTL] Add missing Anno defs, NFC
Add missing global Annotation definitions.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-07-11 22:35:56 -04:00
Prithayan Barua da5d89d02b
[FIRRTL] Add InnerSymAttr verifier (#3487)
Add utilities and verifier for InnerSymAttr.
Add utilities to,
 1. Get sym name for a field ID
 2. Check a property for all field IDs
 3. Get number of symbols

The verifier checks that,
  1. All the fieldIDs specified are unique.
  2. All the inner sym names are unique.
  3. The fieldID is valid.
  4. For ops with zero or multiple results, only the fieldID=0 can have
     an inner sym.
2022-07-11 11:53:49 -07:00
Hideto Ueno 58e58452f3
[SV/Python/ExportVerilog] Allow SVAttributes to be attached everywhere (#3472)
Towards https://github.com/llvm/circt/issues/3430, this PR implements 
generic SV attributes which are allowed to be attached to arbitrary expression. 

1. Disable some SV canonicalizers to keep sv attributes. Canonicalizations 
    of comb and hw are not blocked in this PR (maybe necessary in the future).  
2. HWCleanup cannot merge operations if there is a SV attribute.
3. Currently ExportVerilog emission is implemented for only
   reg, wire, assignments and hw.array_get to reduce the complexity of
   this PR. When SV attributes are attached to unsupported ops,
   ExportVerilog emits errors. 
4. Python bindings are also modified
2022-07-12 00:19:28 +09:00
Morten Borup Petersen 5eba26e411
[HWArith] HWArith dialect rationale and boilerplate (#3456)
Please refer to RationaleHWArith.md.
2022-07-11 11:04:44 +02:00
Hideto Ueno d213389f6a
[SV] Remove mux to if canonicalization (#3473)
This PR removes the canonicalization introduced by https://github.com/llvm/circt/pull/965 which is 
incorrect under 4-values logic. `reg <= cond ? foo: reg;` is not equivalent to `if(cond) reg <= foo` when `cond` is `x`.
2022-07-11 12:18:44 +09:00
Andrew Lenharth 95b52fb6ee
Bump LLVM to dd74d3117de0fd96383beeb4b4b913efcb9f4328 (#3492)
Co-authored-by: Mike Urbach <mikeurbach@gmail.com>
2022-07-09 08:21:17 -05:00
Schuyler Eldridge 7afcbf844b
[FIRRTL] Add, use Inline/Flatten Anno defs, NFC
Add global definitions of InlineAnnotation and FlattenAnnotation and use
them in the ModuleInliner pass.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-07-09 01:20:46 -04:00
Schuyler Eldridge 8592f0f4c2
[FIRRTL] Use Anno defs in PrefixModules, NFC
Add a global annotation definition for NestedPrefixModulesAnnotation and
use this in the PrefixModules pass.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-07-09 01:17:10 -04:00
Schuyler Eldridge 6ad84ebb9e
[FIRRTL] Add, use PrefixInterfaces Anno def, NFC
Add a missing Annotation definition, PrefixInterfacesAnnotation.  Use
this in the Grand Central Views pass instead of a bare string.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-07-09 00:44:20 -04:00
Schuyler Eldridge 31bc113557
[FIRRTL] Combine testbenchDir/testBenchDir, NFC
Delete testbenchDirAnnoClass Annotation definition in favor of
testBenchDirAnnoClass.  Both variants were accidentally defined.
Replace uses of the former with the latter.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-07-09 00:28:55 -04:00
Schuyler Eldridge 99a961163c
[FIRRTL] Anno defs in CreateSiFiveMetadata, NFC
Change the CreateSiFiveMetadata pass to use globally-defined Annotation
class names.  Add any missing Annotation class name definitions from
this pass.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-07-09 00:01:36 -04:00
Schuyler Eldridge 494d49331b
[LowerToHW] Use Annotation defs in LowerToHW, NFC
Change the LowerToHW conversion pass to use globally-defined Annotation
class names.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-07-08 23:11:00 -04:00
Schuyler Eldridge c95e1cf6e6
[FIRRTL] Use Anno defs in WireDFT, NFC
Add and use global Annotation class name definitions for the WireDFT
pass.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-07-08 22:41:08 -04:00
John Demme aa5c574d2a
[MSFT] Make `PassCommon` public (#3493)
`PassCommon` contains `getAndSortModules`, which is generally useful. Make it general by implementing `HWModuleLike` and `HWInstanceLike` and targeting those OpInterfaces instead. Involves a bit of ugliness when converting to/from the OpInterfaces to concrete module ops, but hopefully that'll go away as we add more functionality to said OpInterfaces.
2022-07-08 15:53:26 -07:00
Morten Borup Petersen de1a55f3e9
[SV] Add support for `sv.case` with `hw.enum` (#3478)
This commit adds support in `sv.case` for switching on enum values. In doing so, a fair bit of refactoring is done to `CasePattern`s to more cleanly handle the different cases of bit, enum, and default patterns.

Since `hw.enum` doesn't yet include any notion of value encoding, the `sv.case` operation exclusively works on either enum or bit pattern.
Furthermore, only a single case value can be compared in a case statement (as opposed to `case A, B : ...`). I think this is a good starting point - if support is needed in the future, it will not be complicated to add.

```mlir
hw.module @AnFSM(%clock : i1) {
  %reg = sv.reg : !hw.inout<!hw.enum<A, B, C>>
  %reg_read = sv.read_inout %reg : !hw.inout<!hw.enum<A, B, C>>

  %A = hw.enum_get #hw.enum.value<A, !hw.enum<A, B, C>>
  %B = hw.enum_get #hw.enum.value<B, !hw.enum<A, B, C>>
  %C = hw.enum_get #hw.enum.value<C, !hw.enum<A, B, C>>

  sv.always posedge %clock {
    sv.case case %reg_read : !hw.enum<A, B, C>
      case A : { sv.passign %reg, %B : !hw.enum<A, B, C> }
      case B : { sv.passign %reg, %C : !hw.enum<A, B, C> }
      default : { sv.passign %reg, %A : !hw.enum<A, B, C> }
  }
}
```

emits
```systemverilog
module AnFSM
    enum {A, B, C} reg_0;
    always @(posedge clock) begin
    case (reg_0)
        A:
        reg_0 <= B;
        B:
        reg_0 <= C;
        default:
        reg_0 <= A;
    endcase
```
2022-07-07 09:42:54 +02:00
Tynan McAuley c8d4ab9bed
Fix code/comment typos (#3482) 2022-07-07 01:23:24 -04:00