Commit Graph

1573 Commits

Author SHA1 Message Date
Krystine Sherwin 1e5a50ff3a
Docs: Convert write_cell_rst to use SimHelper 2024-10-15 07:16:39 +13:00
Krystine Sherwin 6bbe763845
Docs: Put cell library help strings into a struct
Allows for more expressive code when constructing help messages for cells.
Will also move extra logic in parsing help strings into the initial python parse instead of doing it in the C++ at export time.
2024-10-15 07:16:39 +13:00
Krystine Sherwin a6641da73c
Docs: Initial version of cell_ref autogen 2024-10-15 07:16:39 +13:00
Emil J. Tywoniak bc5d9d1bd3 functional: fix std::move usage in Factory::constant 2024-10-14 06:28:14 +02:00
Emil J. Tywoniak 785bd44da7 rtlil: represent Const strings as std::string 2024-10-14 06:28:12 +02:00
Emil J 61ed9b6263
Merge pull request #4608 from phsauter/rtlil-const-compress
rtlil: add Const::compress helper function
2024-10-12 20:38:25 -07:00
Emil J 5c9b2df689
Merge pull request #4616 from YosysHQ/emil/cxxopts
driver: replace getopt with cxxopts, replace -B, clean up help
2024-10-12 00:52:34 -07:00
Philippe Sauter c53c87e1f4 rtlil: add Const:: as_int_compressed function 2024-10-09 19:48:57 +02:00
Philippe Sauter 07fb8af05b rtlil: handle all-zeros case in Const::compress 2024-10-09 19:48:57 +02:00
Philippe Sauter 4cd2e04da4 rtlil: add Const::compress helper function
Compresses the current bits to the minimum
width representation by removing leading bits.
2024-10-09 19:48:57 +02:00
Emil J. Tywoniak 575415ade2 driver: switch to cxxopts, replace -B 2024-10-09 15:21:34 +02:00
Mohamed Gaber 3d6b8b8e1a
wheels: fix missing yosys-abc/share directory
* `misc/__init__.py`:
  * checks if there's a `yosys-abc` in the same directory - if yes, sets the variable `sys._pyosys_abc`
  * checks if there's a `share` in the same directory - if yes, sets the variable `sys._pyosys_share_dirname`
* `yosys.cc::init_share_dirname`: check for `sys._pyosys_share_dirname`, use it at the highest priority if Python is enabled
* `yosys.cc::init_abc_executable_name`: check for `sys._pyosys_abc`, use it at at the highest priority if Python is enabled
* `Makefile`: add new target, `share`, to only create the extra targets
* `setup.py`: compile libyosys.so, yosys-abc and share, and copy them all as part of the pyosys build
* `test/arch/ecp5/add_sub.py`: ported `add_sub.ys` to Python to act as a test for the share directory and abc with Python wheels, used in CI
2024-10-09 13:09:14 +03:00
Martin Povišer 380a425598
Merge pull request #4639 from mikesinouye/hashlib
Explictly #include <variant> for std::variant usage.
2024-10-08 16:42:42 +02:00
Miodrag Milanović 535b3304cc
Merge pull request #4534 from donn/test_wheels
Pyosys Wheels
2024-10-08 11:24:16 +02:00
Mike Inouye 1e3973c5cb Explictly #include <variant> for std::variant usage.
Signed-off-by: Mike Inouye <mikeinouye@google.com>
2024-10-07 21:57:30 +00:00
Martin Povišer e46cc57cc4
Merge pull request #4613 from povik/err-never-silence
log: Never silence `log_cmd_error`
2024-10-07 16:12:31 +02:00
Martin Povišer 74e92d10e8
Merge pull request #4593 from povik/aiger2
New aiger backend
2024-10-07 16:11:25 +02:00
Mohamed Gaber 407343a7a1
Pyosys Wheels
* Created `setup.py`: Python package manifest to build `pyosys` wheels with a custom extension to build and include `libyosys.so` using Make
* `.gitignore`: Added byproducts of the Python wheel build process
* `Makefile`: Added `-undefined dynamic_lookup` to `libyosys.so` so missing symbols can be resolved by importing into a Python interpreter
* `kernel/yosys.cc`: Gated `PyImport_AppendInittab` with `!Py_IsInitialized`; as of Python 3.12, the interpreter is already initialized and `PyImport_AppendInittab` would cause an exception to be raised
* Created `wheels.yml`: CI workflow for building wheels for CPython on:
  * Linux (glibc, musl) and Darwin
  * x86-64 and arm64
