4 """Simple script that scans all of the simulator output text fed in
5 through stdin and summarises the total number of system clock ticks."""
8 if sys
.version_info
[0]<3:
11 safe_stdin
= io
.TextIOWrapper(sys
.stdin
.buffer, encoding
="latin-1")
12 lines
= safe_stdin
.readlines()
19 # 'n words read from ...', where = # bytes in hex file
20 if (re
.search(r
'words read from', line
)):
21 (data
, post
) = re
.split(r
'words', line
, 1)
22 data
= re
.sub(r
'[^0-9]',' ',data
).strip().split();
26 bytes
= 0 # wrong size, but better than blowing up
28 # 'Total time since last reset= 0.102021 sec (i clks)',
29 # where i = # system clock ticks.
30 if (re
.search(r
'^Total time', line
)):
31 (pre
, data
) = re
.split(r
'\(', line
)
32 (nticks
, post
) = re
.split(r
' ', data
)
35 print("\n--- Simulator: %d/%d: %d bytes, %d ticks" % (bytes
, ticks
, bytes
, ticks
))