Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added yosys-abc and volare,fix syntax error ,end synthesys with genus #828

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions hardware/common_src/iob_soc_mwrap.v
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ wire [ DATA_W-1:0] d_rdata;
//

`ifdef USE_SPRAM
wire en;
wire [SRAM_ADDR_W-3:0] addr;
wire [DATA_W/8-1:0] we;
wire [DATA_W-1:0] di;
wire [DATA_W-1:0] do;
wire spram_en;
wire [SRAM_ADDR_W-3:0] spram_addr;
wire [DATA_W/8-1:0] spram_we;
wire [DATA_W-1:0] spram_di;
wire [DATA_W-1:0] spram_do;
`endif

iob_soc #(
Expand Down Expand Up @@ -116,11 +116,11 @@ iob_soc #(
.uart_rts_o( uart_rts_o),
//SPRAM
`ifdef USE_SPRAM
.valid_spram_o(en),
.addr_spram_o(addr),
.wstrb_spram_o(we),
.wdata_spram_o(di),
.rdata_spram_i(do),
.valid_spram_o(spram_en),
.addr_spram_o(spram_addr),
.wstrb_spram_o(spram_we),
.wdata_spram_o(spram_di),
.rdata_spram_i(spram_do),
`endif

//rom
Expand Down Expand Up @@ -153,11 +153,11 @@ iob_soc #(
) main_mem_byte (
.clk_i(clk_i),
// data port
.en_i (en),
.addr_i(addr),
.we_i (wstrb),
.d_i (wdata),
.dt_o (rdata)
.en_i (spram_en),
.addr_i(spram_addr),
.we_i (spram_we),
.d_i (spram_di),
.dt_o (spram_do)
);
`else
`ifdef IOB_MEM_NO_READ_ON_WRITE
Expand Down
1 change: 1 addition & 0 deletions hardware/syn/syn_build.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set_db hdl_error_on_latch false
25 changes: 19 additions & 6 deletions submodules/LIB/hardware/syn/build.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ set_db init_hdl_search_path $INCLUDE
set_db stdout_log genus.log
set_db information_level 7
set_db super_thread_debug_directory st_part_log

set_db hdl_error_on_latch true
set_db hdl_error_on_latch true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed? Isn't true the default?

Copy link
Contributor Author

@Vasco-Luz Vasco-Luz Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code already had it set as true. I didn't even think about that. But I will test and see the default value

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but I still don't know the answer

Copy link
Contributor Author

@Vasco-Luz Vasco-Luz Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just tested, the standard the latch error is false. i removed the set from the syn_build.tcl and removed from the set from the build tcl, and it gave no synthesis warnings.

if {[file exists "syn_build.tcl"]} {
source "syn_build.tcl"
}
set_db lp_power_analysis_effort medium
set_db lp_power_unit uW

Expand Down Expand Up @@ -124,10 +126,21 @@ check_design -unresolved

# add optimization constraints
#----------------------------------------------------------------------
read_sdc -stop_on_error ./$NODE/$NAME\_dev.sdc
read_sdc -stop_on_error ./src/$NAME.sdc
read_sdc -stop_on_error ./src/$NAME\_$CSR_IF.sdc
read_sdc -stop_on_error ./$NAME\_tool.sdc
if {[file exists ./$NODE/$NAME\_dev.sdc]} {
read_sdc -stop_on_error ./$NODE/$NAME\_dev.sdc
}

if {[file exists ./src/$NAME.sdc]} {
read_sdc -stop_on_error ./src/$NAME.sdc
}

if {[file exists ./src/$NAME\_$CSR_IF.sdc]} {
read_sdc -stop_on_error ./src/$NAME\_$CSR_IF.sdc
}

if {[file exists ./$NAME\_tool.sdc]} {
read_sdc -stop_on_error ./$NAME\_tool.sdc
}

check_timing_intent

Expand Down
18 changes: 17 additions & 1 deletion submodules/LIB/scripts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
# Hash obtained using `nix-prefetch-url --unpack <url>`
sha256 = "11w3wn2yjhaa5pv20gbfbirvjq6i3m7pqrq2msf0g7cv44vijwgw";
}) {}}:

