Created
April 30, 2020 02:01
-
-
Save miyo/18a624e57197f099f40492c95028fff8 to your computer and use it in GitHub Desktop.
VCDファイルから、指定された信号が変化した時刻と値を抜き出す
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
if __name__ == '__main__': | |
if len(sys.argv) < 3: | |
print("usage: {} vcd target".format(sys.argv[0])) | |
sys.exit(0) | |
vcd = sys.argv[1] | |
target = sys.argv[2] | |
print(vcd) | |
print(target) | |
lines = [] | |
symbol = '' | |
t = 0 | |
with open(vcd) as f: | |
for line in f: | |
s = line.strip() | |
d = s.split() | |
if d[0] == '$var' and d[4] == target: | |
symbol = d[3] | |
print(target, symbol, len(symbol)) | |
elif len(d) == 1 and d[0][0] == '#': | |
t = int(d[0][1:]) | |
else: | |
if(s[-(len(symbol)):] == symbol): | |
print(target, t, s[:-(len(symbol))]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment