-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathexpr2verilog_class.h
181 lines (126 loc) · 4.93 KB
/
expr2verilog_class.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*******************************************************************\
Module:
Author: Daniel Kroening, [email protected]
\*******************************************************************/
#ifndef CPROVER_VERILOG_EXPR2VERILOG_H
#define CPROVER_VERILOG_EXPR2VERILOG_H
#include <util/bitvector_expr.h>
#include <util/std_expr.h>
class sva_abort_exprt;
class sva_case_exprt;
class sva_if_exprt;
class sva_ranged_predicate_exprt;
// Precedences (higher means binds more strongly).
// Follows Table 11-2 in IEEE 1800-2017.
// We deviate from the table for the precedence of concatenation
// and replication, which act like parentheses.
enum class verilog_precedencet
{
MAX = 19,
MEMBER = 18, // [ ] bit-select ( ) parenthesis :: .
NOT = 17, // unary ! ~ & | ~& ~| ^ ~^ ^~ + -
POWER = 16, // ** power
MULT = 15, // * / %
ADD = 14, // + -
SHIFT = 13, // << >> <<< >>>
RELATION = 12, // > >= < <= inside dist
EQUALITY = 11, // == != === !== ==? !=?
BITAND = 10, // &
XOR = 9, // ^ ~^ ^~ (binary)
BITOR = 8, // |
AND = 7, // &&
OR = 6, // ||
IF = 5, // ?:
IMPLIES = 4, // -> <->
ASSIGN = 3, // = += -= etc.
CONCAT = 18, // { } concatenation, {{ }} replication
MIN = 0 // anything even weaker, e.g., SVA
};
class expr2verilogt
{
public:
explicit expr2verilogt(const namespacet &__ns) : ns(__ns)
{
}
virtual ~expr2verilogt()
{
}
virtual std::string convert(const typet &);
virtual std::string convert(const exprt &);
protected:
struct resultt
{
resultt(verilog_precedencet _p, std::string _s) : p(_p), s(std::move(_s))
{
}
verilog_precedencet p;
std::string s;
};
virtual resultt convert_rec(const exprt &src);
resultt convert_array(const exprt &src, verilog_precedencet);
resultt convert_binary(
const multi_ary_exprt &,
const std::string &symbol,
verilog_precedencet);
resultt convert_unary(
const unary_exprt &,
const std::string &symbol,
verilog_precedencet);
resultt convert_if(const if_exprt &, verilog_precedencet);
resultt convert_index(const index_exprt &, verilog_precedencet);
resultt convert_extractbit(const extractbit_exprt &, verilog_precedencet);
resultt convert_member(const member_exprt &, verilog_precedencet);
resultt convert_extractbits(const extractbits_exprt &, verilog_precedencet);
resultt convert_symbol(const exprt &);
resultt
convert_hierarchical_identifier(const class hierarchical_identifier_exprt &);
resultt convert_nondet_symbol(const exprt &);
resultt convert_next_symbol(const exprt &);
resultt convert_constant(const constant_exprt &);
resultt
convert_explicit_const_cast(const class verilog_explicit_const_cast_exprt &);
resultt convert_explicit_signing_cast(
const class verilog_explicit_signing_cast_exprt &);
resultt
convert_explicit_type_cast(const class verilog_explicit_type_cast_exprt &);
resultt convert_typecast(const typecast_exprt &);
resultt
convert_explicit_size_cast(const class verilog_explicit_size_cast_exprt &);
resultt
convert_concatenation(const concatenation_exprt &, verilog_precedencet);
resultt convert_function(const std::string &name, const exprt &src);
resultt convert_sva_case(const sva_case_exprt &);
resultt convert_sva_ranged_predicate(
const std::string &name,
const sva_ranged_predicate_exprt &);
resultt convert_sva_unary(const std::string &name, const unary_exprt &);
resultt convert_sva_unary(const unary_exprt &, const std::string &name);
resultt convert_sva_binary(const std::string &name, const binary_exprt &);
resultt
convert_sva_binary_repetition(const std::string &name, const binary_exprt &);
resultt convert_sva_abort(const std::string &name, const sva_abort_exprt &);
resultt
convert_sva_indexed_binary(const std::string &name, const binary_exprt &);
resultt convert_replication(const replication_exprt &, verilog_precedencet);
resultt convert_norep(const exprt &);
resultt convert_with(const with_exprt &, verilog_precedencet);
resultt convert_sva_cycle_delay(const ternary_exprt &, verilog_precedencet);
resultt convert_sva_if(const sva_if_exprt &);
resultt
convert_sva_sequence_concatenation(const binary_exprt &, verilog_precedencet);
resultt convert_function_call(const class function_call_exprt &);
resultt convert_non_indexed_part_select(
const class verilog_non_indexed_part_select_exprt &,
verilog_precedencet precedence);
resultt convert_indexed_part_select(
const class verilog_indexed_part_select_plus_or_minus_exprt &,
verilog_precedencet precedence);
resultt convert_streaming_concatenation(
const std::string &name,
const class verilog_streaming_concatenation_exprt &);
resultt convert_inside(const class verilog_inside_exprt &);
resultt convert_value_range(const class verilog_value_range_exprt &);
protected:
const namespacet &ns;
};
#endif