2024-10-07 16:39:54 +03:00
Emil J 1f517d6c7d
Merge pull request #4553 from donn/python_scriptfile
-y flag for libyosys Python scripts
2024-10-07 11:02:40 +02:00
Roland Coeurjoly 5ea2c6e6e5 Assume x values for missing signal data in FST
Co-authored-by: Miodrag Milanovic <mmicko@gmail.com>
Co-authored-by: Roland Coeurjoly <rolandcoeurjoly@gmail.com>
2024-10-02 12:08:48 +02:00
Roland Coeurjoly 76c615b2ae Fix: handle VCD variable references with and without whitespace
Co-authored-by: Miodrag Milanović <mmicko@gmail.com>
Co-authored-by: Roland Coeurjoly <rolandcoeurjoly@gmail.com>
2024-10-01 11:51:20 +02:00
Mohamed Gaber 35c8ad61ac
cli/python: error-checking, python interpreter bugfix
* Less brittle method of adding script dirname to sys.path
* Check if scriptfp successfully opens before using it
* Move `log_error` to after `PyErr_Print()` is called
2024-09-30 17:38:43 +03:00
Martin Povišer 3e3515e7d9 log: Never silence `log_cmd_error`
Add extra handling to arrange for `log_cmd_error` never being silenced
by the command line `-v N` option. Similar path for `log_error` exists
already.
2024-09-24 17:47:46 +02:00
Martin Povišer 3a1b003cc3 celltypes: Fix `$buf` eval 2024-09-18 16:55:02 +02:00
Martin Povišer 865df26fac Adjust buf-normalized mode 2024-09-17 10:46:20 +02:00
Claire Xenia Wolf 80119386c0 Add RTLIL "buffered-normalized mode" and improve "bufnorm" pass
Signed-off-by: Claire Xenia Wolf <claire@clairexen.net>
2024-09-17 10:46:20 +02:00
Claire Xenia Wolf d027ead4b5 Improvements in "bufnorm" pass
Signed-off-by: Claire Xenia Wolf <claire@clairexen.net>
2024-09-17 10:46:20 +02:00
Claire Xenia Wolf 4d469f461b Add coarse-grain $buf buffer cell type
Signed-off-by: Claire Xenia Wolf <claire@clairexen.net>
2024-09-17 10:46:20 +02:00
N. Engelhardt c8b42b7d48
Merge pull request #4538 from RCoeurjoly/verific_bounds 2024-09-12 13:04:04 +02:00
Mohamed Gaber 8dac27108e
Typos 2024-09-11 21:45:51 +03:00
Mohamed Gaber 738b5eef0b
Add dirname of script file to sys.path
This matches the behavior of running a Python interpreter, where the
first element of sys.path is the dirname of the script being run.

This allows importing of files and modules in the same directory without
messing with PYTHONPATH or similar.
2024-09-11 21:45:51 +03:00
Mohamed Gaber 38f9e6c3a2
-y flag for libyosys Python scripts
This adds a Python equivalent to the `-c` option, where scripts importing `libyosys` can be imported and used.

Most of the work for this was already done to enable Python passes a couple years back, so this is a relatively small changeset.
2024-09-11 21:45:51 +03:00
Roland Coeurjoly bdc43c6592 Add left and right bound properties to wire. Add test. Fix printing
for signed attributes

