yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
VerilogFrontend Struct Reference
+ Inheritance diagram for VerilogFrontend:
+ Collaboration diagram for VerilogFrontend:

Public Member Functions

 VerilogFrontend ()
 
virtual void help ()
 
virtual void execute (std::istream *&f, std::string filename, std::vector< std::string > args, RTLIL::Design *design)
 
virtual void run_register ()
 
virtual void execute (std::vector< std::string > args, RTLIL::Design *design) YS_OVERRIDE YS_FINAL
 
void extra_args (std::istream *&f, std::string &filename, std::vector< std::string > args, size_t argidx)
 
void extra_args (std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)
 
pre_post_exec_state_t pre_execute ()
 
void post_execute (pre_post_exec_state_t state)
 
void cmd_log_args (const std::vector< std::string > &args)
 
void cmd_error (const std::vector< std::string > &args, size_t argidx, std::string msg)
 

Static Public Member Functions

static void frontend_call (RTLIL::Design *design, std::istream *f, std::string filename, std::string command)
 
static void frontend_call (RTLIL::Design *design, std::istream *f, std::string filename, std::vector< std::string > args)
 
static void call (RTLIL::Design *design, std::string command)
 
static void call (RTLIL::Design *design, std::vector< std::string > args)
 
static void call_on_selection (RTLIL::Design *design, const RTLIL::Selection &selection, std::string command)
 
static void call_on_selection (RTLIL::Design *design, const RTLIL::Selection &selection, std::vector< std::string > args)
 
static void call_on_module (RTLIL::Design *design, RTLIL::Module *module, std::string command)
 
static void call_on_module (RTLIL::Design *design, RTLIL::Module *module, std::vector< std::string > args)
 
static void init_register ()
 
static void done_register ()
 

Data Fields

std::string frontend_name
 
std::string pass_name
 
std::string short_help
 
int call_counter
 
int64_t runtime_ns
 
Passnext_queued_pass
 

Static Public Attributes

static FILE * current_script_file = NULL
 
static std::string last_here_document
 
static std::vector< std::string > next_args
 

Detailed Description

Definition at line 42 of file verilog_frontend.cc.

Constructor & Destructor Documentation

VerilogFrontend::VerilogFrontend ( )
inline

Definition at line 43 of file verilog_frontend.cc.

43 : Frontend("verilog", "read modules from verilog file") { }
Frontend(std::string name, std::string short_help="** document me **")
Definition: register.cc:266

Member Function Documentation

void Pass::call ( RTLIL::Design design,
std::string  command 
)
staticinherited

Definition at line 146 of file register.cc.

147 {
148  std::vector<std::string> args;
149 
150  std::string cmd_buf = command;
151  std::string tok = next_token(cmd_buf, " \t\r\n");
152 
153  if (tok.empty() || tok[0] == '#')
154  return;
155 
156  if (tok[0] == '!') {
157  cmd_buf = command.substr(command.find('!') + 1);
158  while (!cmd_buf.empty() && (cmd_buf.back() == ' ' || cmd_buf.back() == '\t' ||
159  cmd_buf.back() == '\r' || cmd_buf.back() == '\n'))
160  cmd_buf.resize(cmd_buf.size()-1);
161  log_header("Shell command: %s\n", cmd_buf.c_str());
162  int retCode = run_command(cmd_buf);
163  if (retCode != 0)
164  log_cmd_error("Shell command returned error code %d.\n", retCode);
165  return;
166  }
167 
168  while (!tok.empty()) {
169  if (tok == "#")
170  break;
171  if (tok.back() == ';') {
172  int num_semikolon = 0;
173  while (!tok.empty() && tok.back() == ';')
174  tok.resize(tok.size()-1), num_semikolon++;
175  if (!tok.empty())
176  args.push_back(tok);
177  call(design, args);
178  args.clear();
179  if (num_semikolon == 2)
180  call(design, "clean");
181  if (num_semikolon == 3)
182  call(design, "clean -purge");
183  } else
184  args.push_back(tok);
185  tok = next_token(cmd_buf, " \t\r\n");
186  }
187 
188  call(design, args);
189 }
static std::string next_token(bool pass_newline=false)
Definition: preproc.cc:96
void log_header(const char *format,...)
Definition: log.cc:188
int run_command(const std::string &command, std::function< void(const std::string &)> process_line)
Definition: yosys.cc:195
void log_cmd_error(const char *format,...)
Definition: log.cc:211
static void call(RTLIL::Design *design, std::string command)
Definition: register.cc:146

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Pass::call ( RTLIL::Design design,
std::vector< std::string >  args 
)
staticinherited

