-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreatCL0.cpp
More file actions
281 lines (206 loc) · 7.32 KB
/
Copy pathcreatCL0.cpp
File metadata and controls
281 lines (206 loc) · 7.32 KB
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
#include "rpucfg.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <algorithm>
#if 0
int RPUConfig::createCL0File(const String &fileName){
std::ofstream CL0File(fileName.c_str());
assert(CL0File);
const String & graphName = dfgGraph.name();
// uppercase of name
String GRAPHNAME = graphName;
std::transform(GRAPHNAME.begin(), GRAPHNAME.end(),
GRAPHNAME.begin(), ::toupper);
std::size_t cl0size = CL0Context.size();
// Print file
//========================================================
CL0File<<
"/******************************************************\n"
" * This file is generated by RPUCompiler automatically.\n"
" * ----------------------------------------------------\n"
" */\n"
"\n\n"
"#ifndef "<<GRAPHNAME<<"_CL0_H\n"
"#define "<<GRAPHNAME<<"_CL0_H\n"
"\n"
"\n"
"#define "<<GRAPHNAME<<"_LOAD_BASE\t\t"<<SSRAM_LOAD_BASE<<"\n"
"#define "<<GRAPHNAME<<"_STORE_BASE\t\t"<<SSRAM_STORE_BASE<<"\n"
"\n\n"
"#define "<<GRAPHNAME<<"_CL0_SIZE\t"<<std::dec<<cl0size<<"\n\n"
"unsigned int "<<graphName<<"_cl0"<<"_ctx [] = {";
CL0File.fill('0');
for(std::size_t i =0; i <cl0size ; ++i){
CL0File<<"\n\t\t0x"<<std::setw(8)<<std::hex<<CL0Context[i];
if( i + 1 != cl0size)CL0File<<",";
}
CL0File<<"\n};\n\n#endif"<<std::endl;
return 0;
}
#endif
#if 0
int RPUConfig::createCL0File(const String &fileName){
std::ofstream CL0File(fileName.c_str());
assert(CL0File);
const String & graphName = dfgGraph.name();
// uppercase of name
String GRAPHNAME = graphName;
std::transform(GRAPHNAME.begin(), GRAPHNAME.end(),
GRAPHNAME.begin(), ::toupper);
std::size_t cl0size = CL0Context.size();
// Print file
//========================================================
CL0File<<"#ifndef MAIN_C\n"
"#define MAIN_C\n\n"<<std::endl;
CL0File<<
"/*************************************************************\n"
" * This main.c file is generated by RPUCompiler automatically.\n"
" * -----------------------------------------------------------\n"
"*/\n\n"
"// General Purpose Data Types \n"
"typedef char S8; /* signed 8 -bit integer */ \n"
"typedef short S16; /* signed 16-bit integer */ \n"
"typedef long S32; /* signed 32-bit integer */ \n"
"typedef unsigned char U8; /* unsigned 8 -bit integer */ \n"
"typedef unsigned short U16; /* unsigned 16-bit integer */ \n"
"typedef unsigned long U32; /* unsigned 32-bit integer */ \n\n"
"typedef volatile U32 * RP; \n"
"typedef volatile U16 * RP16; \n"
"typedef volatile U8 * RP8; \n"
"\n\n// Hardware REG\n"
"#define RCA_cwi 0xc0000000\n"
"#define RCA_cwi_left_space 0xc0000004\n"
"#define RCA_int_clear 0xc0000030\n"
"#define RCA_cwi_release 0xc0000040\n\n"
"#define RCA_cwi2 0xc0001000\n"
"#define RCA_cwi_left_space2 0xc0001004\n"
"#define RCA_int_clear2 0xc0001030\n\n"
"#define ahb2fb_base 0xd0000000\n\n"
"void main( )\n"
"{";
CL0File.fill('0');
//std::size_t j=0;
reg32 cfghead;
cfghead =CL0Context[0];
int REDLREDSValue;
REDLREDSValue = ((cfghead>>2)&0x1f);
REDLREDSValue += ((cfghead>>7)&0x1f);
unsigned int rcaCounter;
rcaCounter=0;
CL0File<<"\n\n //this is for RCA 0"<<"\n\n";
rcaCounter++;
int cfgheadaddr;
cfgheadaddr=0;
for(std::size_t i =0; i <cl0size ; ++i)
{
if(i<= (1+cfgheadaddr+(REDLREDSValue *2)))
{
CL0File<<" *(RP)(RCA_cwi)= 0x"<<std::setw(8)<<std::hex<<CL0Context[i]<<";\n";
}
if(i ==(cfgheadaddr+(REDLREDSValue*2)+2))
{
int temp_i;
temp_i=i;
cfghead =CL0Context[i];
REDLREDSValue = ((cfghead>>2)&0x1f);
REDLREDSValue += ((cfghead>>7)&0x1f);
cfgheadaddr = i;
i=temp_i - 1;
CL0File<<"\n\n //this is for RCA "<<std::dec<<rcaCounter<<"\n\n";
rcaCounter++;//update this var value
}
}
CL0File<<"\n\n while(1);\n";
CL0File<<"\n}\n\n#endif\n\n"<<std::endl;
return 0;
}
#endif
/*int RPUConfig::createCL0File(const String &fileName){
std::ofstream CL0File(fileName.c_str());
assert(CL0File);
//const String & graphName = dfgGraph.name();
// uppercase of name
//String GRAPHNAME = graphName;
//std::transform(GRAPHNAME.begin(), GRAPHNAME.end(),
// GRAPHNAME.begin(), ::toupper);
std::size_t cl0size = CL0Context.size();
// Print file
//========================================================
CL0File<<"[CWIPACKET]\n";
CL0File<<"Config Word Cnt="<<cl0size<<std::endl;
CL0File.fill('0');
for(std::size_t i =0; i <cl0size ; ++i)
CL0File<<"ConfigWord["<<std::dec<<i<<"]=0x"<<std::setw(8)<<std::hex<<CL0Context[i]<<";\n";
CL0File<<"\n\n"<<std::endl;
return 0;
}
*/
// 2012.7.21 TangSZ tmp
// C_CL0 and GRPLink generated with each DFG (one group)
// CL0 generated once
// configTotal hasn't been initilized except Context
// RPUGroupNumber, onRCANumber incorrect values
//int RPUConfig::createCL0File(const String &fileName, const String &C_fileName){
//
// std::ofstream CL0File(fileName.c_str());
// std::ofstream C_CL0File(C_fileName.c_str());
//
// assert(CL0File);
// assert(C_CL0File);
// 2012.7.21 TangSZ
//
//int RPUConfig::createCL0File(std::ofstream &CL0FileRef, std::ofstream &GRPLinkRef){
// // CL0 Context Generator
// for(Vector<Vector<reg32> >::iterator CL0GrpIter = CL0Context.begin(); CL0GrpIter != CL0Context.end(); ++CL0GrpIter)
// {
// Vector<reg32> curCtx = * CL0GrpIter;
// CL0FileRef<<"#define GROUP"<<RPUGroupNumber()<<"_"<<onRCANumber()<<"_"<<(CL0GrpIter-CL0Context.begin())<<"_CWI\\\n";
// char buf[30];
// sprintf(buf,"GROUP%d_%d_%d_CWI",RPUGroupNumber(),onRCANumber(),CL0GrpIter-CL0Context.begin());
// GRPLinkRef<<"\t\t\t"<<buf<<"\\"<<std::endl;
// GRPLinkRef<<"\t\t\twhile(!RPU0_done){}\\"<<std::endl;
// GRPLinkRef<<"\t\t\tRPU0_done = 0;\\"<<std::endl;
// CL0FileRef.fill('0');
// for(Vector<reg32>::iterator CtxIter = curCtx.begin(); CtxIter != curCtx.end(); ++CtxIter)
// {
// CL0FileRef<<"\t\t\twrite_reg(AHB1_S1_RPU0,0x"<<std::setw(8)<<std::hex<<(*CtxIter)<<");\\\n";
// }
//
// CL0FileRef<<"\t\t\twrite_reg(AHB1_S1_RPU0,0x0000000"<<std::setw(1)<<std::hex<<onRCANumber()<<");\\\n";
// CL0FileRef<<"\t\t\twrite_reg(AHB1_S1_RPU0,0x00008000);\n\n\n\n\n";
// }
// return 0;
//}
//
//
//int RPUConfig::createC_CL0File(std::ofstream &C_CL0FileRef){
// std::size_t cl0cnt = 0;
//
// for(Vector<Vector<reg32> >::iterator C_CtxGrpIter = C_CL0Context.begin(); C_CtxGrpIter != C_CL0Context.end(); ++ C_CtxGrpIter)
// {
// Vector<reg32> C_CtxGrp = * C_CtxGrpIter;
// cl0cnt += C_CtxGrp.size();
// }
//
// C_CL0FileRef<<"[CWIPACKET]\n"<<"Config Word Cnt="<<std::dec<<cl0cnt<<"\n";
//
// C_CL0FileRef.fill('0');
//
// std::size_t ctxCnt = 0;
// for(Vector<Vector<reg32> >::iterator C_CtxGrpIter = C_CL0Context.begin(); C_CtxGrpIter != C_CL0Context.end(); ++ C_CtxGrpIter)
// {
// Vector<reg32> C_CtxGrp = * C_CtxGrpIter;
// for(Vector<reg32>::iterator C_CtxIter = C_CtxGrp.begin(); C_CtxIter != C_CtxGrp.end(); ++C_CtxIter)
// {
// C_CL0FileRef<<"ConfigWord["<<std::dec<<ctxCnt<<"]=0x"<<std::setw(8)<<std::hex<<(*C_CtxIter)<<";\n";
// ctxCnt++;
// }
// }
//
// C_CL0FileRef<<"\n\n\n\n";
// C_CL0FileRef.close();
//
// return 0;
//}