Skip to content

Commit

Permalink
Add -parse-only flag
Browse files Browse the repository at this point in the history
This flag can be used to only check designs, but don't load them into yosys

Signed-off-by: Kamil Rakoczy <krakoczy@antmicro.com>
  • Loading branch information
kamilrakoczy committed Apr 20, 2022
1 parent d09ffc1 commit c6f745a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions systemverilog-plugin/uhdmastshared.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class UhdmAstShared
// Flag that determines whether errors should be fatal
bool stop_on_error = true;

// Flag that determines whether we should only parse the design
// applies only to read_systemverilog command
bool parse_only = false;

// Top nodes of the design (modules, interfaces)
std::unordered_map<std::string, AST::AstNode *> top_nodes;

Expand Down
14 changes: 11 additions & 3 deletions systemverilog-plugin/uhdmcommonfrontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ void UhdmCommonFrontend::print_read_options()
log(" only read the abstract syntax tree and defer actual compilation\n");
log(" to a later 'hierarchy' command. Useful in cases where the default\n");
log(" parameters of modules yield invalid or not synthesizable code.\n");
log(" -parse-only\n");
log(" this parameter only applies to read_systemverilog command,\n");
log(" it runs only Surelog to parse design, but doesn't load generated\n");
log(" tree into Yosys.\n");
log("\n");
}

Expand Down Expand Up @@ -108,6 +112,8 @@ void UhdmCommonFrontend::execute(std::istream *&f, std::string filename, std::ve
dump_rtlil = true;
} else if (args[i] == "-yydebug") {
this->shared.debug_flag = true;
} else if (args[i] == "-parse-only") {
this->shared.parse_only = true;
} else {
unhandled_args.push_back(args[i]);
}
Expand All @@ -128,9 +134,11 @@ void UhdmCommonFrontend::execute(std::istream *&f, std::string filename, std::ve

AST::AstNode *current_ast = parse(filename);

AST::process(design, current_ast, dump_ast1, dump_ast2, no_dump_ptr, dump_vlog1, dump_vlog2, dump_rtlil, false, false, false, false, false, false,
false, false, false, false, dont_redefine, false, defer, default_nettype_wire);
delete current_ast;
if (current_ast) {
AST::process(design, current_ast, dump_ast1, dump_ast2, no_dump_ptr, dump_vlog1, dump_vlog2, dump_rtlil, false, false, false, false, false,
false, false, false, false, false, dont_redefine, false, defer, default_nettype_wire);
delete current_ast;
}
}

YOSYS_NAMESPACE_END
4 changes: 4 additions & 0 deletions systemverilog-plugin/uhdmsurelogastfrontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ struct UhdmSurelogAstFrontend : public UhdmCommonFrontend {
delete clp;
delete symbolTable;
delete errors;
// on parse_only mode, don't try to load design
// into yosys
if (this->shared.parse_only)
return nullptr;

UhdmAst uhdm_ast(this->shared);
AST::AstNode *current_ast = uhdm_ast.visit_designs(uhdm_design);
Expand Down

0 comments on commit c6f745a

Please sign in to comment.