Definition at line 191 of file register.cc.

192 {
193  if (args.size() == 0 || args[0][0] == '#')
194  return;
195 
196  if (echo_mode) {
197  log("%s", create_prompt(design, 0));
198  for (size_t i = 0; i < args.size(); i++)
199  log("%s%s", i ? " " : "", args[i].c_str());
200  log("\n");
201  }
202 
203  if (pass_register.count(args[0]) == 0)
204  log_cmd_error("No such command: %s (type 'help' for a command overview)\n", args[0].c_str());
205 
206  size_t orig_sel_stack_pos = design->selection_stack.size();
207  auto state = pass_register[args[0]]->pre_execute();
208  pass_register[args[0]]->execute(args, design);
209  pass_register[args[0]]->post_execute(state);
210  while (design->selection_stack.size() > orig_sel_stack_pos)
211  design->selection_stack.pop_back();
212 
213  design->check();
214 }
bool echo_mode
Definition: register.cc:30
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
const char * create_prompt(RTLIL::Design *design, int recursion_counter)
Definition: yosys.cc:400
void check()
Definition: rtlil.cc:357
void log_cmd_error(const char *format,...)
Definition: log.cc:211
void log(const char *format,...)
Definition: log.cc:180
std::map< std::string, Pass * > pass_register
Definition: register.cc:35

+ Here is the call graph for this function:

void Pass::call_on_module ( RTLIL::Design design,
RTLIL::Module module,
std::string  command 
)
staticinherited

Definition at line 240 of file register.cc.

241 {
242  std::string backup_selected_active_module = design->selected_active_module;
243  design->selected_active_module = module->name.str();
244  design->selection_stack.push_back(RTLIL::Selection(false));
245  design->selection_stack.back().select(module);
246 
247  Pass::call(design, command);
248 
249  design->selection_stack.pop_back();
250  design->selected_active_module = backup_selected_active_module;
251 }
std::string str() const
Definition: rtlil.h:182
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
RTLIL::IdString name
Definition: rtlil.h:599
std::string selected_active_module
Definition: rtlil.h:511
static void call(RTLIL::Design *design, std::string command)
Definition: register.cc:146

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Pass::call_on_module ( RTLIL::Design design,
RTLIL::Module module,
std::vector< std::string >  args 
)
staticinherited

Definition at line 253 of file register.cc.

254 {
255  std::string backup_selected_active_module = design->selected_active_module;
256  design->selected_active_module = module->name.str();
257  design->selection_stack.push_back(RTLIL::Selection(false));
258  design->selection_stack.back().select(module);
259 
260  Pass::call(design, args);
261 
262  design->selection_stack.pop_back();
263  design->selected_active_module = backup_selected_active_module;
264 }
std::string str() const
Definition: rtlil.h:182
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
RTLIL::IdString name
Definition: rtlil.h:599
std::string selected_active_module
Definition: rtlil.h:511
static void call(RTLIL::Design *design, std::string command)
Definition: register.cc:146

+ Here is the call graph for this function:

void Pass::call_on_selection ( RTLIL::Design design,
const RTLIL::Selection selection,
std::string  command 
)
staticinherited

Definition at line 216 of file register.cc.

217 {
218  std::string backup_selected_active_module = design->selected_active_module;
219  design->selected_active_module.clear();
220  design->selection_stack.push_back(selection);
221 
222  Pass::call(design, command);
223 
224  design->selection_stack.pop_back();
225  design->selected_active_module = backup_selected_active_module;
226 }
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
std::string selected_active_module
Definition: rtlil.h:511
static void call(RTLIL::Design *design, std::string command)
Definition: register.cc:146

