Skip to content

Commit

Permalink
Sync yosys
Browse files Browse the repository at this point in the history
  • Loading branch information
akashlevy committed May 22, 2024
2 parents d2c29a1 + c71262f commit 5173e32
Show file tree
Hide file tree
Showing 28 changed files with 201 additions and 1,198 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/nix-github-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "build nix flake"
on:
pull_request:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: cachix/install-nix-action@v26
with:
install_url: https://releases.nixos.org/nix/nix-2.18.1/install
- run: nix build .?submodules=1
21 changes: 21 additions & 0 deletions .github/workflows/update-flake-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: update-flake-lock
on:
workflow_dispatch: # allows manual triggering
schedule:
- cron: '0 0 * * 0' # runs weekly on Sunday at 00:00

jobs:
lockfile:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@main
with:
pr-title: "Update flake.lock" # Title of PR to be created
pr-labels: | # Labels to be set on the PR
dependencies
automated
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ __pycache__
/tests/unit/objtest/
/tests/ystests
/build
/result

# Created during tests
/tests/arch/quicklogic/pp3/run-test.mk
Expand All @@ -57,4 +58,4 @@ __pycache__
Brewfile.lock.json

# Ignore backups
*.bak
*.bak
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ LIBS += -lrt
endif
endif

YOSYS_VER := REPLACEME
YOSYS_VER := 0.41+101

# Note: We arrange for .gitcommit to contain the (short) commit hash in
# tarballs generated with git-archive(1) using .gitattributes. The git repo
Expand Down Expand Up @@ -1002,11 +1002,12 @@ coverage:
genhtml coverage.info --output-directory coverage_html

qtcreator:
echo "$(CXXFLAGS)" | grep -o '\-D[^ ]*' | tr ' ' '\n' | sed 's/-D/#define /' | sed 's/=/ /'> qtcreator.config
{ for file in $(basename $(OBJS)); do \
for prefix in cc y l; do if [ -f $${file}.$${prefix} ]; then echo $$file.$${prefix}; fi; done \
done; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \); } > qtcreator.files
{ echo .; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \) -printf '%h\n' | sort -u; } > qtcreator.includes
touch qtcreator.config qtcreator.creator
touch qtcreator.creator

vcxsrc: $(GENFILES) $(EXTRA_TARGETS)
rm -rf yosys-win32-vcxsrc-$(YOSYS_VER){,.zip}
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
description = "A nix flake for the Yosys synthesis suite";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
# TODO: don't override src when ./abc is empty
# which happens when the command used is `nix build` and not `nix build ?submodules=1`
abc-verifier = pkgs.abc-verifier.overrideAttrs(x: y: {src = ./abc;});
yosys = pkgs.clangStdenv.mkDerivation {
name = "yosys";
src = ./. ;
buildInputs = with pkgs; [ clang bison flex libffi tcl readline python3 llvmPackages.libcxxClang zlib git pkg-configUpstream ];
checkInputs = with pkgs; [ gtest ];
propagatedBuildInputs = [ abc-verifier ];
preConfigure = "make config-clang";
checkTarget = "test";
installPhase = ''
make install PREFIX=$out ABCEXTERNAL=yosys-abc
ln -s ${abc-verifier}/bin/abc $out/bin/yosys-abc
'';
buildPhase = ''
make -j$(nproc) ABCEXTERNAL=yosys-abc
'';
meta = with pkgs.lib; {
description = "Yosys Open SYnthesis Suite";
homepage = "https://yosyshq.net/yosys/";
license = licenses.isc;
maintainers = with maintainers; [ ];
};
};
in {
packages.default = yosys;
defaultPackage = yosys;
devShell = pkgs.mkShell {
buildInputs = with pkgs; [ clang bison flex libffi tcl readline python3 llvmPackages.libcxxClang zlib git gtest abc-verifier ];
};
}
);
}
38 changes: 33 additions & 5 deletions passes/cmds/logcmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ struct LogPass : public Pass {
{
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
log("\n");
log(" log string\n");
log(" log [options] string\n");
log(" log [ -push | -pop ]\n");
log("\n");
log("Print the given string to the screen and/or the log file. This is useful for TCL\n");
log("scripts, because the TCL command \"puts\" only goes to stdout but not to\n");
Expand All @@ -52,14 +53,26 @@ struct LogPass : public Pass {
log(" -n\n");
log(" do not append a newline\n");
log("\n");
log(" -header\n");
log(" log a pass header\n");
log("\n");
log(" -push\n");
log(" push a new level on the pass counter\n");
log("\n");
log(" -push\n");
log(" pop from the pass counter\n");
log("\n");
}
void execute(std::vector<std::string> args, RTLIL::Design*) override
void execute(std::vector<std::string> args, RTLIL::Design* design) override
{
size_t argidx;
bool to_stdout = false;
bool to_stderr = false;
bool to_log = true;
bool newline = true;
bool header = false;
bool push = false;
bool pop = false;
std::string text;

for (argidx = 1; argidx < args.size(); argidx++)
Expand All @@ -68,15 +81,30 @@ struct LogPass : public Pass {
else if (args[argidx] == "-stderr") to_stderr = true;
else if (args[argidx] == "-nolog") to_log = false;
else if (args[argidx] == "-n") newline = false;
else if (args[argidx] == "-header") header = true;
else if (args[argidx] == "-push") push = true;
else if (args[argidx] == "-pop") pop = true;
else break;
}

if ((push || pop) && args.size() != 2)
log_cmd_error("Bad usage: 'log -push' or 'log -pop' must be used without other arguments.\n");

if (push) { log_push(); return; }
if (pop) { log_pop(); return; }

for (; argidx < args.size(); argidx++)
text += args[argidx] + ' ';
if (!text.empty()) text.resize(text.size()-1);

if (to_stdout) fprintf(stdout, (newline ? "%s\n" : "%s"), text.c_str());
if (to_stderr) fprintf(stderr, (newline ? "%s\n" : "%s"), text.c_str());
if (to_log) log ( (newline ? "%s\n" : "%s"), text.c_str());
const char *fmtline = newline ? "%s\n" : "%s";

if (to_stdout) fprintf(stdout, fmtline, text.c_str());
if (to_stderr) fprintf(stderr, fmtline, text.c_str());
if (to_log) {
if (!header) log(fmtline, text.c_str());
else log_header(design, fmtline, text.c_str());
}
}
} LogPass;

Expand Down
3 changes: 0 additions & 3 deletions techlibs/intel_alm/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ $(eval $(call add_share_file,share/intel_alm/cyclonev,techlibs/intel_alm/cyclone
# RAM
$(eval $(call add_share_file,share/intel_alm/common,techlibs/intel_alm/common/bram_m10k.txt))
$(eval $(call add_share_file,share/intel_alm/common,techlibs/intel_alm/common/bram_m10k_map.v))
$(eval $(call add_share_file,share/intel_alm/common,techlibs/intel_alm/common/bram_m20k.txt))
$(eval $(call add_share_file,share/intel_alm/common,techlibs/intel_alm/common/bram_m20k_map.v))
$(eval $(call add_share_file,share/intel_alm/common,techlibs/intel_alm/common/lutram_mlab.txt))

# Miscellaneous
$(eval $(call add_share_file,share/intel_alm/common,techlibs/intel_alm/common/megafunction_bb.v))
$(eval $(call add_share_file,share/intel_alm/common,techlibs/intel_alm/common/quartus_rename.v))
Loading

0 comments on commit 5173e32

Please sign in to comment.