-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbasicsdt.h
192 lines (143 loc) · 5.31 KB
/
basicsdt.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
182
183
184
185
186
187
188
189
190
191
192
/*************************************************************************
*
* Copyright (c) 2020 Rajit Manohar
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
**************************************************************************
*/
#ifndef __ACT_BASIC_SDT_H__
#define __ACT_BASIC_SDT_H__
#include "sdt.h"
/*
*
* Each original ACT variable will have a unique entry available that
* indicates various properties of the variable. The varmap_info
* structure includes the necessary information.
*
*/
struct varmap_info {
ActId *id;
/*-- flags --*/
unsigned int fcurexpr:1; // found in current expression
unsigned int fischan:1; // channel or int?
unsigned int fisinport:2; // 1 if input, 0 if output, 2 if both
unsigned int fisbool:1; // bool variable or bool chan
int width; // bitwidth
int block_in, block_out; // for internal channels
int nread, nwrite; // for variables
// nread = total # of reads
// nwrite = total # of writes
// for channels
// nread = total # of receives
// nwrite = total # of sends
int iread, iwrite; // running counter used for muxing
};
class BasicSDT : public SDTEngine {
public:
/**
* Basic SDT translator
*
* @param isbundled indicates if the datapath is bundled data (1) or
* QDI (0)
*
* @param isopt is 1 if SDT control optimizations are enabled
*
* @param doimport is set if the output should emit another import
* directive
*
* @param out is the output file name
*
*/
BasicSDT (int isbundled, int isopt, FILE *fpout, const char *expr_file);
virtual ~BasicSDT () { };
int sdt_error () { if (_isdynamic_var) return 1; else return 0; }
protected:
/// Run SDT control optimizations
int optimize;
/// Datapath is bundled data (vs QDI)
int bundled_data;
/// Output file stream
FILE *output_stream;
/*-- mode: currently not used --*/
int _shared_expr_var;
/// mark this as a dynamic memory process
void _chkdynamic (ActId *id);
/// Aux functions for variable information
int _get_isinport (varmap_info *v);
/*
* This function returns the varmap_info structure
* for an ACT identifier
*/
varmap_info *_var_getinfo (ActId *id);
/*
* Use to emit ids
*/
void _emit_mangled_id (FILE *fp, ActId *id);
/* constructs the varmap structure */
void _construct_varmap (act_chp_lang_t *c);
void _construct_varmap_expr (Expr *e);
void _clear_var_flags ();
/*-- the varmap table --*/
struct iHashtable *_varmap;
int _isdynamic_var;
/// Override stmt id to also emit the channel definition in the
/// output stream
int _gen_stmt_id ();
void _emit_skip (int id);
void _emit_expr_block (int eid, int blkid, list_t *eleaf);
void _emit_expr_binary (int id, int width,
int type,
int lid, int lw,
int rid, int rw);
void _emit_expr_unary (int id, int width,
int type, int lid, int lw);
void _emit_expr_ite (int id, int width,
int type, int tid,
int lid, int lw,
int rid, int rw);
void _emit_expr_bitfield (int eid, int lsb, int msb, int lid, int lw);
void _emit_expr_concat2 (int eid, int width, int lid, int lw, int rid, int rw);
void _emit_expr_width_conv (int from, int from_w,
int to, int to_w);
void _emit_expr_const (int eid, int width, int val, bool forced);
/* id = variable port for this identifier */
void _emit_var_read (int eid, ActId *id);
void _emit_transfer (int cid, int eid, ActId *);
void _emit_recv (int cid, ActId *chid, ActId *);
/*-- internal --*/
void _emit_channel_mux (varmap_info *ch);
void _emit_variable_mux (varmap_info *v);
void _emit_comma (int cid, list_t *stmts);
void _emit_semi (int cid, list_t *stmts);
void _emit_semiopt (int cid, list_t *stmts);
void _emit_trueseq (int cid, int sid);
int _gen_fresh_var (int width, ActId **);
int _gen_fresh_var_writeonly (int width, ActId **id);
int _gen_safe_bool (int eid);
void _emit_loop (int cid, list_t *guards, list_t *stmts);
void _emit_doloop (int cid, int guard, int stmt);
void _emit_select (int is_nondet, int cid, list_t *guards, list_t *stmts);
void _emit_probed_select (int cid, list_t *dataguards,
list_t *guards, list_t *stmts);
int _emit_chan_to_probe (ActId *chid);
int _emit_probed_clause (list_t *guards, list_t *probe_list);
void _emit_begin ();
void _emit_end (int toplev);
bool write_process_definition(FILE *fp, Process * p);
void initialize_chp_ints(FILE *fp, Process * p, bool has_overrides);
};
#endif /* __ACT_BASIC_SDT_H__ */