+ Here is the call graph for this function:

void Pass::call_on_selection ( RTLIL::Design design,
const RTLIL::Selection selection,
std::vector< std::string >  args 
)
staticinherited

Definition at line 228 of file register.cc.

229 {
230  std::string backup_selected_active_module = design->selected_active_module;
231  design->selected_active_module.clear();
232  design->selection_stack.push_back(selection);
233 
234  Pass::call(design, args);
235 
236  design->selection_stack.pop_back();
237  design->selected_active_module = backup_selected_active_module;
238 }
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
std::string selected_active_module
Definition: rtlil.h:511
static void call(RTLIL::Design *design, std::string command)
Definition: register.cc:146

+ Here is the call graph for this function:

void Pass::cmd_error ( const std::vector< std::string > &  args,
size_t  argidx,
std::string  msg 
)
inherited

Definition at line 110 of file register.cc.

111 {
112  std::string command_text;
113  int error_pos = 0;
114 
115  for (size_t i = 0; i < args.size(); i++) {
116  if (i < argidx)
117  error_pos += args[i].size() + 1;
118  command_text = command_text + (command_text.empty() ? "" : " ") + args[i];
119  }
120 
121  log("\nSyntax error in command `%s':\n", command_text.c_str());
122  help();
123 
124  log_cmd_error("Command syntax error: %s\n> %s\n> %*s^\n",
125  msg.c_str(), command_text.c_str(), error_pos, "");
126 }
virtual void help()
Definition: register.cc:93
void log_cmd_error(const char *format,...)
Definition: log.cc:211
void log(const char *format,...)
Definition: log.cc:180

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Pass::cmd_log_args ( const std::vector< std::string > &  args)
inherited

Definition at line 100 of file register.cc.

101 {
102  if (args.size() <= 1)
103  return;
104  log("Full command line:");
105  for (size_t i = 0; i < args.size(); i++)
106  log(" %s", args[i].c_str());
107  log("\n");
108 }
void log(const char *format,...)
Definition: log.cc:180

+ Here is the call graph for this function:

void Pass::done_register ( )
staticinherited

Definition at line 62 of file register.cc.

63 {
64  frontend_register.clear();
65  pass_register.clear();
66  backend_register.clear();
68 }
std::map< std::string, Frontend * > frontend_register
Definition: register.cc:34
Pass * first_queued_pass
Definition: register.cc:31
#define log_assert(_assert_expr_)
Definition: log.h:85
#define NULL
std::map< std::string, Pass * > pass_register
Definition: register.cc:35
std::map< std::string, Backend * > backend_register
Definition: register.cc:36

+ Here is the caller graph for this function:

void Frontend::execute ( std::vector< std::string >  args,
RTLIL::Design design 
)
virtualinherited

Implements Pass.

Definition at line 285 of file register.cc.

286 {
287  log_assert(next_args.empty());
288  do {
289  std::istream *f = NULL;
290  next_args.clear();
291  auto state = pre_execute();
292  execute(f, std::string(), args, design);
293  post_execute(state);
294  args = next_args;
295  delete f;
296  } while (!args.empty());
297 }
static std::vector< std::string > next_args
Definition: register.h:79
#define log_assert(_assert_expr_)
Definition: log.h:85
virtual void execute(std::vector< std::string > args, RTLIL::Design *design) YS_OVERRIDE YS_FINAL
Definition: register.cc:285
#define NULL
pre_post_exec_state_t pre_execute()
Definition: register.cc:74
void post_execute(pre_post_exec_state_t state)
Definition: register.cc:84

+ Here is the call graph for this function:

virtual void VerilogFrontend::execute ( std::istream *&  f,
std::string  filename,
std::vector< std::string >  args,
RTLIL::Design design 
)
inlinevirtual

Implements Frontend.

Definition at line 136 of file verilog_frontend.cc.

