mirror of
https://github.com/YosysHQ/yosys
synced 2026-05-25 19:36:21 +00:00
Migrate build system to CMake
See #5895 for details. This commit does not include CI or documentation changes.
This commit is contained in:
parent
9d0cdb8551
commit
cad5353a2a
208 changed files with 5285 additions and 2294 deletions
186
kernel/CMakeLists.txt
Normal file
186
kernel/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
yosys_version_file(version.cc.in version.cc)
|
||||
configure_file(yosys_config.h.in yosys_config.h @ONLY)
|
||||
|
||||
set(cellhelp_sources)
|
||||
foreach (library simlib simcells)
|
||||
add_custom_command(
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cellhelp.py ${CMAKE_SOURCE_DIR}/techlibs/common/${library}.v
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${library}_help.inc
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cellhelp.py
|
||||
${CMAKE_SOURCE_DIR}/techlibs/common/${library}.v
|
||||
> ${CMAKE_CURRENT_BINARY_DIR}/${library}_help.inc
|
||||
VERBATIM
|
||||
)
|
||||
list(APPEND cellhelp_sources ${CMAKE_CURRENT_BINARY_DIR}/${library}_help.inc)
|
||||
endforeach()
|
||||
|
||||
yosys_core(kernel
|
||||
binding.cc
|
||||
binding.h
|
||||
bitpattern.h
|
||||
calc.cc
|
||||
cellaigs.cc
|
||||
cellaigs.h
|
||||
celledges.cc
|
||||
celledges.h
|
||||
celltypes.h
|
||||
compute_graph.h
|
||||
consteval.h
|
||||
constids.inc
|
||||
cost.cc
|
||||
cost.h
|
||||
drivertools.cc
|
||||
drivertools.h
|
||||
ff.cc
|
||||
ff.h
|
||||
ffinit.h
|
||||
ffmerge.cc
|
||||
ffmerge.h
|
||||
fmt.cc
|
||||
fmt.h
|
||||
functional.cc
|
||||
functional.h
|
||||
gzip.cc
|
||||
gzip.h
|
||||
hashlib.h
|
||||
io.cc
|
||||
io.h
|
||||
json.cc
|
||||
json.h
|
||||
log.cc
|
||||
log.h
|
||||
$<${YOSYS_ENABLE_VERIFIC}:log_compat.cc>
|
||||
log_help.cc
|
||||
log_help.h
|
||||
macc.h
|
||||
mem.cc
|
||||
mem.h
|
||||
modtools.h
|
||||
newcelltypes.h
|
||||
pattern.h
|
||||
qcsat.cc
|
||||
qcsat.h
|
||||
register.cc
|
||||
register.h
|
||||
${cellhelp_sources}
|
||||
rtlil_bufnorm.cc
|
||||
rtlil.cc
|
||||
rtlil.h
|
||||
satgen.cc
|
||||
satgen.h
|
||||
scopeinfo.cc
|
||||
scopeinfo.h
|
||||
sexpr.cc
|
||||
sexpr.h
|
||||
sigtools.h
|
||||
tclapi.cc
|
||||
threading.cc
|
||||
threading.h
|
||||
timinginfo.h
|
||||
topo_scc.h
|
||||
utils.h
|
||||
version.cc
|
||||
wallace_tree.h
|
||||
yosys.cc
|
||||
yosys_common.h
|
||||
yosys_config.h
|
||||
yosys.h
|
||||
yw.cc
|
||||
yw.h
|
||||
INCLUDE_DIRS
|
||||
${pybind11_INCLUDE_DIR}
|
||||
LIBRARIES
|
||||
cxxopts
|
||||
$<${YOSYS_ENABLE_PLUGINS}:${Dlfcn_LIBRARIES}>
|
||||
$<${YOSYS_ENABLE_ZLIB}:PkgConfig::zlib>
|
||||
$<${YOSYS_ENABLE_READLINE}:PkgConfig::readline>
|
||||
$<${YOSYS_ENABLE_EDITLINE}:PkgConfig::editline>
|
||||
$<${YOSYS_ENABLE_TCL}:PkgConfig::tcl>
|
||||
$<${YOSYS_ENABLE_PYTHON}:Python3::Python>
|
||||
REQUIRES
|
||||
bigint
|
||||
ezsat
|
||||
json11
|
||||
sha1
|
||||
PROVIDES
|
||||
help
|
||||
echo
|
||||
license
|
||||
tcl
|
||||
shell
|
||||
history
|
||||
script
|
||||
DATA_DIR
|
||||
include/kernel
|
||||
DATA_FILES
|
||||
binding.h
|
||||
bitpattern.h
|
||||
cellaigs.h
|
||||
celledges.h
|
||||
celltypes.h
|
||||
newcelltypes.h
|
||||
consteval.h
|
||||
constids.inc
|
||||
cost.h
|
||||
drivertools.h
|
||||
ff.h
|
||||
ffinit.h
|
||||
ffmerge.h
|
||||
fmt.h
|
||||
gzip.h
|
||||
hashlib.h
|
||||
io.h
|
||||
json.h
|
||||
log.h
|
||||
macc.h
|
||||
modtools.h
|
||||
mem.h
|
||||
qcsat.h
|
||||
register.h
|
||||
rtlil.h
|
||||
satgen.h
|
||||
scopeinfo.h
|
||||
sexpr.h
|
||||
sigtools.h
|
||||
threading.h
|
||||
timinginfo.h
|
||||
utils.h
|
||||
yosys.h
|
||||
yosys_common.h
|
||||
yw.h
|
||||
DATA_EXPLICIT
|
||||
yosys_config.h ${CMAKE_CURRENT_BINARY_DIR}/yosys_config.h
|
||||
ESSENTIAL
|
||||
)
|
||||
|
||||
set(yosys_cc_definitions
|
||||
"$<$<BOOL:${YOSYS_ABC_EXECUTABLE}>:ABCEXTERNAL=\"${YOSYS_ABC_EXECUTABLE}\">"
|
||||
$<$<BOOL:${MSYS}>:YOSYS_WIN32_UNIX_DIR>
|
||||
)
|
||||
set_source_files_properties(yosys.cc PROPERTIES
|
||||
COMPILE_DEFINITIONS "${yosys_cc_definitions}"
|
||||
)
|
||||
|
||||
yosys_core(fstdata
|
||||
fstdata.cc
|
||||
fstdata.h
|
||||
REQUIRES
|
||||
fst
|
||||
DATA_DIR
|
||||
include/kernel
|
||||
DATA_FILES
|
||||
fstdata.h
|
||||
)
|
||||
|
||||
yosys_core(driver
|
||||
driver.cc
|
||||
INCLUDE_DIRS
|
||||
${pybind11_INCLUDE_DIR}
|
||||
LIBRARIES
|
||||
$<${YOSYS_ENABLE_READLINE}:PkgConfig::readline>
|
||||
$<${YOSYS_ENABLE_EDITLINE}:PkgConfig::editline>
|
||||
$<${YOSYS_ENABLE_TCL}:PkgConfig::tcl>
|
||||
$<${YOSYS_ENABLE_PYTHON}:Python3::Python>
|
||||
REQUIRES
|
||||
essentials
|
||||
)
|
||||
100
kernel/cellhelp.py
Normal file
100
kernel/cellhelp.py
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from __future__ import annotations
|
||||
import fileinput
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
class SimHelper:
|
||||
name: str = ""
|
||||
title: str = ""
|
||||
ports: str = ""
|
||||
source: str = ""
|
||||
desc: list[str]
|
||||
code: list[str]
|
||||
group: str = ""
|
||||
ver: str = "1"
|
||||
tags: list[str]
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.desc = []
|
||||
self.tags = []
|
||||
|
||||
def __str__(self) -> str:
|
||||
printed_fields = [
|
||||
"name", "title", "ports", "source", "desc", "code", "group", "ver",
|
||||
"tags",
|
||||
]
|
||||
# generate C++ struct
|
||||
val = f"cell_help[{json.dumps(self.name)}] = "
|
||||
val += "{\n"
|
||||
for field in printed_fields:
|
||||
field_val = getattr(self, field)
|
||||
if isinstance(field_val, list):
|
||||
field_val = "\n".join(field_val)
|
||||
field_val = field_val.strip()
|
||||
val += f' {json.dumps(field_val)},\n'
|
||||
val += "};\n"
|
||||
return val
|
||||
|
||||
def simcells_reparse(cell: SimHelper):
|
||||
# cut manual signature
|
||||
cell.desc = cell.desc[3:]
|
||||
|
||||
# code-block truth table
|
||||
new_desc = []
|
||||
indent = ""
|
||||
for line in cell.desc:
|
||||
if line.startswith("Truth table:"):
|
||||
indent = " "
|
||||
new_desc.pop()
|
||||
new_desc.extend(["::", ""])
|
||||
new_desc.append(indent + line)
|
||||
cell.desc = new_desc
|
||||
|
||||
# set version
|
||||
cell.ver = "2a"
|
||||
|
||||
simHelper = SimHelper()
|
||||
|
||||
for line in fileinput.input():
|
||||
line = line.rstrip()
|
||||
# special comments
|
||||
if line.startswith("//-"):
|
||||
simHelper.desc.append(line[4:] if len(line) > 4 else "")
|
||||
elif line.startswith("//* "):
|
||||
_, key, val = line.split(maxsplit=2)
|
||||
setattr(simHelper, key, val)
|
||||
|
||||
# code parsing
|
||||
if line.startswith("module "):
|
||||
clean_line = line[7:].replace("\\", "").replace(";", "")
|
||||
simHelper.name, simHelper.ports = clean_line.split(maxsplit=1)
|
||||
simHelper.code = []
|
||||
short_filename = Path(fileinput.filename()).name
|
||||
simHelper.source = f'{short_filename}:{fileinput.filelineno()}'
|
||||
elif not line.startswith("endmodule"):
|
||||
line = " " + line
|
||||
try:
|
||||
simHelper.code.append(line.replace("\t", " "))
|
||||
except AttributeError:
|
||||
# no module definition, ignore line
|
||||
pass
|
||||
if line.startswith("endmodule"):
|
||||
short_filename = Path(fileinput.filename()).name
|
||||
if simHelper.ver == "1" and short_filename == "simcells.v":
|
||||
# default simcells parsing
|
||||
simcells_reparse(simHelper)
|
||||
|
||||
# check help
|
||||
if simHelper.desc and simHelper.ver == "1" and short_filename == "simlib.v" and simHelper.desc[1].startswith(' '):
|
||||
simHelper.desc.pop(1)
|
||||
|
||||
# check group
|
||||
assert simHelper.group, f"techlibs/common/{simHelper.source}: {simHelper.name} cell missing group"
|
||||
|
||||
# dump
|
||||
print(simHelper)
|
||||
# new
|
||||
simHelper = SimHelper()
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ static std::string file_base_name(std::string const & path)
|
|||
|
||||
FstData::FstData(std::string filename) : ctx(nullptr)
|
||||
{
|
||||
#if !defined(YOSYS_DISABLE_SPAWN)
|
||||
#if defined(YOSYS_ENABLE_SPAWN)
|
||||
std::string filename_trim = file_base_name(filename);
|
||||
if (filename_trim.size() > 4 && filename_trim.compare(filename_trim.size()-4, std::string::npos, ".vcd") == 0) {
|
||||
filename_trim.erase(filename_trim.size()-4);
|
||||
|
|
@ -87,18 +87,18 @@ static void normalize_brackets(std::string &str)
|
|||
}
|
||||
}
|
||||
|
||||
fstHandle FstData::getHandle(std::string name) {
|
||||
fstHandle FstData::getHandle(std::string name) {
|
||||
normalize_brackets(name);
|
||||
if (name_to_handle.find(name) != name_to_handle.end())
|
||||
return name_to_handle[name];
|
||||
else
|
||||
else
|
||||
return 0;
|
||||
};
|
||||
|
||||
dict<int,fstHandle> FstData::getMemoryHandles(std::string name) {
|
||||
dict<int,fstHandle> FstData::getMemoryHandles(std::string name) {
|
||||
if (memory_to_handle.find(name) != memory_to_handle.end())
|
||||
return memory_to_handle[name];
|
||||
else
|
||||
else
|
||||
return dict<int,fstHandle>();
|
||||
};
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ void FstData::extractVarNames()
|
|||
handle_to_var[h->u.var.handle] = var;
|
||||
std::string clean_name;
|
||||
bool has_space = false;
|
||||
for(size_t i=0;i<strlen(h->u.var.name);i++)
|
||||
for(size_t i=0;i<strlen(h->u.var.name);i++)
|
||||
{
|
||||
char c = h->u.var.name[i];
|
||||
if(c==' ') { has_space = true; break; }
|
||||
|
|
@ -210,7 +210,7 @@ void FstData::reconstruct_callback_attimes(uint64_t pnt_time, fstHandle pnt_faci
|
|||
bool is_clock = false;
|
||||
if (!all_samples) {
|
||||
for(auto &s : clk_signals) {
|
||||
if (s==pnt_facidx) {
|
||||
if (s==pnt_facidx) {
|
||||
is_clock=true;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
#if defined(YOSYS_ENABLE_DLOPEN)
|
||||
# include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
|
|
@ -471,7 +471,7 @@ void log_pop()
|
|||
log_flush();
|
||||
}
|
||||
|
||||
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(YOSYS_ENABLE_PLUGINS)
|
||||
#if defined(YOSYS_ENABLE_DLOPEN)
|
||||
void log_backtrace(const char *prefix, int levels)
|
||||
{
|
||||
if (levels <= 0) return;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ void try_collect_garbage()
|
|||
RTLIL::OwningIdString::collect_garbage();
|
||||
}
|
||||
|
||||
Pass::Pass(std::string name, std::string short_help, source_location location) :
|
||||
Pass::Pass(std::string name, std::string short_help, source_location location) :
|
||||
pass_name(name), short_help(short_help), location(location)
|
||||
{
|
||||
next_queued_pass = first_queued_pass;
|
||||
|
|
@ -217,7 +217,7 @@ void Pass::call(RTLIL::Design *design, std::string command)
|
|||
return;
|
||||
|
||||
if (tok[0] == '!') {
|
||||
#if !defined(YOSYS_DISABLE_SPAWN)
|
||||
#if defined(YOSYS_ENABLE_SPAWN)
|
||||
cmd_buf = command.substr(command.find('!') + 1);
|
||||
while (!cmd_buf.empty() && (cmd_buf.back() == ' ' || cmd_buf.back() == '\t' ||
|
||||
cmd_buf.back() == '\r' || cmd_buf.back() == '\n'))
|
||||
|
|
@ -741,8 +741,8 @@ static void log_warning_flags(Pass *pass) {
|
|||
static struct CellHelpMessages {
|
||||
dict<string, SimHelper> cell_help;
|
||||
CellHelpMessages() {
|
||||
#include "techlibs/common/simlib_help.inc"
|
||||
#include "techlibs/common/simcells_help.inc"
|
||||
#include "kernel/simlib_help.inc"
|
||||
#include "kernel/simcells_help.inc"
|
||||
cell_help.sort();
|
||||
}
|
||||
bool contains(string name) { return cell_help.count(get_cell_name(name)) > 0; }
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#include <deque>
|
||||
|
||||
#include "kernel/yosys_common.h"
|
||||
#include "kernel/log.h"
|
||||
#include "kernel/utils.h"
|
||||
|
||||
#ifdef YOSYS_ENABLE_THREADS
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#endif
|
||||
|
||||
#include "kernel/yosys_common.h"
|
||||
#include "kernel/log.h"
|
||||
#include "kernel/utils.h"
|
||||
|
||||
#ifndef YOSYS_THREADING_H
|
||||
#define YOSYS_THREADING_H
|
||||
|
||||
|
|
|
|||
4
kernel/version.cc.in
Normal file
4
kernel/version.cc.in
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
namespace Yosys {
|
||||
const char *yosys_version_str = "@YOSYS_BUILD_INFO@";
|
||||
const char *yosys_git_hash_str = "@YOSYS_CHECKOUT_INFO@";
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ namespace py = pybind11;
|
|||
# include <dirent.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# if !defined(YOSYS_DISABLE_SPAWN)
|
||||
# if defined(YOSYS_ENABLE_SPAWN)
|
||||
# include <sys/wait.h>
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -179,7 +179,7 @@ void yosys_banner()
|
|||
log(" %s\n", yosys_maybe_version());
|
||||
}
|
||||
|
||||
#if !defined(YOSYS_DISABLE_SPAWN)
|
||||
#if defined(YOSYS_ENABLE_SPAWN)
|
||||
int run_command(const std::string &command, std::function<void(const std::string&)> process_line)
|
||||
{
|
||||
if (!process_line)
|
||||
|
|
@ -636,13 +636,11 @@ void init_share_dirname()
|
|||
yosys_share_dirname = proc_share_path;
|
||||
return;
|
||||
}
|
||||
# ifdef YOSYS_DATDIR
|
||||
proc_share_path = YOSYS_DATDIR "/";
|
||||
if (check_directory_exists(proc_share_path, true)) {
|
||||
yosys_share_dirname = proc_share_path;
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
|
@ -684,11 +682,7 @@ std::string proc_share_dirname()
|
|||
|
||||
std::string proc_program_prefix()
|
||||
{
|
||||
std::string program_prefix;
|
||||
#ifdef YOSYS_PROGRAM_PREFIX
|
||||
program_prefix = YOSYS_PROGRAM_PREFIX;
|
||||
#endif
|
||||
return program_prefix;
|
||||
return YOSYS_PROGRAM_PREFIX;
|
||||
}
|
||||
|
||||
bool fgetline(FILE *f, std::string &buffer)
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@
|
|||
defines the Yosys Makefile would set for your build configuration.
|
||||
#endif
|
||||
|
||||
#include "kernel/yosys_config.h"
|
||||
|
||||
#define FRIEND_TEST(test_case_name, test_name) \
|
||||
friend class test_case_name##_##test_name##_Test
|
||||
|
||||
|
|
@ -91,6 +93,8 @@
|
|||
# undef CONST
|
||||
// `wingdi.h` defines a TRANSPARENT macro that conflicts with X(TRANSPARENT) entry in kernel/constids.inc
|
||||
# undef TRANSPARENT
|
||||
// `wingdi.h` defines an ERROR macro that conflicts with `ERROR()` macro in kernel/tclapi.cc
|
||||
# undef ERROR
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
|
|
|
|||
22
kernel/yosys_config.h.in
Normal file
22
kernel/yosys_config.h.in
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef YOSYS_CONFIG_H
|
||||
#define YOSYS_CONFIG_H
|
||||
|
||||
// Installation parameters
|
||||
#define YOSYS_PROGRAM_PREFIX "@YOSYS_PROGRAM_PREFIX@"
|
||||
#define YOSYS_DATDIR "@YOSYS_INSTALL_DATADIR@"
|
||||
|
||||
// Feature toggles
|
||||
#cmakedefine YOSYS_ENABLE_GLOB
|
||||
#cmakedefine YOSYS_ENABLE_SPAWN
|
||||
#cmakedefine YOSYS_ENABLE_THREADS
|
||||
#cmakedefine YOSYS_ENABLE_DLOPEN
|
||||
#cmakedefine YOSYS_ENABLE_ZLIB
|
||||
#cmakedefine YOSYS_ENABLE_PLUGINS
|
||||
#cmakedefine YOSYS_ENABLE_READLINE
|
||||
#cmakedefine YOSYS_ENABLE_EDITLINE
|
||||
#cmakedefine YOSYS_ENABLE_TCL
|
||||
#cmakedefine YOSYS_ENABLE_PYTHON
|
||||
#cmakedefine YOSYS_ENABLE_VERIFIC
|
||||
#cmakedefine YOSYS_ENABLE_HELP_SOURCE
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue