Skip to content

Commit 0d6b81f

Browse files
committed
SVA: type for named sequences and properties
This introduces a type for named sequences and properties, similar to the type for functions and tasks.
1 parent c5ef5a1 commit 0d6b81f

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

src/hw_cbmc_irep_ids.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ IREP_ID_ONE(verilog_always)
228228
IREP_ID_ONE(verilog_always_comb)
229229
IREP_ID_ONE(verilog_always_ff)
230230
IREP_ID_ONE(verilog_always_latch)
231+
IREP_ID_ONE(verilog_sva_named_property)
232+
IREP_ID_ONE(verilog_sva_named_sequence)
231233
IREP_ID_ONE(named_port_connection)
232234
IREP_ID_ONE(verilog_final)
233235
IREP_ID_ONE(initial)

src/verilog/verilog_types.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,4 +867,88 @@ class verilog_sva_sequence_typet : public typet
867867
}
868868
};
869869

870+
// base class for SVA named sequences and properties
871+
class verilog_sva_named_sequence_property_typet : public typet
872+
{
873+
public:
874+
class portt : public irept
875+
{
876+
public:
877+
portt(irep_idt _identifier, typet _type) : irept(ID_symbol)
878+
{
879+
identifier(_identifier);
880+
type() = std::move(_type);
881+
}
882+
883+
typet &type()
884+
{
885+
return static_cast<typet &>(add(ID_type));
886+
}
887+
888+
const typet &type() const
889+
{
890+
return static_cast<const typet &>(find(ID_type));
891+
}
892+
893+
irep_idt identifier() const
894+
{
895+
return get(ID_identifier);
896+
}
897+
898+
void identifier(irep_idt _identifier)
899+
{
900+
set(ID_identifier, _identifier);
901+
}
902+
903+
const source_locationt &source_location() const
904+
{
905+
return (const source_locationt &)find(ID_C_source_location);
906+
}
907+
};
908+
909+
using portst = std::vector<portt>;
910+
911+
verilog_sva_named_sequence_property_typet(irep_idt _id, portst _ports)
912+
: typet(_id)
913+
{
914+
ports() = std::move(_ports);
915+
}
916+
917+
portst &ports()
918+
{
919+
return (portst &)(add(ID_ports).get_sub());
920+
}
921+
922+
const portst &ports() const
923+
{
924+
return (const portst &)(find(ID_ports).get_sub());
925+
}
926+
};
927+
928+
/// SVA named properties
929+
class verilog_sva_named_property_typet
930+
: public verilog_sva_named_sequence_property_typet
931+
{
932+
public:
933+
explicit verilog_sva_named_property_typet(portst _ports)
934+
: verilog_sva_named_sequence_property_typet{
935+
ID_verilog_sva_named_property,
936+
std::move(_ports)}
937+
{
938+
}
939+
};
940+
941+
/// SVA named sequences
942+
class verilog_sva_named_sequence_typet
943+
: public verilog_sva_named_sequence_property_typet
944+
{
945+
public:
946+
explicit verilog_sva_named_sequence_typet(portst _ports)
947+
: verilog_sva_named_sequence_property_typet{
948+
ID_verilog_sva_named_sequence,
949+
std::move(_ports)}
950+
{
951+
}
952+
};
953+
870954
#endif

0 commit comments

Comments
 (0)