Co-authored-by: N. Engelhardt <nak@yosyshq.com>
Co-authored-by: Roland Coeurjoly <rolandcoeurjoly@gmail.com>
2024-09-10 12:52:42 +02:00
Miodrag Milanović b20df72e1e
Merge pull request #4536 from YosysHQ/functional
Functional Backend
2024-09-06 10:05:04 +02:00
Emil J. Tywoniak bd6f7bb4a7 ff: improve comments 2024-09-05 11:17:12 +02:00
Emily Schmidt 4eeb8d326a functional backend: rename "type" to either "kind" or "sort" to make the terminology consistent 2024-08-28 12:39:41 +01:00
Emily Schmidt b428bf4600 functional backends: identifiers in c++/smtlib may not start with digits 2024-08-27 13:10:34 +01:00
Emily Schmidt 459e6b913a add functional ir documentation 2024-08-27 11:11:02 +01:00
N. Engelhardt 0fc5812dcd
Merge pull request #4541 from YosysHQ/krys/compiler-warnings
Resolve (some) compiler warnings
2024-08-26 15:04:16 +02:00
Emily Schmidt 761eff594f functional backend: missing includes for stl containers 2024-08-22 11:13:58 +01:00
Emily Schmidt 9b5e81b13f drivertools: fix C++20 "incomplete type" error by moving constructors below other definitions 2024-08-22 10:40:56 +01:00
Emily Schmidt f456761e88 add sandia copyright notice to the functional backend 2024-08-21 11:04:11 +01:00
Emily Schmidt 831da51255 add picorv test to functional backend 2024-08-21 11:04:11 +01:00
Emily Schmidt 50047d25b3 functional backend: add different types of input/output/state variables 2024-08-21 11:04:11 +01:00
Emily Schmidt 79a1b691ea silence some more warnings, undo mistaken addition 2024-08-21 11:04:11 +01:00
Emily Schmidt 8f77494263 silence some warnings 2024-08-21 11:04:11 +01:00
Emily Schmidt fbee31080e add optional header and hashlib implementation for optional 2024-08-21 11:04:11 +01:00
Emily Schmidt 850b3a6c29 convert class FunctionalIR to a namespace Functional, rename functionalir.h to functional.h, rename functional.h to compute_graph.h 2024-08-21 11:04:08 +01:00
Emily Schmidt 8c0f625c3a functional backend: topological sort starts with the output and next states nodes, other nodes get deleted 2024-08-21 11:03:29 +01:00
Emily Schmidt 7ac0e92d35 functional backend: rename get_input and get_current_state to input and current_state (more consistent with other methods) 2024-08-21 11:03:29 +01:00
Emily Schmidt 99effb6789 add support for initializing registers and memories to the functional backend 2024-08-21 11:03:29 +01:00
Emily Schmidt 12a31a4418 add MemContents class to mem.h 2024-08-21 11:03:29 +01:00
Emily Schmidt 6d329e142d functional backend: error out if multiply driven or undriven signals are seen, dont bother putting them in functionalir 2024-08-21 11:03:29 +01:00
Emily Schmidt 145af6f10d fix memory handling in functional backend, add more error messages and comments for memory edgecases 2024-08-21 11:03:29 +01:00
Emily Schmidt 4722f13a5d functional backend: reduce $lcu to $alu 2024-08-21 11:03:29 +01:00
Emily Schmidt 3cd5f4ed83 add support for RTLIL cells with multiple outputs to the functional backend, implement $fa,$lcu,$alu 2024-08-21 11:03:29 +01:00
Emily Schmidt 13bacc5c8f eliminate pmux in functional backend 2024-08-21 11:03:29 +01:00
Emily Schmidt c0c90c2c31 functional backend: require shift width == clog2(operand width) 2024-08-21 11:03:29 +01:00
Emily Schmidt 7f8f21b980 remove widths parameters from FunctionalIR factory methods and from functionalir.cc 2024-08-21 11:03:29 +01:00
Emily Schmidt 55c2c17853 document functionalir.h and change visitors to derive from AbstractVisitor. remove extraneous widths arguments from visitors. 2024-08-21 11:03:29 +01:00
Emily Schmidt 6922633b0b fix a few bugs in the functional backend and refactor the testing 2024-08-21 11:03:29 +01:00
Emily Schmidt 9ad859fc0a add bwmux, bweqx, bmux, demux cells 2024-08-21 11:03:29 +01:00
Emily Schmidt 00a65754bb factor out SExpr/SExprWriter classes out of smtlib backend, and also tidy them up/document them 2024-08-21 11:03:27 +01:00
Emily Schmidt 9f660b1e4b rewrite smtlib pass to use SExpr class 2024-08-21 11:02:31 +01:00
Roland Coeurjoly 566e57d24f Support $lut cells. Both C++ and SMT tests pass 2024-08-21 11:02:31 +01:00
Emily Schmidt 1b2986f7fb add support for $mul, $div, $divfloor, $mod, $modfloor, $pow in functional backend 2024-08-21 11:02:31 +01:00
Emily Schmidt 9700df50d6 add generic writer class with formatting function to FunctionalTools 2024-08-21 11:02:31 +01:00
Emily Schmidt eb2bb8c45b tidy up generic functional backend, add generic scope class, tidy up c++ functional backend 2024-08-21 11:02:31 +01:00
Emily Schmidt 6f9e21219b add new generic compute graph and rewrite c++ functional backend to use it 2024-08-21 11:02:29 +01:00
Emily Schmidt 248d5f72d4 add support for std::variant to hashlib 2024-08-21 11:01:09 +01:00
Emily Schmidt dbf2bc3b1d need unsigned comparison when checking shift widths for overflow in functional backend 2024-08-21 11:01:09 +01:00
Emily Schmidt 7b29d177ac add support for memories to c++ and smtlib functional backends 2024-08-21 11:01:09 +01:00
Emily Schmidt 7611dda2eb add initial version of functional smtlib backend 2024-08-21 11:01:09 +01:00
Emily Schmidt 63dea89fac add initial version of functional C++ backend 2024-08-21 11:01:09 +01:00
Emily Schmidt dd5ec84a26 fix bugs in drivertools 2024-08-21 11:01:09 +01:00
Jannis Harder d90268f610 fixup! drivertools: Utility code for indexing and traversing signal drivers 2024-08-21 11:01:09 +01:00
Jannis Harder d4e3daa9d0 ComputeGraph datatype for the upcoming functional backend 2024-08-21 11:01:09 +01:00
Jannis Harder f29422f745 topo_scc: Add sources_first option 2024-08-21 11:01:09 +01:00
Jannis Harder 56572978f5 drivertools: Utility code for indexing and traversing signal drivers
It adds `DriveBit`, `DriveChunk` and `DriveSpec` types which are similar
to `SigBit`, `SigChunk` and `SigSpec` but can also directly represent
cell ports, undriven bits and multiple drivers. For indexing an RTLIL
module and for querying signal drivers it comes with a `DriverMap` type
which is somewhat similar to a `SigMap` but is guaranteed to produce
signal drivers as returned representatives.

