141 std::string top_module_name;
143 bool big_endian =
false;
144 std::string neg =
"Vss", pos =
"Vdd", ncpf =
"_NC";
149 for (argidx = 1; argidx <
args.size(); argidx++)
151 if (
args[argidx] ==
"-big_endian") {
155 if (
args[argidx] ==
"-neg" && argidx+1 <
args.size()) {
156 neg =
args[++argidx];
159 if (
args[argidx] ==
"-pos" && argidx+1 <
args.size()) {
160 pos =
args[++argidx];
163 if (
args[argidx] ==
"-nc_prefix" && argidx+1 <
args.size()) {
164 ncpf =
args[++argidx];
167 if (
args[argidx] ==
"-top" && argidx+1 <
args.size()) {
168 top_module_name =
args[++argidx];
175 if (top_module_name.empty())
176 for (
auto & mod_it:design->
modules_)
177 if (mod_it.second->get_bool_attribute(
"\\top"))
178 top_module_name = mod_it.first.str();
183 for (
auto module_it : design->
modules_)
186 if (module->get_bool_attribute(
"\\blackbox"))
190 log_error(
"Found unmapped processes in module %s: unmapped processes are not supported in SPICE backend!\n",
RTLIL::id2cstr(module->
name));
192 log_error(
"Found munmapped emories in module %s: unmapped memories are not supported in SPICE backend!\n",
RTLIL::id2cstr(module->
name));
199 std::vector<RTLIL::Wire*> ports;
200 for (
auto wire_it : module->
wires_) {
204 while (
int(ports.size()) < wire->
port_id)
205 ports.push_back(
NULL);
206 ports.at(wire->
port_id-1) = wire;
212 if (wire->
width > 1) {
213 for (
int i = 0; i < wire->
width; i++)
223 if (!top_module_name.empty()) {
224 if (top_module ==
NULL)
225 log_error(
"Can't find top module `%s'!\n", top_module_name.c_str());
230 *f <<
stringf(
"************************\n");
231 *f <<
stringf(
"* end of SPICE netlist *\n");
232 *f <<
stringf(
"************************\n");
const char * yosys_version_str
std::string stringf(const char *fmt,...)
void log_header(const char *format,...)
std::map< RTLIL::IdString, RTLIL::Wire * > wires_
std::map< RTLIL::IdString, RTLIL::Memory * > memories
void log_error(const char *format,...)
static std::string escape_id(std::string str)
void extra_args(std::ostream *&f, std::string &filename, std::vector< std::string > args, size_t argidx)
#define log_assert(_assert_expr_)
static void print_spice_module(std::ostream &f, RTLIL::Module *module, RTLIL::Design *design, std::string &neg, std::string &pos, std::string &ncpf, bool big_endian)
static const char * id2cstr(const RTLIL::IdString &str)
std::map< RTLIL::IdString, RTLIL::Process * > processes
std::map< RTLIL::IdString, RTLIL::Module * > modules_