Skip to content

Commit

Permalink
Compare with golden references
Browse files Browse the repository at this point in the history
  • Loading branch information
mole99 committed Apr 13, 2024
1 parent 98a7140 commit 7911e11
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Binary file removed test/default.png
Binary file not shown.
16 changes: 14 additions & 2 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def draw_frame(dut):
else:
screen_x += 1

#@cocotb.test()
@cocotb.test()
async def test_vga_default(dut):
"""Draw one frame with the default shader"""

Expand Down Expand Up @@ -116,9 +116,10 @@ def load_shader(shader_name):

with open(f'../sw/binary/{shader_name}.bit') as f:
for line in f.readlines():
line = line.replace('_', '')
if '//' in line:
line = line.split('//')[0]
line = line.replace('_', '')
line.strip()
if line:
shader.append(int(line, 2))

Expand Down Expand Up @@ -172,6 +173,17 @@ async def test_vga_load(dut, shader_name='test7'):

image = await taks_draw_frame.join()
image.save(f"{shader_name}.png")

gold = Image.open(f'../sw/images/{shader_name}.png')

# Scale with factor
gold = gold.resize((gold.width*NUM_INSTR, gold.height*NUM_INSTR), Image.NEAREST)

gold.save(f"{shader_name}_gold.png")

# Check that images are the same
diff = ImageChops.difference(image.convert('RGB'), gold.convert('RGB'))
assert(not diff.getbbox())

await ClockCycles(dut.clk, 10)

Expand Down

0 comments on commit 7911e11

Please sign in to comment.