Skip to content

Commit

Permalink
Add testcase to test cumulative strobes. #38
Browse files Browse the repository at this point in the history
  • Loading branch information
amykyta3 committed May 4, 2023
1 parent 2e37e58 commit fc82345
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
83 changes: 83 additions & 0 deletions tests/test_write_buffer/tb_template.sv
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,88 @@
cpuif.assert_read('h2C, 'h1234);
cpuif.assert_read('h2E, 'h4);

//--------------------------------------------------------------------------
// strobes
//--------------------------------------------------------------------------
// reg1
// reset field to known state
cpuif.write('h0, 'h0000);
cpuif.write('h2, 'h0000);
cpuif.write('h4, 'h0000);
cpuif.write('h6, 'h0000);
@cb;
cpuif.assert_read('h0, 'h0);
cpuif.assert_read('h2, 'h0);
cpuif.assert_read('h4, 'h0);
cpuif.assert_read('h6, 'h0);
assert(cb.hwif_out.reg1.f1.value == 0);

cpuif.write('h0, 'hABCD, 'hF000);
cpuif.write('h2, 'h1234, 'h0F00);
cpuif.write('h4, 'h5678, 'h00F0);
cpuif.write('h6, 'hEF12, 'h000F);
@cb;
cpuif.assert_read('h0, 'hA000);
cpuif.assert_read('h2, 'h0200);
cpuif.assert_read('h4, 'h0070);
cpuif.assert_read('h6, 'h0002);
assert(cb.hwif_out.reg1.f1.value == 'h0002_0070_0200_A000);

// Check that strobes are cumulative
cpuif.write('h0, 'h0030, 'h00F0);
cpuif.write('h2, 'h0070, 'h00F0);
cpuif.write('h4, 'h000D, 'h000F);
cpuif.write('h4, 'hA000, 'hF000);
cpuif.write('h2, 'h0008, 'h000F);
cpuif.write('h0, 'h0200, 'h0F00);
cpuif.write('h6, 'hA000, 'hF000);
cpuif.write('h6, 'h0F00, 'h0F00);
@cb;
cpuif.assert_read('h0, 'hA230);
cpuif.assert_read('h2, 'h0278);
cpuif.assert_read('h4, 'hA07D);
cpuif.assert_read('h6, 'hAF02);
assert(cb.hwif_out.reg1.f1.value == 'hAF02_A07D_0278_A230);

// reg1_msb0
// reset field to known state
cpuif.write('h8, 'h0000);
cpuif.write('hA, 'h0000);
cpuif.write('hC, 'h0000);
cpuif.write('hE, 'h0000);
@cb;
cpuif.assert_read('h8, 'h0);
cpuif.assert_read('hA, 'h0);
cpuif.assert_read('hC, 'h0);
cpuif.assert_read('hE, 'h0);
assert(cb.hwif_out.reg1_msb0.f1.value == 0);

cpuif.write('h8, 'hABCD, 'hF000);
cpuif.write('hA, 'h1234, 'h0F00);
cpuif.write('hC, 'h5678, 'h00F0);
cpuif.write('hE, 'hEF12, 'h000F);
@cb;
cpuif.assert_read('h8, 'hA000);
cpuif.assert_read('hA, 'h0200);
cpuif.assert_read('hC, 'h0070);
cpuif.assert_read('hE, 'h0002);
assert({<<{cb.hwif_out.reg1_msb0.f1.value}} == 'h0002_0070_0200_A000);

// Check that strobes are cumulative
cpuif.write('h8, 'h0030, 'h00F0);
cpuif.write('hA, 'h0070, 'h00F0);
cpuif.write('hC, 'h000D, 'h000F);
cpuif.write('hC, 'hA000, 'hF000);
cpuif.write('hA, 'h0008, 'h000F);
cpuif.write('h8, 'h0200, 'h0F00);
cpuif.write('hE, 'hA000, 'hF000);
cpuif.write('hE, 'h0F00, 'h0F00);
@cb;
cpuif.assert_read('h8, 'hA230);
cpuif.assert_read('hA, 'h0278);
cpuif.assert_read('hC, 'hA07D);
cpuif.assert_read('hE, 'hAF02);
assert({<<{cb.hwif_out.reg1_msb0.f1.value}} == 'hAF02_A07D_0278_A230);


{% endblock %}
3 changes: 3 additions & 0 deletions tests/test_write_buffer/testcase.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from ..lib.sim_testcase import SimTestCase
from ..lib.cpuifs.passthrough import Passthrough

class Test(SimTestCase):
cpuif = Passthrough() # test with bit strobes

def test_dut(self):
self.run_test()

0 comments on commit fc82345

Please sign in to comment.