Initial Commit - Forked from PeakRDL-regblock @ a440cc19769069be831d267505da4f3789a26695
This commit is contained in:
0
tests/test_counter_basics/__init__.py
Normal file
0
tests/test_counter_basics/__init__.py
Normal file
69
tests/test_counter_basics/regblock.rdl
Normal file
69
tests/test_counter_basics/regblock.rdl
Normal file
@@ -0,0 +1,69 @@
|
||||
addrmap top {
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=na; counter;
|
||||
} implied_up[3:0] = 0xD;
|
||||
field {
|
||||
sw=r; hw=na; counter;
|
||||
incrvalue=1;
|
||||
} up[7:4] = 0xD;
|
||||
field {
|
||||
sw=r; hw=na; counter;
|
||||
decrvalue=1;
|
||||
} down[11:8] = 0x4;
|
||||
field {
|
||||
sw=r; hw=r; counter;
|
||||
incrvalue=1;
|
||||
decrvalue=1;
|
||||
overflow; underflow;
|
||||
} updown[15:12] = 0;
|
||||
|
||||
field {
|
||||
sw=r; hw=na; counter;
|
||||
incrvalue=3;
|
||||
decrvalue=3;
|
||||
} updown2[19:16] = 0;
|
||||
|
||||
field {
|
||||
sw=r; hw=na; counter;
|
||||
incrwidth=2;
|
||||
decrwidth=2;
|
||||
} updown3[23:20] = 0;
|
||||
|
||||
field {
|
||||
sw=r; hw=na; counter;
|
||||
} updown4[27:24] = 0;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} step[29:28] = 0;
|
||||
updown4->incrvalue = step;
|
||||
updown4->decrvalue = step;
|
||||
|
||||
field {
|
||||
sw=w; hw=r; singlepulse;
|
||||
} do_count_up[30:30] = 0;
|
||||
field {
|
||||
sw=w; hw=r; singlepulse;
|
||||
} do_count_down[31:31] = 0;
|
||||
updown2->incr = do_count_up;
|
||||
updown2->decr = do_count_down;
|
||||
updown3->incr = do_count_up;
|
||||
updown3->decr = do_count_down;
|
||||
updown4->incr = updown3->incr;
|
||||
updown4->decr = updown3->decr;
|
||||
} simple @ 0x0;
|
||||
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=na; rclr; counter;
|
||||
} overflow_count[8] = 0;
|
||||
|
||||
field {
|
||||
sw=r; hw=na; rclr; counter;
|
||||
} underflow_count[8] = 0;
|
||||
} wrap_counter @ 0x4;
|
||||
wrap_counter.overflow_count->incr = simple.updown3->overflow;
|
||||
wrap_counter.underflow_count->incr = simple.updown3->underflow;
|
||||
};
|
||||
147
tests/test_counter_basics/tb_template.sv
Normal file
147
tests/test_counter_basics/tb_template.sv
Normal file
@@ -0,0 +1,147 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test simple counters
|
||||
//--------------------------------------------------------------------------
|
||||
// up
|
||||
cpuif.assert_read('h0, 'hD, 'h000F);
|
||||
cb.hwif_in.simple.implied_up.incr <= '1;
|
||||
repeat(4) @cb;
|
||||
cb.hwif_in.simple.implied_up.incr <= '0;
|
||||
cpuif.assert_read('h0, 'h1, 'h000F);
|
||||
|
||||
// up
|
||||
cpuif.assert_read('h0, 'hD0, 'h00F0);
|
||||
cb.hwif_in.simple.up.incr <= '1;
|
||||
repeat(4) @cb;
|
||||
cb.hwif_in.simple.up.incr <= '0;
|
||||
cpuif.assert_read('h0, 'h10, 'h00F0);
|
||||
|
||||
// down
|
||||
cpuif.assert_read('h0, 'h400, 'h0F00);
|
||||
cb.hwif_in.simple.down.decr <= '1;
|
||||
repeat(6) @cb;
|
||||
cb.hwif_in.simple.down.decr <= '0;
|
||||
cpuif.assert_read('h0, 'hE00, 'h0F00);
|
||||
|
||||
// up/down via hw
|
||||
cpuif.assert_read('h0, 'h0000, 'hF000);
|
||||
cb.hwif_in.simple.updown.incr <= '1;
|
||||
repeat(6) @cb;
|
||||
cb.hwif_in.simple.updown.incr <= '0;
|
||||
cpuif.assert_read('h0, 'h6000, 'hF000);
|
||||
cb.hwif_in.simple.updown.decr <= '1;
|
||||
repeat(6) @cb;
|
||||
cb.hwif_in.simple.updown.decr <= '0;
|
||||
cpuif.assert_read('h0, 'h0000, 'hF000);
|
||||
cb.hwif_in.simple.updown.decr <= '1;
|
||||
repeat(6) @cb;
|
||||
cb.hwif_in.simple.updown.decr <= '0;
|
||||
cpuif.assert_read('h0, 'hA000, 'hF000);
|
||||
cb.hwif_in.simple.updown.incr <= '1;
|
||||
repeat(6) @cb;
|
||||
cb.hwif_in.simple.updown.incr <= '0;
|
||||
cpuif.assert_read('h0, 'h0000, 'hF000);
|
||||
|
||||
// up/down external underflow
|
||||
fork
|
||||
begin
|
||||
##0;
|
||||
forever begin
|
||||
assert(cb.hwif_out.simple.updown.value == 0);
|
||||
if(cb.hwif_out.simple.updown.underflow) break;
|
||||
@cb;
|
||||
end
|
||||
@cb;
|
||||
forever begin
|
||||
assert(cb.hwif_out.simple.updown.value == 15);
|
||||
assert(cb.hwif_out.simple.updown.underflow == 0);
|
||||
@cb;
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
repeat(2) @cb;
|
||||
cb.hwif_in.simple.updown.decr <= '1;
|
||||
@cb;
|
||||
cb.hwif_in.simple.updown.decr <= '0;
|
||||
repeat(2) @cb;
|
||||
end
|
||||
join_any
|
||||
disable fork;
|
||||
|
||||
// up/down external overflow
|
||||
fork
|
||||
begin
|
||||
##0;
|
||||
forever begin
|
||||
assert(cb.hwif_out.simple.updown.value == 15);
|
||||
if(cb.hwif_out.simple.updown.overflow) break;
|
||||
@cb;
|
||||
end
|
||||
@cb;
|
||||
forever begin
|
||||
assert(cb.hwif_out.simple.updown.value == 0);
|
||||
assert(cb.hwif_out.simple.updown.overflow == 0);
|
||||
@cb;
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
repeat(2) @cb;
|
||||
cb.hwif_in.simple.updown.incr <= '1;
|
||||
@cb;
|
||||
cb.hwif_in.simple.updown.incr <= '0;
|
||||
repeat(2) @cb;
|
||||
end
|
||||
join_any
|
||||
disable fork;
|
||||
|
||||
|
||||
// up/down via sw
|
||||
cpuif.assert_read('h0, 'h00000, 'hF0000);
|
||||
repeat(3) cpuif.write('h0, 'h4000_0000); // incr
|
||||
cpuif.assert_read('h0, 'h90000, 'hF0000);
|
||||
repeat(3) cpuif.write('h0, 'h8000_0000); // decr
|
||||
cpuif.assert_read('h0, 'h00000, 'hF0000);
|
||||
repeat(3) cpuif.write('h0, 'h8000_0000); // decr
|
||||
cpuif.assert_read('h0, 'h70000, 'hF0000);
|
||||
repeat(3) cpuif.write('h0, 'h4000_0000); // incr
|
||||
cpuif.assert_read('h0, 'h00000, 'hF0000);
|
||||
|
||||
// up/down via hw + external dynamic stepsize
|
||||
cpuif.assert_read('h0, 'h000000, 'hF00000);
|
||||
cb.hwif_in.simple.updown3.incrvalue <= 'h2;
|
||||
repeat(3) cpuif.write('h0, 'h4000_0000); // incr
|
||||
cpuif.assert_read('h0, 'h600000, 'hF00000);
|
||||
cpuif.assert_read('h4, 'h00_00); // no overflows or underflows
|
||||
cb.hwif_in.simple.updown3.decrvalue <= 'h3;
|
||||
repeat(3) cpuif.write('h0, 'h8000_0000); // decr
|
||||
cpuif.assert_read('h0, 'hD00000, 'hF00000);
|
||||
cpuif.assert_read('h4, 'h01_00); // one underflow
|
||||
cb.hwif_in.simple.updown3.incrvalue <= 'h1;
|
||||
repeat(2) cpuif.write('h0, 'h4000_0000); // incr
|
||||
cpuif.assert_read('h0, 'hF00000, 'hF00000);
|
||||
cpuif.assert_read('h4, 'h00_00); // no overflows or underflows
|
||||
repeat(1) cpuif.write('h0, 'h4000_0000); // incr
|
||||
cpuif.assert_read('h0, 'h000000, 'hF00000);
|
||||
cpuif.assert_read('h4, 'h00_01); // one overflow
|
||||
repeat(32) cpuif.write('h0, 'h4000_0000); // incr
|
||||
cpuif.assert_read('h0, 'h000000, 'hF00000);
|
||||
cpuif.assert_read('h4, 'h00_02); // overflow
|
||||
|
||||
// up/down via hw + referenced dynamic stepsize
|
||||
cpuif.assert_read('h0, 'h0000000, 'hF000000);
|
||||
repeat(4) cpuif.write('h0, 'h4000_0000 + (2'h3 << 28)); // + 3
|
||||
cpuif.assert_read('h0, 'hC000000, 'hF000000);
|
||||
repeat(4) cpuif.write('h0, 'h8000_0000 + (2'h1 << 28)); // - 1
|
||||
cpuif.assert_read('h0, 'h8000000, 'hF000000);
|
||||
repeat(2) cpuif.write('h0, 'h8000_0000 + (2'h3 << 28)); // - 3
|
||||
cpuif.assert_read('h0, 'h2000000, 'hF000000);
|
||||
{% endblock %}
|
||||
5
tests/test_counter_basics/testcase.py
Normal file
5
tests/test_counter_basics/testcase.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
|
||||
class Test(SimTestCase):
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
Reference in New Issue
Block a user