3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-06-23 14:23:41 +00:00

Merge branch 'YosysHQ:main' into main

This commit is contained in:
Akash Levy 2024-12-08 15:44:46 -08:00 committed by GitHub
commit 8bb193d7c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 6393 additions and 6309 deletions

View file

@ -168,7 +168,7 @@ ifeq ($(OS), Haiku)
CXXFLAGS += -D_DEFAULT_SOURCE
endif
YOSYS_VER := 0.47+201
YOSYS_VER := 0.47+211
# Note: We arrange for .gitcommit to contain the (short) commit hash in
# tarballs generated with git-archive(1) using .gitattributes. The git repo

View file

@ -169,6 +169,10 @@ public:
return !(*this == other);
}
int hash() const {
return mkhash(scope_name.hash(), hash_ptr_ops::hash(target));
}
bool valid() const {
return target != nullptr;
}

View file

@ -59,3 +59,4 @@ OBJS += passes/cmds/splitnetlist.o
OBJS += passes/cmds/reconstructbusses.o
OBJS += passes/cmds/wrapcell.o
OBJS += passes/cmds/setenv.o

58
passes/cmds/setenv.cc Normal file
View 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

View file

@ -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_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/brams_map.v))
$(eval $(call add_share_file,share/gowin,techlibs/gowin/brams.txt))

View file

@ -63,16 +63,17 @@ if __name__ == '__main__':
parser.add_argument('gowin_dir', nargs='?', default='/opt/gowin/')
args = parser.parse_args()
dirs = [
os.path.join(args.gowin_dir, 'IDE/simlib/gw1n/'),
os.path.join(args.gowin_dir, 'IDE/simlib/gw2a/'),
os.path.join(args.gowin_dir, 'IDE/simlib/gw5a/'),
]
families = {
'gw1n': os.path.join(args.gowin_dir, 'IDE/simlib/gw1n/'),
'gw2a': os.path.join(args.gowin_dir, 'IDE/simlib/gw2a/'),
'gw5a': os.path.join(args.gowin_dir, 'IDE/simlib/gw5a/'),
}
with open('cells_xtra.v', 'w') as fout:
fout.write('// Created by cells_xtra.py\n')
fout.write('\n')
for dir in dirs:
if not os.path.isdir(dir):
print(f'{dir} is not a directory')
xtract_cells_decl(dir, fout)
for family, dir in families.items():
if not os.path.isdir(dir):
print(f'{dir} is not a directory')
else:
with open(f'cells_xtra_{family}.v', 'w') as fout:
fout.write('// Created by cells_xtra.py\n')
fout.write('\n')
xtract_cells_decl(dir, fout)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -86,17 +86,22 @@ struct SynthGowinPass : public ScriptPass
log(" read/write collision\" (same result as setting the no_rw_check\n");
log(" attribute on all memories).\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("The following commands are executed by this synthesis command:\n");
help_script();
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;
void clear_flags() override
{
family = "gw1n";
top_opt = "-auto-top";
vout_file = "";
json_file = "";
@ -132,6 +137,10 @@ struct SynthGowinPass : public ScriptPass
json_file = args[++argidx];
continue;
}
if (args[argidx] == "-family" && argidx+1 < args.size()) {
family = args[++argidx];
continue;
}
if (args[argidx] == "-run" && argidx+1 < args.size()) {
size_t pos = args[argidx+1].find(':');
if (pos == std::string::npos)
@ -210,7 +219,7 @@ struct SynthGowinPass : public ScriptPass
if (check_label("begin"))
{
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()));
}

View file

@ -0,0 +1 @@
${filename}

4
tests/verific/setenv.ys Normal file
View file

@ -0,0 +1,4 @@
setenv filename case.sv
verific -f -sv setenv.flist
verific -import top
select -assert-mod-count 1 top