⑨ lab ≡ who cares?!

Work/Synopsys/Notes

Random work notes for esoteric use cases…

⑨ lab ≡ Go away…!

Go away…!

Overview

The notes on this page are not for you. Seriously, this stuff here is specialised for my use case only, go away…!

Converting Instruction Traces

Plan9/plan9port

Using rc, sed, and awk on Plan or plan9port:

 % cat cnv.rc
#!/bin/rc
# -- Convert RASCAL VCS to nSIM style trace
fn Help{
	echo `{basename $0}^' < vcs.trc'
}
fn Convert{
# Example RASCAL VCS trace:
# …
# 184900:         -debug - 5e2b7f80|srl      10,[status32]   | limm:0000000a
# 185760:      86 000000b0 584a0000|movl     r0,0            | w0: r0  <- 00000000
# 185770:         000000b4 ----4104|movl_s   r1,r0           |
#       :        .000000b6 ----4204|movl_s   r2,r0           | w0: r2  <- 00000000 w2: r1  <- 00000000
# 185780:         000000b8 ----4304|movl_s   r3,r0           |
# …
# 1. *delete* lines starting with ('#' or '-' or '[A-Z]')
#      or (containing `-debug` transactions)
#      or (containing write-backs only)
# 2. *match* 
#      \1 time stamp
#      \2 stall cycles
#      \3 program counter
#      \4 encoding
#    …and move \1 to the front separating fields using `|`
# 3. print 0 as latency for 2nd instruction in dual-issue bundle
# 4. print 1 as latency for instruction with no stalls
# 5. print latency for all other instructions
# 6. *delete* (enter|leave) micro-ops using *awk*
	
sed '/(^(#|\-|[A-Z]+)|\-debug|[0-9]+:[A-Z ]+\|[ ]+\|)/d
s/^([ ]*[0-9]*):[A-Z ]+([\*0-9]*)[\.: ]([0-9abcdef]+) ([^\|]+)\|/X\2 \| \1 \| 0x\3 \| 0x\4 \| /
s/^X (\| [ ]+ \|)/0 \1/
s/^X (\| [0-9]+ \|)/1 \1/
s/^X([\*0-9]+)/\1/
' $1 \
| awk -F '|' '
BEGIN{ pc=1 }
$5 ~ /(enter|leave)/ { print $0; pc=$3; next   }
{    if(pc==1)       { print $0;        next } }
{    if(pc!=$3)      { print $0; pc=1        } }
'
}
# --
switch ($#*) {
	case 0
		Help
	case *
		Convert $1
}

Linux

Using sh, GNU sed, and awk on Linux:

 $ cat cnv.sh
#!/bin/sh
# -- Convert RASCAL VCS to nSIM style trace

# Example RASCAL VCS trace:
# …
# 184900:         -debug - 5e2b7f80|srl      10,[status32]   | limm:0000000a
# 185760:      86 000000b0 584a0000|movl     r0,0            | w0: r0  <- 00000000
# 185770:         000000b4 ----4104|movl_s   r1,r0           |
#       :        .000000b6 ----4204|movl_s   r2,r0           | w0: r2  <- 00000000 w2: r1  <- 00000000
# 185780:         000000b8 ----4304|movl_s   r3,r0           |
# …
# 1. *delete* lines starting with ('#' or '-' or '[A-Z]')
#      or (containing `-debug` transactions)
#      or (containing write-backs only)
# 2. *match* 
#      \1 time stamp
#      \2 stall cycles
#      \3 program counter
#      \4 encoding
#    …and move \1 to the front separating fields using `|`
# 3. print 0 as latency for 2nd instruction in dual-issue bundle
# 4. print 1 as latency for instruction with no stalls
# 5. print latency for all other instructions
# 6. *delete* (enter|leave) micro-ops using *awk*

sed -E '/(^(#|\-|[A-Z]+)|\-debug|[0-9]+:[A-Z ]+\|[ ]+\|)/d
s/^([ ]*[0-9]*):[A-Z ]+([\*0-9]*)[\.: ]([0-9abcdef]+) ([^\|]+)\|/X\2 \| \1 \| 0x\3 \| 0x\4 \| /
s/^X (\| [ ]+ \|)/0 \1/
s/^X (\| [0-9]+ \|)/1 \1/
s/^X([\*0-9]+)/\1/
' $1 \
| awk -F '|' '
BEGIN{ pc=1 }
$5 ~ /(enter|leave)/ { print $0; pc=$3; next   }
{    if(pc==1)       { print $0;        next } }
{    if(pc!=$3)      { print $0; pc=1        } }
'

#Dev #Work #SNPS