137  {
138  bool flag_dump_ast1 = false;
139  bool flag_dump_ast2 = false;
140  bool flag_dump_vlog = false;
141  bool flag_nolatches = false;
142  bool flag_nomem2reg = false;
143  bool flag_mem2reg = false;
144  bool flag_ppdump = false;
145  bool flag_nopp = false;
146  bool flag_lib = false;
147  bool flag_noopt = false;
148  bool flag_icells = false;
149  bool flag_ignore_redef = false;
150  bool flag_defer = false;
151  std::map<std::string, std::string> defines_map;
152  std::list<std::string> include_dirs;
153  std::list<std::string> attributes;
154 
155  frontend_verilog_yydebug = false;
156  sv_mode = false;
157 
158  log_header("Executing Verilog-2005 frontend.\n");
159 
160  args.insert(args.begin()+1, verilog_defaults.begin(), verilog_defaults.end());
161 
162  size_t argidx;
163  for (argidx = 1; argidx < args.size(); argidx++) {
164  std::string arg = args[argidx];
165  if (arg == "-sv") {
166  sv_mode = true;
167  continue;
168  }
169  if (arg == "-dump_ast1") {
170  flag_dump_ast1 = true;
171  continue;
172  }
173  if (arg == "-dump_ast2") {
174  flag_dump_ast2 = true;
175  continue;
176  }
177  if (arg == "-dump_vlog") {
178  flag_dump_vlog = true;
179  continue;
180  }
181  if (arg == "-yydebug") {
183  continue;
184  }
185  if (arg == "-nolatches") {
186  flag_nolatches = true;
187  continue;
188  }
189  if (arg == "-nomem2reg") {
190  flag_nomem2reg = true;
191  continue;
192  }
193  if (arg == "-mem2reg") {
194  flag_mem2reg = true;
195  continue;
196  }
197  if (arg == "-ppdump") {
198  flag_ppdump = true;
199  continue;
200  }
201  if (arg == "-nopp") {
202  flag_nopp = true;
203  continue;
204  }
205  if (arg == "-lib") {
206  flag_lib = true;
207  continue;
208  }
209  if (arg == "-noopt") {
210  flag_noopt = true;
211  continue;
212  }
213  if (arg == "-icells") {
214  flag_icells = true;
215  continue;
216  }
217  if (arg == "-ignore_redef") {
218  flag_ignore_redef = true;
219  continue;
220  }
221  if (arg == "-defer") {
222  flag_defer = true;
223  continue;
224  }
225  if (arg == "-setattr" && argidx+1 < args.size()) {
226  attributes.push_back(RTLIL::escape_id(args[++argidx]));
227  continue;
228  }
229  if (arg == "-D" && argidx+1 < args.size()) {
230  std::string name = args[++argidx], value;
231  size_t equal = name.find('=', 2);
232  if (equal != std::string::npos) {
233  value = arg.substr(equal+1);
234  name = arg.substr(0, equal);
235  }
236  defines_map[name] = value;
237  continue;
238  }
239  if (arg.compare(0, 2, "-D") == 0) {
240  size_t equal = arg.find('=', 2);
241  std::string name = arg.substr(2, equal-2);
242  std::string value;
243  if (equal != std::string::npos)
244  value = arg.substr(equal+1);
245  defines_map[name] = value;
246  continue;
247  }
248  if (arg == "-I" && argidx+1 < args.size()) {
249  include_dirs.push_back(args[++argidx]);
250  continue;
251  }
252  if (arg.compare(0, 2, "-I") == 0) {
253  include_dirs.push_back(arg.substr(2));
254  continue;
255  }
256  break;
257  }
258  extra_args(f, filename, args, argidx);
259 
260  log("Parsing %s input from `%s' to AST representation.\n", sv_mode ? "SystemVerilog" : "Verilog", filename.c_str());
261 
262  AST::current_filename = filename;
265 
267  default_nettype_wire = true;
268 
269  lexin = f;
270  std::string code_after_preproc;
271 
272  if (!flag_nopp) {
273  code_after_preproc = frontend_verilog_preproc(*f, filename, defines_map, include_dirs);
274  if (flag_ppdump)
275  log("-- Verilog code after preprocessor --\n%s-- END OF DUMP --\n", code_after_preproc.c_str());
276  lexin = new std::istringstream(code_after_preproc);
277  }
278 
283 
284  for (auto &child : current_ast->children) {
285  if (child->type == AST::AST_MODULE)
286  for (auto &attr : attributes)
287  if (child->attributes.count(attr) == 0)
288  child->attributes[attr] = AST::AstNode::mkconst_int(1, false);
289  }
290 
291  AST::process(design, current_ast, flag_dump_ast1, flag_dump_ast2, flag_dump_vlog, flag_nolatches, flag_nomem2reg, flag_mem2reg, flag_lib, flag_noopt, flag_icells, flag_ignore_redef, flag_defer, default_nettype_wire);
292 
293  if (!flag_nopp)
294  delete lexin;
295 
296  delete current_ast;
297  current_ast = NULL;
298 
299  log("Successfully finished Verilog frontend.\n");
300  }
bool flag_lib
Definition: ast.cc:56
static AstNode * mkconst_int(uint32_t v, bool is_signed, int width=32)
Definition: ast.cc:672
void log_header(const char *format,...)
Definition: log.cc:188
std::string frontend_verilog_preproc(std::istream &f, std::string filename, const std::map< std::string, std::string > pre_defines_map, const std::list< std::string > include_dirs)
Definition: preproc.cc:212
void(* set_line_num)(int)
Definition: ast.cc:50
bool flag_dump_ast1
Definition: ast.cc:56
AstNode * current_ast
Definition: ast.cc:57
static std::vector< std::string > verilog_defaults
static std::string escape_id(std::string str)
Definition: rtlil.h:251
int frontend_verilog_yyget_lineno(void)
int(* get_line_num)()
Definition: ast.cc:51
YOSYS_NAMESPACE_END int frontend_verilog_yydebug
bool flag_dump_ast2
Definition: ast.cc:56
bool flag_noopt
Definition: ast.cc:56
int frontend_verilog_yyparse(void)
std::istream * lexin
std::string current_filename
Definition: ast.cc:49
#define NULL
void log(const char *format,...)
Definition: log.cc:180
void frontend_verilog_yyrestart(FILE *f)
bool flag_nolatches
Definition: ast.cc:56
bool flag_mem2reg
Definition: ast.cc:56
void process(RTLIL::Design *design, AstNode *ast, bool dump_ast1, bool dump_ast2, bool dump_vlog, bool nolatches, bool nomem2reg, bool mem2reg, bool lib, bool noopt, bool icells, bool ignore_redef, bool defer, bool autowire)
Definition: ast.cc:967
bool flag_icells
Definition: ast.cc:56
int frontend_verilog_yylex_destroy(void)
bool flag_nomem2reg
Definition: ast.cc:56
void extra_args(std::istream *&f, std::string &filename, std::vector< std::string > args, size_t argidx)
Definition: register.cc:302
bool flag_dump_vlog
Definition: ast.cc:56
void frontend_verilog_yyset_lineno(int)

