简体   繁体   English

SystemC-在systemc仿真中测量并包括文件解析时间

[英]SystemC - measure and include file parsing time in systemc simulation

I have a simple C++ function which parse CSV (10-10k rows) file line-by-line and insert each field in defined structure, array of structures to be more specific. 我有一个简单的C ++函数,该函数逐行分析CSV(10-10k行)文件,并将每个字段插入定义的结构中,结构数组更加具体。

Now I want to measure parsing time using systemc methods (without C++ utilities, eg clock() ) and include it in simulation like any other process and generate trace file - is it possible at all? 现在,我想使用systemc方法(没有C ++实用程序,例如clock() )来测量解析时间,并将其像其他进程一样包含在仿真中并生成跟踪文件-可能吗?

For couple of days I am struggling doing that in every possible way. 几天来,我一直在竭尽全力地做到这一点。 Actually I have realised that sc_time_stamp() is useless in that particular case as it only shows declared sc_start() simulation elapsed time. 实际上,我已经意识到sc_time_stamp()在那种特殊情况下是无用的,因为它只显示声明的sc_start()模拟经过的时间。

I thought it will be as simple as: 我以为会很简单:

  1. wait() until pos.edg
  2. parseFile()
  3. signal.write(1)
  4. doOtherStuff()

but apparently it's not... 但显然不是

Internet is full of adders, counters and other logic stuff examples but I did not found anything related to my problem. 互联网上到处都是加法器,计数器和其他逻辑示例,但我没有发现与我的问题有关的任何内容。

Thanks in advance! 提前致谢!

SystemC is a modeling library. SystemC是一个建模库。 So you can only measure simulation time with sc_time_stamp. 因此,您只能使用sc_time_stamp测量模拟时间 If you want to measure physical time you will need to measure it with some other C/C++ library ( Easily measure elapsed time ). 如果要测量物理时间,则需要使用其他一些C / C ++库进行测量轻松测量经过的时间 )。

Then, if you want to add this time to your simulation time, you can put 然后,如果您想将此时间添加到模拟时间中,可以将

wait( measured_parsing_time );

Your question "measure parsing time using systemc" and the pseudo code example you gave appear to indicate you want to measure real-time. 您的问题“使用systemc测量解析时间”和您给出的伪代码示例似乎表明您想实时测量。 The pseudo-code 伪代码

wait some-event
parseFile()
signal.write(1)
...

Will take exactly zero simulation time since (unless parseFile() itself has wait statements) parseFile() is carried out in one delta cycle. 由于(除非parseFile()本身具有等待语句)parseFile()是在一个增量周期中执行的,所以它将完全花费零时间。 If parseFile() does have wait statements (wait 10ms for example) then in simulation time it will take 10 ms. 如果parseFile()确实具有wait语句(例如,等待10毫秒),则在仿真时间将花费10毫秒。 The only way systemc has of knowing how long a process takes to complete is if you tell it. systemc知道完成一个过程需要多长时间的唯一方法是告诉您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM