Commit Graph

94 Commits

Author SHA1 Message Date
cepheus 930aabe70f
[CMake] Fix install failure with CMAKE_SLANG_FRONTEND_ENABLED enabled (#7437)
Slang compiler relies on the third-party libraries like unordered_dense and fmt
library. The fmt library provides two ways to integrated it:
  1.Headers-only
  2.Seperately compiled
The main purpose of this commit is to avoid installation failure of CIRCT project due
to finding fmt header file in wrong path which is in circt `include` directory when
CMake_slang_Frontend_enabled is turned on. We hope to not install header files coming
from fmt library.
2024-08-06 11:29:30 +08:00
Martin Erhart 2345382e67
[LLHD] Remove llhd-sim (#7351) 2024-07-19 17:54:14 +01:00
Fabian Schuiki 719bbfde79
[CAPI] Add circt-capi target and build it in CI (#7017)
Add a `circt-capi` target that depends on all C API libraries. Introduce
a new `add_circt_public_c_api_library` CMake function that wraps around
the MLIR equivalent, but also adds a dependency from `circt-capi`. Make
at least the short integration tests CI job build the `circt-capi`
target to ensure it has a bit of CI coverage.
2024-05-09 11:21:33 -07:00
Martin Erhart 7598a8e067
[circt-lec] Port to SMT dialect based compiler pipeline (#6908) 2024-04-21 08:06:39 +02:00
Martin Erhart 87020b2ed4
[SMT] Add SMT-LIB export translation (#6870) 2024-03-27 08:57:21 +01:00
Théo Degioanni 83a8292085
[arcilator] Introduce integrated JIT for simulation execution (#6783)
This PR adds a JIT runtime for arcilator, backed by MLIR's ExecutionEngine. This JIT allows executing `arc.sim` operations directly from the arcilator binary.
2024-03-18 10:27:08 +00:00
Mike Urbach 1abb2c6710
[CMake] Add CMake targets to install all CIRCT libraries. (#6798)
These targets are useful for downstream projects that want to install
all CIRCT libraries. The CMake commands follow how similar targets are
set up in upstream MLIR.
2024-03-07 20:13:03 -07:00
Will Dietz 01f73c922e
CMake: Fetch slang via git to workaround version check bug. (#6640)
Fixes #6639.
2024-02-02 21:49:26 -06:00
Fabian Schuiki 6d29091d08
[ImportVerilog] Add missing MSVC option for Slang
Add a missing `/EHsc` option to Slang builds using MSVC.
2024-01-30 15:31:15 -08:00
Fabian Schuiki 3d8b7d08d9
[ImportVerilog] Add Slang frontend dependency (#6620)
This is the first PR in a longer chain that adds basic SV support to
CIRCT.

Add the Slang Verilog frontend as a CIRCT dependency. This will be the
foundation for CIRCT's Verilog parsing, elaboration, type checking, and
lowering to the core dialects. By default, Slang is built as a static
library from scratch, which is then linked into the new `ImportVerilog`
conversion. Alternatively, CIRCT can also be linked against a local
Slang installation provided by the system.

Add the `ImportVerilog` conversion library. This library statically
links in the Slang dependency and wraps it in an exception-safe,
LLVM-style API. Currently this only consists of the `getSlangVersion`
function and the necessary linking flags to get it to link statically
against Slang.

Add the `circt-verilog` tool, which will provide a fully-flegded
interface to the new `ImportVerilog` library. Later on we'll also add an
MLIR translation library for single-file SV import. But in general, SV
builds take a lot of command line options (macros, search paths, etc.)
and multiple input files, which is why we have a dedicated tool. All the
tool does at the moment is print the linked Slang version. More to come.

Note that this intentionally links against **version 3** of Slang. Newer
versions are available -- 4 and 5 as of this commit -- but they rely on
fairly new C++ compiler features that didn't work out of the box in our
CI images. We'll eventually want to upgrade, but for now Slang 3 is
sufficient to get the ball rolling.

See https://github.com/MikePopoloski/slang for details on Slang.

Co-authored-by: ShiZuoye <albertethon@163.com>
Co-authored-by: hunterzju <hunter_ht@zju.edu.cn>
Co-authored-by: 孙海龙 <hailong.sun@terapines.com>
2024-01-30 13:22:00 -08:00
John Demme 1927491cff
[ESI] Move Cap'nProto into ESI runtime (#6354)
Simplifies the CIRCT proper build. Also mitigates a runtime binary distribution problem by requiring users to compile the runtime themselves.
2023-10-30 13:45:17 -07:00
John Demme 03e1d94d5c
[ESI] Rip out Cap'nProto schema generation (#6349)
This turned out to be a bad idea. We're still using Cap'nProto for Cosim, just with the message being a blob which is already encoded by the client. This is nearly identical to what happens in hardware, just Cap'nProto/DPI as the transport layer.

Goodbye old frenemy.
2023-10-26 19:58:24 -07:00
John Demme c01f75ca09
[ESI] Change method of packaging collateral (#6000)
Avoid use of new CMake feature FILE_SET.
2023-08-31 11:23:50 -07:00
Vito Gamberini 11d61f80a5
[CMake] Implement add_circt_tool() (#5821)
- Adds/renames the associated CMake variables:
   * CIRCT_BUILD_TOOLS
   * CIRCT_INCLUDE_TOOLS
   * CIRCT_TOOLS_INSTALL_DIR

- Actually uses the CIRCT_INCLUDE_TOOLS variable now
2023-08-10 18:37:45 -05:00
Will Dietz 50cdf443ba
[cmake][CI] Use llvm_gtest target directly. (#5804)
Upstream now has option for installing these components for use in downstream standalone builds:
llvm/llvm-project@0807986 .

Look for (and prefer) this approach, and update our LLVM builds that we install to use this.
2023-08-08 11:44:21 -05:00
John Demme 71fd2dc84e
[Capnp] Move the minimum CMake version logic to only run if capnp is found (#5335) 2023-06-07 16:47:15 -07:00
John Demme d22117d20f
[CMake] Require cmake >= 3.23 but only on capnp builds (#5243)
Some of our CMake code which is only used in Capnp builds uses newer CMake
features. Since most compilations are not capnp builds, only require the new
version for those builds.
2023-05-24 17:44:16 -07:00
John Demme d8b2ba6db6 Revert "[NFC] Bump CMake version since ESI uses it"
This reverts commit f7e40324a6.
2023-05-24 23:44:11 +00:00
Nandor Licker f7e40324a6 [NFC] Bump CMake version since ESI uses it 2023-05-23 18:58:13 +03:00
Robert Young 620fb72918
[circt-lec] Clean up includes and linking (#5186)
Add the z3 include directories as system includes, not normal includes, to the
circt-lec tool.  Including the z3 headers this way will prevent clang from
putting out warnings on code in the z3 headers.
2023-05-15 10:40:03 -04:00
frog-in-the-well 5e5f3a3f79
[circt-lec] Introduce the `circt-lec` tool (#3991)
A logical equivalence checking tool for CIRCT. As of now it covers some 
basic `hw` operations and the whole `comb` dialect. Z3 acts as the 
logical backend and has been introduced as a build dependency for the 
tool. Furthermore, regression tests for part of the implemented
operations and features have been written.

Co-authored-by: Hideto Ueno <uenoku.tokotoko@gmail.com>
2023-05-01 09:02:20 -07:00
Will Dietz 60d4c5115d
[cmake] Tweak suggested release tags, suggest firtool over sifive. (#4676) 2023-02-17 18:55:46 -06:00
Will Dietz 7aa178ac00 Revert "Disable -Wno-suggest-override for llvm_gtest_main as well. (#4434)"
This doesn't seem to be working, drop for now.

There should be a way to leverage the unittest CMakeLists.txt
instead of having these rules for them ourselves.

This reverts commit 21220aadb6.
2022-12-22 23:31:51 -06:00
Will Dietz 21220aadb6
Disable -Wno-suggest-override for llvm_gtest_main as well. (#4434)
PR #4409 disabled this for our unittests themselves, but
these warnings are still emitted when building llvm_gtest_main
in the non-unified build scenario where we have our own build rule.

Would be nice to remove all this.
2022-12-12 16:50:41 -06:00
Prithayan Barua af8f81087f
Bump LLVM (#4297)
* Bump LLVM

* cmake: Change lookup for unittest bits, now in /third-party.

Co-authored-by: Will Dietz <will.dietz@sifive.com>
2022-11-14 09:36:44 -08:00
Andrew Young 4107b83d78
Link gtest against portable threading lib (#4099)
When we build CIRCT as a standalone project (not a unified build), we
build gtest from scratch for our unit tests.  This is currently
hard-coded to link against pthreads, which does not work on Windows. We
can use the built in `Threads::Threads` cmake library which is more
portable.  This fixes the unit test linking on Windows.
2022-10-13 16:27:36 -07:00
Will Dietz 43d5d57d0b
Fixes to build system to support unittests again, add to CI (#4082)
1. test: tweak test discovery to enable unittests, fix deps var.

Discovery will find the generated lit.site.cfg.py, which
knows how to load the lit.cfg.py.

This could be gated on whether we're building "standalone",
as flang does, but that still doesn't work as we are not part
of the config mapping.

cc #2750.

Also fixup typo in variable name, .._DEPS -> .._DEPENDS.

2. cmake: gtest is available if built with LLVM, set accordingly.

We only include the unittests directory if we think the GTEST bits
are available, which we were not indicating in the non-standalone case.

Fix this, and FWIW this is also done in flang's CMakeLists.txt .

3. [CI] Add check-circt-unit to testing.
2022-10-12 19:46:06 -05:00
Morten Borup Petersen e271db5f4b [CMakeLists] ... and fix again 2022-10-06 13:27:54 +02:00
Morten Borup Petersen 0cb9bc2563 [CMakeLists] Fix reported path of last commit 2022-10-06 10:41:35 +02:00
Morten Borup Petersen 8569992f57 [CMakeLists] Inform if CapNProto was found 2022-10-06 10:40:06 +02:00
Christian Ulmann 33309a8854
[Python][Testing] Resolve python for testing purposes (#3738)
Look for a python executable even when the bindings are disabled.
This is required for the cocotb integration tests.
2022-08-18 08:26:38 +02:00
Martin Erhart dd2e9120c1
[ExportSystemC] Basic infrastructure for emission (#3726)
This commit introduces the base classes and utilities to implement
emission patterns and an emission printer which takes the role of a
driver that can be called in a circt-translate pass. Also includes
emission patterns for the builtin module and SCModule operations to
(1) allow to implement some basic unit and integration tests
(2) show the reviewer how emission patterns look like using this
infrastructure.
2022-08-17 00:55:08 +02:00
Morten Borup Petersen 5da9701741
Require iverilog version >=11 (#3548)
Icarus verilog v11, released in 2020, adds support for important constructs such as `always_ff, always_comb` in SV. Since virtually all non-trivial circuits will leverage these constructs during SV emission, it seems sensible to require an `iverilog` version that actually is able to simulate the circuits we generate.
2022-07-19 09:08:20 +02:00
Hideto Ueno fe1ddfc6e3
[CMake] Make version generation opt-out (#3178)
This commit disables the version generation by default since it creates
unnecessary warnings in out-of-tree builds.
2022-05-24 16:40:55 +09:00
sinofp b7e1ad378e
[ExportVerilog] Include Build Information in Output Files (#2613)
This PR adds a functionality to include build information in output files. 
The format of the version string is  `<releases tag name>-
<how many commits since the tag>-g(means git)<current commit hash>[-dirty]`

Two cmake flags are added to control version strings, 
`CIRCT_RELEASE_TAG_ENABLED` (default is On) and 
`CIRCT_RELEASE_TAG` (default is `circtorg`). 
If `CIRCT_RELEASE_TAG_ENABLED` is false, the version string becomes 
"unknown" and cmake script is ran only at the first cmake configuration.  Example,
 
```
$ cmake .. -DCIRCT_RELEASE_TAG=pycde
// Generated by CIRCT pycde-0.0.5-28-ge846cf26e
module Bar(

$ cmake .. -DCIRCT_RELEASE_TAG=sifive
// Generated by CIRCT sifive/0/9/0-31-ge846cf26e
module Bar(

$  cmake .. -DCIRCT_RELEASE_TAG_ENABLED=Off
// Generated by CIRCT unknown git version
```

Co-authored-by: Hideto Ueno <uenoku.tokotoko@gmail.com>
2022-05-24 02:31:08 +09:00
huanghuang b237718c73
[cmake] Configure policy CMP0116 (#2879)
CMake 3.20 will result in many warnings on this policy.
  This commit silence it with the use of 'old' behaviour.
  And CMake 3.23 does warn it and simple use 'old' behaviour.
  Probably we can remove this when minimal cmake version up to 3.23.
2022-04-13 09:20:37 +08:00
Julian Oppermann a59b494d42
[Docs] [CMake] Add install script for OR-Tools; mention it in Getting Started guide (#2868) 2022-04-12 20:31:37 +02:00
Nandor Licker a0a2ef9219
[Tests] Added Icarus Verilog test harness (#2739)
If questa or vivado are not found, `iverilog` is used to run supported tests. Tests which cannot be executed using this simulator can be disabled by adding `// DISABLED: ieee-sim-iverilog` or `// DISABLED: iverilog`.

Icarus verilog tests can be disabled altogether by passing `-DIVERILOG_DISABLE=ON` to cmake, similarly to other simulators.

resolves llvm/circt#879
2022-03-26 10:21:20 +02:00
Fabian Schuiki 246d4fdd34
Bump LLVM to 61814586 (#2758) 2022-03-14 14:13:45 +01:00
Fabian Schuiki 4c74e87023
[Moore] Add SystemVerilog types (#2699)
Add an implementation of the SystemVerilog type system to the Moore
dialect, modeled after the one in Moore's Rust codebase:

https://github.com/fabianschuiki/moore/blob/master/src/svlog/ty.rs

This is the first step towards migrating a larger chunk of the Moore
codebase into CIRCT, as it allows Moore's codegen to start emitting
higher-level operations (e.g., `moore.mir.concat`, to be added later)
instead of directly dropping to LLHD/HW. Doing so will allow us to
eventually move the codegen over into CIRCT, and start work on
implementing the type checking and type inference on the higher-level
operations.

My hope is that we might eventually be able to reconcile the Moore types
and some of the higher-level operations with the SV dialect, since both
work with SystemVerilog, albeit for two diametrically opposed purposes.

The types are designed to very clearly distinguish between packed and
unpacked types, and provide a certain level of guarantees about the
structure of nested types through C++ types. For example, struct
aggregate types and typedefs/decltype constructs come in a packed and
unpacked flavor to enforce proper nesting of these types.

Where user-defined types are involved, for example through structs and
typedefs/decltype, the MLIR types aim to capture enough information to
faithfully reconstruct the type as it was originally formulated by the
user. This helps provide good and understandable diagnostics. As a
concrete example, integer types capture whether their sign was provided
explicitly by the user, in order to distinguish `int` and `int signed`,
despite those two types being semantically identical.

This commit also adds a `unittests` directory as seen in LLVM and MLIR,
to test the human-readable serialization of the Moore types and other
type attributes.
2022-03-04 08:48:45 +01:00
John Demme a943165b35
[CMake] Fix Python configure (#2646)
On Ubuntu 21.10, cmake configure fails to find Python. Just use the
upstream configuration macro, which has been updated.
2022-02-17 15:01:28 -08:00
Julian Oppermann 677d780169
[Scheduling] Set up infrastructure for using OR-Tools' solvers. (#2465) 2022-01-18 10:55:15 +01:00
Fabian Schuiki 416560123e [CMake] Align CIRCTConfig.cmake more closely with MLIR
Update the `cmake/modules/CMakeLists.txt` file and friends such that the
config file also includes the `CIRCT_TOOLS_BINARY_DIR` variable, and the
generation of that file resembles that in MLIR more closely. This should
make it easier in the future to use some of LLVM's cmake utilities.
2022-01-13 11:19:03 +01:00
Fabian Schuiki 209c85d305 [CMake] Update header install commands to match MLIRs
Update the `install` commands concerned with the CIRCT header files to
match the MLIR style: one for `circt` and `circt-c` in the source tree,
and one for `circt` and `circt-c` in the build tree.

This only affects out-of-tree users of CIRCT and in the worst case
provide additional header files than what they have seen so far.
2022-01-13 11:19:03 +01:00
Andrew Lenharth c53630bd31 [NFC] Fix capitalization in cmake package name
Not sure if this is from cmake changing the file name, or being more pendantic, but we now match the actual capitalization of the file distributed by cmake.
2021-11-02 11:06:19 -05:00
mikeurbach 4d67846de9
[Python] Limit Python dependency to Development.Module when possible. (#1977)
After CMake 3.18, we are able to limit the scope of the search to just
Development.Module. Searching for Development will fail in situations
where the Python libraries are not available. When possible, limit to
just Development.Module. See:
https://pybind11.readthedocs.io/en/stable/compiling.html#findpython-mode
2021-10-12 14:33:49 -07:00
Chris Lattner 6d96350dcf [CMake] Revert some changes inadvertently landed.
This fixes Issue #1833.
2021-09-21 17:52:26 -07:00
Prithayan Barua 34d3ed999e
[SV][ExportVerilog] Add symbol to verbatim macro substitution (#1798)
The verbatim op can be used for macro substitution with values. This PR adds 
support for macro substitution with symbols.
For example, 
```mlir 
sv.verbatim  "MACRO({{0}}, {{1}} reg={{4}}, {{3}})"
          (%add, %xor)  : i8,i8
          {symbols= [@reg1, @module1, @instance1]}
```
In the above operation, `0` and `1` will be replaced by `%add` and `%xor` ,
 `4` with the verilog name of the symbol `@instance1`  and `3` with the 
verilog name of the symbol `@module1`.

Changes in this commit:
1. Add the optional array of symbols as an attribute to the `VerbatimOp`
2. Add a type constraint for an array of `FlatSymbolRefAttr`, this can be pushed to `mlir`.
3. Update `ExportVerilog` to get the verilog name for any symbol. Most of the changes 
                     in `ExportVerilog` is just to ensure the final symbol names can be tracked.                    
4. Update docs and test cases.
2021-09-21 16:09:35 -07:00
Andrew Young 2829895862
[Tests] Add equiv-rtl.sh as a Lit tool (#1816)
`equiv-rtl.sh` is a utility script used to test formal equivalence in
our integration tests.  This change adds it as a tool which Lit knows
how to find instead of using a relative path to invoke the script.
2021-09-20 13:35:37 -07:00
John Demme 7da2c14788 [CMake] Fix CapnProto find_package in unified builds 2021-09-07 22:28:15 -07:00