+ Here is the call graph for this function:

void Pass::extra_args ( std::vector< std::string >  args,
size_t  argidx,
RTLIL::Design design,
bool  select = true 
)
inherited

Definition at line 128 of file register.cc.

129 {
130  for (; argidx < args.size(); argidx++)
131  {
132  std::string arg = args[argidx];
133 
134  if (arg.substr(0, 1) == "-")
135  cmd_error(args, argidx, "Unknown option or option in arguments.");
136 
137  if (!select)
138  cmd_error(args, argidx, "Extra argument.");
139 
140  handle_extra_select_args(this, args, argidx, args.size(), design);
141  break;
142  }
143  // cmd_log_args(args);
144 }
void cmd_error(const std::vector< std::string > &args, size_t argidx, std::string msg)
Definition: register.cc:110
void handle_extra_select_args(Pass *pass, std::vector< std::string > args, size_t argidx, size_t args_size, RTLIL::Design *design)
Definition: select.cc:803

+ Here is the call graph for this function:

void Frontend::extra_args ( std::istream *&  f,
std::string &  filename,
std::vector< std::string >  args,
size_t  argidx 
)
inherited

Definition at line 302 of file register.cc.

303 {
304  bool called_with_fp = f != NULL;
305 
306  next_args.clear();
307  for (; argidx < args.size(); argidx++)
308  {
309  std::string arg = args[argidx];
310 
311  if (arg.substr(0, 1) == "-")
312  cmd_error(args, argidx, "Unknown option or option in arguments.");
313  if (f != NULL)
314  cmd_error(args, argidx, "Extra filename argument in direct file mode.");
315 
316  filename = arg;
317  if (filename == "<<" && argidx+1 < args.size())
318  filename += args[++argidx];
319  if (filename.substr(0, 2) == "<<") {
321  log_error("Unexpected here document '%s' outside of script!\n", filename.c_str());
322  if (filename.size() <= 2)
323  log_error("Missing EOT marker in here document!\n");
324  std::string eot_marker = filename.substr(2);
325  last_here_document.clear();
326  while (1) {
327  std::string buffer;
328  char block[4096];
329  while (1) {
330  if (fgets(block, 4096, Frontend::current_script_file) == NULL)
331  log_error("Unexpected end of file in here document '%s'!\n", filename.c_str());
332  buffer += block;
333  if (buffer.size() > 0 && (buffer[buffer.size() - 1] == '\n' || buffer[buffer.size() - 1] == '\r'))
334  break;
335  }
336  size_t indent = buffer.find_first_not_of(" \t\r\n");
337  if (indent != std::string::npos && buffer.substr(indent, eot_marker.size()) == eot_marker)
338  break;
339  last_here_document += buffer;
340  }
341  f = new std::istringstream(last_here_document);
342  } else {
343  if (filename.substr(0, 2) == "+/")
344  filename = proc_share_dirname() + filename.substr(1);
345  std::ifstream *ff = new std::ifstream;
346  ff->open(filename.c_str());
347  if (ff->fail())
348  delete ff;
349  else
350  f = ff;
351  }
352  if (f == NULL)
353  log_cmd_error("Can't open input file `%s' for reading: %s\n", filename.c_str(), strerror(errno));
354 
355  for (size_t i = argidx+1; i < args.size(); i++)
356  if (args[i].substr(0, 1) == "-")
357  cmd_error(args, i, "Found option, expected arguments.");
358 
359  if (argidx+1 < args.size()) {
360  next_args.insert(next_args.begin(), args.begin(), args.begin()+argidx);
361  next_args.insert(next_args.begin()+argidx, args.begin()+argidx+1, args.end());
362  args.erase(args.begin()+argidx+1, args.end());
363  }
364  break;
365  }
366  if (f == NULL)
367  cmd_error(args, argidx, "No filename given.");
368 
369  if (called_with_fp)
370  args.push_back(filename);
371  args[0] = pass_name;
372  // cmd_log_args(args);
373 }
void cmd_error(const std::vector< std::string > &args, size_t argidx, std::string msg)
Definition: register.cc:110
static std::string last_here_document
Definition: register.h:70
void log_error(const char *format,...)
Definition: log.cc:204
static FILE * current_script_file
Definition: register.h:69
std::string pass_name
Definition: register.h:29
static std::vector< std::string > next_args
Definition: register.h:79
void log_cmd_error(const char *format,...)
Definition: log.cc:211
#define NULL
std::string proc_share_dirname()
Definition: yosys.cc:543

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Frontend::frontend_call ( RTLIL::Design design,
std::istream *  f,
std::string  filename,
std::string  command 
)
staticinherited