A `DriverMap` can also optionally preserve connections via intermediate
wires (e.g. querying the driver of a cell input port will return a
connected intermediate wire, querying the driver of that wire will
return the cell output port that's driving the wire).
2024-08-21 11:00:21 +01:00
Jannis Harder f24e2536c6 kernel/rtlil: Add `SigBit operator[](int offset)` to `SigChunk`
This is already supported by `SigSpec` and since both `SigChunk` and
`SigSpec` implement `extract` which is the multi-bit variant of this,
there is no good reason for `SigChunk` to not support
`SigBit operator[](int offset)`.
2024-08-21 10:58:39 +01:00
Jannis Harder c73c8a39cf kernel/log: Add log_str helper for custom log_* functions/overloads
When implementing custom log_... functions or custom overloads for the
core log functions like log_signal it is necessary to return `char *`
that are valid long enough.

The log_... functions implemented in log.cc use either `log_id_cache` or
`string_buf` which both are cleared on log_pop.

This commit adds a public `log_str` function which stores its argument
in the `log_id_cache` and returns the stored copy, such that custom
log functions outside of log.cc can also create strings that remain
valid until the next `log_pop`.
2024-08-21 10:58:39 +01:00
Jannis Harder 0922142567 Add generic topological sort and SCC detection
This adds a generic non-recursive implementation of Tarjan's linear time
SCC algorithm that produces components in topological order. It can be
instantiated to work directly on any graph representation for which the
enumerate_nodes and enumerate_successors interface can be implemented.
2024-08-21 10:58:39 +01:00
Emil J. Tywoniak 4847caac49 driver: print maximum memory usage on macOS as well 2024-08-19 12:50:12 +02:00
Krystine Sherwin 7b47f645d7
Address warnings
- Setting default values
- Fixing mismatched types
- Guarding unused var
2024-08-16 04:30:31 +12:00
Emil J 92cac63845
Merge pull request #4344 from widlarizer/emil/keep_hierarchy
cost: add keep_hierarchy pass with min_cost argument
2024-07-29 16:33:08 +02:00
Emil J 051d83205d
Merge pull request #4471 from georgerennie/hashlib_primes
hashlib: Add some more primes
2024-07-29 15:10:22 +02:00
Emil J. Tywoniak 4b29f64142 cost: add model for techmapped cell count, keep_hierarchy pass with -min_cost parameter 2024-07-29 10:26:02 +02:00
Emil J 49eaa108a5
Merge pull request #4425 from YosysHQ/emil/doc-sigmap
sigmap: comments
2024-07-29 10:18:44 +02:00
Roland Coeurjoly ce11ddbf21 Simplified run_frontend by using a lambda function for file extension checks and combining blif and eblif into a single condition. 2024-07-23 17:55:04 +02:00
Roland Coeurjoly 8c1431f373 Guess VHDL frontend for both *.vhd and *vhdl files 2024-07-23 17:01:57 +02:00
Emil J. Tywoniak 583db7b15e sigmap: comments 2024-07-18 16:02:11 +02:00
Alexander von Gluck 2f514487cb haiku: Basic fixes to build under Haiku 2024-07-15 12:57:34 +02:00
George Rennie 339d4e8932 hashlib: Correct prime sequence 2024-07-02 08:10:18 +01:00
George Rennie 78ae4ed9ac hashlib: Add some more primes
* Add some primes as suggested in #4458. This allows larger hashtables
  to be allocated for very big designs
2024-07-01 12:37:41 +01:00
Martin Povišer 07daf61ae6
Merge pull request #4467 from povik/fix-add-shiftx
rtlil: Fix `addShiftx` for signed shifts
2024-06-26 18:17:28 +02:00
Martin Povišer 89d939334e rtlil: Fix `addShiftx` for signed shifts
Only the `B` input (the shift amount) can be marked as signed on a
`$shiftx` cell. Adapt the helper accordingly and prevent it from
creating invalid RTLIL when called with `is_signed` set. Previously
it would mark both `A` and `B` as signed.
2024-06-21 15:14:08 +02:00
Miodrag Milanovic 141a2e3638 Make C++17 compiler required 2024-06-17 16:55:36 +02:00
Martin Povišer fc82251105 techmap: Support dynamic cell types 2024-05-03 13:33:28 +02:00
KrystalDelusion c3ae33da33
Merge pull request #4285 from YosysHQ/typo_fixup
Typo fixing
2024-04-25 09:54:48 +12:00
Martin Povišer 178eceb32d rtlil: Replace the packed `SigSpec::extract` impl 2024-04-22 16:23:51 +02:00