let
yosys = import ./yosys.nix { inherit pkgs; };
in
pkgs.mkShell {
name = "iob-shell";
buildInputs = with pkgs; [
buildInputs = with pkgs; [
bash
gnumake
verilog
Expand All @@ -32,5 +36,17 @@ pkgs.mkShell {
libreoffice
minicom # Terminal emulator
lrzsz # For Zmodem file transfers via serial connection of the terminal emulator
# Add Volare custom Python installation
(let
volareSrc = pkgs.fetchFromGitHub {
owner = "efabless";
repo = "volare";
rev = "47325949b87e857d75f81d306f02ebccf952cb15";
sha256 = "sha256-H9B/vZUs0O2jwmidCTMYhO0JY4DL+gmQNeVawaccvuU=";
};
in import "${volareSrc}" {
inherit pkgs;
})
yosys
];
}
6 changes: 0 additions & 6 deletions submodules/LIB/scripts/iob_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,12 +740,6 @@ def _copy_srcs(cls, exclude_file_list=[], highest_superclass=None):
),
)
continue
elif directory == "hardware/common_src":
shutil.copytree(
os.path.join(os.getcwd(), directory),
Copy link
Contributor Author

@Vasco-Luz Vasco-Luz Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this lines is something that i added in an old commit but they serve no purpose, because the directory(common_src) is copied ether way in the last else. and worst maybe they are causing problems with other cores.

os.path.join(cls.build_dir, directory),
dirs_exist_ok=False,
)
elif directory == "hardware/fpga":
# Skip if board_list is empty
if cls.board_list is None:
Expand Down
14 changes: 14 additions & 0 deletions submodules/LIB/scripts/patches/yosys/abc-editline.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/src/base/main/mainUtils.c b/src/base/main/mainUtils.c
index 245e936a..0a3cde72 100644
--- a/src/base/main/mainUtils.c
+++ b/src/base/main/mainUtils.c
@@ -22,8 +22,7 @@
#include "mainInt.h"

#ifdef ABC_USE_READLINE
-#include <readline/readline.h>
-#include <readline/history.h>
+#include <editline/readline.h>
#endif

ABC_NAMESPACE_IMPL_START
13 changes: 13 additions & 0 deletions submodules/LIB/scripts/patches/yosys/fix-clang-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/Makefile b/Makefile
index 86abc6958..a72f7b792 100644
--- a/Makefile
+++ b/Makefile
@@ -187,7 +192,7 @@ endif
endif

ifeq ($(CONFIG),clang)
-CXX = clang
+CXX = clang++
LD = clang++
CXXFLAGS += -std=$(CXXSTD) -Os
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H"
46 changes: 46 additions & 0 deletions submodules/LIB/scripts/patches/yosys/plugin-search-dirs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
diff --git a/passes/cmds/plugin.cc b/passes/cmds/plugin.cc
index 08b4aa8c4..1b7639bc9 100644
--- a/passes/cmds/plugin.cc
+++ b/passes/cmds/plugin.cc
@@ -87,15 +87,34 @@ void load_plugin(std::string filename, std::vector<std::string> aliases)

// We were unable to open the file, try to do so from the plugin directory
if (hdl == NULL && orig_filename.find('/') == std::string::npos) {
- hdl = dlopen([orig_filename]() {
- std::string new_path = proc_share_dirname() + "plugins/" + orig_filename;
+ std::string install_dir = proc_share_dirname() + "plugins";
+ std::vector<std::string> all_dirs;
+ all_dirs.push_back(install_dir);

- // Check if we need to append .so
- if (new_path.find(".so") == std::string::npos)
- new_path.append(".so");
+ char* plugin_dirs = getenv("NIX_YOSYS_PLUGIN_DIRS");

- return new_path;
- }().c_str(), RTLD_LAZY|RTLD_LOCAL);
+ if (plugin_dirs != NULL) {
+ std::string p(plugin_dirs), t;
+ std::stringstream ss(p);
+
+ while(std::getline(ss, t, ':')) {
+ all_dirs.push_back(t);
+ }
+ }
+
+ for (auto dir : all_dirs) {
+ hdl = dlopen([&]() {
+ std::string new_path = dir + "/" + orig_filename;
+
+ // Check if we need to append .so
+ if (new_path.find(".so") == std::string::npos)
+ new_path.append(".so");
+
+ return new_path;
+ }().c_str(), RTLD_LAZY|RTLD_LOCAL);
+ if (hdl != NULL)
+ break;
+ }
}

if (hdl == NULL)
67 changes: 67 additions & 0 deletions submodules/LIB/scripts/yosys-abc.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright 2023 Efabless Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Copyright (c) 2003-2023 Eelco Dolstra and the Nixpkgs/NixOS contributors
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

{ pkgs ? import <nixpkgs> {} }:

let
lib = pkgs.lib;
cmake = pkgs.cmake;
libedit = pkgs.libedit;
rev = "896e5e7dedf9b9b1459fa019f1fa8aa8101fdf43";
yosys_abc_src = pkgs.fetchFromGitHub {
owner = "YosysHQ";
repo = "abc";
rev = rev;
sha256 = "sha256-sMBCIV698TIvU/sgTwgPFWDC1kl2TeGv+3pQ06gs7aM=";
};
yosys_abc = pkgs.clangStdenv.mkDerivation rec {
name = "yosys-abc";
src = yosys_abc_src;
patches = [
./patches/yosys/abc-editline.patch
];
postPatch = ''
sed -i "s@-lreadline@-ledit@" ./Makefile
'';
nativeBuildInputs = [ cmake ];
buildInputs = [ libedit ];
installPhase = "mkdir -p $out/bin && mv abc $out/bin";
passthru.rev = rev;
meta = with lib; {
description = "A tool for squential logic synthesis and formal verification (YosysHQ's Fork)";
homepage = "https://people.eecs.berkeley.edu/~alanmi/abc";
license = licenses.mit;
mainProgram = "abc";
platforms = platforms.unix;
};
};
in
yosys_abc
111 changes: 111 additions & 0 deletions submodules/LIB/scripts/yosys.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{ pkgs ? import <nixpkgs> {} }:

let
yosys_abc = import ./yosys-abc.nix { inherit pkgs; };

symlinkJoin = pkgs.symlinkJoin;
python3 = pkgs.python3;
lib = pkgs.lib;
makeWrapper = pkgs.makeWrapper;
clangStdenv = pkgs.clangStdenv;
fetchFromGitHub = pkgs.fetchFromGitHub;
pkg-config = pkgs.pkg-config;
bison = pkgs.bison;
flex = pkgs.flex;
tcl = pkgs.tcl;
libedit = pkgs.libedit;
libbsd = pkgs.libbsd;
libffi = pkgs.libffi;
zlib = pkgs.zlib;

py3env = python3.withPackages (pp:
with pp; [
click
xmlschema
]);

yosys = clangStdenv.mkDerivation rec {
name = "yosys";

src = fetchFromGitHub {
owner = "YosysHQ";
repo = "yosys";
rev = "543faed9c8cd7c33bbb407577d56e4b7444ba61c";
sha256 = "sha256-mzMBhnIEgToez6mGFOvO7zBA+rNivZ9OnLQsjBBDamA=";
};

nativeBuildInputs = [pkg-config bison flex];
propagatedBuildInputs = [yosys_abc];

buildInputs = [
tcl
libedit
libbsd
libffi
zlib
py3env
];

passthru = {
inherit py3env;
inherit withPlugins;
};

patches = [
./patches/yosys/fix-clang-build.patch
./patches/yosys/plugin-search-dirs.patch
];

postPatch = ''
substituteInPlace ./Makefile \
--replace 'echo UNKNOWN' 'echo ${builtins.substring 0 10 src.rev}'

chmod +x ./misc/yosys-config.in
patchShebangs tests ./misc/yosys-config.in

sed -i 's@ENABLE_EDITLINE := 0@ENABLE_EDITLINE := 1@' Makefile
sed -i 's@ENABLE_READLINE := 1@ENABLE_READLINE := 0@' Makefile
sed -Ei 's@PRETTY = 1@PRETTY = 0@' ./Makefile
'';

preBuild = let
shortAbcRev = builtins.substring 0 7 yosys_abc.rev;
in ''
chmod -R u+w .
make config-clang

echo 'ABCEXTERNAL = ${yosys_abc}/bin/abc' >> Makefile.conf

if ! grep -q "ABCREV = ${shortAbcRev}" Makefile; then
echo "ERROR: yosys isn't compatible with the provided abc (${yosys_abc}), failing."
exit 1
fi
'';

postBuild = "ln -sfv ${yosys_abc}/bin/abc ./yosys-abc";
postInstall = "ln -sfv ${yosys_abc}/bin/abc $out/bin/yosys-abc";

makeFlags = ["PREFIX=${placeholder "out"}"];
doCheck = false;
enableParallelBuilding = true;
};

withPlugins = plugins: let
paths = lib.closePropagation plugins;
dylibs = lib.lists.flatten (map (n: n.dylibs) plugins);
in let
module_flags = with builtins;
concatStringsSep " "
(map (so: "--add-flags -m --add-flags ${so}") dylibs);
in (symlinkJoin {
name = "${yosys.name}-with-plugins";
paths = paths ++ [yosys];
nativeBuildInputs = [makeWrapper];
postBuild = ''
wrapProgram $out/bin/yosys \
--set NIX_YOSYS_PLUGIN_DIRS $out/share/yosys/plugins \
${module_flags}
'';
});
in
yosys
Loading