Definition at line 375 of file register.cc.

376 {
377  std::vector<std::string> args;
378  char *s = strdup(command.c_str());
379  for (char *p = strtok(s, " \t\r\n"); p; p = strtok(NULL, " \t\r\n"))
380  args.push_back(p);
381  free(s);
382  frontend_call(design, f, filename, args);
383 }
void free(void *)
static void frontend_call(RTLIL::Design *design, std::istream *f, std::string filename, std::string command)
Definition: register.cc:375
#define NULL

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Frontend::frontend_call ( RTLIL::Design design,
std::istream *  f,
std::string  filename,
std::vector< std::string >  args 
)
staticinherited

Definition at line 385 of file register.cc.

386 {
387  if (args.size() == 0)
388  return;
389  if (frontend_register.count(args[0]) == 0)
390  log_cmd_error("No such frontend: %s\n", args[0].c_str());
391 
392  if (f != NULL) {
393  auto state = frontend_register[args[0]]->pre_execute();
394  frontend_register[args[0]]->execute(f, filename, args, design);
395  frontend_register[args[0]]->post_execute(state);
396  } else if (filename == "-") {
397  std::istream *f_cin = &std::cin;
398  auto state = frontend_register[args[0]]->pre_execute();
399  frontend_register[args[0]]->execute(f_cin, "<stdin>", args, design);
400  frontend_register[args[0]]->post_execute(state);
401  } else {
402  if (!filename.empty())
403  args.push_back(filename);
404  frontend_register[args[0]]->execute(args, design);
405  }
406 
407  design->check();
408 }
std::map< std::string, Frontend * > frontend_register
Definition: register.cc:34
void check()
Definition: rtlil.cc:357
void log_cmd_error(const char *format,...)
Definition: log.cc:211
#define NULL

