Initial Commit - Forked from PeakRDL-regblock @ a440cc19769069be831d267505da4f3789a26695
This commit is contained in:
0
tests/test_counter_saturate/__init__.py
Normal file
0
tests/test_counter_saturate/__init__.py
Normal file
88
tests/test_counter_saturate/regblock.rdl
Normal file
88
tests/test_counter_saturate/regblock.rdl
Normal file
@@ -0,0 +1,88 @@
|
||||
addrmap top {
|
||||
field strobe_t {
|
||||
sw=w; hw=r; singlepulse;
|
||||
};
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=r; counter;
|
||||
incrsaturate;
|
||||
decrsaturate;
|
||||
} count[8] = 0;
|
||||
|
||||
strobe_t increment[9:9] = 0;
|
||||
strobe_t decrement[10:10] = 0;
|
||||
strobe_t clear[11:11] = 0;
|
||||
strobe_t set[12:12] = 0;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} step[23:16] = 1;
|
||||
|
||||
count->incr = increment;
|
||||
count->decr = decrement;
|
||||
count->hwclr = clear;
|
||||
count->hwset = set;
|
||||
count->incrvalue = step;
|
||||
count->decrvalue = step;
|
||||
} saturate_via_bool @ 0x0;
|
||||
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=r; counter;
|
||||
incrsaturate = 250;
|
||||
decrsaturate = 5;
|
||||
} count[8] = 0;
|
||||
|
||||
strobe_t increment[9:9] = 0;
|
||||
strobe_t decrement[10:10] = 0;
|
||||
strobe_t clear[11:11] = 0;
|
||||
strobe_t set[12:12] = 0;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} step[23:16] = 1;
|
||||
|
||||
count->incr = increment;
|
||||
count->decr = decrement;
|
||||
count->hwclr = clear;
|
||||
count->hwset = set;
|
||||
count->decrvalue = step;
|
||||
count->incrvalue = count->decrvalue;
|
||||
} saturate_via_const @ 0x4;
|
||||
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=r; counter;
|
||||
} count[8] = 0;
|
||||
|
||||
strobe_t increment[9:9] = 0;
|
||||
strobe_t decrement[10:10] = 0;
|
||||
strobe_t clear[11:11] = 0;
|
||||
strobe_t set[12:12] = 0;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} step[23:16] = 1;
|
||||
|
||||
count->incr = increment;
|
||||
count->decr = decrement;
|
||||
count->hwclr = clear;
|
||||
count->hwset = set;
|
||||
count->incrvalue = step;
|
||||
count->decrvalue = count->incrvalue;
|
||||
} saturate_via_ref @ 0x8;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} min[8] = 0x00;
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} max[8] = 0xFF;
|
||||
} saturate_control @ 0xC;
|
||||
saturate_via_ref.count -> decrsaturate = saturate_control.min;
|
||||
saturate_via_ref.count -> incrsaturate = saturate_control.max;
|
||||
};
|
||||
214
tests/test_counter_saturate/tb_template.sv
Normal file
214
tests/test_counter_saturate/tb_template.sv
Normal file
@@ -0,0 +1,214 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
// counter controls are the same for each sub-test
|
||||
`define incr (1<<9)
|
||||
`define decr (1<<10)
|
||||
`define clr (1<<11)
|
||||
`define set (1<<12)
|
||||
`define step(n) (n<<16)
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test incrsaturate = true; decrsaturate = true;
|
||||
//--------------------------------------------------------------------------
|
||||
cpuif.assert_read('h0, 'h00, 'hFF);
|
||||
|
||||
// incrsaturate via +1
|
||||
cpuif.write('h0, `set);
|
||||
cpuif.assert_read('h0, 'hFF, 'hFF);
|
||||
cpuif.write('h0, `decr + `step(1));
|
||||
cpuif.assert_read('h0, 'hFE, 'hFF);
|
||||
cpuif.write('h0, `incr + `step(1));
|
||||
cpuif.assert_read('h0, 'hFF, 'hFF);
|
||||
cpuif.write('h0, `incr + `step(1));
|
||||
cpuif.assert_read('h0, 'hFF, 'hFF);
|
||||
|
||||
// decrsaturate via +1
|
||||
cpuif.write('h0, `clr);
|
||||
cpuif.assert_read('h0, 'h00, 'hFF);
|
||||
cpuif.write('h0, `incr + `step(1));
|
||||
cpuif.assert_read('h0, 'h01, 'hFF);
|
||||
cpuif.write('h0, `decr + `step(1));
|
||||
cpuif.assert_read('h0, 'h00, 'hFF);
|
||||
cpuif.write('h0, `decr + `step(1));
|
||||
cpuif.assert_read('h0, 'h00, 'hFF);
|
||||
|
||||
// incrsaturate via larger steps
|
||||
cpuif.write('h0, `set);
|
||||
cpuif.assert_read('h0, 'hFF, 'hFF);
|
||||
cpuif.write('h0, `decr + `step(1));
|
||||
cpuif.assert_read('h0, 'hFE, 'hFF);
|
||||
cpuif.write('h0, `incr + `step(2));
|
||||
cpuif.assert_read('h0, 'hFF, 'hFF);
|
||||
cpuif.write('h0, `incr + `step(3));
|
||||
cpuif.assert_read('h0, 'hFF, 'hFF);
|
||||
cpuif.write('h0, `incr + `step(255));
|
||||
cpuif.assert_read('h0, 'hFF, 'hFF);
|
||||
|
||||
// decrsaturate via larger steps
|
||||
cpuif.write('h0, `clr);
|
||||
cpuif.assert_read('h0, 'h00, 'hFF);
|
||||
cpuif.write('h0, `incr + `step(1));
|
||||
cpuif.assert_read('h0, 'h01, 'hFF);
|
||||
cpuif.write('h0, `decr + `step(2));
|
||||
cpuif.assert_read('h0, 'h00, 'hFF);
|
||||
cpuif.write('h0, `decr + `step(3));
|
||||
cpuif.assert_read('h0, 'h00, 'hFF);
|
||||
cpuif.write('h0, `decr + `step(255));
|
||||
cpuif.assert_read('h0, 'h00, 'hFF);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test incrsaturate = 250; decrsaturate = 5;
|
||||
//--------------------------------------------------------------------------
|
||||
cpuif.assert_read('h4, 'h00, 'hFF);
|
||||
|
||||
// incrsaturate via +1
|
||||
cpuif.write('h4, `set);
|
||||
cpuif.assert_read('h4, 'hFF, 'hFF);
|
||||
cpuif.write('h4, `decr + `step(1));
|
||||
cpuif.assert_read('h4, 'hFE, 'hFF);
|
||||
cpuif.write('h4, `incr + `step(1));
|
||||
cpuif.assert_read('h4, 'hFA, 'hFF);
|
||||
cpuif.write('h4, `incr + `step(1));
|
||||
cpuif.assert_read('h4, 'hFA, 'hFF);
|
||||
|
||||
// decrsaturate via +1
|
||||
cpuif.write('h4, `clr);
|
||||
cpuif.assert_read('h4, 'h00, 'hFF);
|
||||
cpuif.write('h4, `incr + `step(1));
|
||||
cpuif.assert_read('h4, 'h01, 'hFF);
|
||||
cpuif.write('h4, `decr + `step(1));
|
||||
cpuif.assert_read('h4, 'h05, 'hFF);
|
||||
cpuif.write('h4, `decr + `step(1));
|
||||
cpuif.assert_read('h4, 'h05, 'hFF);
|
||||
|
||||
// incrsaturate via larger steps
|
||||
cpuif.write('h4, `set);
|
||||
cpuif.assert_read('h4, 'hFF, 'hFF);
|
||||
cpuif.write('h4, `decr + `step(1));
|
||||
cpuif.assert_read('h4, 'hFE, 'hFF);
|
||||
cpuif.write('h4, `incr + `step(2));
|
||||
cpuif.assert_read('h4, 'hFA, 'hFF);
|
||||
cpuif.write('h4, `incr + `step(3));
|
||||
cpuif.assert_read('h4, 'hFA, 'hFF);
|
||||
cpuif.write('h4, `incr + `step(255));
|
||||
cpuif.assert_read('h4, 'hFA, 'hFF);
|
||||
|
||||
// decrsaturate via larger steps
|
||||
cpuif.write('h4, `clr);
|
||||
cpuif.assert_read('h4, 'h00, 'hFF);
|
||||
cpuif.write('h4, `incr + `step(1));
|
||||
cpuif.assert_read('h4, 'h01, 'hFF);
|
||||
cpuif.write('h4, `decr + `step(2));
|
||||
cpuif.assert_read('h4, 'h05, 'hFF);
|
||||
cpuif.write('h4, `decr + `step(3));
|
||||
cpuif.assert_read('h4, 'h05, 'hFF);
|
||||
cpuif.write('h4, `decr + `step(255));
|
||||
cpuif.assert_read('h4, 'h05, 'hFF);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test incrsaturate = <ref 255>; decrsaturate = <ref 0>;
|
||||
//--------------------------------------------------------------------------
|
||||
cpuif.assert_read('h8, 'h00, 'hFF);
|
||||
|
||||
// incrsaturate via +1
|
||||
cpuif.write('h8, `set);
|
||||
cpuif.assert_read('h8, 'hFF, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(1));
|
||||
cpuif.assert_read('h8, 'hFE, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(1));
|
||||
cpuif.assert_read('h8, 'hFF, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(1));
|
||||
cpuif.assert_read('h8, 'hFF, 'hFF);
|
||||
|
||||
// decrsaturate via +1
|
||||
cpuif.write('h8, `clr);
|
||||
cpuif.assert_read('h8, 'h00, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(1));
|
||||
cpuif.assert_read('h8, 'h01, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(1));
|
||||
cpuif.assert_read('h8, 'h00, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(1));
|
||||
cpuif.assert_read('h8, 'h00, 'hFF);
|
||||
|
||||
// incrsaturate via larger steps
|
||||
cpuif.write('h8, `set);
|
||||
cpuif.assert_read('h8, 'hFF, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(1));
|
||||
cpuif.assert_read('h8, 'hFE, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(2));
|
||||
cpuif.assert_read('h8, 'hFF, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(3));
|
||||
cpuif.assert_read('h8, 'hFF, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(255));
|
||||
cpuif.assert_read('h8, 'hFF, 'hFF);
|
||||
|
||||
// decrsaturate via larger steps
|
||||
cpuif.write('h8, `clr);
|
||||
cpuif.assert_read('h8, 'h00, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(1));
|
||||
cpuif.assert_read('h8, 'h01, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(2));
|
||||
cpuif.assert_read('h8, 'h00, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(3));
|
||||
cpuif.assert_read('h8, 'h00, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(255));
|
||||
cpuif.assert_read('h8, 'h00, 'hFF);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test incrsaturate = <ref 250>; decrsaturate = <ref 5>;
|
||||
//--------------------------------------------------------------------------
|
||||
cpuif.write('hc, 'hFA_05);
|
||||
|
||||
cpuif.assert_read('h4, 'h05, 'hFF);
|
||||
|
||||
// incrsaturate via +1
|
||||
cpuif.write('h8, `set);
|
||||
cpuif.assert_read('h8, 'hFF, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(1));
|
||||
cpuif.assert_read('h8, 'hFE, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(1));
|
||||
cpuif.assert_read('h8, 'hFA, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(1));
|
||||
cpuif.assert_read('h8, 'hFA, 'hFF);
|
||||
|
||||
// decrsaturate via +1
|
||||
cpuif.write('h8, `clr);
|
||||
cpuif.assert_read('h8, 'h00, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(1));
|
||||
cpuif.assert_read('h8, 'h01, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(1));
|
||||
cpuif.assert_read('h8, 'h05, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(1));
|
||||
cpuif.assert_read('h8, 'h05, 'hFF);
|
||||
|
||||
// incrsaturate via larger steps
|
||||
cpuif.write('h8, `set);
|
||||
cpuif.assert_read('h8, 'hFF, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(1));
|
||||
cpuif.assert_read('h8, 'hFE, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(2));
|
||||
cpuif.assert_read('h8, 'hFA, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(3));
|
||||
cpuif.assert_read('h8, 'hFA, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(255));
|
||||
cpuif.assert_read('h8, 'hFA, 'hFF);
|
||||
|
||||
// decrsaturate via larger steps
|
||||
cpuif.write('h8, `clr);
|
||||
cpuif.assert_read('h8, 'h00, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(1));
|
||||
cpuif.assert_read('h8, 'h01, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(2));
|
||||
cpuif.assert_read('h8, 'h05, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(3));
|
||||
cpuif.assert_read('h8, 'h05, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(255));
|
||||
cpuif.assert_read('h8, 'h05, 'hFF);
|
||||
|
||||
{% endblock %}
|
||||
5
tests/test_counter_saturate/testcase.py
Normal file
5
tests/test_counter_saturate/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