mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-23 22:33:41 +00:00
Merge branch 'YosysHQ:main' into main
This commit is contained in:
commit
8bb193d7c5
13 changed files with 6393 additions and 6309 deletions
2
Makefile
2
Makefile
|
@ -168,7 +168,7 @@ ifeq ($(OS), Haiku)
|
||||||
CXXFLAGS += -D_DEFAULT_SOURCE
|
CXXFLAGS += -D_DEFAULT_SOURCE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
YOSYS_VER := 0.47+201
|
YOSYS_VER := 0.47+211
|
||||||
|
|
||||||
# Note: We arrange for .gitcommit to contain the (short) commit hash in
|
# Note: We arrange for .gitcommit to contain the (short) commit hash in
|
||||||
# tarballs generated with git-archive(1) using .gitattributes. The git repo
|
# tarballs generated with git-archive(1) using .gitattributes. The git repo
|
||||||
|
|
|
@ -169,6 +169,10 @@ public:
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int hash() const {
|
||||||
|
return mkhash(scope_name.hash(), hash_ptr_ops::hash(target));
|
||||||
|
}
|
||||||
|
|
||||||
bool valid() const {
|
bool valid() const {
|
||||||
return target != nullptr;
|
return target != nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,3 +59,4 @@ OBJS += passes/cmds/splitnetlist.o
|
||||||
OBJS += passes/cmds/reconstructbusses.o
|
OBJS += passes/cmds/reconstructbusses.o
|
||||||
|
|
||||||
OBJS += passes/cmds/wrapcell.o
|
OBJS += passes/cmds/wrapcell.o
|
||||||
|
OBJS += passes/cmds/setenv.o
|
||||||
|
|
58
passes/cmds/setenv.cc
Normal file
58
passes/cmds/setenv.cc
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* yosys -- Yosys Open SYnthesis Suite
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 N. Engelhardt <nak@yosyshq.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "kernel/register.h"
|
||||||
|
#include "kernel/rtlil.h"
|
||||||
|
#include "kernel/log.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
USING_YOSYS_NAMESPACE
|
||||||
|
PRIVATE_NAMESPACE_BEGIN
|
||||||
|
struct SetenvPass : public Pass {
|
||||||
|
SetenvPass() : Pass("setenv", "set an environment variable") { }
|
||||||
|
void help() override
|
||||||
|
{
|
||||||
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
||||||
|
log("\n");
|
||||||
|
log(" setenv name value\n");
|
||||||
|
log("\n");
|
||||||
|
log("Set the given environment variable on the current process. Values containing\n");
|
||||||
|
log("whitespace must be passed in double quotes (\").\n");
|
||||||
|
log("\n");
|
||||||
|
}
|
||||||
|
void execute(std::vector<std::string> args, [[maybe_unused]] RTLIL::Design *design) override
|
||||||
|
{
|
||||||
|
if(args.size() != 3)
|
||||||
|
log_cmd_error("Wrong number of arguments given.\n");
|
||||||
|
|
||||||
|
std::string name = args[1];
|
||||||
|
std::string value = args[2];
|
||||||
|
if (value.front() == '\"' && value.back() == '\"') value = value.substr(1, value.size() - 2);
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
_putenv_s(name.c_str(), value.c_str());
|
||||||
|
#else
|
||||||
|
if (setenv(name.c_str(), value.c_str(), 1))
|
||||||
|
log_cmd_error("Invalid name \"%s\".\n", name.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
} SetenvPass;
|
||||||
|
|
||||||
|
PRIVATE_NAMESPACE_END
|
|
@ -3,7 +3,9 @@ OBJS += techlibs/gowin/synth_gowin.o
|
||||||
|
|
||||||
$(eval $(call add_share_file,share/gowin,techlibs/gowin/cells_map.v))
|
$(eval $(call add_share_file,share/gowin,techlibs/gowin/cells_map.v))
|
||||||
$(eval $(call add_share_file,share/gowin,techlibs/gowin/cells_sim.v))
|
$(eval $(call add_share_file,share/gowin,techlibs/gowin/cells_sim.v))
|
||||||
$(eval $(call add_share_file,share/gowin,techlibs/gowin/cells_xtra.v))
|
$(eval $(call add_share_file,share/gowin,techlibs/gowin/cells_xtra_gw1n.v))
|
||||||
|
$(eval $(call add_share_file,share/gowin,techlibs/gowin/cells_xtra_gw2a.v))
|
||||||
|
$(eval $(call add_share_file,share/gowin,techlibs/gowin/cells_xtra_gw5a.v))
|
||||||
$(eval $(call add_share_file,share/gowin,techlibs/gowin/arith_map.v))
|
$(eval $(call add_share_file,share/gowin,techlibs/gowin/arith_map.v))
|
||||||
$(eval $(call add_share_file,share/gowin,techlibs/gowin/brams_map.v))
|
$(eval $(call add_share_file,share/gowin,techlibs/gowin/brams_map.v))
|
||||||
$(eval $(call add_share_file,share/gowin,techlibs/gowin/brams.txt))
|
$(eval $(call add_share_file,share/gowin,techlibs/gowin/brams.txt))
|
||||||
|
|
|
@ -63,16 +63,17 @@ if __name__ == '__main__':
|
||||||
parser.add_argument('gowin_dir', nargs='?', default='/opt/gowin/')
|
parser.add_argument('gowin_dir', nargs='?', default='/opt/gowin/')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
dirs = [
|
families = {
|
||||||
os.path.join(args.gowin_dir, 'IDE/simlib/gw1n/'),
|
'gw1n': os.path.join(args.gowin_dir, 'IDE/simlib/gw1n/'),
|
||||||
os.path.join(args.gowin_dir, 'IDE/simlib/gw2a/'),
|
'gw2a': os.path.join(args.gowin_dir, 'IDE/simlib/gw2a/'),
|
||||||
os.path.join(args.gowin_dir, 'IDE/simlib/gw5a/'),
|
'gw5a': os.path.join(args.gowin_dir, 'IDE/simlib/gw5a/'),
|
||||||
]
|
}
|
||||||
|
|
||||||
with open('cells_xtra.v', 'w') as fout:
|
for family, dir in families.items():
|
||||||
fout.write('// Created by cells_xtra.py\n')
|
if not os.path.isdir(dir):
|
||||||
fout.write('\n')
|
print(f'{dir} is not a directory')
|
||||||
for dir in dirs:
|
else:
|
||||||
if not os.path.isdir(dir):
|
with open(f'cells_xtra_{family}.v', 'w') as fout:
|
||||||
print(f'{dir} is not a directory')
|
fout.write('// Created by cells_xtra.py\n')
|
||||||
xtract_cells_decl(dir, fout)
|
fout.write('\n')
|
||||||
|
xtract_cells_decl(dir, fout)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
1893
techlibs/gowin/cells_xtra_gw1n.v
Normal file
1893
techlibs/gowin/cells_xtra_gw1n.v
Normal file
File diff suppressed because it is too large
Load diff
1724
techlibs/gowin/cells_xtra_gw2a.v
Normal file
1724
techlibs/gowin/cells_xtra_gw2a.v
Normal file
File diff suppressed because it is too large
Load diff
2680
techlibs/gowin/cells_xtra_gw5a.v
Normal file
2680
techlibs/gowin/cells_xtra_gw5a.v
Normal file
File diff suppressed because it is too large
Load diff
|
@ -86,17 +86,22 @@ struct SynthGowinPass : public ScriptPass
|
||||||
log(" read/write collision\" (same result as setting the no_rw_check\n");
|
log(" read/write collision\" (same result as setting the no_rw_check\n");
|
||||||
log(" attribute on all memories).\n");
|
log(" attribute on all memories).\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
|
log(" -family <family>\n");
|
||||||
|
log(" sets the gowin family to the specified value. The default is 'gw1n'.\n");
|
||||||
|
log(" The following families are supported:\n");
|
||||||
|
log(" 'gw1n', 'gw2a', 'gw5a'.\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
log("The following commands are executed by this synthesis command:\n");
|
log("The following commands are executed by this synthesis command:\n");
|
||||||
help_script();
|
help_script();
|
||||||
log("\n");
|
log("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
string top_opt, vout_file, json_file;
|
string top_opt, vout_file, json_file, family;
|
||||||
bool retime, nobram, nolutram, flatten, nodffe, nowidelut, abc9, noiopads, noalu, no_rw_check;
|
bool retime, nobram, nolutram, flatten, nodffe, nowidelut, abc9, noiopads, noalu, no_rw_check;
|
||||||
|
|
||||||
void clear_flags() override
|
void clear_flags() override
|
||||||
{
|
{
|
||||||
|
family = "gw1n";
|
||||||
top_opt = "-auto-top";
|
top_opt = "-auto-top";
|
||||||
vout_file = "";
|
vout_file = "";
|
||||||
json_file = "";
|
json_file = "";
|
||||||
|
@ -132,6 +137,10 @@ struct SynthGowinPass : public ScriptPass
|
||||||
json_file = args[++argidx];
|
json_file = args[++argidx];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (args[argidx] == "-family" && argidx+1 < args.size()) {
|
||||||
|
family = args[++argidx];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (args[argidx] == "-run" && argidx+1 < args.size()) {
|
if (args[argidx] == "-run" && argidx+1 < args.size()) {
|
||||||
size_t pos = args[argidx+1].find(':');
|
size_t pos = args[argidx+1].find(':');
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
|
@ -210,7 +219,7 @@ struct SynthGowinPass : public ScriptPass
|
||||||
if (check_label("begin"))
|
if (check_label("begin"))
|
||||||
{
|
{
|
||||||
run("read_verilog -specify -lib +/gowin/cells_sim.v");
|
run("read_verilog -specify -lib +/gowin/cells_sim.v");
|
||||||
run("read_verilog -specify -lib +/gowin/cells_xtra.v");
|
run(stringf("read_verilog -specify -lib +/gowin/cells_xtra_%s.v", help_mode ? "<family>" : family.c_str()));
|
||||||
run(stringf("hierarchy -check %s", help_mode ? "-top <top>" : top_opt.c_str()));
|
run(stringf("hierarchy -check %s", help_mode ? "-top <top>" : top_opt.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
tests/verific/setenv.flist
Normal file
1
tests/verific/setenv.flist
Normal file
|
@ -0,0 +1 @@
|
||||||
|
${filename}
|
4
tests/verific/setenv.ys
Normal file
4
tests/verific/setenv.ys
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
setenv filename case.sv
|
||||||
|
verific -f -sv setenv.flist
|
||||||
|
verific -import top
|
||||||
|
select -assert-mod-count 1 top
|
Loading…
Add table
Add a link
Reference in a new issue