+ Here is the call graph for this function:

virtual void VerilogFrontend::help ( )
inlinevirtual

Reimplemented from Pass.

Definition at line 44 of file verilog_frontend.cc.

45  {
46  // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
47  log("\n");
48  log(" read_verilog [options] [filename]\n");
49  log("\n");
50  log("Load modules from a verilog file to the current design. A large subset of\n");
51  log("Verilog-2005 is supported.\n");
52  log("\n");
53  log(" -sv\n");
54  log(" enable support for SystemVerilog features. (only a small subset\n");
55  log(" of SystemVerilog is supported)\n");
56  log("\n");
57  log(" -dump_ast1\n");
58  log(" dump abstract syntax tree (before simplification)\n");
59  log("\n");
60  log(" -dump_ast2\n");
61  log(" dump abstract syntax tree (after simplification)\n");
62  log("\n");
63  log(" -dump_vlog\n");
64  log(" dump ast as verilog code (after simplification)\n");
65  log("\n");
66  log(" -yydebug\n");
67  log(" enable parser debug output\n");
68  log("\n");
69  log(" -nolatches\n");
70  log(" usually latches are synthesized into logic loops\n");
71  log(" this option prohibits this and sets the output to 'x'\n");
72  log(" in what would be the latches hold condition\n");
73  log("\n");
74  log(" this behavior can also be achieved by setting the\n");
75  log(" 'nolatches' attribute on the respective module or\n");
76  log(" always block.\n");
77  log("\n");
78  log(" -nomem2reg\n");
79  log(" under certain conditions memories are converted to registers\n");
80  log(" early during simplification to ensure correct handling of\n");
81  log(" complex corner cases. this option disables this behavior.\n");
82  log("\n");
83  log(" this can also be achieved by setting the 'nomem2reg'\n");
84  log(" attribute on the respective module or register.\n");
85  log("\n");
86  log(" -mem2reg\n");
87  log(" always convert memories to registers. this can also be\n");
88  log(" achieved by setting the 'mem2reg' attribute on the respective\n");
89  log(" module or register.\n");
90  log("\n");
91  log(" -ppdump\n");
92  log(" dump verilog code after pre-processor\n");
93  log("\n");
94  log(" -nopp\n");
95  log(" do not run the pre-processor\n");
96  log("\n");
97  log(" -lib\n");
98  log(" only create empty blackbox modules\n");
99  log("\n");
100  log(" -noopt\n");
101  log(" don't perform basic optimizations (such as const folding) in the\n");
102  log(" high-level front-end.\n");
103  log("\n");
104  log(" -icells\n");
105  log(" interpret cell types starting with '$' as internal cell types\n");
106  log("\n");
107  log(" -ignore_redef\n");
108  log(" ignore re-definitions of modules. (the default behavior is to\n");
109  log(" create an error message.)\n");
110  log("\n");
111  log(" -defer\n");
112  log(" only read the abstract syntax tree and defer actual compilation\n");
113  log(" to a later 'hierarchy' command. Useful in cases where the default\n");
114  log(" parameters of modules yield invalid or not synthesizable code.\n");
115  log("\n");
116  log(" -setattr <attribute_name>\n");
117  log(" set the specified attribute (to the value 1) on all loaded modules\n");
118  log("\n");
119  log(" -Dname[=definition]\n");
120  log(" define the preprocessor symbol 'name' and set its optional value\n");
121  log(" 'definition'\n");
122  log("\n");
123  log(" -Idir\n");
124  log(" add 'dir' to the directories which are used when searching include\n");
125  log(" files\n");
126  log("\n");
127  log("The command 'verilog_defaults' can be used to register default options for\n");
128  log("subsequent calls to 'read_verilog'.\n");
129  log("\n");
130  log("Note that the Verilog frontend does a pretty good job of processing valid\n");
131  log("verilog input, but has not very good error reporting. It generally is\n");
132  log("recommended to use a simulator (for example icarus verilog) for checking\n");
133  log("the syntax of the code, rather than to rely on read_verilog for that.\n");
134  log("\n");
135  }
void log(const char *format,...)
Definition: log.cc:180

