229{
230
231
232
233 const std::vector<std::string> cmdArgs = { argv,
234 argv + argc };
235
236
237 uint32_t emusize = 8192;
238 uint32_t req_chunksize = 464;
239 uint32_t pattern_id = 0;
240 uint32_t idle_chars = 1;
241 bool random_sz = false;
242 bool crc_new = true;
243 bool use_streamid = false;
244 bool add_busy = false;
245 bool omit_one_soc = false;
246 bool omit_one_eoc = false;
247 bool add_crc_err = false;
248 std::string
filename =
"emuconfigreg";
249
250
251 for (unsigned j = 0; j < cmdArgs.size(); j++) {
252 std::string arg = cmdArgs[j];
253 if (arg == "-h" || arg == "--help") {
254 std::ostringstream oss;
255 oss
256 << "\nThis app is used to create basic emulator configurations for the FELIX to use with flx-config. Usage: \n"
257 << " -h/--help : display help messege \n"
258 << " --filename : output configuration filename \n"
259
260 << " --chunkSize : chunk sie of each block of data \n"
261 << " --idles : number of idle charachters between chunks \n"
262 << " --pattern : type of data to write \n"
263 << " 0 is incrimental \n"
264 << " 1 sets all to 0xAA55AA55 \n"
265 << " 2 sets all to 0xFFFFFFFF \n"
266 << " 3 sets all to 0x00000000";
268 exit(0);
269 } else if (arg == "--filename") {
270
271 if (j >= cmdArgs.size() - 1)
272 {
273 TLOG() <<
"No file name was specified";
274 break;
275 }
277
278
279
280
281
282
283
284
285 } else if (arg == "--chunkSize") {
286 if (j >= cmdArgs.size() - 1) {
287 TLOG() <<
"No value was specified";
288 break;
289 }
290 req_chunksize = std::stoi(cmdArgs[j + 1]);
291
292 } else if (arg == "--idles") {
293 if (j >= cmdArgs.size() - 1) {
294 TLOG() <<
"No value was specified";
295 break;
296 }
297 idle_chars = std::stoi(cmdArgs[j + 1]);
298
299 } else if (arg == "--pattern") {
300 if (j >= cmdArgs.size() - 1) {
301 TLOG() <<
"No value was specified";
302 break;
303 }
304 pattern_id = std::stoi(cmdArgs[j + 1]);
305 }
306 }
307
308 TLOG() <<
"chunk size : " << req_chunksize;
309 TLOG() <<
"idle characters : " << idle_chars;
310 TLOG() <<
"pattern type : " << pattern_id;
311
312 filename +=
"_" + std::to_string(req_chunksize) +
"_" + std::to_string(idle_chars) +
"_" + std::to_string(pattern_id);
314
316 std::ofstream output;
318
320 emusize,
321 req_chunksize,
322 pattern_id,
323 idle_chars,
324 random_sz,
325 crc_new,
326 use_streamid,
327 add_busy,
328 omit_one_soc,
329 omit_one_eoc,
330 add_crc_err);
331
332 for (unsigned i = 0; i < emusize; i++) {
333 output << "FE_EMU_CONFIG_WRADDR=0x" << std::hex << i << std::endl;
334 output << "FE_EMU_CONFIG_WRDATA=0x" << std::hex << emudata[i] << std::endl;
335 output << "FE_EMU_CONFIG_WE=1" << std::endl;
336 output << "FE_EMU_CONFIG_WE=0" << std::endl;
337 }
338
339 output.close();
340
341 TLOG() <<
"Config file written.";
342
343}
bool generateFm(uint64_t *emudata, uint64_t emusize, uint32_t req_chunksize, uint32_t pattern_id, uint32_t idle_chars, bool random_sz, bool crc_new, bool use_streamid, bool add_busy, bool omit_one_soc, bool omit_one_eoc, bool add_crc_err)
const constexpr size_t EMU_SIZE