Skip to content

Commit 53bba2d

Browse files
committed
Verilog: strengthen typing when using verilog_blockt
This introduces a method for accessing the statements in the block.
1 parent 825e4bc commit 53bba2d

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

src/verilog/verilog_expr.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,25 @@ class verilog_blockt:public verilog_statementt
648648
verilog_blockt():verilog_statementt(ID_block)
649649
{
650650
}
651-
652-
inline irep_idt get_identifier() const
651+
652+
using statementst = std::vector<verilog_statementt>;
653+
654+
statementst &statements()
655+
{
656+
return (statementst &)operands();
657+
}
658+
659+
const statementst &statements() const
660+
{
661+
return (const statementst &)operands();
662+
}
663+
664+
irep_idt identifier() const
653665
{
654666
return get(ID_identifier);
655667
}
656-
657-
inline bool is_named() const
668+
669+
bool is_named() const
658670
{
659671
return !get(ID_identifier).empty();
660672
}

src/verilog/verilog_interfaces.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,8 @@ void verilog_typecheckt::interface_block(
857857

858858
if(is_named)
859859
{
860-
irep_idt identifier=statement.get_identifier();
861-
860+
irep_idt identifier = statement.identifier();
861+
862862
// need to add to symbol table
863863
symbolt symbol;
864864

@@ -892,9 +892,8 @@ void verilog_typecheckt::interface_block(
892892

893893
// do block itself
894894

895-
forall_operands(it, statement)
896-
interface_statement(
897-
static_cast<const verilog_statementt &>(*it));
895+
for(auto &block_statement : statement.statements())
896+
interface_statement(block_statement);
898897

899898
if(is_named)
900899
named_blocks.pop_back();

src/verilog/verilog_synthesis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,8 +1570,8 @@ Function: verilog_synthesist::synth_block
15701570

15711571
void verilog_synthesist::synth_block(const verilog_blockt &statement)
15721572
{
1573-
forall_operands(it, statement)
1574-
synth_statement(static_cast<const verilog_statementt &>(*it));
1573+
for(auto &block_statement : statement.statements())
1574+
synth_statement(block_statement);
15751575
}
15761576

15771577
/*******************************************************************\

src/verilog/verilog_typecheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -778,11 +778,11 @@ void verilog_typecheckt::convert_block(verilog_blockt &statement)
778778
bool is_named=statement.is_named();
779779

780780
if(is_named)
781-
enter_named_block(statement.get_identifier());
781+
enter_named_block(statement.identifier());
782+
783+
for(auto &block_statement : statement.statements())
784+
convert_statement(block_statement);
782785

783-
Forall_operands(it, statement)
784-
convert_statement(to_verilog_statement(*it));
785-
786786
if(is_named)
787787
named_blocks.pop_back();
788788
}

0 commit comments

Comments
 (0)