+ Here is the call graph for this function:

void Pass::init_register ( )
staticinherited

Definition at line 54 of file register.cc.

55 {
56  while (first_queued_pass) {
59  }
60 }
Pass * first_queued_pass
Definition: register.cc:31
Pass * next_queued_pass
Definition: register.h:60
virtual void run_register()
Definition: register.cc:48

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Pass::post_execute ( Pass::pre_post_exec_state_t  state)
inherited

Definition at line 84 of file register.cc.

85 {
86  int64_t time_ns = PerformanceTimer::query() - state.begin_ns;
87  runtime_ns += time_ns;
88  current_pass = state.parent_pass;
89  if (current_pass)
90  current_pass->runtime_ns -= time_ns;
91 }
static int64_t query()
Definition: log.h:151
int64_t runtime_ns
Definition: register.h:37
Pass * current_pass
Definition: register.cc:32
Pass * parent_pass
Definition: register.h:40
int64_t begin_ns
Definition: register.h:41

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Pass::pre_post_exec_state_t Pass::pre_execute ( )
inherited

Definition at line 74 of file register.cc.

75 {
76  pre_post_exec_state_t state;
77  call_counter++;
78  state.begin_ns = PerformanceTimer::query();
79  state.parent_pass = current_pass;
80  current_pass = this;
81  return state;
82 }
static int64_t query()
Definition: log.h:151
Pass * current_pass
Definition: register.cc:32
int call_counter
Definition: register.h:36

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Frontend::run_register ( )
virtualinherited

Reimplemented from Pass.

Definition at line 272 of file register.cc.

273 {
274  log_assert(pass_register.count(pass_name) == 0);
275  pass_register[pass_name] = this;
276 
279 }
std::map< std::string, Frontend * > frontend_register
Definition: register.cc:34
std::string frontend_name
Definition: register.h:72
std::string pass_name
Definition: register.h:29
#define log_assert(_assert_expr_)
Definition: log.h:85
std::map< std::string, Pass * > pass_register
Definition: register.cc:35

Field Documentation

int Pass::call_counter
inherited

Definition at line 36 of file register.h.

FILE * Frontend::current_script_file = NULL
staticinherited

Definition at line 69 of file register.h.

std::string Frontend::frontend_name
inherited

Definition at line 72 of file register.h.

std::string Frontend::last_here_document
staticinherited

Definition at line 70 of file register.h.

std::vector< std::string > Frontend::next_args
staticinherited

Definition at line 79 of file register.h.

Pass* Pass::next_queued_pass
inherited

Definition at line 60 of file register.h.

std::string Pass::pass_name
inherited

Definition at line 29 of file register.h.

int64_t Pass::runtime_ns
inherited

Definition at line 37 of file register.h.

std::string Pass::short_help
inherited

Definition at line 29 of file register.h.


The documentation for this struct was generated from the following file: