// instanciate global variables (private API)
namespace AST_INTERNAL {
- bool flag_dump_ast, flag_dump_ast_diff, flag_dump_vlog, flag_nolatches, flag_nomem2reg, flag_mem2reg, flag_lib, flag_noopt;
+ bool flag_dump_ast1, flag_dump_ast2, flag_dump_vlog, flag_nolatches, flag_nomem2reg, flag_mem2reg, flag_lib, flag_noopt;
AstNode *current_ast, *current_ast_mod;
std::map<std::string, AstNode*> current_scope;
RTLIL::SigSpec *genRTLIL_subst_from = NULL;
// create a nice text representation of the node
// (traverse tree by recursion, use 'other' pointer for diffing two AST trees)
-void AstNode::dumpAst(FILE *f, std::string indent, AstNode *other)
+void AstNode::dumpAst(FILE *f, std::string indent)
{
if (f == NULL) {
for (auto f : log_files)
- dumpAst(f, indent, other);
+ dumpAst(f, indent);
return;
}
- if (other != NULL) {
- if (type != other->type)
- goto found_diff_to_other;
- if (children.size() != other->children.size())
- goto found_diff_to_other;
- if (str != other->str)
- goto found_diff_to_other;
- if (bits != other->bits)
- goto found_diff_to_other;
- if (is_input != other->is_input)
- goto found_diff_to_other;
- if (is_output != other->is_output)
- goto found_diff_to_other;
- if (is_reg != other->is_reg)
- goto found_diff_to_other;
- if (is_signed != other->is_signed)
- goto found_diff_to_other;
- if (range_valid != other->range_valid)
- goto found_diff_to_other;
- if (port_id != other->port_id)
- goto found_diff_to_other;
- if (range_left != other->range_left)
- goto found_diff_to_other;
- if (range_right != other->range_right)
- goto found_diff_to_other;
- if (integer != other->integer)
- goto found_diff_to_other;
- if (0) {
- found_diff_to_other:
- other->dumpAst(f, indent + "- ");
- this->dumpAst(f, indent + "+ ");
- return;
- }
- }
std::string type_name = type2str(type);
fprintf(f, "%s%s <%s:%d>", indent.c_str(), type_name.c_str(), filename.c_str(), linenum);
fprintf(f, "\n");
for (size_t i = 0; i < children.size(); i++)
- children[i]->dumpAst(f, indent + " ", other ? other->children[i] : NULL);
+ children[i]->dumpAst(f, indent + " ");
}
// helper function for AstNode::dumpVlog()
current_ast_mod = ast;
AstNode *ast_before_simplify = ast->clone();
+ if (flag_dump_ast1) {
+ log("Dumping verilog AST before simplification:\n");
+ ast->dumpAst(NULL, " ");
+ log("--- END OF AST DUMP ---\n");
+ }
+
while (ast->simplify(!flag_noopt, false, false, 0)) { }
- if (flag_dump_ast) {
- log("Dumping verilog AST (as requested by %s option):\n", flag_dump_ast_diff ? "dump_ast_diff" : "dump_ast");
- ast->dumpAst(NULL, " ", flag_dump_ast_diff ? ast_before_simplify : NULL);
+ if (flag_dump_ast2) {
+ log("Dumping verilog AST after simplification:\n");
+ ast->dumpAst(NULL, " ");
log("--- END OF AST DUMP ---\n");
}
}
// create AstModule instances for all modules in the AST tree and add them to 'design'
-void AST::process(RTLIL::Design *design, AstNode *ast, bool dump_ast, bool dump_ast_diff, bool dump_vlog, bool nolatches, bool nomem2reg, bool mem2reg, bool lib, bool noopt)
+void AST::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)
{
current_ast = ast;
- flag_dump_ast = dump_ast;
- flag_dump_ast_diff = dump_ast_diff;
+ flag_dump_ast1 = dump_ast1;
+ flag_dump_ast2 = dump_ast2;
flag_dump_vlog = dump_vlog;
flag_nolatches = nolatches;
flag_nomem2reg = nomem2reg;
log_header("Executing AST frontend in derive mode using pre-parsed AST for module `%s'.\n", name.c_str());
current_ast = NULL;
- flag_dump_ast = false;
- flag_dump_ast_diff = false;
+ flag_dump_ast1 = false;
+ flag_dump_ast2 = false;
flag_dump_vlog = false;
flag_nolatches = nolatches;
flag_nomem2reg = nomem2reg;
log_header("Executing AST frontend in update_auto_wires mode using pre-parsed AST for module `%s'.\n", name.c_str());
current_ast = NULL;
- flag_dump_ast = false;
- flag_dump_ast_diff = false;
+ flag_dump_ast1 = false;
+ flag_dump_ast2 = false;
flag_dump_vlog = false;
flag_nolatches = nolatches;
flag_nomem2reg = nomem2reg;
void meminfo(int &mem_width, int &mem_size, int &addr_bits);
// create a human-readable text representation of the AST (for debugging)
- void dumpAst(FILE *f, std::string indent, AstNode *other = NULL);
+ void dumpAst(FILE *f, std::string indent);
void dumpVlog(FILE *f, std::string indent);
// used by genRTLIL() for detecting expression width and sign
};
// process an AST tree (ast must point to an AST_DESIGN node) and generate RTLIL code
- void process(RTLIL::Design *design, AstNode *ast, bool dump_ast = false, bool dump_ast_diff = false, bool dump_vlog = false, bool nolatches = false, bool nomem2reg = false, bool mem2reg = false, bool lib = false, bool noopt = false);
+ void process(RTLIL::Design *design, AstNode *ast, bool dump_ast1 = false, bool dump_ast2 = false, bool dump_vlog = false, bool nolatches = false, bool nomem2reg = false, bool mem2reg = false, bool lib = false, bool noopt = false);
// parametric modules are supported directly by the AST library
// therfore we need our own derivate of RTLIL::Module with overloaded virtual functions
namespace AST_INTERNAL
{
// internal state variables
- extern bool flag_dump_ast, flag_dump_ast_diff, flag_nolatches, flag_nomem2reg, flag_mem2reg, flag_lib, flag_noopt;
+ extern bool flag_dump_ast1, flag_dump_ast2, flag_nolatches, flag_nomem2reg, flag_mem2reg, flag_lib, flag_noopt;
extern AST::AstNode *current_ast, *current_ast_mod;
extern std::map<std::string, AST::AstNode*> current_scope;
extern RTLIL::SigSpec *genRTLIL_subst_from, *genRTLIL_subst_to, ignoreThisSignalsInInitial;
log("Load modules from a verilog file to the current design. A large subset of\n");
log("Verilog-2005 is supported.\n");
log("\n");
- log(" -dump_ast\n");
- log(" dump abstract syntax tree (after simplification)\n");
+ log(" -dump_ast1\n");
+ log(" dump abstract syntax tree (before simplification)\n");
log("\n");
- log(" -dump_ast_diff\n");
- log(" dump ast differences before and after simplification\n");
+ log(" -dump_ast2\n");
+ log(" dump abstract syntax tree (after simplification)\n");
log("\n");
log(" -dump_vlog\n");
log(" dump ast as verilog code (after simplification)\n");
}
virtual void execute(FILE *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design)
{
- bool flag_dump_ast = false;
- bool flag_dump_ast_diff = false;
+ bool flag_dump_ast1 = false;
+ bool flag_dump_ast2 = false;
bool flag_dump_vlog = false;
bool flag_nolatches = false;
bool flag_nomem2reg = false;
size_t argidx;
for (argidx = 1; argidx < args.size(); argidx++) {
std::string arg = args[argidx];
- if (arg == "-dump_ast") {
- flag_dump_ast = true;
+ if (arg == "-dump_ast1") {
+ flag_dump_ast1 = true;
continue;
}
- if (arg == "-dump_ast_diff") {
- flag_dump_ast = true;
- flag_dump_ast_diff = true;
+ if (arg == "-dump_ast2") {
+ flag_dump_ast2 = true;
continue;
}
if (arg == "-dump_vlog") {
frontend_verilog_yyparse();
frontend_verilog_yylex_destroy();
- AST::process(design, current_ast, flag_dump_ast, flag_dump_ast_diff, flag_dump_vlog, flag_nolatches, flag_nomem2reg, flag_mem2reg, flag_lib, flag_noopt);
+ AST::process(design, current_ast, flag_dump_ast1, flag_dump_ast2, flag_dump_vlog, flag_nolatches, flag_nomem2reg, flag_mem2reg, flag_lib, flag_noopt);
if (!flag_nopp)
fclose(fp);