Skip to content

Commit

Permalink
Merge pull request #350 from diffblue/elaborate_genvar
Browse files Browse the repository at this point in the history
Verilog: genvar symbols now created during elaboration
  • Loading branch information
kroening authored Jan 23, 2024
2 parents a9bc480 + 8947804 commit a849576
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/verilog/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SRC = expr2verilog.cpp \
sva_expr.cpp \
verilog_elaborate_constants.cpp \
verilog_elaborate.cpp \
verilog_expr.cpp \
verilog_generate.cpp \
verilog_interfaces.cpp \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,30 @@ void verilog_typecheckt::collect_symbols(const verilog_declt &decl)
}
}
}
else if(decl_class == ID_verilog_genvar)
{
symbolt symbol{irep_idt{}, verilog_genvar_typet{}, mode};

symbol.module = module_identifier;
symbol.value.make_nil();

for(auto &declarator : decl.declarators())
{
DATA_INVARIANT(declarator.id() == ID_declarator, "must have declarator");

symbol.base_name = declarator.base_name();
symbol.location = declarator.source_location();

if(symbol.base_name.empty())
throw errort().with_location(decl.source_location())
<< "empty symbol name";

symbol.name = hierarchical_identifier(symbol.base_name);
symbol.pretty_name = strip_verilog_prefix(symbol.name);

add_symbol(symbol);
}
}
}

void verilog_typecheckt::collect_symbols(const verilog_statementt &statement)
Expand Down Expand Up @@ -364,6 +388,15 @@ void verilog_typecheckt::collect_symbols(
collect_symbols(to_verilog_initial(module_item).statement());
}
else if(module_item.id() == ID_generate_block)
{
auto &generate_block = to_verilog_generate_block(module_item);
for(auto &sub_module_item : generate_block.module_items())
collect_symbols(sub_module_item);
}
else if(module_item.id() == ID_generate_for)
{
}
else if(module_item.id() == ID_generate_if)
{
}
else if(module_item.id() == ID_inst || module_item.id() == ID_inst_builtin)
Expand Down
7 changes: 2 additions & 5 deletions src/verilog/verilog_interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,10 @@ void verilog_typecheckt::interface_module_decl(
interface_function_or_task(decl);
return;
}
else if(port_class == ID_verilog_genvar)
{
type = verilog_genvar_typet();
}
else if(
port_class == ID_input || port_class == ID_output ||
port_class == ID_output_register || port_class == ID_inout)
port_class == ID_output_register || port_class == ID_inout ||
port_class == ID_verilog_genvar)
{
// symbol already created during elaboration
return;
Expand Down

0 comments on commit a849576

Please sign in to comment.