-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexternoptsdt.h
176 lines (150 loc) · 6.21 KB
/
externoptsdt.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
#ifndef __ACT_EXTERNOPT_SDT_H__
#define __ACT_EXTERNOPT_SDT_H__
#include "basicsdt.h"
#include "config_pkg.h"
#include <act/expropt.h>
/**
* the ExternOpt Syntax directed translation class takes a CHP process
* and expans and translates it to production rules. all data path
* parts are handed of to an external syntesis and mapping tool, like
* yosys or genus. the controll path is handeled identiacal the the
* basic Syntax directed translation which this class inherits from.
*
*/
class ExternOptSDT : public BasicSDT {
public:
/**
* constructs a SDT translator.
*
* @param isbundled indicate if the translation is to bundled data
* (1) or qdi (0)
* @param isopt is handed of to BasicSDT - should have no function
* @param doimport an additional act file that should be imported
* by the output
* @param out the path to the output file that the translated prs
* act is writen to.
* @param exprfile the path to the file all the datapath elements
* are writen to
* @param map the selected external sysntesis tool to be used for
* the logic syntesis and mapping - defaults to yosys.
* @param tmp_path the path where all the temporary files are
* generated, not implemented yet.
*/
ExternOptSDT (int isbundled,
int isopt,
FILE *fpout,
const char *ef,
const char *map = "yosys",
const char *tmp_path = ".") :
BasicSDT(isbundled, isopt, fpout, ef) {
tmp_file_path = tmp_path;
_map = map;
mapper = NULL;
}
~ExternOptSDT () {
if (mapper) { delete mapper; }
}
private:
const char *_map;
/**
* the path where the temporary syntesis files are generated in, not yet implemented uses the exceution directory of the program currently.
*/
const char *tmp_file_path;
/**
* the datapath expression translator form the expropt library
*/
ExternalExprOpt *mapper;
/**
* the map that contains the pointer addess of the act expression var as key and a int id as the varname to be used in the translation
*/
struct iHashtable *_inexprmap;
/**
* the map that contains the pointer addess of the act expression as key and a int indicating the bitwidth of the expression var
*/
struct iHashtable *_inwidthmap;
/**
* the map that contains the pointer addess of the act full expression as key and a int id as the varname it is to be assined to
*/
struct iHashtable *_outexprmap;
/**
* the map that contains the pointer addess of the act expression as key and a int indicating the bitwidth of the var it is assigned to
*/
struct iHashtable *_outwidthmap;
protected:
/**
* construct in and out data structurs, hand off expression to external tool, wrap mapped logic and bypass handshaking.
* overwrite sdt behavior
*
* @param id expression id used to identify the expression
* @param tgt_width target width the expression should output
* @param e the expression itself (act data structure)
*/
void _emit_expr (int *id, int tgt_width, Expr *e);
/**
* go through the expression datastructure and find all input vars and register them in the in maps.
* @param e the expression itself (act data structure)
* @param collect_phase if it is searching the vars or if it is printing the var wrappers
*/
void _expr_collect_vars (Expr *e, int collect_phase);
/**
* A helper to go through the expression datastructure and compute the resulting bitwidth.
* @param ex the expression itself (act data structure)
* @return int the calculated bitwidth resulting out of the expression
*/
int get_expr_width(Expr *ex);
/**
* prints and creates a constant in qdi mode, or in bundeled data mode if its a constant guard => infinite loop
*
* @param id the id the constant should carry
* @param width the bit width of the constant
* @param val the value the constant emmits
* @param isguard if it is a guard so it is created also in bundled data mode
*/
void _emit_expr_const (int id, int width, int val, bool forced);
/**
* creates a wrapper for the expression block from wires in to a channel,
* converts the width in qdi mode if expression width and target width do not match.
*
* @param from the id of the expression block
* @param from_w the output width of the expression block
* @param to the id of the wrapper
* @param to_w and the width of the resulting signal (to which it should be converted to)
*/
void _emit_expr_width_conv (int from, int from_w,int to, int to_w);
/**
* instanciates the expression block and prints the input connections in the constructor
*
* @param id the inst id the block should have.
* @param blkid the id of the block that is in the expression file.
* @param exprs the input variables (pointers) that need to be connected the the block - the id will be taken from the in map for the given pointer
*/
void _emit_expr_block (int id, int blkid, list_t *exprs);
/**
* generates a temp var for guards so the result of the guard is cached properly
* @param eid the id of the signal to be guarded
* @return int the id of the guarded signal
*/
int _gen_safe_bool (int eid);
/**
* emmits all guards and wraps them appropiately
* @TODO implemnt concurrent eval of guards and combine them for optimisation
* @param isloop if the guards are part of a loop
* @param gc the guards
* @param reslist list the output ids of the guards are stored in
*/
void _emit_guardlist (int isloop, act_chp_gc_t *gc, list_t *reslist);
/**
*
* @param new_id the id that wrapps the original id
* @param old_id the original id
* @param width the expression width of the channel
*/
void _emit_expr_array_wrap(int new_id, int old_id, int width);
/**
* connects the ctl channel around the expr block
* @param id the id of the out channel
* @param all_leaves all the in channels
*/
void _emit_bd_ctl_bypass (int id, list_t *all_leaves, double delay_max);
};
#endif /* __ACT_EXTERNOPT_SDT_H__ */