Initial Commit - Forked from PeakRDL-regblock @ a440cc19769069be831d267505da4f3789a26695
This commit is contained in:
0
tests/test_counter_threshold/__init__.py
Normal file
0
tests/test_counter_threshold/__init__.py
Normal file
36
tests/test_counter_threshold/regblock.rdl
Normal file
36
tests/test_counter_threshold/regblock.rdl
Normal file
@@ -0,0 +1,36 @@
|
||||
addrmap top {
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=r; counter;
|
||||
incrthreshold;
|
||||
decrthreshold;
|
||||
} count[4] = 0;
|
||||
} threshold_via_bool @ 0x0;
|
||||
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=r; counter;
|
||||
incrthreshold = 10;
|
||||
decrthreshold = 5;
|
||||
} count[4] = 0;
|
||||
} threshold_via_const @ 0x4;
|
||||
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=r; counter;
|
||||
} count[4] = 0;
|
||||
} threshold_via_ref @ 0x8;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} min[4] = 0x4;
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} max[4] = 0xB;
|
||||
} threshold_control @ 0xC;
|
||||
threshold_via_ref.count -> decrthreshold = threshold_control.min;
|
||||
threshold_via_ref.count -> incrthreshold = threshold_control.max;
|
||||
};
|
||||
115
tests/test_counter_threshold/tb_template.sv
Normal file
115
tests/test_counter_threshold/tb_template.sv
Normal file
@@ -0,0 +1,115 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test incrthreshold = true; incrthreshold = true;
|
||||
//--------------------------------------------------------------------------
|
||||
cpuif.assert_read('h0, 'h0);
|
||||
|
||||
fork
|
||||
begin
|
||||
forever begin
|
||||
@cb;
|
||||
if(cb.hwif_out.threshold_via_bool.count.value == 0)
|
||||
assert(cb.hwif_out.threshold_via_bool.count.decrthreshold == 1'b1);
|
||||
else
|
||||
assert(cb.hwif_out.threshold_via_bool.count.decrthreshold == 1'b0);
|
||||
|
||||
if(cb.hwif_out.threshold_via_bool.count.value == 15)
|
||||
assert(cb.hwif_out.threshold_via_bool.count.incrthreshold == 1'b1);
|
||||
else
|
||||
assert(cb.hwif_out.threshold_via_bool.count.incrthreshold == 1'b0);
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
@cb;
|
||||
cb.hwif_in.threshold_via_bool.count.incr <= '1;
|
||||
repeat(32) @cb;
|
||||
cb.hwif_in.threshold_via_bool.count.incr <= '0;
|
||||
cb.hwif_in.threshold_via_bool.count.decr <= '1;
|
||||
repeat(32) @cb;
|
||||
cb.hwif_in.threshold_via_bool.count.decr <= '0;
|
||||
@cb;
|
||||
@cb;
|
||||
end
|
||||
join_any
|
||||
disable fork;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test incrthreshold = 10; incrthreshold = 5;
|
||||
//--------------------------------------------------------------------------
|
||||
cpuif.assert_read('h4, 'h0);
|
||||
|
||||
fork
|
||||
begin
|
||||
forever begin
|
||||
@cb;
|
||||
if(cb.hwif_out.threshold_via_const.count.value <= 5)
|
||||
assert(cb.hwif_out.threshold_via_const.count.decrthreshold == 1'b1);
|
||||
else
|
||||
assert(cb.hwif_out.threshold_via_const.count.decrthreshold == 1'b0);
|
||||
|
||||
if(cb.hwif_out.threshold_via_const.count.value >= 10)
|
||||
assert(cb.hwif_out.threshold_via_const.count.incrthreshold == 1'b1);
|
||||
else
|
||||
assert(cb.hwif_out.threshold_via_const.count.incrthreshold == 1'b0);
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
@cb;
|
||||
cb.hwif_in.threshold_via_const.count.incr <= '1;
|
||||
repeat(32) @cb;
|
||||
cb.hwif_in.threshold_via_const.count.incr <= '0;
|
||||
cb.hwif_in.threshold_via_const.count.decr <= '1;
|
||||
repeat(32) @cb;
|
||||
cb.hwif_in.threshold_via_const.count.decr <= '0;
|
||||
@cb;
|
||||
@cb;
|
||||
end
|
||||
join_any
|
||||
disable fork;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test incrthreshold = ref; incrthreshold =ref;
|
||||
//--------------------------------------------------------------------------
|
||||
cpuif.assert_read('h8, 'h0);
|
||||
|
||||
fork
|
||||
begin
|
||||
forever begin
|
||||
@cb;
|
||||
if(cb.hwif_out.threshold_via_ref.count.value <= 4)
|
||||
assert(cb.hwif_out.threshold_via_ref.count.decrthreshold == 1'b1);
|
||||
else
|
||||
assert(cb.hwif_out.threshold_via_ref.count.decrthreshold == 1'b0);
|
||||
|
||||
if(cb.hwif_out.threshold_via_ref.count.value >= 11)
|
||||
assert(cb.hwif_out.threshold_via_ref.count.incrthreshold == 1'b1);
|
||||
else
|
||||
assert(cb.hwif_out.threshold_via_ref.count.incrthreshold == 1'b0);
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
@cb;
|
||||
cb.hwif_in.threshold_via_ref.count.incr <= '1;
|
||||
repeat(32) @cb;
|
||||
cb.hwif_in.threshold_via_ref.count.incr <= '0;
|
||||
cb.hwif_in.threshold_via_ref.count.decr <= '1;
|
||||
repeat(32) @cb;
|
||||
cb.hwif_in.threshold_via_ref.count.decr <= '0;
|
||||
@cb;
|
||||
@cb;
|
||||
end
|
||||
join_any
|
||||
disable fork;
|
||||
|
||||
|
||||
{% endblock %}
|
||||
5
tests/test_counter_threshold/testcase.py
Normal file
5
tests/test_counter_threshold/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