added assert plots

This commit is contained in:
alexmadison 2022-02-28 13:57:28 +01:00
parent ee59fc9a44
commit 73ae3b0f19
1 changed files with 39 additions and 6 deletions

View File

@ -82,6 +82,20 @@ Use -exclude='regex' to specify signals to exclude (or -ex).""")
if exclude_given: if exclude_given:
entries = [e for e in entries if re.search(exclude_re, e[1]) == None] entries = [e for e in entries if re.search(exclude_re, e[1]) == None]
# Check if start time given
for arg in argv:
r = re.findall(r'-t0=(\d+)', arg)
if len(r) >= 1:
print(f"Filtering by start time t0 = {r[0]}")
entries = [e for e in entries if int(e[0]) >= int(r[0])]
# Check if end time given
for arg in argv:
r = re.findall(r'-t1=(\d+)', arg)
if len(r) >= 1:
print(f"Filtering by start time t0 = {r[0]}")
entries = [e for e in entries if int(e[0]) <= int(r[0])]
assert len(entries) >= 1, "No valid entries in prsim.out!" assert len(entries) >= 1, "No valid entries in prsim.out!"
# Get list of all sigs and times # Get list of all sigs and times
@ -130,7 +144,7 @@ Use -exclude='regex' to specify signals to exclude (or -ex).""")
# Generate figure # Generate figure
# weird sizing is to try to keep "pixel" sizes approx const # weird sizing is to try to keep "pixel" sizes approx const
fig = plt.figure(figsize = (num_sigs/3+0.5,num_times/3+0.2), dpi = 100) fig = plt.figure(figsize = (num_times/3+0.2,num_sigs/3+0.2), dpi = 100)
image = np.zeros((num_sigs, num_times, 3), dtype = int) image = np.zeros((num_sigs, num_times, 3), dtype = int)
image[signals_matrix == 0] = colour_undefined image[signals_matrix == 0] = colour_undefined
@ -173,18 +187,37 @@ Use -exclude='regex' to specify signals to exclude (or -ex).""")
else: else:
s1 = s0 s1 = s0
arrow_c = "black" if by_val == 1 else "grey"
if by_val == 1: if by_val == 1:
plt.arrow(t0, s1, 0, s0-s1 + 0.2*np.sign(s0-s1), head_width = 0.5, width = 0.2, ec = "none", lw = 0, fc = "black", length_includes_head = True) plt.arrow(t0, s1, 0, s0-s1 + 0.2*np.sign(s0-s1), head_width = 0.5, width = 0.2,
ec = "none", lw = 0, fc = "black", length_includes_head = True)
else: else:
plt.arrow(t0, s1, 0, s0-s1 + 0.2*np.sign(s0-s1), head_width = 0, width = 0.2, ec = "none", lw = 0, fc = "black", length_includes_head = True) plt.arrow(t0, s1, 0, s0-s1 + 0.2*np.sign(s0-s1), head_width = 0, width = 0.2,
plt.scatter((t0),(s0), c = "black", s = 30) ec = "none", lw = 0, fc = "black", length_includes_head = True)
plt.scatter((t0),(s0), c = "black", s = 40)
# Write times on x axis # Write times on x axis
for time in unique_times: for time in unique_times:
ax.text(time_to_index(time), num_sigs, time, ha = "center", va = "top", size = 10, rotation = 90) ax.text(time_to_index(time), num_sigs, time, ha = "center", va = "top", size = 10, rotation = 90)
# Find and plot wrong Assert statements
asserts = re.findall(r"\t *(\d+) .*\nWRONG ASSERT:\t(.+)", f)
if len(asserts): print("Failed asserts found!")
for a in asserts:
print(a)
time = int(a[0])
index = time_to_index(time)
ax.axvline(index+0.5, c = "red", lw = 2)
ax.text(index+0.5, -1, a[1], rotation = 90, ha = "center", va = "bottom", c = "red")
# Find echoed statements of the form "[digits] text"
echoes = re.findall(r"\t *(\d+) [^\t]*\n(\[\d+\].+)", f)
for a in echoes:
time = int(a[0])
index = time_to_index(time)
c = "xkcd:bright purple"
ax.axvline(index+0.5, c = c, lw = 2)
ax.text(index+0.5, -1, a[1], rotation = 90, ha = "center", va = "bottom", c = c)
output_type = ".pdf" output_type = ".pdf"
for arg in argv: for arg in argv:
if arg == "-png": output_type = ".png" if arg == "-png": output_type = ".png"