Reorganize test dir to ensure test of installed pkg
This commit is contained in:
104
tests/README.md
Normal file
104
tests/README.md
Normal file
@@ -0,0 +1,104 @@
|
||||
|
||||
# Test Dependencies
|
||||
|
||||
## Questa
|
||||
|
||||
Testcases require an installation of the Questa simulator, and for `vlog` & `vsim`
|
||||
commands to be visible via the PATH environment variable.
|
||||
|
||||
*Questa - Intel FPGA Starter Edition* can be downloaded for free from Intel:
|
||||
* Go to https://www.intel.com/content/www/us/en/collections/products/fpga/software/downloads.html?edition=pro&s=Newest
|
||||
* Select latest version of *Intel Quartus Prime Pro*
|
||||
* Go to the *Individual Files* tab.
|
||||
* Download Questa files. (Don't forget part 2!)
|
||||
* Install
|
||||
* Go to https://licensing.intel.com/psg/s/sales-signup-evaluationlicenses
|
||||
* Generate a free *Starter Edition* license file for Questa
|
||||
* Easiest to use a *fixed* license using your NIC ID (MAC address of your network card via `ifconfig`)
|
||||
* Download the license file and point the `LM_LICENSE_FILE` environment variable to the folder which contains it.
|
||||
|
||||
|
||||
## Vivado (optional)
|
||||
|
||||
To run synthesis tests, Vivado needs to be installed and visible via the PATH environment variable.
|
||||
|
||||
Vivado can be downloaded for free from: https://www.xilinx.com/support/download.html
|
||||
|
||||
To skip synthesis tests, export the following environment variable:
|
||||
```bash
|
||||
export SKIP_SYNTH_TESTS=1
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Python Packages
|
||||
Install dependencies required for running tests
|
||||
|
||||
```bash
|
||||
python3 -m pip install test/requirements.txt
|
||||
```
|
||||
|
||||
|
||||
|
||||
# Running tests
|
||||
|
||||
Tests can be launched from the test directory using `pytest`.
|
||||
Use `pytest --workers auto` to run tests in parallel.
|
||||
|
||||
To run all tests:
|
||||
```bash
|
||||
python3 setup.py install
|
||||
pytest tests
|
||||
```
|
||||
|
||||
You can also run a specific testcase. For example:
|
||||
```bash
|
||||
pytest tests/test_hw_access
|
||||
```
|
||||
|
||||
|
||||
|
||||
# Test organization
|
||||
|
||||
The goal for this test infrastructure is to make it easy to add small-standalone
|
||||
testcases, with minimal repetition/boilerplate code that is usually present in
|
||||
SystemVerilog testbenches.
|
||||
|
||||
To accomplish this, Jinja templates are used extensively to generate the
|
||||
resulting `tb.sv` file, as well as assist in dynamic testcase parameterization.
|
||||
|
||||
|
||||
|
||||
## CPU Interfaces
|
||||
Each CPU interface type is described in its own folder as follows:
|
||||
|
||||
`lib/cpuifs/<type>/__init__.py`
|
||||
: Definitions for CPU Interface test mode classes.
|
||||
|
||||
`lib/cpuifs/<type>/tb_inst.sv`
|
||||
: Jinja template that defines how the CPU interface is declared & instantiated in the testbench file.
|
||||
|
||||
`lib/cpuifs/<type>/*.sv`
|
||||
: Any other files required for compilation.
|
||||
|
||||
|
||||
|
||||
## Testcase
|
||||
Each testcase group has its own folder and contains the following:
|
||||
|
||||
`test_*/__init__.py`
|
||||
: Empty file required for test discovery.
|
||||
|
||||
`test_*/regblock.rdl`
|
||||
: Testcase RDL file. Testcase infrastructure will automatically compile this and generate the regblock output SystemVerilog.
|
||||
|
||||
`test_*/tb_template.sv`
|
||||
: Jinja template that defines the testcase-specific sequence.
|
||||
|
||||
`test_*/testcase.py`
|
||||
: Defines Python unittest testcase entry point.
|
||||
|
||||
|
||||
|
||||
## Parameterization
|
||||
Testcase classes can be parameterized using the [parameterized](https://github.com/wolever/parameterized) extension. This allows the same testcase to be run against multiple permutations of regblock export modes such as CPU interfaces, retiming flop stages, or even RDL parameterizations.
|
||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
0
tests/lib/__init__.py
Normal file
0
tests/lib/__init__.py
Normal file
121
tests/lib/base_testcase.py
Normal file
121
tests/lib/base_testcase.py
Normal file
@@ -0,0 +1,121 @@
|
||||
from typing import Optional, List
|
||||
import unittest
|
||||
import os
|
||||
import glob
|
||||
import shutil
|
||||
import inspect
|
||||
import pathlib
|
||||
|
||||
import pytest
|
||||
from systemrdl import RDLCompiler
|
||||
|
||||
from peakrdl.regblock import RegblockExporter
|
||||
from .cpuifs.base import CpuifTestMode
|
||||
from .cpuifs.apb3 import APB3
|
||||
|
||||
|
||||
class BaseTestCase(unittest.TestCase):
|
||||
#: Path to the testcase's RDL file.
|
||||
#: Relative to the testcase's dir. If unset, the first RDL file found in the
|
||||
#: testcase dir will be used
|
||||
rdl_file = None # type: Optional[str]
|
||||
|
||||
#: RDL type name to elaborate. If unset, compiler will automatically choose
|
||||
#: the top.
|
||||
rdl_elab_target = None # type: Optional[str]
|
||||
|
||||
#: Parameters to pass into RDL elaboration
|
||||
rdl_elab_params = {}
|
||||
|
||||
#: Define what CPUIF to use for this testcase
|
||||
cpuif = APB3() # type: CpuifTestMode
|
||||
|
||||
# Other exporter args:
|
||||
retime_read_fanin = False
|
||||
retime_read_response = False
|
||||
|
||||
#: this gets auto-loaded via the _load_request autouse fixture
|
||||
request = None # type: pytest.FixtureRequest
|
||||
|
||||
exporter = RegblockExporter()
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _load_request(self, request):
|
||||
self.request = request
|
||||
|
||||
@classmethod
|
||||
def get_testcase_dir(cls) -> str:
|
||||
class_dir = os.path.dirname(inspect.getfile(cls))
|
||||
return class_dir
|
||||
|
||||
@classmethod
|
||||
def get_run_dir(cls) -> str:
|
||||
this_dir = cls.get_testcase_dir()
|
||||
run_dir = os.path.join(this_dir, "run.out", cls.__name__)
|
||||
return run_dir
|
||||
|
||||
@classmethod
|
||||
def _write_params(cls) -> None:
|
||||
"""
|
||||
Write out the class parameters to a file so that it is easier to debug
|
||||
how a testcase was parameterized
|
||||
"""
|
||||
path = os.path.join(cls.get_run_dir(), "params.txt")
|
||||
|
||||
with open(path, 'w') as f:
|
||||
for k, v in cls.__dict__.items():
|
||||
if k.startswith("_") or callable(v):
|
||||
continue
|
||||
f.write(f"{k}: {repr(v)}\n")
|
||||
|
||||
|
||||
@classmethod
|
||||
def _export_regblock(cls):
|
||||
"""
|
||||
Call the peakrdl.regblock exporter to generate the DUT
|
||||
"""
|
||||
this_dir = cls.get_testcase_dir()
|
||||
|
||||
if cls.rdl_file:
|
||||
rdl_file = cls.rdl_file
|
||||
else:
|
||||
# Find any *.rdl file in testcase dir
|
||||
rdl_file = glob.glob(os.path.join(this_dir, "*.rdl"))[0]
|
||||
|
||||
rdlc = RDLCompiler()
|
||||
rdlc.compile_file(rdl_file)
|
||||
root = rdlc.elaborate(cls.rdl_elab_target, "regblock", cls.rdl_elab_params)
|
||||
|
||||
cls.exporter.export(
|
||||
root,
|
||||
cls.get_run_dir(),
|
||||
module_name="regblock",
|
||||
package_name="regblock_pkg",
|
||||
cpuif_cls=cls.cpuif.cpuif_cls,
|
||||
retime_read_fanin=cls.retime_read_fanin,
|
||||
retime_read_response=cls.retime_read_response,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# Create fresh build dir
|
||||
run_dir = cls.get_run_dir()
|
||||
if os.path.exists(run_dir):
|
||||
shutil.rmtree(run_dir)
|
||||
pathlib.Path(run_dir).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
cls._write_params()
|
||||
|
||||
# Convert testcase RDL file --> SV
|
||||
cls._export_regblock()
|
||||
|
||||
|
||||
def setUp(self) -> None:
|
||||
# cd into the run directory
|
||||
self.original_cwd = os.getcwd()
|
||||
os.chdir(self.get_run_dir())
|
||||
|
||||
|
||||
def run_test(self, plusargs:List[str] = None) -> None:
|
||||
simulator = self.simulator_cls(testcase_cls_inst=self)
|
||||
simulator.run(plusargs)
|
||||
0
tests/lib/cpuifs/__init__.py
Normal file
0
tests/lib/cpuifs/__init__.py
Normal file
18
tests/lib/cpuifs/apb3/__init__.py
Normal file
18
tests/lib/cpuifs/apb3/__init__.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from ..base import CpuifTestMode
|
||||
|
||||
from peakrdl.regblock.cpuif.apb3 import APB3_Cpuif, APB3_Cpuif_flattened
|
||||
|
||||
class APB3(CpuifTestMode):
|
||||
cpuif_cls = APB3_Cpuif
|
||||
rtl_files = [
|
||||
"apb3_intf.sv",
|
||||
]
|
||||
tb_files = [
|
||||
"apb3_intf.sv",
|
||||
"apb3_intf_driver.sv",
|
||||
]
|
||||
tb_template = "tb_inst.sv"
|
||||
|
||||
class FlatAPB3(APB3):
|
||||
cpuif_cls = APB3_Cpuif_flattened
|
||||
rtl_files = []
|
||||
40
tests/lib/cpuifs/apb3/apb3_intf.sv
Normal file
40
tests/lib/cpuifs/apb3/apb3_intf.sv
Normal file
@@ -0,0 +1,40 @@
|
||||
interface apb3_intf #(
|
||||
parameter DATA_WIDTH = 32,
|
||||
parameter ADDR_WIDTH = 32
|
||||
);
|
||||
// Command
|
||||
logic PSEL;
|
||||
logic PENABLE;
|
||||
logic PWRITE;
|
||||
logic [ADDR_WIDTH-1:0] PADDR;
|
||||
logic [DATA_WIDTH-1:0] PWDATA;
|
||||
|
||||
// Response
|
||||
logic [DATA_WIDTH-1:0] PRDATA;
|
||||
logic PREADY;
|
||||
logic PSLVERR;
|
||||
|
||||
modport master (
|
||||
output PSEL,
|
||||
output PENABLE,
|
||||
output PWRITE,
|
||||
output PADDR,
|
||||
output PWDATA,
|
||||
|
||||
input PRDATA,
|
||||
input PREADY,
|
||||
input PSLVERR
|
||||
);
|
||||
|
||||
modport slave (
|
||||
input PSEL,
|
||||
input PENABLE,
|
||||
input PWRITE,
|
||||
input PADDR,
|
||||
input PWDATA,
|
||||
|
||||
output PRDATA,
|
||||
output PREADY,
|
||||
output PSLVERR
|
||||
);
|
||||
endinterface
|
||||
116
tests/lib/cpuifs/apb3/apb3_intf_driver.sv
Normal file
116
tests/lib/cpuifs/apb3/apb3_intf_driver.sv
Normal file
@@ -0,0 +1,116 @@
|
||||
interface apb3_intf_driver #(
|
||||
parameter DATA_WIDTH = 32,
|
||||
parameter ADDR_WIDTH = 32
|
||||
)(
|
||||
input wire clk,
|
||||
input wire rst,
|
||||
apb3_intf.master m_apb
|
||||
);
|
||||
|
||||
timeunit 1ps;
|
||||
timeprecision 1ps;
|
||||
|
||||
logic PSEL;
|
||||
logic PENABLE;
|
||||
logic PWRITE;
|
||||
logic [ADDR_WIDTH-1:0] PADDR;
|
||||
logic [DATA_WIDTH-1:0] PWDATA;
|
||||
logic [DATA_WIDTH-1:0] PRDATA;
|
||||
logic PREADY;
|
||||
logic PSLVERR;
|
||||
|
||||
assign m_apb.PSEL = PSEL;
|
||||
assign m_apb.PENABLE = PENABLE;
|
||||
assign m_apb.PWRITE = PWRITE;
|
||||
assign m_apb.PADDR = PADDR;
|
||||
assign m_apb.PWDATA = PWDATA;
|
||||
assign PRDATA = m_apb.PRDATA;
|
||||
assign PREADY = m_apb.PREADY;
|
||||
assign PSLVERR = m_apb.PSLVERR;
|
||||
|
||||
default clocking cb @(posedge clk);
|
||||
default input #1step output #1;
|
||||
output PSEL;
|
||||
output PENABLE;
|
||||
output PWRITE;
|
||||
output PADDR;
|
||||
output PWDATA;
|
||||
input PRDATA;
|
||||
input PREADY;
|
||||
input PSLVERR;
|
||||
endclocking
|
||||
|
||||
task automatic reset();
|
||||
cb.PSEL <= '0;
|
||||
cb.PENABLE <= '0;
|
||||
cb.PWRITE <= '0;
|
||||
cb.PADDR <= '0;
|
||||
cb.PWDATA <= '0;
|
||||
endtask
|
||||
|
||||
semaphore txn_mutex = new(1);
|
||||
|
||||
task automatic write(logic [ADDR_WIDTH-1:0] addr, logic [DATA_WIDTH-1:0] data);
|
||||
txn_mutex.get();
|
||||
##0;
|
||||
|
||||
// Initiate transfer
|
||||
cb.PSEL <= '1;
|
||||
cb.PENABLE <= '0;
|
||||
cb.PWRITE <= '1;
|
||||
cb.PADDR <= addr;
|
||||
cb.PWDATA <= data;
|
||||
@(cb);
|
||||
|
||||
// active phase
|
||||
cb.PENABLE <= '1;
|
||||
@(cb);
|
||||
|
||||
// Wait for response
|
||||
while(cb.PREADY !== 1'b1) @(cb);
|
||||
reset();
|
||||
txn_mutex.put();
|
||||
endtask
|
||||
|
||||
task automatic read(logic [ADDR_WIDTH-1:0] addr, output logic [DATA_WIDTH-1:0] data);
|
||||
txn_mutex.get();
|
||||
##0;
|
||||
|
||||
// Initiate transfer
|
||||
cb.PSEL <= '1;
|
||||
cb.PENABLE <= '0;
|
||||
cb.PWRITE <= '0;
|
||||
cb.PADDR <= addr;
|
||||
cb.PWDATA <= '0;
|
||||
@(cb);
|
||||
|
||||
// active phase
|
||||
cb.PENABLE <= '1;
|
||||
@(cb);
|
||||
|
||||
// Wait for response
|
||||
while(cb.PREADY !== 1'b1) @(cb);
|
||||
assert(!$isunknown(cb.PRDATA)) else $error("Read from 0x%0x returned X's on PRDATA", addr);
|
||||
assert(!$isunknown(cb.PSLVERR)) else $error("Read from 0x%0x returned X's on PSLVERR", addr);
|
||||
data = cb.PRDATA;
|
||||
reset();
|
||||
txn_mutex.put();
|
||||
endtask
|
||||
|
||||
task automatic assert_read(logic [ADDR_WIDTH-1:0] addr, logic [DATA_WIDTH-1:0] expected_data, logic [DATA_WIDTH-1:0] mask = '1);
|
||||
logic [DATA_WIDTH-1:0] data;
|
||||
read(addr, data);
|
||||
data &= mask;
|
||||
assert(data == expected_data) else $error("Read from 0x%x returned 0x%x. Expected 0x%x", addr, data, expected_data);
|
||||
endtask
|
||||
|
||||
initial begin
|
||||
reset();
|
||||
end
|
||||
|
||||
initial forever begin
|
||||
@cb;
|
||||
if(!rst) assert(!$isunknown(cb.PREADY)) else $error("Saw X on PREADY!");
|
||||
end
|
||||
|
||||
endinterface
|
||||
32
tests/lib/cpuifs/apb3/tb_inst.sv
Normal file
32
tests/lib/cpuifs/apb3/tb_inst.sv
Normal file
@@ -0,0 +1,32 @@
|
||||
{% sv_line_anchor %}
|
||||
apb3_intf #(
|
||||
.DATA_WIDTH({{exporter.cpuif.data_width}}),
|
||||
.ADDR_WIDTH({{exporter.cpuif.addr_width}})
|
||||
) s_apb();
|
||||
apb3_intf_driver #(
|
||||
.DATA_WIDTH({{exporter.cpuif.data_width}}),
|
||||
.ADDR_WIDTH({{exporter.cpuif.addr_width}})
|
||||
) cpuif (
|
||||
.clk(clk),
|
||||
.rst(rst),
|
||||
.m_apb(s_apb)
|
||||
);
|
||||
{% if type(cpuif).__name__.startswith("Flat") %}
|
||||
{% sv_line_anchor %}
|
||||
wire s_apb_psel;
|
||||
wire s_apb_penable;
|
||||
wire s_apb_pwrite;
|
||||
wire [{{exporter.cpuif.addr_width - 1}}:0] s_apb_paddr;
|
||||
wire [{{exporter.cpuif.data_width - 1}}:0] s_apb_pwdata;
|
||||
wire s_apb_pready;
|
||||
wire [{{exporter.cpuif.data_width - 1}}:0] s_apb_prdata;
|
||||
wire s_apb_pslverr;
|
||||
assign s_apb_psel = s_apb.PSEL;
|
||||
assign s_apb_penable = s_apb.PENABLE;
|
||||
assign s_apb_pwrite = s_apb.PWRITE;
|
||||
assign s_apb_paddr = s_apb.PADDR;
|
||||
assign s_apb_pwdata = s_apb.PWDATA;
|
||||
assign s_apb.PREADY = s_apb_pready;
|
||||
assign s_apb.PRDATA = s_apb_prdata;
|
||||
assign s_apb.PSLVERR = s_apb_pslverr;
|
||||
{% endif %}
|
||||
18
tests/lib/cpuifs/axi4lite/__init__.py
Normal file
18
tests/lib/cpuifs/axi4lite/__init__.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from ..base import CpuifTestMode
|
||||
|
||||
from peakrdl.regblock.cpuif.axi4lite import AXI4Lite_Cpuif, AXI4Lite_Cpuif_flattened
|
||||
|
||||
class AXI4Lite(CpuifTestMode):
|
||||
cpuif_cls = AXI4Lite_Cpuif
|
||||
rtl_files = [
|
||||
"axi4lite_intf.sv",
|
||||
]
|
||||
tb_files = [
|
||||
"axi4lite_intf.sv",
|
||||
"axi4lite_intf_driver.sv",
|
||||
]
|
||||
tb_template = "tb_inst.sv"
|
||||
|
||||
class FlatAXI4Lite(AXI4Lite):
|
||||
cpuif_cls = AXI4Lite_Cpuif_flattened
|
||||
rtl_files = []
|
||||
80
tests/lib/cpuifs/axi4lite/axi4lite_intf.sv
Normal file
80
tests/lib/cpuifs/axi4lite/axi4lite_intf.sv
Normal file
@@ -0,0 +1,80 @@
|
||||
interface axi4lite_intf #(
|
||||
parameter DATA_WIDTH = 32,
|
||||
parameter ADDR_WIDTH = 32
|
||||
);
|
||||
logic AWREADY;
|
||||
logic AWVALID;
|
||||
logic [ADDR_WIDTH-1:0] AWADDR;
|
||||
logic [2:0] AWPROT;
|
||||
|
||||
logic WREADY;
|
||||
logic WVALID;
|
||||
logic [DATA_WIDTH-1:0] WDATA;
|
||||
logic [DATA_WIDTH/8-1:0] WSTRB;
|
||||
|
||||
logic BREADY;
|
||||
logic BVALID;
|
||||
logic [1:0] BRESP;
|
||||
|
||||
logic ARREADY;
|
||||
logic ARVALID;
|
||||
logic [ADDR_WIDTH-1:0] ARADDR;
|
||||
logic [2:0] ARPROT;
|
||||
|
||||
logic RREADY;
|
||||
logic RVALID;
|
||||
logic [DATA_WIDTH-1:0] RDATA;
|
||||
logic [1:0] RRESP;
|
||||
|
||||
modport master (
|
||||
input AWREADY,
|
||||
output AWVALID,
|
||||
output AWADDR,
|
||||
output AWPROT,
|
||||
|
||||
input WREADY,
|
||||
output WVALID,
|
||||
output WDATA,
|
||||
output WSTRB,
|
||||
|
||||
output BREADY,
|
||||
input BVALID,
|
||||
input BRESP,
|
||||
|
||||
input ARREADY,
|
||||
output ARVALID,
|
||||
output ARADDR,
|
||||
output ARPROT,
|
||||
|
||||
output RREADY,
|
||||
input RVALID,
|
||||
input RDATA,
|
||||
input RRESP
|
||||
);
|
||||
|
||||
modport slave (
|
||||
output AWREADY,
|
||||
input AWVALID,
|
||||
input AWADDR,
|
||||
input AWPROT,
|
||||
|
||||
output WREADY,
|
||||
input WVALID,
|
||||
input WDATA,
|
||||
input WSTRB,
|
||||
|
||||
input BREADY,
|
||||
output BVALID,
|
||||
output BRESP,
|
||||
|
||||
output ARREADY,
|
||||
input ARVALID,
|
||||
input ARADDR,
|
||||
input ARPROT,
|
||||
|
||||
input RREADY,
|
||||
output RVALID,
|
||||
output RDATA,
|
||||
output RRESP
|
||||
);
|
||||
endinterface
|
||||
193
tests/lib/cpuifs/axi4lite/axi4lite_intf_driver.sv
Normal file
193
tests/lib/cpuifs/axi4lite/axi4lite_intf_driver.sv
Normal file
@@ -0,0 +1,193 @@
|
||||
interface axi4lite_intf_driver #(
|
||||
parameter DATA_WIDTH = 32,
|
||||
parameter ADDR_WIDTH = 32
|
||||
)(
|
||||
input wire clk,
|
||||
input wire rst,
|
||||
axi4lite_intf.master m_axil
|
||||
);
|
||||
|
||||
timeunit 1ps;
|
||||
timeprecision 1ps;
|
||||
|
||||
logic AWREADY;
|
||||
logic AWVALID;
|
||||
logic [ADDR_WIDTH-1:0] AWADDR;
|
||||
logic [2:0] AWPROT;
|
||||
|
||||
logic WREADY;
|
||||
logic WVALID;
|
||||
logic [DATA_WIDTH-1:0] WDATA;
|
||||
logic [DATA_WIDTH/8-1:0] WSTRB;
|
||||
|
||||
logic BREADY;
|
||||
logic BVALID;
|
||||
logic [1:0] BRESP;
|
||||
|
||||
logic ARREADY;
|
||||
logic ARVALID;
|
||||
logic [ADDR_WIDTH-1:0] ARADDR;
|
||||
logic [2:0] ARPROT;
|
||||
|
||||
logic RREADY;
|
||||
logic RVALID;
|
||||
logic [DATA_WIDTH-1:0] RDATA;
|
||||
logic [1:0] RRESP;
|
||||
|
||||
assign AWREADY = m_axil.AWREADY;
|
||||
assign m_axil.AWVALID = AWVALID;
|
||||
assign m_axil.AWADDR = AWADDR;
|
||||
assign m_axil.AWPROT = AWPROT;
|
||||
assign WREADY = m_axil.WREADY;
|
||||
assign m_axil.WVALID = WVALID;
|
||||
assign m_axil.WDATA = WDATA;
|
||||
assign m_axil.WSTRB = WSTRB;
|
||||
assign m_axil.BREADY = BREADY;
|
||||
assign BVALID = m_axil.BVALID;
|
||||
assign BRESP = m_axil.BRESP;
|
||||
assign ARREADY = m_axil.ARREADY;
|
||||
assign m_axil.ARVALID = ARVALID;
|
||||
assign m_axil.ARADDR = ARADDR;
|
||||
assign m_axil.ARPROT = ARPROT;
|
||||
assign m_axil.RREADY = RREADY;
|
||||
assign RVALID = m_axil.RVALID;
|
||||
assign RDATA = m_axil.RDATA;
|
||||
assign RRESP = m_axil.RRESP;
|
||||
|
||||
default clocking cb @(posedge clk);
|
||||
default input #1step output #1;
|
||||
input AWREADY;
|
||||
output AWVALID;
|
||||
output AWADDR;
|
||||
output AWPROT;
|
||||
input WREADY;
|
||||
output WVALID;
|
||||
output WDATA;
|
||||
output WSTRB;
|
||||
inout BREADY;
|
||||
input BVALID;
|
||||
input BRESP;
|
||||
input ARREADY;
|
||||
output ARVALID;
|
||||
output ARADDR;
|
||||
output ARPROT;
|
||||
inout RREADY;
|
||||
input RVALID;
|
||||
input RDATA;
|
||||
input RRESP;
|
||||
endclocking
|
||||
|
||||
task automatic reset();
|
||||
cb.AWVALID <= '0;
|
||||
cb.AWADDR <= '0;
|
||||
cb.AWPROT <= '0;
|
||||
cb.WVALID <= '0;
|
||||
cb.WDATA <= '0;
|
||||
cb.WSTRB <= '0;
|
||||
cb.ARVALID <= '0;
|
||||
cb.ARADDR <= '0;
|
||||
cb.ARPROT <= '0;
|
||||
endtask
|
||||
|
||||
initial forever begin
|
||||
cb.RREADY <= $urandom_range(1, 0);
|
||||
cb.BREADY <= $urandom_range(1, 0);
|
||||
@cb;
|
||||
end
|
||||
|
||||
semaphore txn_aw_mutex = new(1);
|
||||
semaphore txn_w_mutex = new(1);
|
||||
semaphore txn_b_mutex = new(1);
|
||||
semaphore txn_ar_mutex = new(1);
|
||||
semaphore txn_r_mutex = new(1);
|
||||
|
||||
task automatic write(logic [ADDR_WIDTH-1:0] addr, logic [DATA_WIDTH-1:0] data);
|
||||
bit w_before_aw;
|
||||
w_before_aw = $urandom_range(1,0);
|
||||
|
||||
fork
|
||||
begin
|
||||
txn_aw_mutex.get();
|
||||
##0;
|
||||
if(w_before_aw) repeat($urandom_range(2,0)) @cb;
|
||||
cb.AWVALID <= '1;
|
||||
cb.AWADDR <= addr;
|
||||
cb.AWPROT <= '0;
|
||||
@(cb);
|
||||
while(cb.AWREADY !== 1'b1) @(cb);
|
||||
cb.AWVALID <= '0;
|
||||
txn_aw_mutex.put();
|
||||
end
|
||||
|
||||
begin
|
||||
txn_w_mutex.get();
|
||||
##0;
|
||||
if(!w_before_aw) repeat($urandom_range(2,0)) @cb;
|
||||
cb.WVALID <= '1;
|
||||
cb.WDATA <= data;
|
||||
cb.WSTRB <= '1; // TODO: Support byte strobes
|
||||
@(cb);
|
||||
while(cb.WREADY !== 1'b1) @(cb);
|
||||
cb.WVALID <= '0;
|
||||
cb.WSTRB <= '0;
|
||||
txn_w_mutex.put();
|
||||
end
|
||||
|
||||
begin
|
||||
txn_b_mutex.get();
|
||||
@cb;
|
||||
while(!(cb.BREADY === 1'b1 && cb.BVALID === 1'b1)) @(cb);
|
||||
assert(!$isunknown(cb.BRESP)) else $error("Read from 0x%0x returned X's on BRESP", addr);
|
||||
txn_b_mutex.put();
|
||||
end
|
||||
join
|
||||
endtask
|
||||
|
||||
task automatic read(logic [ADDR_WIDTH-1:0] addr, output logic [DATA_WIDTH-1:0] data);
|
||||
|
||||
fork
|
||||
begin
|
||||
txn_ar_mutex.get();
|
||||
##0;
|
||||
cb.ARVALID <= '1;
|
||||
cb.ARADDR <= addr;
|
||||
cb.ARPROT <= '0;
|
||||
@(cb);
|
||||
while(cb.ARREADY !== 1'b1) @(cb);
|
||||
cb.ARVALID <= '0;
|
||||
txn_ar_mutex.put();
|
||||
end
|
||||
|
||||
begin
|
||||
txn_r_mutex.get();
|
||||
@cb;
|
||||
while(!(cb.RREADY === 1'b1 && cb.RVALID === 1'b1)) @(cb);
|
||||
assert(!$isunknown(cb.RDATA)) else $error("Read from 0x%0x returned X's on RDATA", addr);
|
||||
assert(!$isunknown(cb.RRESP)) else $error("Read from 0x%0x returned X's on RRESP", addr);
|
||||
data = cb.RDATA;
|
||||
txn_r_mutex.put();
|
||||
end
|
||||
join
|
||||
endtask
|
||||
|
||||
task automatic assert_read(logic [ADDR_WIDTH-1:0] addr, logic [DATA_WIDTH-1:0] expected_data, logic [DATA_WIDTH-1:0] mask = '1);
|
||||
logic [DATA_WIDTH-1:0] data;
|
||||
read(addr, data);
|
||||
data &= mask;
|
||||
assert(data == expected_data) else $error("Read from 0x%x returned 0x%x. Expected 0x%x", addr, data, expected_data);
|
||||
endtask
|
||||
|
||||
initial begin
|
||||
reset();
|
||||
end
|
||||
|
||||
initial forever begin
|
||||
@cb;
|
||||
if(!rst) assert(!$isunknown(cb.AWREADY)) else $error("Saw X on AWREADY!");
|
||||
if(!rst) assert(!$isunknown(cb.WREADY)) else $error("Saw X on WREADY!");
|
||||
if(!rst) assert(!$isunknown(cb.BVALID)) else $error("Saw X on BVALID!");
|
||||
if(!rst) assert(!$isunknown(cb.ARREADY)) else $error("Saw X on ARREADY!");
|
||||
if(!rst) assert(!$isunknown(cb.RVALID)) else $error("Saw X on RVALID!");
|
||||
end
|
||||
|
||||
endinterface
|
||||
54
tests/lib/cpuifs/axi4lite/tb_inst.sv
Normal file
54
tests/lib/cpuifs/axi4lite/tb_inst.sv
Normal file
@@ -0,0 +1,54 @@
|
||||
{% sv_line_anchor %}
|
||||
axi4lite_intf #(
|
||||
.DATA_WIDTH({{exporter.cpuif.data_width}}),
|
||||
.ADDR_WIDTH({{exporter.cpuif.addr_width}})
|
||||
) s_axil();
|
||||
axi4lite_intf_driver #(
|
||||
.DATA_WIDTH({{exporter.cpuif.data_width}}),
|
||||
.ADDR_WIDTH({{exporter.cpuif.addr_width}})
|
||||
) cpuif (
|
||||
.clk(clk),
|
||||
.rst(rst),
|
||||
.m_axil(s_axil)
|
||||
);
|
||||
{% if type(cpuif).__name__.startswith("Flat") %}
|
||||
{% sv_line_anchor %}
|
||||
wire s_axil_awready;
|
||||
wire s_axil_awvalid;
|
||||
wire [{{exporter.cpuif.addr_width - 1}}:0] s_axil_awaddr;
|
||||
wire [2:0] s_axil_awprot;
|
||||
wire s_axil_wready;
|
||||
wire s_axil_wvalid;
|
||||
wire [{{exporter.cpuif.data_width - 1}}:0] s_axil_wdata;
|
||||
wire [{{exporter.cpuif.data_width_bytes - 1}}:0] s_axil_wstrb;
|
||||
wire s_axil_bready;
|
||||
wire s_axil_bvalid;
|
||||
wire [1:0] s_axil_bresp;
|
||||
wire s_axil_arready;
|
||||
wire s_axil_arvalid;
|
||||
wire [{{exporter.cpuif.addr_width - 1}}:0] s_axil_araddr;
|
||||
wire [2:0] s_axil_arprot;
|
||||
wire s_axil_rready;
|
||||
wire s_axil_rvalid;
|
||||
wire [{{exporter.cpuif.data_width - 1}}:0] s_axil_rdata;
|
||||
wire [1:0] s_axil_rresp;
|
||||
assign s_axil.AWREADY = s_axil_awready;
|
||||
assign s_axil_awvalid = s_axil.AWVALID;
|
||||
assign s_axil_awaddr = s_axil.AWADDR;
|
||||
assign s_axil_awprot = s_axil.AWPROT;
|
||||
assign s_axil.WREADY = s_axil_wready;
|
||||
assign s_axil_wvalid = s_axil.WVALID;
|
||||
assign s_axil_wdata = s_axil.WDATA;
|
||||
assign s_axil_wstrb = s_axil.WSTRB;
|
||||
assign s_axil_bready = s_axil.BREADY;
|
||||
assign s_axil.BVALID = s_axil_bvalid;
|
||||
assign s_axil.BRESP = s_axil_bresp;
|
||||
assign s_axil.ARREADY = s_axil_arready;
|
||||
assign s_axil_arvalid = s_axil.ARVALID;
|
||||
assign s_axil_araddr = s_axil.ARADDR;
|
||||
assign s_axil_arprot = s_axil.ARPROT;
|
||||
assign s_axil_rready = s_axil.RREADY;
|
||||
assign s_axil.RVALID = s_axil_rvalid;
|
||||
assign s_axil.RDATA = s_axil_rdata;
|
||||
assign s_axil.RRESP = s_axil_rresp;
|
||||
{% endif %}
|
||||
87
tests/lib/cpuifs/base.py
Normal file
87
tests/lib/cpuifs/base.py
Normal file
@@ -0,0 +1,87 @@
|
||||
from typing import List, TYPE_CHECKING
|
||||
import os
|
||||
import inspect
|
||||
|
||||
import jinja2 as jj
|
||||
|
||||
from peakrdl.regblock.cpuif.base import CpuifBase
|
||||
|
||||
from ..sv_line_anchor import SVLineAnchor
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from peakrdl.regblock import RegblockExporter
|
||||
from ..sim_testcase import SimTestCase
|
||||
|
||||
class CpuifTestMode:
|
||||
cpuif_cls = None # type: CpuifBase
|
||||
|
||||
# Files required by the DUT
|
||||
# Paths are relative to the class that assigns this
|
||||
rtl_files = [] # type: List[str]
|
||||
|
||||
# Files required by the sim testbench
|
||||
# Paths are relative to the class that assigns this
|
||||
tb_files = [] # type: List[str]
|
||||
|
||||
# Path is relative to the class that assigns this
|
||||
tb_template = ""
|
||||
|
||||
|
||||
def _get_class_dir_of_variable(self, varname:str) -> str:
|
||||
"""
|
||||
Traverse up the MRO and find the first class that explicitly assigns
|
||||
the variable of name varname. Returns the directory that contains the
|
||||
class definition.
|
||||
"""
|
||||
for cls in inspect.getmro(self.__class__):
|
||||
if varname in cls.__dict__:
|
||||
class_dir = os.path.dirname(inspect.getfile(cls))
|
||||
return class_dir
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
def _get_file_paths(self, varname:str) -> List[str]:
|
||||
class_dir = self._get_class_dir_of_variable(varname)
|
||||
files = getattr(self, varname)
|
||||
cwd = os.getcwd()
|
||||
|
||||
new_files = []
|
||||
for file in files:
|
||||
relpath = os.path.relpath(
|
||||
os.path.join(class_dir, file),
|
||||
cwd
|
||||
)
|
||||
new_files.append(relpath)
|
||||
return new_files
|
||||
|
||||
|
||||
def get_sim_files(self) -> List[str]:
|
||||
files = self._get_file_paths("rtl_files") + self._get_file_paths("tb_files")
|
||||
unique_files = []
|
||||
[unique_files.append(f) for f in files if f not in unique_files]
|
||||
return unique_files
|
||||
|
||||
|
||||
def get_synth_files(self) -> List[str]:
|
||||
return self._get_file_paths("rtl_files")
|
||||
|
||||
|
||||
def get_tb_inst(self, tb_cls: 'SimTestCase', exporter: 'RegblockExporter') -> str:
|
||||
class_dir = self._get_class_dir_of_variable("tb_template")
|
||||
loader = jj.FileSystemLoader(class_dir)
|
||||
jj_env = jj.Environment(
|
||||
loader=loader,
|
||||
undefined=jj.StrictUndefined,
|
||||
extensions=[SVLineAnchor],
|
||||
)
|
||||
|
||||
context = {
|
||||
"cpuif": self,
|
||||
"cls": tb_cls,
|
||||
"exporter": exporter,
|
||||
"type": type,
|
||||
}
|
||||
|
||||
template = jj_env.get_template(self.tb_template)
|
||||
|
||||
return template.render(context)
|
||||
11
tests/lib/cpuifs/passthrough/__init__.py
Normal file
11
tests/lib/cpuifs/passthrough/__init__.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from ..base import CpuifTestMode
|
||||
|
||||
from peakrdl.regblock.cpuif.passthrough import PassthroughCpuif
|
||||
|
||||
class Passthrough(CpuifTestMode):
|
||||
cpuif_cls = PassthroughCpuif
|
||||
rtl_files = []
|
||||
tb_files = [
|
||||
"passthrough_driver.sv",
|
||||
]
|
||||
tb_template = "tb_inst.sv"
|
||||
119
tests/lib/cpuifs/passthrough/passthrough_driver.sv
Normal file
119
tests/lib/cpuifs/passthrough/passthrough_driver.sv
Normal file
@@ -0,0 +1,119 @@
|
||||
interface passthrough_driver #(
|
||||
parameter DATA_WIDTH = 32,
|
||||
parameter ADDR_WIDTH = 32
|
||||
)(
|
||||
input wire clk,
|
||||
input wire rst,
|
||||
|
||||
output logic m_cpuif_req,
|
||||
output logic m_cpuif_req_is_wr,
|
||||
output logic [ADDR_WIDTH-1:0] m_cpuif_addr,
|
||||
output logic [DATA_WIDTH-1:0] m_cpuif_wr_data,
|
||||
input wire m_cpuif_req_stall_wr,
|
||||
input wire m_cpuif_req_stall_rd,
|
||||
input wire m_cpuif_rd_ack,
|
||||
input wire m_cpuif_rd_err,
|
||||
input wire [DATA_WIDTH-1:0] m_cpuif_rd_data,
|
||||
input wire m_cpuif_wr_ack,
|
||||
input wire m_cpuif_wr_err
|
||||
);
|
||||
|
||||
timeunit 1ps;
|
||||
timeprecision 1ps;
|
||||
|
||||
default clocking cb @(posedge clk);
|
||||
default input #1step output #1;
|
||||
output m_cpuif_req;
|
||||
output m_cpuif_req_is_wr;
|
||||
output m_cpuif_addr;
|
||||
output m_cpuif_wr_data;
|
||||
input m_cpuif_req_stall_wr;
|
||||
input m_cpuif_req_stall_rd;
|
||||
input m_cpuif_rd_ack;
|
||||
input m_cpuif_rd_err;
|
||||
input m_cpuif_rd_data;
|
||||
input m_cpuif_wr_ack;
|
||||
input m_cpuif_wr_err;
|
||||
endclocking
|
||||
|
||||
task automatic reset();
|
||||
cb.m_cpuif_req <= '0;
|
||||
cb.m_cpuif_req_is_wr <= '0;
|
||||
cb.m_cpuif_addr <= '0;
|
||||
cb.m_cpuif_wr_data <= '0;
|
||||
endtask
|
||||
|
||||
semaphore txn_req_mutex = new(1);
|
||||
semaphore txn_resp_mutex = new(1);
|
||||
|
||||
task automatic write(logic [ADDR_WIDTH-1:0] addr, logic [DATA_WIDTH-1:0] data);
|
||||
fork
|
||||
begin
|
||||
// Initiate transfer
|
||||
txn_req_mutex.get();
|
||||
##0;
|
||||
cb.m_cpuif_req <= '1;
|
||||
cb.m_cpuif_req_is_wr <= '1;
|
||||
cb.m_cpuif_addr <= addr;
|
||||
cb.m_cpuif_wr_data <= data;
|
||||
@(cb);
|
||||
while(cb.m_cpuif_req_stall_wr !== 1'b0) @(cb);
|
||||
reset();
|
||||
txn_req_mutex.put();
|
||||
end
|
||||
|
||||
begin
|
||||
// Wait for response
|
||||
txn_resp_mutex.get();
|
||||
@cb;
|
||||
while(cb.m_cpuif_wr_ack !== 1'b1) @(cb);
|
||||
txn_resp_mutex.put();
|
||||
end
|
||||
join
|
||||
endtask
|
||||
|
||||
task automatic read(logic [ADDR_WIDTH-1:0] addr, output logic [DATA_WIDTH-1:0] data);
|
||||
fork
|
||||
begin
|
||||
// Initiate transfer
|
||||
txn_req_mutex.get();
|
||||
##0;
|
||||
cb.m_cpuif_req <= '1;
|
||||
cb.m_cpuif_req_is_wr <= '0;
|
||||
cb.m_cpuif_addr <= addr;
|
||||
@(cb);
|
||||
while(cb.m_cpuif_req_stall_rd !== 1'b0) @(cb);
|
||||
reset();
|
||||
txn_req_mutex.put();
|
||||
end
|
||||
|
||||
begin
|
||||
// Wait for response
|
||||
txn_resp_mutex.get();
|
||||
@cb;
|
||||
while(cb.m_cpuif_rd_ack !== 1'b1) @(cb);
|
||||
assert(!$isunknown(cb.m_cpuif_rd_data)) else $error("Read from 0x%0x returned X's on m_cpuif_rd_data", addr);
|
||||
data = cb.m_cpuif_rd_data;
|
||||
txn_resp_mutex.put();
|
||||
end
|
||||
join
|
||||
endtask
|
||||
|
||||
task automatic assert_read(logic [ADDR_WIDTH-1:0] addr, logic [DATA_WIDTH-1:0] expected_data, logic [DATA_WIDTH-1:0] mask = '1);
|
||||
logic [DATA_WIDTH-1:0] data;
|
||||
read(addr, data);
|
||||
data &= mask;
|
||||
assert(data == expected_data) else $error("Read from 0x%x returned 0x%x. Expected 0x%x", addr, data, expected_data);
|
||||
endtask
|
||||
|
||||
initial begin
|
||||
reset();
|
||||
end
|
||||
|
||||
initial forever begin
|
||||
@cb;
|
||||
if(!rst) assert(!$isunknown(cb.m_cpuif_rd_ack)) else $error("Saw X on m_cpuif_rd_ack!");
|
||||
if(!rst) assert(!$isunknown(cb.m_cpuif_wr_ack)) else $error("Saw X on m_cpuif_wr_ack!");
|
||||
end
|
||||
|
||||
endinterface
|
||||
30
tests/lib/cpuifs/passthrough/tb_inst.sv
Normal file
30
tests/lib/cpuifs/passthrough/tb_inst.sv
Normal file
@@ -0,0 +1,30 @@
|
||||
{% sv_line_anchor %}
|
||||
wire s_cpuif_req;
|
||||
wire s_cpuif_req_is_wr;
|
||||
wire [{{exporter.cpuif.addr_width-1}}:0] s_cpuif_addr;
|
||||
wire [{{exporter.cpuif.data_width-1}}:0] s_cpuif_wr_data;
|
||||
wire s_cpuif_req_stall_wr;
|
||||
wire s_cpuif_req_stall_rd;
|
||||
wire s_cpuif_rd_ack;
|
||||
wire s_cpuif_rd_err;
|
||||
wire [{{exporter.cpuif.data_width-1}}:0] s_cpuif_rd_data;
|
||||
wire s_cpuif_wr_ack;
|
||||
wire s_cpuif_wr_err;
|
||||
passthrough_driver #(
|
||||
.DATA_WIDTH({{exporter.cpuif.data_width}}),
|
||||
.ADDR_WIDTH({{exporter.cpuif.addr_width}})
|
||||
) cpuif (
|
||||
.clk(clk),
|
||||
.rst(rst),
|
||||
.m_cpuif_req(s_cpuif_req),
|
||||
.m_cpuif_req_is_wr(s_cpuif_req_is_wr),
|
||||
.m_cpuif_addr(s_cpuif_addr),
|
||||
.m_cpuif_wr_data(s_cpuif_wr_data),
|
||||
.m_cpuif_req_stall_wr(s_cpuif_req_stall_wr),
|
||||
.m_cpuif_req_stall_rd(s_cpuif_req_stall_rd),
|
||||
.m_cpuif_rd_ack(s_cpuif_rd_ack),
|
||||
.m_cpuif_rd_err(s_cpuif_rd_err),
|
||||
.m_cpuif_rd_data(s_cpuif_rd_data),
|
||||
.m_cpuif_wr_ack(s_cpuif_wr_ack),
|
||||
.m_cpuif_wr_err(s_cpuif_wr_err)
|
||||
);
|
||||
74
tests/lib/sim_testcase.py
Normal file
74
tests/lib/sim_testcase.py
Normal file
@@ -0,0 +1,74 @@
|
||||
from typing import List
|
||||
import os
|
||||
import jinja2 as jj
|
||||
|
||||
from .sv_line_anchor import SVLineAnchor
|
||||
|
||||
from .simulators.questa import Questa
|
||||
from .simulators import StubSimulator
|
||||
|
||||
from .base_testcase import BaseTestCase
|
||||
|
||||
SIM_CLS = Questa
|
||||
if os.environ.get("STUB_SIMULATOR", False):
|
||||
SIM_CLS = StubSimulator
|
||||
|
||||
|
||||
class SimTestCase(BaseTestCase):
|
||||
#: Abort test if it exceeds this number of clock cycles
|
||||
timeout_clk_cycles = 5000
|
||||
|
||||
simulator_cls = SIM_CLS
|
||||
|
||||
@classmethod
|
||||
def _generate_tb(cls):
|
||||
"""
|
||||
Render the testbench template into actual tb.sv
|
||||
"""
|
||||
template_root_path = os.path.join(os.path.dirname(__file__), "..")
|
||||
loader = jj.FileSystemLoader(
|
||||
template_root_path
|
||||
)
|
||||
jj_env = jj.Environment(
|
||||
loader=loader,
|
||||
undefined=jj.StrictUndefined,
|
||||
extensions=[SVLineAnchor],
|
||||
)
|
||||
|
||||
context = {
|
||||
"cls": cls,
|
||||
"exporter": cls.exporter,
|
||||
}
|
||||
|
||||
# template path needs to be relative to the Jinja loader root
|
||||
template_path = os.path.join(cls.get_testcase_dir(), "tb_template.sv")
|
||||
template_path = os.path.relpath(template_path, template_root_path)
|
||||
template = jj_env.get_template(template_path)
|
||||
|
||||
output_path = os.path.join(cls.get_run_dir(), "tb.sv")
|
||||
stream = template.stream(context)
|
||||
stream.dump(output_path)
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
|
||||
# Create testbench from template
|
||||
cls._generate_tb()
|
||||
|
||||
simulator = cls.simulator_cls(testcase_cls=cls)
|
||||
|
||||
# cd into the build directory
|
||||
cwd = os.getcwd()
|
||||
os.chdir(cls.get_run_dir())
|
||||
try:
|
||||
simulator.compile()
|
||||
finally:
|
||||
# cd back
|
||||
os.chdir(cwd)
|
||||
|
||||
|
||||
def run_test(self, plusargs:List[str] = None) -> None:
|
||||
simulator = self.simulator_cls(testcase_cls_inst=self)
|
||||
simulator.run(plusargs)
|
||||
33
tests/lib/simulators/__init__.py
Normal file
33
tests/lib/simulators/__init__.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from typing import Type, TYPE_CHECKING, List
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..sim_testcase import SimTestCase
|
||||
|
||||
class Simulator:
|
||||
|
||||
def __init__(self, testcase_cls: 'Type[SimTestCase]' = None, testcase_cls_inst: 'SimTestCase' = None) -> None:
|
||||
self.testcase_cls = testcase_cls
|
||||
self.testcase_cls_inst = testcase_cls_inst
|
||||
|
||||
@property
|
||||
def tb_files(self) -> List[str]:
|
||||
files = []
|
||||
files.extend(self.testcase_cls.cpuif.get_sim_files())
|
||||
files.append("regblock_pkg.sv")
|
||||
files.append("regblock.sv")
|
||||
files.append("tb.sv")
|
||||
|
||||
return files
|
||||
|
||||
def compile(self) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
def run(self, plusargs:List[str] = None) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
class StubSimulator(Simulator):
|
||||
def compile(self) -> None:
|
||||
pass
|
||||
|
||||
def run(self, plusargs:List[str] = None) -> None:
|
||||
pass
|
||||
64
tests/lib/simulators/questa.py
Normal file
64
tests/lib/simulators/questa.py
Normal file
@@ -0,0 +1,64 @@
|
||||
from typing import List
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
from . import Simulator
|
||||
|
||||
class Questa(Simulator):
|
||||
def compile(self) -> None:
|
||||
cmd = [
|
||||
"vlog", "-sv", "-quiet", "-l", "build.log",
|
||||
|
||||
"+incdir+%s" % os.path.join(os.path.dirname(__file__), ".."),
|
||||
|
||||
# Use strict LRM conformance
|
||||
"-svinputport=net",
|
||||
|
||||
# all warnings are errors
|
||||
"-warning", "error",
|
||||
|
||||
# Ignore noisy warning about vopt-time checking of always_comb/always_latch
|
||||
"-suppress", "2583",
|
||||
]
|
||||
|
||||
# Add source files
|
||||
cmd.extend(self.tb_files)
|
||||
|
||||
# Run command!
|
||||
subprocess.run(cmd, check=True)
|
||||
|
||||
|
||||
def run(self, plusargs:List[str] = None) -> None:
|
||||
plusargs = plusargs or []
|
||||
|
||||
test_name = self.testcase_cls_inst.request.node.name
|
||||
|
||||
# call vsim
|
||||
cmd = [
|
||||
"vsim", "-quiet",
|
||||
"-voptargs=+acc",
|
||||
"-msgmode", "both",
|
||||
"-do", "set WildcardFilter [lsearch -not -all -inline $WildcardFilter Memory]",
|
||||
"-do", "log -r /*;",
|
||||
"-do", "run -all; exit;",
|
||||
"-c",
|
||||
"-l", "%s.log" % test_name,
|
||||
"-wlf", "%s.wlf" % test_name,
|
||||
"tb",
|
||||
]
|
||||
for plusarg in plusargs:
|
||||
cmd.append("+" + plusarg)
|
||||
subprocess.run(cmd, check=True)
|
||||
|
||||
self.assertSimLogPass("%s.log" % test_name)
|
||||
|
||||
|
||||
def assertSimLogPass(self, path: str):
|
||||
self.testcase_cls_inst.assertTrue(os.path.isfile(path))
|
||||
|
||||
with open(path, encoding="utf-8") as f:
|
||||
for line in f:
|
||||
if line.startswith("# ** Error"):
|
||||
self.testcase_cls_inst.fail(line)
|
||||
elif line.startswith("# ** Fatal"):
|
||||
self.testcase_cls_inst.fail(line)
|
||||
61
tests/lib/simulators/xilinx.py
Normal file
61
tests/lib/simulators/xilinx.py
Normal file
@@ -0,0 +1,61 @@
|
||||
from typing import List
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
from . import Simulator
|
||||
|
||||
class Xilinx(Simulator):
|
||||
"""
|
||||
Don't bother using the Xilinx simulator... Its buggy and extraordinarily slow.
|
||||
As observed in v2021.1, clocking block assignments do not seem to actually simulate
|
||||
correctly - assignment statements get ignored or the values get mangled.
|
||||
|
||||
Keeping this here in case someday it works better...
|
||||
"""
|
||||
def compile(self) -> None:
|
||||
cmd = [
|
||||
"xvlog", "--sv",
|
||||
"--include", os.path.join(os.path.dirname(__file__), ".."),
|
||||
]
|
||||
cmd.extend(self.tb_files)
|
||||
subprocess.run(cmd, check=True)
|
||||
|
||||
cmd = [
|
||||
"xelab",
|
||||
"--timescale", "1ns/1ps",
|
||||
"--debug", "all",
|
||||
"tb",
|
||||
]
|
||||
subprocess.run(cmd, check=True)
|
||||
|
||||
|
||||
def run(self, plusargs:List[str] = None) -> None:
|
||||
plusargs = plusargs or []
|
||||
|
||||
test_name = self.testcase_cls_inst.request.node.name
|
||||
|
||||
# call vsim
|
||||
cmd = [
|
||||
"xsim",
|
||||
"--R",
|
||||
"--log", "%s.log" % test_name,
|
||||
"tb",
|
||||
]
|
||||
|
||||
for plusarg in plusargs:
|
||||
cmd.append("--testplusarg")
|
||||
cmd.append(plusarg)
|
||||
subprocess.run(cmd, check=True)
|
||||
|
||||
self.assertSimLogPass("%s.log" % test_name)
|
||||
|
||||
|
||||
def assertSimLogPass(self, path: str):
|
||||
self.testcase_cls_inst.assertTrue(os.path.isfile(path))
|
||||
|
||||
with open(path, encoding="utf-8") as f:
|
||||
for line in f:
|
||||
if line.startswith("Error:"):
|
||||
self.testcase_cls_inst.fail(line)
|
||||
elif line.startswith("Fatal:"):
|
||||
self.testcase_cls_inst.fail(line)
|
||||
10
tests/lib/sv_line_anchor.py
Normal file
10
tests/lib/sv_line_anchor.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from jinja2_simple_tags import StandaloneTag
|
||||
|
||||
class SVLineAnchor(StandaloneTag):
|
||||
"""
|
||||
Define a custom Jinja tag that emits a SystemVerilog `line directive so that
|
||||
assertion messages can get properly back-annotated
|
||||
"""
|
||||
tags = {"sv_line_anchor"}
|
||||
def render(self):
|
||||
return f'`line {self.lineno + 1} "{self.template}" 0'
|
||||
36
tests/lib/synth_testcase.py
Normal file
36
tests/lib/synth_testcase.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from typing import List
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from .base_testcase import BaseTestCase
|
||||
|
||||
@pytest.mark.skipif(os.environ.get("SKIP_SYNTH_TESTS", False), reason="user skipped")
|
||||
class SynthTestCase(BaseTestCase):
|
||||
|
||||
def _get_synth_files(self) -> List[str]:
|
||||
files = []
|
||||
files.extend(self.cpuif.get_synth_files())
|
||||
files.append("regblock_pkg.sv")
|
||||
files.append("regblock.sv")
|
||||
|
||||
return files
|
||||
|
||||
|
||||
def run_synth(self) -> None:
|
||||
script = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"synthesis/vivado/run.tcl"
|
||||
)
|
||||
|
||||
cmd = [
|
||||
"vivado", "-nojournal", "-notrace",
|
||||
"-mode", "batch",
|
||||
"-log", "out.log",
|
||||
"-source", script,
|
||||
"-tclargs"
|
||||
]
|
||||
cmd.extend(self._get_synth_files())
|
||||
|
||||
subprocess.run(cmd, check=True)
|
||||
8
tests/lib/synthesis/vivado/constr.xdc
Normal file
8
tests/lib/synthesis/vivado/constr.xdc
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
create_clock -period 10.000 -name clk [get_ports clk]
|
||||
|
||||
set_input_delay -clock [get_clocks clk] -min -add_delay 0.000 [get_ports -filter {(DIRECTION == IN) && (NAME != clk)}]
|
||||
set_input_delay -clock [get_clocks clk] -max -add_delay 0.000 [get_ports -filter {(DIRECTION == IN) && (NAME != clk)}]
|
||||
|
||||
set_output_delay -clock [get_clocks clk] -min -add_delay 0.000 [get_ports -filter {DIRECTION == OUT}]
|
||||
set_output_delay -clock [get_clocks clk] -max -add_delay 0.000 [get_ports -filter {DIRECTION == OUT}]
|
||||
34
tests/lib/synthesis/vivado/run.tcl
Normal file
34
tests/lib/synthesis/vivado/run.tcl
Normal file
@@ -0,0 +1,34 @@
|
||||
set this_dir [file dirname [file normalize [info script]]]
|
||||
set files $argv
|
||||
|
||||
|
||||
# Multi-driven
|
||||
set_msg_config -id {[Synth 8-6858]} -new_severity "ERROR"
|
||||
set_msg_config -id {[Synth 8-6859]} -new_severity "ERROR"
|
||||
|
||||
# Implicit net
|
||||
set_msg_config -id {[Synth 8-992]} -new_severity "ERROR"
|
||||
|
||||
# Non-combo always_comb
|
||||
set_msg_config -id {[Synth 8-87]} -new_severity "ERROR"
|
||||
|
||||
# Latch
|
||||
set_msg_config -id {[Synth 8-327]} -new_severity "ERROR"
|
||||
|
||||
# Timing loop
|
||||
set_msg_config -id {[Synth 8-295]} -new_severity "ERROR"
|
||||
|
||||
# Promote all critical warnings to errors
|
||||
set_msg_config -severity {CRITICAL WARNING} -new_severity "ERROR"
|
||||
|
||||
|
||||
set_part xczu7eg-ffvf1517-2-i
|
||||
read_verilog -sv $files
|
||||
read_xdc $this_dir/constr.xdc
|
||||
synth_design -top regblock -mode out_of_context
|
||||
|
||||
#write_checkpoint -force synth.dcp
|
||||
|
||||
if {[get_msg_config -count -severity {CRITICAL WARNING}] || [get_msg_config -count -severity ERROR]} {
|
||||
error "Encountered errors"
|
||||
}
|
||||
99
tests/lib/tb_base.sv
Normal file
99
tests/lib/tb_base.sv
Normal file
@@ -0,0 +1,99 @@
|
||||
{% sv_line_anchor %}
|
||||
module tb;
|
||||
timeunit 1ns;
|
||||
timeprecision 1ps;
|
||||
|
||||
logic rst = '1;
|
||||
logic clk = '0;
|
||||
initial forever begin
|
||||
#5ns;
|
||||
clk = ~clk;
|
||||
end
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// DUT Signal declarations
|
||||
//--------------------------------------------------------------------------
|
||||
{%- if exporter.hwif.has_input_struct %}
|
||||
regblock_pkg::regblock__in_t hwif_in;
|
||||
{%- endif %}
|
||||
|
||||
{%- if exporter.hwif.has_output_struct %}
|
||||
regblock_pkg::regblock__out_t hwif_out;
|
||||
{%- endif %}
|
||||
|
||||
{%- block declarations %}
|
||||
{%- endblock %}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Clocking
|
||||
//--------------------------------------------------------------------------
|
||||
default clocking cb @(posedge clk);
|
||||
default input #1step output #1;
|
||||
output rst;
|
||||
{%- if exporter.hwif.has_input_struct %}
|
||||
output hwif_in;
|
||||
{%- endif %}
|
||||
|
||||
{%- if exporter.hwif.has_output_struct %}
|
||||
input hwif_out;
|
||||
{%- endif %}
|
||||
|
||||
{%- filter indent %}
|
||||
{%- block clocking_dirs %}
|
||||
{%- endblock %}
|
||||
{%- endfilter %}
|
||||
endclocking
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// CPUIF
|
||||
//--------------------------------------------------------------------------
|
||||
{{cls.cpuif.get_tb_inst(cls, exporter)|indent}}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// DUT
|
||||
//--------------------------------------------------------------------------
|
||||
{% sv_line_anchor %}
|
||||
regblock dut (.*);
|
||||
|
||||
{%- if exporter.hwif.has_output_struct %}
|
||||
{% sv_line_anchor %}
|
||||
initial begin
|
||||
logic [$bits(hwif_out)-1:0] tmp;
|
||||
forever begin
|
||||
##1;
|
||||
tmp = {>>{hwif_out}}; // Workaround for Xilinx's xsim - assign to tmp variable
|
||||
if(!rst) assert(!$isunknown(tmp)) else $error("hwif_out has X's!");
|
||||
end
|
||||
end
|
||||
{%- endif %}
|
||||
{% sv_line_anchor %}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test Sequence
|
||||
//--------------------------------------------------------------------------
|
||||
initial begin
|
||||
cb.rst <= '1;
|
||||
{%- if exporter.hwif.has_input_struct %}
|
||||
cb.hwif_in <= '{default: '0};
|
||||
{%- endif %}
|
||||
|
||||
begin
|
||||
{%- filter indent(8) %}
|
||||
{%- block seq %}
|
||||
{%- endblock %}
|
||||
{%- endfilter %}
|
||||
end
|
||||
{% sv_line_anchor %}
|
||||
##5;
|
||||
$finish();
|
||||
end
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Monitor for timeout
|
||||
//--------------------------------------------------------------------------
|
||||
initial begin
|
||||
##{{cls.timeout_clk_cycles}};
|
||||
$fatal(1, "Test timed out after {{cls.timeout_clk_cycles}} clock cycles");
|
||||
end
|
||||
|
||||
endmodule
|
||||
29
tests/lib/test_params.py
Normal file
29
tests/lib/test_params.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from itertools import product
|
||||
|
||||
from .cpuifs.apb3 import APB3, FlatAPB3
|
||||
from .cpuifs.axi4lite import AXI4Lite, FlatAXI4Lite
|
||||
from .cpuifs.passthrough import Passthrough
|
||||
|
||||
|
||||
all_cpuif = [
|
||||
APB3(),
|
||||
FlatAPB3(),
|
||||
AXI4Lite(),
|
||||
FlatAXI4Lite(),
|
||||
Passthrough(),
|
||||
]
|
||||
|
||||
def get_permutations(spec):
|
||||
param_list = []
|
||||
for v in product(*spec.values()):
|
||||
param_list.append(dict(zip(spec, v)))
|
||||
return param_list
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# TODO: this wont scale well. Create groups of permutations. not necessary to permute everything all the time.
|
||||
TEST_PARAMS = get_permutations({
|
||||
"cpuif": all_cpuif,
|
||||
"retime_read_fanin": [True, False],
|
||||
"retime_read_response": [True, False],
|
||||
"reuse_hwif_typedefs": [True, False],
|
||||
})
|
||||
9
tests/mypy.ini
Normal file
9
tests/mypy.ini
Normal file
@@ -0,0 +1,9 @@
|
||||
[mypy]
|
||||
ignore_missing_imports = True
|
||||
strict_optional = False
|
||||
disallow_incomplete_defs = True
|
||||
disallow_untyped_defs = True
|
||||
warn_unused_configs = True
|
||||
warn_unused_ignores = True
|
||||
warn_unreachable = True
|
||||
disallow_untyped_calls = True
|
||||
571
tests/pylint.rc
Normal file
571
tests/pylint.rc
Normal file
@@ -0,0 +1,571 @@
|
||||
[MASTER]
|
||||
|
||||
# A comma-separated list of package or module names from where C extensions may
|
||||
# be loaded. Extensions are loading into the active Python interpreter and may
|
||||
# run arbitrary code.
|
||||
extension-pkg-allow-list=
|
||||
|
||||
# A comma-separated list of package or module names from where C extensions may
|
||||
# be loaded. Extensions are loading into the active Python interpreter and may
|
||||
# run arbitrary code. (This is an alternative name to extension-pkg-allow-list
|
||||
# for backward compatibility.)
|
||||
extension-pkg-whitelist=
|
||||
|
||||
# Return non-zero exit code if any of these messages/categories are detected,
|
||||
# even if score is above --fail-under value. Syntax same as enable. Messages
|
||||
# specified are enabled, while categories only check already-enabled messages.
|
||||
fail-on=
|
||||
|
||||
# Specify a score threshold to be exceeded before program exits with error.
|
||||
fail-under=10.0
|
||||
|
||||
# Files or directories to be skipped. They should be base names, not paths.
|
||||
ignore=CVS, parser, docs, test
|
||||
|
||||
# Add files or directories matching the regex patterns to the ignore-list. The
|
||||
# regex matches against paths.
|
||||
ignore-paths=
|
||||
|
||||
# Files or directories matching the regex patterns are skipped. The regex
|
||||
# matches against base names, not paths.
|
||||
ignore-patterns=
|
||||
|
||||
# Python code to execute, usually for sys.path manipulation such as
|
||||
# pygtk.require().
|
||||
#init-hook=
|
||||
|
||||
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
|
||||
# number of processors available to use.
|
||||
jobs=0
|
||||
|
||||
# Control the amount of potential inferred values when inferring a single
|
||||
# object. This can help the performance when dealing with large functions or
|
||||
# complex, nested conditions.
|
||||
limit-inference-results=100
|
||||
|
||||
# List of plugins (as comma separated values of python module names) to load,
|
||||
# usually to register additional checkers.
|
||||
load-plugins=
|
||||
|
||||
# Pickle collected data for later comparisons.
|
||||
persistent=yes
|
||||
|
||||
# When enabled, pylint would attempt to guess common misconfiguration and emit
|
||||
# user-friendly hints instead of false-positive error messages.
|
||||
suggestion-mode=yes
|
||||
|
||||
# Allow loading of arbitrary C extensions. Extensions are imported into the
|
||||
# active Python interpreter and may run arbitrary code.
|
||||
unsafe-load-any-extension=no
|
||||
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
|
||||
# Only show warnings with the listed confidence levels. Leave empty to show
|
||||
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED.
|
||||
confidence=
|
||||
|
||||
# Disable the message, report, category or checker with the given id(s). You
|
||||
# can either give multiple identifiers separated by comma (,) or put this
|
||||
# option multiple times (only on the command line, not in the configuration
|
||||
# file where it should appear only once). You can also use "--disable=all" to
|
||||
# disable everything first and then reenable specific checks. For example, if
|
||||
# you want to run only the similarities checker, you can use "--disable=all
|
||||
# --enable=similarities". If you want to run only the classes checker, but have
|
||||
# no Warning level messages displayed, use "--disable=all --enable=classes
|
||||
# --disable=W".
|
||||
disable=
|
||||
# Disable for now during development
|
||||
fixme,
|
||||
|
||||
# User ignored limits
|
||||
too-many-lines,
|
||||
too-many-locals,
|
||||
too-many-branches,
|
||||
too-many-return-statements,
|
||||
too-few-public-methods,
|
||||
too-many-public-methods,
|
||||
too-many-statements,
|
||||
too-many-instance-attributes,
|
||||
too-many-function-args,
|
||||
line-too-long,
|
||||
|
||||
# Noise / Don't care
|
||||
no-else-return,
|
||||
no-self-use,
|
||||
unused-variable,
|
||||
invalid-name,
|
||||
missing-docstring,
|
||||
abstract-method,
|
||||
protected-access,
|
||||
duplicate-code,
|
||||
unused-argument
|
||||
|
||||
# Enable the message, report, category or checker with the given id(s). You can
|
||||
# either give multiple identifier separated by comma (,) or put this option
|
||||
# multiple time (only on the command line, not in the configuration file where
|
||||
# it should appear only once). See also the "--disable" option for examples.
|
||||
enable=c-extension-no-member
|
||||
|
||||
|
||||
[REPORTS]
|
||||
|
||||
# Python expression which should return a score less than or equal to 10. You
|
||||
# have access to the variables 'error', 'warning', 'refactor', and 'convention'
|
||||
# which contain the number of messages in each category, as well as 'statement'
|
||||
# which is the total number of statements analyzed. This score is used by the
|
||||
# global evaluation report (RP0004).
|
||||
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
|
||||
|
||||
# Template used to display messages. This is a python new-style format string
|
||||
# used to format the message information. See doc for all details.
|
||||
#msg-template=
|
||||
|
||||
# Set the output format. Available formats are text, parseable, colorized, json
|
||||
# and msvs (visual studio). You can also give a reporter class, e.g.
|
||||
# mypackage.mymodule.MyReporterClass.
|
||||
output-format=text
|
||||
|
||||
# Tells whether to display a full report or only the messages.
|
||||
reports=no
|
||||
|
||||
# Activate the evaluation score.
|
||||
score=no
|
||||
|
||||
|
||||
[REFACTORING]
|
||||
|
||||
# Maximum number of nested blocks for function / method body
|
||||
max-nested-blocks=5
|
||||
|
||||
# Complete name of functions that never returns. When checking for
|
||||
# inconsistent-return-statements if a never returning function is called then
|
||||
# it will be considered as an explicit return statement and no message will be
|
||||
# printed.
|
||||
never-returning-functions=sys.exit,argparse.parse_error
|
||||
|
||||
|
||||
[STRING]
|
||||
|
||||
# This flag controls whether inconsistent-quotes generates a warning when the
|
||||
# character used as a quote delimiter is used inconsistently within a module.
|
||||
check-quote-consistency=no
|
||||
|
||||
# This flag controls whether the implicit-str-concat should generate a warning
|
||||
# on implicit string concatenation in sequences defined over several lines.
|
||||
check-str-concat-over-line-jumps=no
|
||||
|
||||
|
||||
[SPELLING]
|
||||
|
||||
# Limits count of emitted suggestions for spelling mistakes.
|
||||
max-spelling-suggestions=4
|
||||
|
||||
# Spelling dictionary name. Available dictionaries: en_GB (aspell), en_AU
|
||||
# (aspell), en_US (hunspell), en (aspell), en_CA (aspell).
|
||||
spelling-dict=
|
||||
|
||||
# List of comma separated words that should be considered directives if they
|
||||
# appear and the beginning of a comment and should not be checked.
|
||||
spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy:
|
||||
|
||||
# List of comma separated words that should not be checked.
|
||||
spelling-ignore-words=
|
||||
|
||||
# A path to a file that contains the private dictionary; one word per line.
|
||||
spelling-private-dict-file=
|
||||
|
||||
# Tells whether to store unknown words to the private dictionary (see the
|
||||
# --spelling-private-dict-file option) instead of raising a message.
|
||||
spelling-store-unknown-words=no
|
||||
|
||||
|
||||
[LOGGING]
|
||||
|
||||
# The type of string formatting that logging methods do. `old` means using %
|
||||
# formatting, `new` is for `{}` formatting.
|
||||
logging-format-style=old
|
||||
|
||||
# Logging modules to check that the string format arguments are in logging
|
||||
# function parameter format.
|
||||
logging-modules=logging
|
||||
|
||||
|
||||
[VARIABLES]
|
||||
|
||||
# List of additional names supposed to be defined in builtins. Remember that
|
||||
# you should avoid defining new builtins when possible.
|
||||
additional-builtins=
|
||||
|
||||
# Tells whether unused global variables should be treated as a violation.
|
||||
allow-global-unused-variables=yes
|
||||
|
||||
# List of names allowed to shadow builtins
|
||||
allowed-redefined-builtins=
|
||||
|
||||
# List of strings which can identify a callback function by name. A callback
|
||||
# name must start or end with one of those strings.
|
||||
callbacks=cb_,
|
||||
_cb
|
||||
|
||||
# A regular expression matching the name of dummy variables (i.e. expected to
|
||||
# not be used).
|
||||
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
|
||||
|
||||
# Argument names that match this expression will be ignored. Default to name
|
||||
# with leading underscore.
|
||||
ignored-argument-names=_.*|^ignored_|^unused_
|
||||
|
||||
# Tells whether we should check for unused import in __init__ files.
|
||||
init-import=no
|
||||
|
||||
# List of qualified module names which can have objects that can redefine
|
||||
# builtins.
|
||||
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
|
||||
|
||||
|
||||
[SIMILARITIES]
|
||||
|
||||
# Comments are removed from the similarity computation
|
||||
ignore-comments=yes
|
||||
|
||||
# Docstrings are removed from the similarity computation
|
||||
ignore-docstrings=yes
|
||||
|
||||
# Imports are removed from the similarity computation
|
||||
ignore-imports=no
|
||||
|
||||
# Signatures are removed from the similarity computation
|
||||
ignore-signatures=no
|
||||
|
||||
# Minimum lines number of a similarity.
|
||||
min-similarity-lines=10
|
||||
|
||||
|
||||
[TYPECHECK]
|
||||
|
||||
# List of decorators that produce context managers, such as
|
||||
# contextlib.contextmanager. Add to this list to register other decorators that
|
||||
# produce valid context managers.
|
||||
contextmanager-decorators=contextlib.contextmanager
|
||||
|
||||
# List of members which are set dynamically and missed by pylint inference
|
||||
# system, and so shouldn't trigger E1101 when accessed. Python regular
|
||||
# expressions are accepted.
|
||||
generated-members=
|
||||
|
||||
# Tells whether missing members accessed in mixin class should be ignored. A
|
||||
# mixin class is detected if its name ends with "mixin" (case insensitive).
|
||||
ignore-mixin-members=yes
|
||||
|
||||
# Tells whether to warn about missing members when the owner of the attribute
|
||||
# is inferred to be None.
|
||||
ignore-none=yes
|
||||
|
||||
# This flag controls whether pylint should warn about no-member and similar
|
||||
# checks whenever an opaque object is returned when inferring. The inference
|
||||
# can return multiple potential results while evaluating a Python object, but
|
||||
# some branches might not be evaluated, which results in partial inference. In
|
||||
# that case, it might be useful to still emit no-member and other checks for
|
||||
# the rest of the inferred objects.
|
||||
ignore-on-opaque-inference=yes
|
||||
|
||||
# List of class names for which member attributes should not be checked (useful
|
||||
# for classes with dynamically set attributes). This supports the use of
|
||||
# qualified names.
|
||||
ignored-classes=optparse.Values,thread._local,_thread._local
|
||||
|
||||
# List of module names for which member attributes should not be checked
|
||||
# (useful for modules/projects where namespaces are manipulated during runtime
|
||||
# and thus existing member attributes cannot be deduced by static analysis). It
|
||||
# supports qualified module names, as well as Unix pattern matching.
|
||||
ignored-modules=
|
||||
|
||||
# Show a hint with possible names when a member name was not found. The aspect
|
||||
# of finding the hint is based on edit distance.
|
||||
missing-member-hint=yes
|
||||
|
||||
# The minimum edit distance a name should have in order to be considered a
|
||||
# similar match for a missing member name.
|
||||
missing-member-hint-distance=1
|
||||
|
||||
# The total number of similar names that should be taken in consideration when
|
||||
# showing a hint for a missing member.
|
||||
missing-member-max-choices=1
|
||||
|
||||
# List of decorators that change the signature of a decorated function.
|
||||
signature-mutators=
|
||||
|
||||
|
||||
[FORMAT]
|
||||
|
||||
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
|
||||
expected-line-ending-format=
|
||||
|
||||
# Regexp for a line that is allowed to be longer than the limit.
|
||||
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
|
||||
|
||||
# Number of spaces of indent required inside a hanging or continued line.
|
||||
indent-after-paren=4
|
||||
|
||||
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
|
||||
# tab).
|
||||
indent-string=' '
|
||||
|
||||
# Maximum number of characters on a single line.
|
||||
max-line-length=110
|
||||
|
||||
# Maximum number of lines in a module.
|
||||
max-module-lines=2000
|
||||
|
||||
# Allow the body of a class to be on the same line as the declaration if body
|
||||
# contains single statement.
|
||||
single-line-class-stmt=no
|
||||
|
||||
# Allow the body of an if to be on the same line as the test if there is no
|
||||
# else.
|
||||
single-line-if-stmt=no
|
||||
|
||||
|
||||
[MISCELLANEOUS]
|
||||
|
||||
# List of note tags to take in consideration, separated by a comma.
|
||||
notes=FIXME,
|
||||
XXX,
|
||||
TODO
|
||||
|
||||
|
||||
[BASIC]
|
||||
|
||||
# Naming style matching correct argument names.
|
||||
argument-naming-style=snake_case
|
||||
|
||||
# Regular expression matching correct argument names. Overrides argument-
|
||||
# naming-style.
|
||||
#argument-rgx=
|
||||
|
||||
# Naming style matching correct attribute names.
|
||||
attr-naming-style=snake_case
|
||||
|
||||
# Regular expression matching correct attribute names. Overrides attr-naming-
|
||||
# style.
|
||||
#attr-rgx=
|
||||
|
||||
# Bad variable names which should always be refused, separated by a comma.
|
||||
bad-names=foo,
|
||||
bar,
|
||||
baz,
|
||||
toto,
|
||||
tutu,
|
||||
tata
|
||||
|
||||
# Bad variable names regexes, separated by a comma. If names match any regex,
|
||||
# they will always be refused
|
||||
bad-names-rgxs=
|
||||
|
||||
# Naming style matching correct class attribute names.
|
||||
class-attribute-naming-style=any
|
||||
|
||||
# Regular expression matching correct class attribute names. Overrides class-
|
||||
# attribute-naming-style.
|
||||
#class-attribute-rgx=
|
||||
|
||||
# Naming style matching correct class constant names.
|
||||
class-const-naming-style=UPPER_CASE
|
||||
|
||||
# Regular expression matching correct class constant names. Overrides class-
|
||||
# const-naming-style.
|
||||
#class-const-rgx=
|
||||
|
||||
# Naming style matching correct class names.
|
||||
class-naming-style=PascalCase
|
||||
|
||||
# Regular expression matching correct class names. Overrides class-naming-
|
||||
# style.
|
||||
#class-rgx=
|
||||
|
||||
# Naming style matching correct constant names.
|
||||
const-naming-style=UPPER_CASE
|
||||
|
||||
# Regular expression matching correct constant names. Overrides const-naming-
|
||||
# style.
|
||||
#const-rgx=
|
||||
|
||||
# Minimum line length for functions/classes that require docstrings, shorter
|
||||
# ones are exempt.
|
||||
docstring-min-length=-1
|
||||
|
||||
# Naming style matching correct function names.
|
||||
function-naming-style=snake_case
|
||||
|
||||
# Regular expression matching correct function names. Overrides function-
|
||||
# naming-style.
|
||||
#function-rgx=
|
||||
|
||||
# Good variable names which should always be accepted, separated by a comma.
|
||||
good-names=i,
|
||||
j,
|
||||
k,
|
||||
ex,
|
||||
Run,
|
||||
_
|
||||
|
||||
# Good variable names regexes, separated by a comma. If names match any regex,
|
||||
# they will always be accepted
|
||||
good-names-rgxs=
|
||||
|
||||
# Include a hint for the correct naming format with invalid-name.
|
||||
include-naming-hint=no
|
||||
|
||||
# Naming style matching correct inline iteration names.
|
||||
inlinevar-naming-style=any
|
||||
|
||||
# Regular expression matching correct inline iteration names. Overrides
|
||||
# inlinevar-naming-style.
|
||||
#inlinevar-rgx=
|
||||
|
||||
# Naming style matching correct method names.
|
||||
method-naming-style=snake_case
|
||||
|
||||
# Regular expression matching correct method names. Overrides method-naming-
|
||||
# style.
|
||||
#method-rgx=
|
||||
|
||||
# Naming style matching correct module names.
|
||||
module-naming-style=snake_case
|
||||
|
||||
# Regular expression matching correct module names. Overrides module-naming-
|
||||
# style.
|
||||
#module-rgx=
|
||||
|
||||
# Colon-delimited sets of names that determine each other's naming style when
|
||||
# the name regexes allow several styles.
|
||||
name-group=
|
||||
|
||||
# Regular expression which should only match function or class names that do
|
||||
# not require a docstring.
|
||||
no-docstring-rgx=^_
|
||||
|
||||
# List of decorators that produce properties, such as abc.abstractproperty. Add
|
||||
# to this list to register other decorators that produce valid properties.
|
||||
# These decorators are taken in consideration only for invalid-name.
|
||||
property-classes=abc.abstractproperty
|
||||
|
||||
# Naming style matching correct variable names.
|
||||
variable-naming-style=snake_case
|
||||
|
||||
# Regular expression matching correct variable names. Overrides variable-
|
||||
# naming-style.
|
||||
#variable-rgx=
|
||||
|
||||
|
||||
[CLASSES]
|
||||
|
||||
# Warn about protected attribute access inside special methods
|
||||
check-protected-access-in-special-methods=no
|
||||
|
||||
# List of method names used to declare (i.e. assign) instance attributes.
|
||||
defining-attr-methods=__init__,
|
||||
__new__,
|
||||
setUp,
|
||||
__post_init__
|
||||
|
||||
# List of member names, which should be excluded from the protected access
|
||||
# warning.
|
||||
exclude-protected=_asdict,
|
||||
_fields,
|
||||
_replace,
|
||||
_source,
|
||||
_make
|
||||
|
||||
# List of valid names for the first argument in a class method.
|
||||
valid-classmethod-first-arg=cls
|
||||
|
||||
# List of valid names for the first argument in a metaclass class method.
|
||||
valid-metaclass-classmethod-first-arg=cls
|
||||
|
||||
|
||||
[DESIGN]
|
||||
|
||||
# List of qualified class names to ignore when countint class parents (see
|
||||
# R0901)
|
||||
ignored-parents=
|
||||
|
||||
# Maximum number of arguments for function / method.
|
||||
max-args=8
|
||||
|
||||
# Maximum number of attributes for a class (see R0902).
|
||||
max-attributes=7
|
||||
|
||||
# Maximum number of boolean expressions in an if statement (see R0916).
|
||||
max-bool-expr=5
|
||||
|
||||
# Maximum number of branch for function / method body.
|
||||
max-branches=12
|
||||
|
||||
# Maximum number of locals for function / method body.
|
||||
max-locals=15
|
||||
|
||||
# Maximum number of parents for a class (see R0901).
|
||||
max-parents=7
|
||||
|
||||
# Maximum number of public methods for a class (see R0904).
|
||||
max-public-methods=20
|
||||
|
||||
# Maximum number of return / yield for function / method body.
|
||||
max-returns=6
|
||||
|
||||
# Maximum number of statements in function / method body.
|
||||
max-statements=50
|
||||
|
||||
# Minimum number of public methods for a class (see R0903).
|
||||
min-public-methods=2
|
||||
|
||||
|
||||
[IMPORTS]
|
||||
|
||||
# List of modules that can be imported at any level, not just the top level
|
||||
# one.
|
||||
allow-any-import-level=
|
||||
|
||||
# Allow wildcard imports from modules that define __all__.
|
||||
allow-wildcard-with-all=no
|
||||
|
||||
# Analyse import fallback blocks. This can be used to support both Python 2 and
|
||||
# 3 compatible code, which means that the block might have code that exists
|
||||
# only in one or another interpreter, leading to false positives when analysed.
|
||||
analyse-fallback-blocks=no
|
||||
|
||||
# Deprecated modules which should not be used, separated by a comma.
|
||||
deprecated-modules=
|
||||
|
||||
# Output a graph (.gv or any supported image format) of external dependencies
|
||||
# to the given file (report RP0402 must not be disabled).
|
||||
ext-import-graph=
|
||||
|
||||
# Output a graph (.gv or any supported image format) of all (i.e. internal and
|
||||
# external) dependencies to the given file (report RP0402 must not be
|
||||
# disabled).
|
||||
import-graph=
|
||||
|
||||
# Output a graph (.gv or any supported image format) of internal dependencies
|
||||
# to the given file (report RP0402 must not be disabled).
|
||||
int-import-graph=
|
||||
|
||||
# Force import order to recognize a module as part of the standard
|
||||
# compatibility libraries.
|
||||
known-standard-library=
|
||||
|
||||
# Force import order to recognize a module as part of a third party library.
|
||||
known-third-party=enchant
|
||||
|
||||
# Couples of modules and preferred modules, separated by a comma.
|
||||
preferred-modules=
|
||||
|
||||
|
||||
[EXCEPTIONS]
|
||||
|
||||
# Exceptions that will emit a warning when being caught. Defaults to
|
||||
# "BaseException, Exception".
|
||||
overgeneral-exceptions=BaseException,
|
||||
Exception
|
||||
2
tests/pytest.ini
Normal file
2
tests/pytest.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[pytest]
|
||||
python_files = test_*.py testcase.py
|
||||
6
tests/requirements.txt
Normal file
6
tests/requirements.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
pytest
|
||||
parameterized
|
||||
pytest-parallel
|
||||
jinja2-simple-tags
|
||||
pylint
|
||||
mypy
|
||||
29
tests/run.sh
Executable file
29
tests/run.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
this_dir="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
|
||||
# Initialize venv
|
||||
venv_bin=$this_dir/.venv/bin
|
||||
python3 -m venv $this_dir/.venv
|
||||
source $this_dir/.venv/bin/activate
|
||||
|
||||
# Install test dependencies
|
||||
pip install -U pip setuptools wheel
|
||||
pip install -r $this_dir/requirements.txt
|
||||
|
||||
# Install dut
|
||||
cd $this_dir/../
|
||||
pip install .
|
||||
cd $this_dir
|
||||
|
||||
# Run unit tests
|
||||
export SKIP_SYNTH_TESTS=1
|
||||
pytest --workers auto
|
||||
|
||||
# Run lint
|
||||
pylint --rcfile $this_dir/pylint.rc ../src/peakrdl
|
||||
|
||||
# Run static type checking
|
||||
mypy $this_dir/../src/peakrdl
|
||||
0
tests/test_bitwise_reduce/__init__.py
Normal file
0
tests/test_bitwise_reduce/__init__.py
Normal file
8
tests/test_bitwise_reduce/regblock.rdl
Normal file
8
tests/test_bitwise_reduce/regblock.rdl
Normal file
@@ -0,0 +1,8 @@
|
||||
addrmap top {
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=r;
|
||||
anded; ored; xored;
|
||||
} f[7:0] = 0;
|
||||
} r1;
|
||||
};
|
||||
44
tests/test_bitwise_reduce/tb_template.sv
Normal file
44
tests/test_bitwise_reduce/tb_template.sv
Normal file
@@ -0,0 +1,44 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
cpuif.write('h0, 'h00);
|
||||
@cb;
|
||||
assert(cb.hwif_out.r1.f.anded == 1'b0);
|
||||
assert(cb.hwif_out.r1.f.ored == 1'b0);
|
||||
assert(cb.hwif_out.r1.f.xored == 1'b0);
|
||||
|
||||
cpuif.write('h0, 'h01);
|
||||
@cb;
|
||||
assert(cb.hwif_out.r1.f.anded == 1'b0);
|
||||
assert(cb.hwif_out.r1.f.ored == 1'b1);
|
||||
assert(cb.hwif_out.r1.f.xored == 1'b1);
|
||||
|
||||
cpuif.write('h0, 'h02);
|
||||
@cb;
|
||||
assert(cb.hwif_out.r1.f.anded == 1'b0);
|
||||
assert(cb.hwif_out.r1.f.ored == 1'b1);
|
||||
assert(cb.hwif_out.r1.f.xored == 1'b1);
|
||||
|
||||
cpuif.write('h0, 'h03);
|
||||
@cb;
|
||||
assert(cb.hwif_out.r1.f.anded == 1'b0);
|
||||
assert(cb.hwif_out.r1.f.ored == 1'b1);
|
||||
assert(cb.hwif_out.r1.f.xored == 1'b0);
|
||||
|
||||
cpuif.write('h0, 'hFE);
|
||||
@cb;
|
||||
assert(cb.hwif_out.r1.f.anded == 1'b0);
|
||||
assert(cb.hwif_out.r1.f.ored == 1'b1);
|
||||
assert(cb.hwif_out.r1.f.xored == 1'b1);
|
||||
|
||||
cpuif.write('h0, 'hFF);
|
||||
@cb;
|
||||
assert(cb.hwif_out.r1.f.anded == 1'b1);
|
||||
assert(cb.hwif_out.r1.f.ored == 1'b1);
|
||||
assert(cb.hwif_out.r1.f.xored == 1'b0);
|
||||
{% endblock %}
|
||||
5
tests/test_bitwise_reduce/testcase.py
Normal file
5
tests/test_bitwise_reduce/testcase.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
|
||||
class Test(SimTestCase):
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
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 = do_count_up;
|
||||
updown4->decr = do_count_down;
|
||||
} 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()
|
||||
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->incrvalue = step;
|
||||
count->decrvalue = step;
|
||||
} 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 = step;
|
||||
} 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, 'h05, 'hFF);
|
||||
|
||||
// incrsaturate via +1
|
||||
cpuif.write('h4, `set);
|
||||
cpuif.assert_read('h4, 'hFA, 'hFF);
|
||||
cpuif.write('h4, `decr + `step(1));
|
||||
cpuif.assert_read('h4, 'hF9, '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, 'h05, 'hFF);
|
||||
cpuif.write('h4, `incr + `step(1));
|
||||
cpuif.assert_read('h4, 'h06, '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, 'hFA, 'hFF);
|
||||
cpuif.write('h4, `decr + `step(1));
|
||||
cpuif.assert_read('h4, 'hF9, '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, 'h05, 'hFF);
|
||||
cpuif.write('h4, `incr + `step(1));
|
||||
cpuif.assert_read('h4, 'h06, '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, 'hFA, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(1));
|
||||
cpuif.assert_read('h8, 'hF9, '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, 'h05, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(1));
|
||||
cpuif.assert_read('h8, 'h06, '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, 'hFA, 'hFF);
|
||||
cpuif.write('h8, `decr + `step(1));
|
||||
cpuif.assert_read('h8, 'hF9, '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, 'h05, 'hFF);
|
||||
cpuif.write('h8, `incr + `step(1));
|
||||
cpuif.assert_read('h8, 'h06, '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()
|
||||
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()
|
||||
0
tests/test_field_types/__init__.py
Normal file
0
tests/test_field_types/__init__.py
Normal file
64
tests/test_field_types/regblock.rdl
Normal file
64
tests/test_field_types/regblock.rdl
Normal file
@@ -0,0 +1,64 @@
|
||||
addrmap top {
|
||||
default regwidth = 8;
|
||||
|
||||
// All the valid combinations from Table 12
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=rw; we; // Storage element
|
||||
} f[8] = 10;
|
||||
} r1;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=r; // Storage element
|
||||
} f[8] = 20;
|
||||
} r2;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=w; wel; // Storage element
|
||||
} f[8] = 30;
|
||||
} r3;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na; // Storage element
|
||||
} f[8] = 40;
|
||||
} r4;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=rw; we; // Storage element
|
||||
} f[8] = 50;
|
||||
} r5;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=r; // Wire/Bus - constant value
|
||||
} f[8] = 60;
|
||||
} r6;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=w; // Wire/Bus - hardware assigns value
|
||||
} f[8];
|
||||
} r7;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=na; // Wire/Bus - constant value
|
||||
} f[8] = 80;
|
||||
} r8;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=w; hw=rw; we; // Storage element
|
||||
} f[8] = 90;
|
||||
} r9;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=w; hw=r; // Storage element
|
||||
} f[8] = 100;
|
||||
} r10;
|
||||
};
|
||||
131
tests/test_field_types/tb_template.sv
Normal file
131
tests/test_field_types/tb_template.sv
Normal file
@@ -0,0 +1,131 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
cb.hwif_in.r3.f.wel <= 1;
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
// r1 - sw=rw; hw=rw; we; // Storage element
|
||||
cpuif.assert_read('h0, 10);
|
||||
assert(cb.hwif_out.r1.f.value == 10);
|
||||
|
||||
cpuif.write('h0, 11);
|
||||
cpuif.assert_read('h0, 11);
|
||||
assert(cb.hwif_out.r1.f.value == 11);
|
||||
|
||||
cb.hwif_in.r1.f.next <= 9;
|
||||
cpuif.assert_read('h0, 11);
|
||||
assert(cb.hwif_out.r1.f.value == 11);
|
||||
cb.hwif_in.r1.f.next <= 12;
|
||||
cb.hwif_in.r1.f.we <= 1;
|
||||
@cb;
|
||||
cb.hwif_in.r1.f.next <= 0;
|
||||
cb.hwif_in.r1.f.we <= 0;
|
||||
cpuif.assert_read('h0, 12);
|
||||
assert(cb.hwif_out.r1.f.value == 12);
|
||||
|
||||
|
||||
// r2 - sw=rw; hw=r; // Storage element
|
||||
cpuif.assert_read('h1, 20);
|
||||
assert(cb.hwif_out.r2.f.value == 20);
|
||||
|
||||
cpuif.write('h1, 21);
|
||||
cpuif.assert_read('h1, 21);
|
||||
assert(cb.hwif_out.r2.f.value == 21);
|
||||
|
||||
|
||||
// r3 - sw=rw; hw=w; wel; // Storage element
|
||||
cpuif.assert_read('h2, 30);
|
||||
|
||||
cpuif.write('h2, 31);
|
||||
cpuif.assert_read('h2, 31);
|
||||
|
||||
cb.hwif_in.r3.f.next <= 29;
|
||||
cpuif.assert_read('h2, 31);
|
||||
cb.hwif_in.r3.f.next <= 32;
|
||||
cb.hwif_in.r3.f.wel <= 0;
|
||||
@cb;
|
||||
cb.hwif_in.r3.f.next <= 0;
|
||||
cb.hwif_in.r3.f.wel <= 1;
|
||||
cpuif.assert_read('h2, 32);
|
||||
|
||||
|
||||
// r4 - sw=rw; hw=na; // Storage element
|
||||
cpuif.assert_read('h3, 40);
|
||||
cpuif.write('h3, 41);
|
||||
cpuif.assert_read('h3, 41);
|
||||
|
||||
|
||||
// r5 - sw=r; hw=rw; we; // Storage element
|
||||
cpuif.assert_read('h4, 50);
|
||||
assert(cb.hwif_out.r5.f.value == 50);
|
||||
|
||||
cpuif.write('h4, 51);
|
||||
cpuif.assert_read('h4, 50);
|
||||
assert(cb.hwif_out.r5.f.value == 50);
|
||||
|
||||
cb.hwif_in.r5.f.next <= 9;
|
||||
cpuif.assert_read('h4, 50);
|
||||
assert(cb.hwif_out.r5.f.value == 50);
|
||||
cb.hwif_in.r5.f.next <= 52;
|
||||
cb.hwif_in.r5.f.we <= 1;
|
||||
@cb;
|
||||
cb.hwif_in.r5.f.next <= 0;
|
||||
cb.hwif_in.r5.f.we <= 0;
|
||||
cpuif.assert_read('h4, 52);
|
||||
assert(cb.hwif_out.r5.f.value == 52);
|
||||
|
||||
|
||||
// r6 - sw=r; hw=r; // Wire/Bus - constant value
|
||||
cpuif.assert_read('h5, 60);
|
||||
assert(cb.hwif_out.r6.f.value == 60);
|
||||
cpuif.write('h5, 61);
|
||||
cpuif.assert_read('h5, 60);
|
||||
assert(cb.hwif_out.r6.f.value == 60);
|
||||
|
||||
|
||||
// r7 - sw=r; hw=w; // Wire/Bus - hardware assigns value
|
||||
cpuif.assert_read('h6, 0);
|
||||
cb.hwif_in.r7.f.next <= 70;
|
||||
cpuif.assert_read('h6, 70);
|
||||
cpuif.write('h6, 71);
|
||||
cpuif.assert_read('h6, 70);
|
||||
|
||||
|
||||
// r8 - sw=r; hw=na; // Wire/Bus - constant value
|
||||
cpuif.assert_read('h7, 80);
|
||||
cpuif.write('h7, 81);
|
||||
cpuif.assert_read('h7, 80);
|
||||
|
||||
|
||||
// r9 - sw=w; hw=rw; we; // Storage element
|
||||
cpuif.assert_read('h8, 0);
|
||||
assert(cb.hwif_out.r9.f.value == 90);
|
||||
|
||||
cpuif.write('h8, 91);
|
||||
cpuif.assert_read('h8, 0);
|
||||
assert(cb.hwif_out.r9.f.value == 91);
|
||||
|
||||
cb.hwif_in.r9.f.next <= 89;
|
||||
cpuif.assert_read('h8, 0);
|
||||
assert(cb.hwif_out.r9.f.value == 91);
|
||||
cb.hwif_in.r9.f.next <= 92;
|
||||
cb.hwif_in.r9.f.we <= 1;
|
||||
@cb;
|
||||
cb.hwif_in.r9.f.next <= 0;
|
||||
cb.hwif_in.r9.f.we <= 0;
|
||||
cpuif.assert_read('h8, 0);
|
||||
assert(cb.hwif_out.r9.f.value == 92);
|
||||
|
||||
|
||||
// r10 - sw=w; hw=r; // Storage element
|
||||
cpuif.assert_read('h9, 0);
|
||||
assert(cb.hwif_out.r10.f.value == 100);
|
||||
|
||||
cpuif.write('h9, 101);
|
||||
cpuif.assert_read('h9, 0);
|
||||
assert(cb.hwif_out.r10.f.value == 101);
|
||||
|
||||
{% endblock %}
|
||||
5
tests/test_field_types/testcase.py
Normal file
5
tests/test_field_types/testcase.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
|
||||
class Test(SimTestCase):
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
0
tests/test_hw_access/__init__.py
Normal file
0
tests/test_hw_access/__init__.py
Normal file
73
tests/test_hw_access/regblock.rdl
Normal file
73
tests/test_hw_access/regblock.rdl
Normal file
@@ -0,0 +1,73 @@
|
||||
addrmap top {
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} hw_enable[7:0] = 0xFF;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} hw_mask[15:8] = 0x00;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} hw_clr[16:16] = 0;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} hw_set[17:17] = 0;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} hw_we[18:18] = 0;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} hw_wel[20:20] = 1;
|
||||
} hw_ctrl;
|
||||
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=w;
|
||||
we; hwclr; hwset;
|
||||
} f[7:0] = 0x11;
|
||||
} r1;
|
||||
r1.f->hwenable = hw_ctrl.hw_enable;
|
||||
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=w;
|
||||
we; hwclr; hwset;
|
||||
} f[7:0] = 0x22;
|
||||
} r2;
|
||||
r2.f->hwmask = hw_ctrl.hw_mask;
|
||||
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=w;
|
||||
} f[7:0] = 0x33;
|
||||
} r3;
|
||||
r3.f->hwenable = hw_ctrl.hw_enable;
|
||||
r3.f->hwclr = hw_ctrl.hw_clr;
|
||||
r3.f->hwset = hw_ctrl.hw_set;
|
||||
r3.f->we = hw_ctrl.hw_we;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=w;
|
||||
} f[7:0] = 0x44;
|
||||
} r4;
|
||||
r4.f->wel = hw_ctrl.hw_wel;
|
||||
|
||||
reg {
|
||||
signal {} f_next_value[8];
|
||||
signal {} f_we;
|
||||
field {
|
||||
sw=rw; hw=w;
|
||||
next = f_next_value;
|
||||
we = f_we;
|
||||
} f[7:0] = 0x55;
|
||||
} r5;
|
||||
};
|
||||
105
tests/test_hw_access/tb_template.sv
Normal file
105
tests/test_hw_access/tb_template.sv
Normal file
@@ -0,0 +1,105 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
// check initial conditions
|
||||
cpuif.assert_read('h4, 'h11);
|
||||
cpuif.assert_read('h8, 'h22);
|
||||
cpuif.assert_read('hC, 'h33);
|
||||
|
||||
//---------------------------------
|
||||
// set hwenable = F0
|
||||
cpuif.write('h0, 'h00_F0);
|
||||
|
||||
// test hwenable + we
|
||||
cb.hwif_in.r1.f.next <= 'hAB;
|
||||
cb.hwif_in.r1.f.we <= '1;
|
||||
@cb;
|
||||
cb.hwif_in.r1.f.we <= '0;
|
||||
cpuif.assert_read('h4, 'hA1);
|
||||
|
||||
// test hwenable + hwclr
|
||||
cb.hwif_in.r1.f.hwclr <= '1;
|
||||
@cb;
|
||||
cb.hwif_in.r1.f.hwclr <= '0;
|
||||
cpuif.assert_read('h4, 'h01);
|
||||
|
||||
// test hwenable + hwset
|
||||
cb.hwif_in.r1.f.hwset <= '1;
|
||||
@cb;
|
||||
cb.hwif_in.r1.f.hwset <= '0;
|
||||
cpuif.assert_read('h4, 'hF1);
|
||||
|
||||
|
||||
//---------------------------------
|
||||
// set hwmask = F0
|
||||
cpuif.write('h0, 'hF0_00);
|
||||
|
||||
// test hwmask + we
|
||||
cb.hwif_in.r2.f.next <= 'hAB;
|
||||
cb.hwif_in.r2.f.we <= '1;
|
||||
@cb;
|
||||
cb.hwif_in.r2.f.we <= '0;
|
||||
cpuif.assert_read('h8, 'h2B);
|
||||
|
||||
// test hwmask + hwclr
|
||||
cb.hwif_in.r2.f.hwclr <= '1;
|
||||
@cb;
|
||||
cb.hwif_in.r2.f.hwclr <= '0;
|
||||
cpuif.assert_read('h8, 'h20);
|
||||
|
||||
// test hwmask + hwset
|
||||
cb.hwif_in.r2.f.hwset <= '1;
|
||||
@cb;
|
||||
cb.hwif_in.r2.f.hwset <= '0;
|
||||
cpuif.assert_read('h8, 'h2F);
|
||||
|
||||
//---------------------------------
|
||||
// test hwenable + hwclr via reference
|
||||
// toggle hwenable = F0, hwclr=1
|
||||
cpuif.write('h0, 'h1_00_F0);
|
||||
cpuif.write('h0, 'h0_00_00);
|
||||
cpuif.assert_read('hC, 'h03);
|
||||
|
||||
// test hwenable + hwset via reference
|
||||
// toggle hwenable = 0F, hwset=1
|
||||
cpuif.write('h0, 'h2_00_0F);
|
||||
cpuif.write('h0, 'h0_00_00);
|
||||
cpuif.assert_read('hC, 'h0F);
|
||||
|
||||
// test hwenable + we via reference
|
||||
cb.hwif_in.r3.f.next <= 'hAA;
|
||||
// toggle hwenable = 0F, we=1
|
||||
cpuif.write('h0, 'h4_00_0F);
|
||||
cpuif.write('h0, 'h0_00_00);
|
||||
cpuif.assert_read('hC, 'h0A);
|
||||
|
||||
//---------------------------------
|
||||
// test wel via reference
|
||||
cb.hwif_in.r4.f.next <= 'hBB;
|
||||
// toggle wel
|
||||
cpuif.write('h0, 'h10_00_00);
|
||||
cpuif.write('h0, 'h00_00_00);
|
||||
cpuif.assert_read('h10, 'hBB);
|
||||
|
||||
cb.hwif_in.r4.f.next <= 'hCC;
|
||||
// toggle wel
|
||||
cpuif.write('h0, 'h10_00_00);
|
||||
cpuif.write('h0, 'h00_00_00);
|
||||
cpuif.assert_read('h10, 'hCC);
|
||||
|
||||
//---------------------------------
|
||||
// test we and next via reference
|
||||
cb.hwif_in.r5.f_next_value <= 'h54;
|
||||
cpuif.assert_read('h14, 'h55);
|
||||
cb.hwif_in.r5.f_next_value <= 'h56;
|
||||
cb.hwif_in.r5.f_we <= '1;
|
||||
@cb;
|
||||
cb.hwif_in.r5.f_next_value <= '0;
|
||||
cb.hwif_in.r5.f_we <= '0;
|
||||
cpuif.assert_read('h14, 'h56);
|
||||
{% endblock %}
|
||||
5
tests/test_hw_access/testcase.py
Normal file
5
tests/test_hw_access/testcase.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
|
||||
class Test(SimTestCase):
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
0
tests/test_interrupts/__init__.py
Normal file
0
tests/test_interrupts/__init__.py
Normal file
106
tests/test_interrupts/regblock.rdl
Normal file
106
tests/test_interrupts/regblock.rdl
Normal file
@@ -0,0 +1,106 @@
|
||||
addrmap top {
|
||||
//---------------------------------
|
||||
reg {
|
||||
field ctrl_t {
|
||||
sw=rw; hw=na;
|
||||
};
|
||||
ctrl_t irq0[8] = 0;
|
||||
ctrl_t irq1[1] = 0;
|
||||
}
|
||||
ctrl_enable @ 0x100,
|
||||
ctrl_mask @ 0x104,
|
||||
ctrl_haltenable @ 0x108,
|
||||
ctrl_haltmask @ 0x10c;
|
||||
//---------------------------------
|
||||
|
||||
reg {
|
||||
field intr_t {
|
||||
sw=rw; hw=w;
|
||||
level intr;
|
||||
woclr;
|
||||
};
|
||||
|
||||
intr_t irq0[8] = 0;
|
||||
intr_t irq1[1] = 0;
|
||||
}
|
||||
level_irqs_1 @ 0x0,
|
||||
level_irqs_2 @ 0x4,
|
||||
level_irqs_3 @ 0x8;
|
||||
|
||||
level_irqs_2.irq0->enable = ctrl_enable.irq0;
|
||||
level_irqs_2.irq1->enable = ctrl_enable.irq1;
|
||||
level_irqs_2.irq0->haltenable = ctrl_haltenable.irq0;
|
||||
level_irqs_2.irq1->haltenable = ctrl_haltenable.irq1;
|
||||
level_irqs_3.irq0->mask = ctrl_mask.irq0;
|
||||
level_irqs_3.irq1->mask = ctrl_mask.irq1;
|
||||
level_irqs_3.irq0->haltmask = ctrl_haltmask.irq0;
|
||||
level_irqs_3.irq1->haltmask = ctrl_haltmask.irq1;
|
||||
//---------------------------------
|
||||
|
||||
reg {
|
||||
field intr_t {
|
||||
sw=rw; hw=w;
|
||||
posedge intr;
|
||||
woclr;
|
||||
};
|
||||
|
||||
intr_t irq0[8] = 0;
|
||||
intr_t irq1[1] = 0;
|
||||
} posedge_irqs @ 0x10;
|
||||
|
||||
//---------------------------------
|
||||
|
||||
reg {
|
||||
field intr_t {
|
||||
sw=rw; hw=w;
|
||||
negedge intr;
|
||||
woclr;
|
||||
};
|
||||
|
||||
intr_t irq0[8] = 0;
|
||||
intr_t irq1[1] = 0;
|
||||
} negedge_irqs @ 0x20;
|
||||
|
||||
//---------------------------------
|
||||
|
||||
reg {
|
||||
field intr_t {
|
||||
sw=rw; hw=w;
|
||||
bothedge intr;
|
||||
woclr;
|
||||
};
|
||||
|
||||
intr_t irq0[8] = 0;
|
||||
intr_t irq1[1] = 0;
|
||||
} bothedge_irqs @ 0x30;
|
||||
|
||||
//---------------------------------
|
||||
|
||||
reg {
|
||||
field intr_t {
|
||||
sw=r; hw=w;
|
||||
nonsticky intr;
|
||||
};
|
||||
|
||||
intr_t level_active[1];
|
||||
intr_t posedge_active[1];
|
||||
intr_t negedge_active[1];
|
||||
intr_t bothedge_active[1];
|
||||
intr_t level_halt_active[1];
|
||||
} top_irq @ 0x40;
|
||||
|
||||
top_irq.level_active->next = level_irqs_1->intr;
|
||||
top_irq.posedge_active->next = posedge_irqs->intr;
|
||||
top_irq.negedge_active->next = negedge_irqs->intr;
|
||||
top_irq.bothedge_active->next = bothedge_irqs->intr;
|
||||
top_irq.level_halt_active->next = level_irqs_2->halt;
|
||||
|
||||
//---------------------------------
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=w;
|
||||
sticky;
|
||||
} stickyfield[8] = 0;
|
||||
} stickyreg @ 0x50;
|
||||
|
||||
};
|
||||
237
tests/test_interrupts/tb_template.sv
Normal file
237
tests/test_interrupts/tb_template.sv
Normal file
@@ -0,0 +1,237 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
// Enable all interrupts
|
||||
cpuif.write('h100, 'h1FF); // ctrl_enable
|
||||
cpuif.write('h104, 'h000); // ctrl_mask
|
||||
cpuif.write('h108, 'h1FF); // ctrl_haltenable
|
||||
cpuif.write('h10C, 'h000); // ctrl_haltmask
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test level_irqs_1
|
||||
cpuif.assert_read('h0, 'h000);
|
||||
assert(cb.hwif_out.level_irqs_1.intr == 1'b0);
|
||||
cb.hwif_in.level_irqs_1.irq0.next <= 'h0F;
|
||||
@cb;
|
||||
cb.hwif_in.level_irqs_1.irq0.next <= 'h00;
|
||||
cpuif.assert_read('h0, 'h00F);
|
||||
assert(cb.hwif_out.level_irqs_1.intr == 1'b1);
|
||||
cpuif.write('h0, 'h3);
|
||||
cpuif.assert_read('h0, 'h00C);
|
||||
assert(cb.hwif_out.level_irqs_1.intr == 1'b1);
|
||||
cpuif.write('h0, 'hC);
|
||||
cpuif.assert_read('h0, 'h000);
|
||||
assert(cb.hwif_out.level_irqs_1.intr == 1'b0);
|
||||
|
||||
cb.hwif_in.level_irqs_1.irq1.next <= 'b1;
|
||||
@cb;
|
||||
cb.hwif_in.level_irqs_1.irq1.next <= 'b0;
|
||||
cpuif.assert_read('h0, 'h100);
|
||||
assert(cb.hwif_out.level_irqs_1.intr == 1'b1);
|
||||
cpuif.write('h0, 'h100);
|
||||
@cb;
|
||||
assert(cb.hwif_out.level_irqs_1.intr == 1'b0);
|
||||
cpuif.assert_read('h0, 'h0);
|
||||
|
||||
cb.hwif_in.level_irqs_1.irq1.next <= 'b1;
|
||||
cpuif.assert_read('h0, 'h100);
|
||||
assert(cb.hwif_out.level_irqs_1.intr == 1'b1);
|
||||
cpuif.write('h0, 'h100);
|
||||
cpuif.assert_read('h0, 'h100);
|
||||
assert(cb.hwif_out.level_irqs_1.intr == 1'b1);
|
||||
cb.hwif_in.level_irqs_1.irq1.next <= 'b0;
|
||||
cpuif.assert_read('h0, 'h100);
|
||||
assert(cb.hwif_out.level_irqs_1.intr == 1'b1);
|
||||
cpuif.write('h0, 'h100);
|
||||
cpuif.assert_read('h0, 'h000);
|
||||
assert(cb.hwif_out.level_irqs_1.intr == 1'b0);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test level_irqs_2
|
||||
cpuif.assert_read('h4, 'h000);
|
||||
assert(cb.hwif_out.level_irqs_2.intr == 1'b0);
|
||||
assert(cb.hwif_out.level_irqs_2.halt == 1'b0);
|
||||
cb.hwif_in.level_irqs_2.irq0.next <= 'h0F;
|
||||
@cb;
|
||||
cb.hwif_in.level_irqs_2.irq0.next <= 'h00;
|
||||
cpuif.assert_read('h4, 'h00F);
|
||||
assert(cb.hwif_out.level_irqs_2.intr == 1'b1);
|
||||
assert(cb.hwif_out.level_irqs_2.halt == 1'b1);
|
||||
cpuif.write('h100, 'h0); // ctrl_enable
|
||||
@cb;
|
||||
assert(cb.hwif_out.level_irqs_2.intr == 1'b0);
|
||||
assert(cb.hwif_out.level_irqs_2.halt == 1'b1);
|
||||
cpuif.write('h108, 'h0); // ctrl_haltenable
|
||||
@cb;
|
||||
assert(cb.hwif_out.level_irqs_2.intr == 1'b0);
|
||||
assert(cb.hwif_out.level_irqs_2.halt == 1'b0);
|
||||
cpuif.write('h100, 'h1FF); // ctrl_enable
|
||||
cpuif.write('h108, 'h1FF); // ctrl_haltenable
|
||||
@cb;
|
||||
assert(cb.hwif_out.level_irqs_2.intr == 1'b1);
|
||||
assert(cb.hwif_out.level_irqs_2.halt == 1'b1);
|
||||
cpuif.write('h4, 'h1FF);
|
||||
@cb;
|
||||
assert(cb.hwif_out.level_irqs_2.intr == 1'b0);
|
||||
assert(cb.hwif_out.level_irqs_2.halt == 1'b0);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test level_irqs_3
|
||||
cpuif.assert_read('h8, 'h000);
|
||||
assert(cb.hwif_out.level_irqs_3.intr == 1'b0);
|
||||
assert(cb.hwif_out.level_irqs_3.halt == 1'b0);
|
||||
cb.hwif_in.level_irqs_3.irq0.next <= 'h0F;
|
||||
@cb;
|
||||
cb.hwif_in.level_irqs_3.irq0.next <= 'h00;
|
||||
cpuif.assert_read('h8, 'h00F);
|
||||
assert(cb.hwif_out.level_irqs_3.intr == 1'b1);
|
||||
assert(cb.hwif_out.level_irqs_3.halt == 1'b1);
|
||||
cpuif.write('h104, 'h0F); // ctrl_mask
|
||||
@cb;
|
||||
assert(cb.hwif_out.level_irqs_3.intr == 1'b0);
|
||||
assert(cb.hwif_out.level_irqs_3.halt == 1'b1);
|
||||
cpuif.write('h10C, 'hF); // ctrl_haltmask
|
||||
@cb;
|
||||
assert(cb.hwif_out.level_irqs_3.intr == 1'b0);
|
||||
assert(cb.hwif_out.level_irqs_3.halt == 1'b0);
|
||||
cpuif.write('h104, 'h0); // ctrl_mask
|
||||
cpuif.write('h10C, 'h0); // ctrl_haltmask
|
||||
@cb;
|
||||
assert(cb.hwif_out.level_irqs_3.intr == 1'b1);
|
||||
assert(cb.hwif_out.level_irqs_3.halt == 1'b1);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test posedge_irqs
|
||||
cpuif.assert_read('h10, 'h000);
|
||||
assert(cb.hwif_out.posedge_irqs.intr == 1'b0);
|
||||
cb.hwif_in.posedge_irqs.irq1.next <= 1'b1;
|
||||
@cb;
|
||||
cpuif.assert_read('h10, 'h100);
|
||||
assert(cb.hwif_out.posedge_irqs.intr == 1'b1);
|
||||
cpuif.write('h10, 'h100);
|
||||
cpuif.assert_read('h10, 'h000);
|
||||
assert(cb.hwif_out.posedge_irqs.intr == 1'b0);
|
||||
cpuif.assert_read('h10, 'h000);
|
||||
|
||||
cb.hwif_in.posedge_irqs.irq1.next <= 1'b0;
|
||||
cpuif.assert_read('h10, 'h000);
|
||||
assert(cb.hwif_out.posedge_irqs.intr == 1'b0);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test negedge_irqs
|
||||
cpuif.assert_read('h20, 'h000);
|
||||
assert(cb.hwif_out.negedge_irqs.intr == 1'b0);
|
||||
cb.hwif_in.negedge_irqs.irq1.next <= 1'b1;
|
||||
@cb;
|
||||
cpuif.assert_read('h20, 'h000);
|
||||
assert(cb.hwif_out.negedge_irqs.intr == 1'b0);
|
||||
cb.hwif_in.negedge_irqs.irq1.next <= 1'b0;
|
||||
cpuif.assert_read('h20, 'h100);
|
||||
assert(cb.hwif_out.negedge_irqs.intr == 1'b1);
|
||||
cpuif.write('h20, 'h100);
|
||||
cpuif.assert_read('h20, 'h000);
|
||||
assert(cb.hwif_out.negedge_irqs.intr == 1'b0);
|
||||
cpuif.assert_read('h20, 'h000);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test bothedge_irqs
|
||||
cpuif.assert_read('h30, 'h000);
|
||||
assert(cb.hwif_out.bothedge_irqs.intr == 1'b0);
|
||||
|
||||
cb.hwif_in.bothedge_irqs.irq1.next <= 1'b1;
|
||||
cpuif.assert_read('h30, 'h100);
|
||||
assert(cb.hwif_out.bothedge_irqs.intr == 1'b1);
|
||||
cpuif.write('h30, 'h100);
|
||||
cpuif.assert_read('h30, 'h000);
|
||||
assert(cb.hwif_out.bothedge_irqs.intr == 1'b0);
|
||||
cpuif.assert_read('h30, 'h000);
|
||||
|
||||
cb.hwif_in.bothedge_irqs.irq1.next <= 1'b0;
|
||||
cpuif.assert_read('h30, 'h100);
|
||||
assert(cb.hwif_out.bothedge_irqs.intr == 1'b1);
|
||||
cpuif.write('h30, 'h100);
|
||||
cpuif.assert_read('h30, 'h000);
|
||||
assert(cb.hwif_out.bothedge_irqs.intr == 1'b0);
|
||||
cpuif.assert_read('h30, 'h000);
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
cpuif.assert_read('h40, 'h000);
|
||||
assert(cb.hwif_out.top_irq.intr == 1'b0);
|
||||
|
||||
cb.hwif_in.level_irqs_1.irq0.next <= 'h01;
|
||||
@cb;
|
||||
cb.hwif_in.level_irqs_1.irq0.next <= 'h00;
|
||||
cpuif.assert_read('h40, 'b0001);
|
||||
assert(cb.hwif_out.top_irq.intr == 1'b1);
|
||||
cpuif.write('h0, 'h01);
|
||||
cpuif.assert_read('h40, 'b0000);
|
||||
assert(cb.hwif_out.top_irq.intr == 1'b0);
|
||||
|
||||
cb.hwif_in.posedge_irqs.irq0.next <= 'h01;
|
||||
@cb;
|
||||
cb.hwif_in.posedge_irqs.irq0.next <= 'h00;
|
||||
cpuif.assert_read('h40, 'b0010);
|
||||
assert(cb.hwif_out.top_irq.intr == 1'b1);
|
||||
cpuif.write('h10, 'h01);
|
||||
cpuif.assert_read('h40, 'b0000);
|
||||
assert(cb.hwif_out.top_irq.intr == 1'b0);
|
||||
|
||||
cb.hwif_in.negedge_irqs.irq0.next <= 'h01;
|
||||
@cb;
|
||||
cb.hwif_in.negedge_irqs.irq0.next <= 'h00;
|
||||
@cb;
|
||||
cpuif.assert_read('h40, 'b0100);
|
||||
assert(cb.hwif_out.top_irq.intr == 1'b1);
|
||||
cpuif.write('h20, 'h01);
|
||||
cpuif.assert_read('h40, 'b0000);
|
||||
assert(cb.hwif_out.top_irq.intr == 1'b0);
|
||||
|
||||
cb.hwif_in.bothedge_irqs.irq0.next <= 'h01;
|
||||
@cb;
|
||||
cb.hwif_in.bothedge_irqs.irq0.next <= 'h00;
|
||||
cpuif.assert_read('h40, 'b1000);
|
||||
assert(cb.hwif_out.top_irq.intr == 1'b1);
|
||||
cpuif.write('h30, 'h01);
|
||||
cpuif.assert_read('h40, 'b0000);
|
||||
assert(cb.hwif_out.top_irq.intr == 1'b0);
|
||||
|
||||
cpuif.write('h108, 'h000); // ctrl_haltenable
|
||||
cb.hwif_in.level_irqs_2.irq0.next <= 'h01;
|
||||
@cb;
|
||||
cb.hwif_in.level_irqs_2.irq0.next <= 'h00;
|
||||
@cb;
|
||||
cpuif.assert_read('h40, 'b00000);
|
||||
assert(cb.hwif_out.top_irq.intr == 1'b0);
|
||||
|
||||
cpuif.write('h108, 'h001); // ctrl_haltenable
|
||||
cpuif.assert_read('h40, 'b10000);
|
||||
assert(cb.hwif_out.top_irq.intr == 1'b1);
|
||||
|
||||
cpuif.write('h4, 'h01);
|
||||
cpuif.assert_read('h40, 'b00000);
|
||||
assert(cb.hwif_out.top_irq.intr == 1'b0);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Test multi-bit sticky reg
|
||||
cpuif.assert_read('h50, 'h00);
|
||||
cb.hwif_in.stickyreg.stickyfield.next <= 'h12;
|
||||
@cb;
|
||||
cb.hwif_in.stickyreg.stickyfield.next <= 'h34;
|
||||
@cb;
|
||||
cb.hwif_in.stickyreg.stickyfield.next <= 'h56;
|
||||
@cb;
|
||||
cpuif.assert_read('h50, 'h12);
|
||||
cpuif.write('h50, 'h00);
|
||||
@cb;
|
||||
cb.hwif_in.stickyreg.stickyfield.next <= 'h78;
|
||||
@cb;
|
||||
cpuif.assert_read('h50, 'h56);
|
||||
|
||||
|
||||
{% endblock %}
|
||||
5
tests/test_interrupts/testcase.py
Normal file
5
tests/test_interrupts/testcase.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
|
||||
class Test(SimTestCase):
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
0
tests/test_onread_onwrite/__init__.py
Normal file
0
tests/test_onread_onwrite/__init__.py
Normal file
61
tests/test_onread_onwrite/regblock.rdl
Normal file
61
tests/test_onread_onwrite/regblock.rdl
Normal file
@@ -0,0 +1,61 @@
|
||||
addrmap top {
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
onread = rclr;
|
||||
} f1[7:0] = 0xF0;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
onread = rset;
|
||||
} f2[15:8] = 0x0F;
|
||||
} r1;
|
||||
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
onwrite = woset;
|
||||
} f1[3:0] = 0x0;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
onwrite = woclr;
|
||||
} f2[7:4] = 0xF;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
onwrite = wot;
|
||||
} f3[11:8] = 0x0;
|
||||
} r2;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
onwrite = wzs;
|
||||
} f1[3:0] = 0x0;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
onwrite = wzc;
|
||||
} f2[7:4] = 0xF;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
onwrite = wzt;
|
||||
} f3[11:8] = 0x0;
|
||||
} r3;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
onwrite = wclr;
|
||||
} f1[7:0] = 0xF0;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
onwrite = wset;
|
||||
} f2[15:8] = 0x0F;
|
||||
} r4;
|
||||
};
|
||||
30
tests/test_onread_onwrite/tb_template.sv
Normal file
30
tests/test_onread_onwrite/tb_template.sv
Normal file
@@ -0,0 +1,30 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
cpuif.assert_read('h0, 'h0F_F0);
|
||||
cpuif.assert_read('h0, 'hFF_00);
|
||||
cpuif.write ('h0, 'h00_FF);
|
||||
cpuif.assert_read('h0, 'h00_FF);
|
||||
cpuif.assert_read('h0, 'hFF_00);
|
||||
|
||||
cpuif.assert_read('h4, 'h0_F_0);
|
||||
cpuif.write ('h4, 'h1_1_1);
|
||||
cpuif.assert_read('h4, 'h1_E_1);
|
||||
cpuif.write ('h4, 'h1_2_2);
|
||||
cpuif.assert_read('h4, 'h0_C_3);
|
||||
|
||||
cpuif.assert_read('h8, 'h0_F_0);
|
||||
cpuif.write ('h8, 'hE_E_E);
|
||||
cpuif.assert_read('h8, 'h1_E_1);
|
||||
cpuif.write ('h8, 'hE_D_D);
|
||||
cpuif.assert_read('h8, 'h0_C_3);
|
||||
|
||||
cpuif.assert_read('hC, 'h0F_F0);
|
||||
cpuif.write ('hC, 'h12_34);
|
||||
cpuif.assert_read('hC, 'hFF_00);
|
||||
{% endblock %}
|
||||
5
tests/test_onread_onwrite/testcase.py
Normal file
5
tests/test_onread_onwrite/testcase.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
|
||||
class Test(SimTestCase):
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
0
tests/test_pipelined_cpuif/__init__.py
Normal file
0
tests/test_pipelined_cpuif/__init__.py
Normal file
8
tests/test_pipelined_cpuif/regblock.rdl
Normal file
8
tests/test_pipelined_cpuif/regblock.rdl
Normal file
@@ -0,0 +1,8 @@
|
||||
addrmap regblock {
|
||||
default sw=rw;
|
||||
default hw=r;
|
||||
|
||||
reg {
|
||||
field {} x[31:0] = 0;
|
||||
} x[64] @ 0 += 4;
|
||||
};
|
||||
50
tests/test_pipelined_cpuif/tb_template.sv
Normal file
50
tests/test_pipelined_cpuif/tb_template.sv
Normal file
@@ -0,0 +1,50 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
// Write all regs in parallel burst
|
||||
for(int i=0; i<64; i++) begin
|
||||
fork
|
||||
automatic int i_fk = i;
|
||||
begin
|
||||
cpuif.write(i_fk*4, i_fk + 32'h12340000);
|
||||
end
|
||||
join_none
|
||||
end
|
||||
wait fork;
|
||||
|
||||
// Verify HW value
|
||||
@cb;
|
||||
for(int i=0; i<64; i++) begin
|
||||
assert(cb.hwif_out.x[i].x.value == i + 32'h12340000)
|
||||
else $error("hwif_out.x[i] == 0x%0x. Expected 0x%0x", cb.hwif_out.x[i].x.value, i + 32'h12340000);
|
||||
end
|
||||
|
||||
// Read all regs in parallel burst
|
||||
for(int i=0; i<64; i++) begin
|
||||
fork
|
||||
automatic int i_fk = i;
|
||||
begin
|
||||
cpuif.assert_read(i_fk*4, i_fk + 32'h12340000);
|
||||
end
|
||||
join_none
|
||||
end
|
||||
wait fork;
|
||||
|
||||
// Mix read/writes
|
||||
for(int i=0; i<64; i++) begin
|
||||
fork
|
||||
automatic int i_fk = i;
|
||||
begin
|
||||
cpuif.write(i_fk*4, i_fk + 32'h56780000);
|
||||
cpuif.assert_read(i_fk*4, i_fk + 32'h56780000);
|
||||
end
|
||||
join_none
|
||||
end
|
||||
wait fork;
|
||||
|
||||
{% endblock %}
|
||||
9
tests/test_pipelined_cpuif/testcase.py
Normal file
9
tests/test_pipelined_cpuif/testcase.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from parameterized import parameterized_class
|
||||
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
from ..lib.test_params import TEST_PARAMS
|
||||
|
||||
@parameterized_class(TEST_PARAMS)
|
||||
class Test(SimTestCase):
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
0
tests/test_precedence/__init__.py
Normal file
0
tests/test_precedence/__init__.py
Normal file
26
tests/test_precedence/regblock.rdl
Normal file
26
tests/test_precedence/regblock.rdl
Normal file
@@ -0,0 +1,26 @@
|
||||
addrmap top {
|
||||
reg {
|
||||
field {
|
||||
sw=rw;
|
||||
hw=w; we;
|
||||
precedence=sw;
|
||||
} f_sw = 0;
|
||||
field {
|
||||
sw=rw;
|
||||
hw=w; we;
|
||||
precedence=hw;
|
||||
} f_hw = 0;
|
||||
} r1 @ 0x0;
|
||||
|
||||
reg {
|
||||
default counter;
|
||||
default sw=r;
|
||||
default hw=na;
|
||||
|
||||
field {} f_sw_count[3:0] = 0;
|
||||
field {} f_hw_count[7:4] = 0;
|
||||
} r1_events @ 0x4;
|
||||
|
||||
r1_events.f_sw_count->incr = r1.f_sw;
|
||||
r1_events.f_hw_count->incr = r1.f_hw;
|
||||
};
|
||||
26
tests/test_precedence/tb_template.sv
Normal file
26
tests/test_precedence/tb_template.sv
Normal file
@@ -0,0 +1,26 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
// Always write both fields from hardware
|
||||
cb.hwif_in.r1.f_sw.next <= '0;
|
||||
cb.hwif_in.r1.f_sw.we <= '1;
|
||||
cb.hwif_in.r1.f_hw.next <= '0;
|
||||
cb.hwif_in.r1.f_hw.we <= '1;
|
||||
@cb;
|
||||
@cb;
|
||||
|
||||
cpuif.assert_read('h0, 'b00);
|
||||
cpuif.assert_read('h4, 'h00);
|
||||
|
||||
cpuif.write('h0, 'b11);
|
||||
cpuif.write('h0, 'b11);
|
||||
cpuif.write('h0, 'b11);
|
||||
cpuif.assert_read('h0, 'h00);
|
||||
cpuif.assert_read('h4, 'h03);
|
||||
|
||||
{% endblock %}
|
||||
5
tests/test_precedence/testcase.py
Normal file
5
tests/test_precedence/testcase.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
|
||||
class Test(SimTestCase):
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
0
tests/test_read_fanin/__init__.py
Normal file
0
tests/test_read_fanin/__init__.py
Normal file
10
tests/test_read_fanin/regblock.rdl
Normal file
10
tests/test_read_fanin/regblock.rdl
Normal file
@@ -0,0 +1,10 @@
|
||||
addrmap top #(
|
||||
longint N_REGS = 1,
|
||||
longint REGWIDTH = 32
|
||||
) {
|
||||
reg reg_t {
|
||||
regwidth = REGWIDTH;
|
||||
field {sw=rw; hw=na;} f[REGWIDTH] = 1;
|
||||
};
|
||||
reg_t regs[N_REGS];
|
||||
};
|
||||
34
tests/test_read_fanin/tb_template.sv
Normal file
34
tests/test_read_fanin/tb_template.sv
Normal file
@@ -0,0 +1,34 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{%- block declarations %}
|
||||
{% sv_line_anchor %}
|
||||
localparam REGWIDTH = {{cls.regwidth}};
|
||||
localparam STRIDE = REGWIDTH/8;
|
||||
localparam N_REGS = {{cls.n_regs}};
|
||||
{%- endblock %}
|
||||
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
bit [REGWIDTH-1:0] data[N_REGS];
|
||||
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
foreach(data[i]) data[i] = {$urandom(), $urandom(), $urandom(), $urandom()};
|
||||
|
||||
for(int i=0; i<N_REGS; i++) begin
|
||||
cpuif.assert_read(i*STRIDE, 'h1);
|
||||
end
|
||||
|
||||
for(int i=0; i<N_REGS; i++) begin
|
||||
cpuif.write(i*STRIDE, data[i]);
|
||||
end
|
||||
|
||||
for(int i=0; i<N_REGS; i++) begin
|
||||
cpuif.assert_read(i*STRIDE, data[i]);
|
||||
end
|
||||
|
||||
assert($bits(dut.cpuif_wr_data) == REGWIDTH);
|
||||
{% endblock %}
|
||||
37
tests/test_read_fanin/testcase.py
Normal file
37
tests/test_read_fanin/testcase.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from parameterized import parameterized_class
|
||||
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
from ..lib.test_params import get_permutations
|
||||
|
||||
|
||||
PARAMS = get_permutations({
|
||||
"regwidth" : [8, 16, 32, 64],
|
||||
})
|
||||
@parameterized_class(PARAMS)
|
||||
class TestFanin(SimTestCase):
|
||||
retime_read_fanin = False
|
||||
n_regs = 20
|
||||
regwidth = 32
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.rdl_elab_params = {
|
||||
"N_REGS": cls.n_regs,
|
||||
"REGWIDTH": cls.regwidth,
|
||||
}
|
||||
super().setUpClass()
|
||||
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
|
||||
|
||||
PARAMS = get_permutations({
|
||||
"n_regs" : [1, 4, 7, 9, 11],
|
||||
"regwidth" : [8, 16, 32, 64],
|
||||
})
|
||||
@parameterized_class(PARAMS)
|
||||
class TestRetimedFanin(TestFanin):
|
||||
retime_read_fanin = True
|
||||
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
0
tests/test_reset_signals/__init__.py
Normal file
0
tests/test_reset_signals/__init__.py
Normal file
80
tests/test_reset_signals/regblock.rdl
Normal file
80
tests/test_reset_signals/regblock.rdl
Normal file
@@ -0,0 +1,80 @@
|
||||
|
||||
signal {
|
||||
cpuif_reset; activehigh;
|
||||
} root_cpuif_reset;
|
||||
|
||||
signal {} r5f2_resetvalue[16];
|
||||
|
||||
addrmap top {
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} f1[16] = 0x1234;
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} f2[16] = 0x5678;
|
||||
} r1;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} f1[16] = 0x1234;
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} f2[16] = 0x5678;
|
||||
|
||||
signal {
|
||||
field_reset; activehigh; sync;
|
||||
} my_reset;
|
||||
} r2;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} f1[16] = 0x1234;
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} f2[16] = 0x5678;
|
||||
|
||||
signal {
|
||||
field_reset; activehigh; async;
|
||||
} my_areset;
|
||||
} r3;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} f1[16] = 0x1234;
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} f2[16] = 0x5678;
|
||||
|
||||
signal {
|
||||
field_reset; activelow; sync;
|
||||
} my_reset_n;
|
||||
} r4;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} f1[16] = 0x1234;
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
reset = r5f2_resetvalue;
|
||||
} f2[16];
|
||||
|
||||
signal {
|
||||
field_reset; activelow; async;
|
||||
} my_areset_n;
|
||||
} r5;
|
||||
|
||||
signal {
|
||||
activehigh; sync;
|
||||
} f2_reset;
|
||||
|
||||
r1.f2->resetsignal = f2_reset;
|
||||
r2.f2->resetsignal = f2_reset;
|
||||
r3.f2->resetsignal = f2_reset;
|
||||
r4.f2->resetsignal = f2_reset;
|
||||
r5.f2->resetsignal = f2_reset;
|
||||
};
|
||||
128
tests/test_reset_signals/tb_template.sv
Normal file
128
tests/test_reset_signals/tb_template.sv
Normal file
@@ -0,0 +1,128 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{%- block declarations %}
|
||||
logic root_cpuif_reset;
|
||||
logic [15:0] r5f2_resetvalue;
|
||||
{%- endblock %}
|
||||
|
||||
{%- block clocking_dirs %}
|
||||
output root_cpuif_reset;
|
||||
output r5f2_resetvalue;
|
||||
{%- endblock %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
cb.root_cpuif_reset <= '1;
|
||||
cb.hwif_in.r2.my_reset <= '1;
|
||||
cb.hwif_in.r3.my_areset <= '1;
|
||||
cb.hwif_in.r4.my_reset_n <= '0;
|
||||
cb.hwif_in.r5.my_areset_n <= '0;
|
||||
cb.hwif_in.f2_reset <= '1;
|
||||
cb.r5f2_resetvalue <= 'hABCD;
|
||||
##2;
|
||||
cb.rst <= '0;
|
||||
cb.root_cpuif_reset <= '0;
|
||||
cb.hwif_in.r2.my_reset <= '0;
|
||||
cb.hwif_in.r3.my_areset <= '0;
|
||||
cb.hwif_in.r4.my_reset_n <= '1;
|
||||
cb.hwif_in.r5.my_areset_n <= '1;
|
||||
cb.hwif_in.f2_reset <= '0;
|
||||
##1;
|
||||
|
||||
|
||||
cpuif.assert_read('h00, 'h5678_1234);
|
||||
cpuif.assert_read('h04, 'h5678_1234);
|
||||
cpuif.assert_read('h08, 'h5678_1234);
|
||||
cpuif.assert_read('h0c, 'h5678_1234);
|
||||
cpuif.assert_read('h10, 'hABCD_1234);
|
||||
|
||||
for(int i=0; i<5; i++) cpuif.write(i*4, 0);
|
||||
|
||||
cpuif.assert_read('h00, 'h0000_0000);
|
||||
cpuif.assert_read('h04, 'h0000_0000);
|
||||
cpuif.assert_read('h08, 'h0000_0000);
|
||||
cpuif.assert_read('h0c, 'h0000_0000);
|
||||
cpuif.assert_read('h10, 'h0000_0000);
|
||||
|
||||
cb.rst <= '1;
|
||||
@cb;
|
||||
cb.rst <= '0;
|
||||
@cb;
|
||||
|
||||
cpuif.assert_read('h00, 'h0000_1234);
|
||||
cpuif.assert_read('h04, 'h0000_0000);
|
||||
cpuif.assert_read('h08, 'h0000_0000);
|
||||
cpuif.assert_read('h0c, 'h0000_0000);
|
||||
cpuif.assert_read('h10, 'h0000_0000);
|
||||
|
||||
for(int i=0; i<5; i++) cpuif.write(i*4, 0);
|
||||
|
||||
cb.hwif_in.r2.my_reset <= '1;
|
||||
@cb;
|
||||
cb.hwif_in.r2.my_reset <= '0;
|
||||
@cb;
|
||||
|
||||
cpuif.assert_read('h00, 'h0000_0000);
|
||||
cpuif.assert_read('h04, 'h0000_1234);
|
||||
cpuif.assert_read('h08, 'h0000_0000);
|
||||
cpuif.assert_read('h0c, 'h0000_0000);
|
||||
cpuif.assert_read('h10, 'h0000_0000);
|
||||
|
||||
for(int i=0; i<5; i++) cpuif.write(i*4, 0);
|
||||
|
||||
##1;
|
||||
#2ns;
|
||||
hwif_in.r3.my_areset = '1;
|
||||
#1ns;
|
||||
hwif_in.r3.my_areset = '0;
|
||||
##1;
|
||||
|
||||
cpuif.assert_read('h00, 'h0000_0000);
|
||||
cpuif.assert_read('h04, 'h0000_0000);
|
||||
cpuif.assert_read('h08, 'h0000_1234);
|
||||
cpuif.assert_read('h0c, 'h0000_0000);
|
||||
cpuif.assert_read('h10, 'h0000_0000);
|
||||
|
||||
for(int i=0; i<5; i++) cpuif.write(i*4, 0);
|
||||
|
||||
cb.hwif_in.r4.my_reset_n <= '0;
|
||||
@cb;
|
||||
cb.hwif_in.r4.my_reset_n <= '1;
|
||||
@cb;
|
||||
|
||||
cpuif.assert_read('h00, 'h0000_0000);
|
||||
cpuif.assert_read('h04, 'h0000_0000);
|
||||
cpuif.assert_read('h08, 'h0000_0000);
|
||||
cpuif.assert_read('h0c, 'h0000_1234);
|
||||
cpuif.assert_read('h10, 'h0000_0000);
|
||||
|
||||
for(int i=0; i<5; i++) cpuif.write(i*4, 0);
|
||||
|
||||
##1;
|
||||
#2ns;
|
||||
hwif_in.r5.my_areset_n = '0;
|
||||
#1ns;
|
||||
hwif_in.r5.my_areset_n = '1;
|
||||
##1;
|
||||
|
||||
cpuif.assert_read('h00, 'h0000_0000);
|
||||
cpuif.assert_read('h04, 'h0000_0000);
|
||||
cpuif.assert_read('h08, 'h0000_0000);
|
||||
cpuif.assert_read('h0c, 'h0000_0000);
|
||||
cpuif.assert_read('h10, 'h0000_1234);
|
||||
|
||||
for(int i=0; i<5; i++) cpuif.write(i*4, 0);
|
||||
|
||||
@cb;
|
||||
cb.hwif_in.f2_reset <= '1;
|
||||
cb.r5f2_resetvalue <= 'h3210;
|
||||
@cb;
|
||||
cb.hwif_in.f2_reset <= '0;
|
||||
|
||||
cpuif.assert_read('h00, 'h5678_0000);
|
||||
cpuif.assert_read('h04, 'h5678_0000);
|
||||
cpuif.assert_read('h08, 'h5678_0000);
|
||||
cpuif.assert_read('h0c, 'h5678_0000);
|
||||
cpuif.assert_read('h10, 'h3210_0000);
|
||||
|
||||
{% endblock %}
|
||||
5
tests/test_reset_signals/testcase.py
Normal file
5
tests/test_reset_signals/testcase.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
|
||||
class Test(SimTestCase):
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
0
tests/test_singlepulse/__init__.py
Normal file
0
tests/test_singlepulse/__init__.py
Normal file
8
tests/test_singlepulse/regblock.rdl
Normal file
8
tests/test_singlepulse/regblock.rdl
Normal file
@@ -0,0 +1,8 @@
|
||||
addrmap top {
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=r;
|
||||
singlepulse;
|
||||
} f[0:0] = 0;
|
||||
} r1;
|
||||
};
|
||||
56
tests/test_singlepulse/tb_template.sv
Normal file
56
tests/test_singlepulse/tb_template.sv
Normal file
@@ -0,0 +1,56 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
int event_count;
|
||||
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
// No pulse if writing zero
|
||||
event_count = 0;
|
||||
fork
|
||||
begin
|
||||
##0;
|
||||
forever begin
|
||||
@cb;
|
||||
if(cb.hwif_out.r1.f.value) begin
|
||||
event_count++;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
cpuif.write('h0, 'h0);
|
||||
repeat(5) @cb;
|
||||
end
|
||||
join_any
|
||||
disable fork;
|
||||
assert(event_count == 0) else $error("Observed excess singlepulse events: %0d", event_count);
|
||||
|
||||
// single pulse
|
||||
event_count = 0;
|
||||
fork
|
||||
begin
|
||||
##0;
|
||||
forever begin
|
||||
@cb;
|
||||
if(cb.hwif_out.r1.f.value) begin
|
||||
event_count++;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
cpuif.write('h0, 'h1);
|
||||
repeat(5) @cb;
|
||||
end
|
||||
join_any
|
||||
disable fork;
|
||||
assert(event_count == 1) else $error("Observed incorrect number of singlepulse events: %0d", event_count);
|
||||
|
||||
// auto-clears
|
||||
cpuif.assert_read('h0, 'h0);
|
||||
|
||||
{% endblock %}
|
||||
5
tests/test_singlepulse/testcase.py
Normal file
5
tests/test_singlepulse/testcase.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
|
||||
class Test(SimTestCase):
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
0
tests/test_structural_sw_rw/__init__.py
Normal file
0
tests/test_structural_sw_rw/__init__.py
Normal file
34
tests/test_structural_sw_rw/regblock.rdl
Normal file
34
tests/test_structural_sw_rw/regblock.rdl
Normal file
@@ -0,0 +1,34 @@
|
||||
addrmap regblock {
|
||||
default sw=rw;
|
||||
default hw=r;
|
||||
|
||||
reg my_reg {
|
||||
field {} a[8] = 0x23;
|
||||
field {} b = 0;
|
||||
field {} c[31:31] = 1;
|
||||
};
|
||||
|
||||
my_reg r0 @0x000;
|
||||
r0.a->reset = 0x42;
|
||||
|
||||
my_reg r1[2][3][4] @0x10 += 8;
|
||||
|
||||
my_reg r2 @0x1000;
|
||||
r2.a->reset = 0x11;
|
||||
|
||||
|
||||
reg subreg {
|
||||
field {} x[7:4] = 1;
|
||||
};
|
||||
regfile subrf {
|
||||
subreg r1[4] @ 0x0 += 4;
|
||||
regfile {
|
||||
subreg r1 @ 0x0;
|
||||
subreg r2[2] @ 0x4 += 4;
|
||||
subreg r3 @ 0xc;
|
||||
} sub[2] @ 0x10 += 0x10;
|
||||
subreg r2[4] @ 0x30 += 4;
|
||||
};
|
||||
subrf sub2[2] @ 0x2000 += 0x40;
|
||||
subreg r3 @ 0x2080;
|
||||
};
|
||||
64
tests/test_structural_sw_rw/tb_template.sv
Normal file
64
tests/test_structural_sw_rw/tb_template.sv
Normal file
@@ -0,0 +1,64 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
// Assert value via frontdoor
|
||||
cpuif.assert_read(0, 32'h8000_0042);
|
||||
for(int i=0; i<2*3*4; i++) begin
|
||||
cpuif.assert_read('h10+i*8, 32'h8000_0023);
|
||||
end
|
||||
cpuif.assert_read('h1000, 32'h8000_0011);
|
||||
for(int i=0; i<33; i++) begin
|
||||
cpuif.assert_read('h2000 +i*4, 32'h0000_0010);
|
||||
end
|
||||
|
||||
// Assert via hwif
|
||||
assert(cb.hwif_out.r0.a.value == 'h42);
|
||||
assert(cb.hwif_out.r0.b.value == 'h0);
|
||||
assert(cb.hwif_out.r0.c.value == 'h1);
|
||||
foreach(cb.hwif_out.r1[x, y, z]) begin
|
||||
assert(cb.hwif_out.r1[x][y][z].a.value == 'h23);
|
||||
assert(cb.hwif_out.r1[x][y][z].b.value == 'h0);
|
||||
assert(cb.hwif_out.r1[x][y][z].c.value == 'h1);
|
||||
end
|
||||
assert(cb.hwif_out.r2.a.value == 'h11);
|
||||
assert(cb.hwif_out.r2.b.value == 'h0);
|
||||
assert(cb.hwif_out.r2.c.value == 'h1);
|
||||
|
||||
// Write values
|
||||
cpuif.write(0, 32'h8000_0002);
|
||||
for(int i=0; i<2*3*4; i++) begin
|
||||
cpuif.write('h10+i*8, i+'h110a);
|
||||
end
|
||||
cpuif.write('h1000, 32'h0000_0000);
|
||||
for(int i=0; i<33; i++) begin
|
||||
cpuif.write('h2000 +i*4, i << 4);
|
||||
end
|
||||
|
||||
// Assert value via frontdoor
|
||||
cpuif.assert_read(0, 32'h8000_0002);
|
||||
for(int i=0; i<2*3*4; i++) begin
|
||||
cpuif.assert_read('h10+i*8, i+'h10a);
|
||||
end
|
||||
cpuif.assert_read('h1000, 32'h0000_0000);
|
||||
for(int i=0; i<33; i++) begin
|
||||
cpuif.assert_read('h2000 +i*4, (i << 4) & 'hF0);
|
||||
end
|
||||
|
||||
// Assert via hwif
|
||||
assert(cb.hwif_out.r0.a.value == 'h02);
|
||||
assert(cb.hwif_out.r0.b.value == 'h0);
|
||||
assert(cb.hwif_out.r0.c.value == 'h1);
|
||||
foreach(cb.hwif_out.r1[x, y, z]) begin
|
||||
assert(cb.hwif_out.r1[x][y][z].a.value == x*12+y*4+z+10);
|
||||
assert(cb.hwif_out.r1[x][y][z].b.value == 'h1);
|
||||
assert(cb.hwif_out.r1[x][y][z].c.value == 'h0);
|
||||
end
|
||||
assert(cb.hwif_out.r2.a.value == 'h0);
|
||||
assert(cb.hwif_out.r2.b.value == 'h0);
|
||||
assert(cb.hwif_out.r2.c.value == 'h0);
|
||||
{% endblock %}
|
||||
15
tests/test_structural_sw_rw/testcase.py
Normal file
15
tests/test_structural_sw_rw/testcase.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from parameterized import parameterized_class
|
||||
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
from ..lib.synth_testcase import SynthTestCase
|
||||
from ..lib.test_params import TEST_PARAMS
|
||||
|
||||
@parameterized_class(TEST_PARAMS)
|
||||
class Test(SimTestCase):
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
|
||||
@parameterized_class(TEST_PARAMS)
|
||||
class TestSynth(SynthTestCase):
|
||||
def test_dut(self):
|
||||
self.run_synth()
|
||||
0
tests/test_swacc_swmod/__init__.py
Normal file
0
tests/test_swacc_swmod/__init__.py
Normal file
25
tests/test_swacc_swmod/regblock.rdl
Normal file
25
tests/test_swacc_swmod/regblock.rdl
Normal file
@@ -0,0 +1,25 @@
|
||||
addrmap top {
|
||||
default regwidth = 8;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=r; hw=w;
|
||||
swacc;
|
||||
} f[8];
|
||||
} r1;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=r;
|
||||
swmod;
|
||||
} f[8] = 20;
|
||||
} r2;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=r;
|
||||
swmod;
|
||||
rclr;
|
||||
} f[8] = 30;
|
||||
} r3;
|
||||
};
|
||||
92
tests/test_swacc_swmod/tb_template.sv
Normal file
92
tests/test_swacc_swmod/tb_template.sv
Normal file
@@ -0,0 +1,92 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
logic [7:0] counter;
|
||||
logic [7:0] rd_data;
|
||||
logic [7:0] latched_data;
|
||||
int event_count;
|
||||
latched_data = 'x;
|
||||
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
// Verify that hwif gets sampled at the same cycle as swacc strobe
|
||||
counter = 'h10;
|
||||
cb.hwif_in.r1.f.next <= counter;
|
||||
@cb;
|
||||
event_count = 0;
|
||||
fork
|
||||
begin
|
||||
##0;
|
||||
forever begin
|
||||
counter++;
|
||||
cb.hwif_in.r1.f.next <= counter;
|
||||
@cb;
|
||||
if(cb.hwif_out.r1.f.swacc) begin
|
||||
latched_data = counter;
|
||||
event_count++;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
cpuif.read('h0, rd_data);
|
||||
@cb;
|
||||
end
|
||||
join_any
|
||||
disable fork;
|
||||
assert(rd_data == latched_data) else $error("Read returned 0x%0x but swacc strobed during 0x%0x", rd_data, latched_data);
|
||||
assert(event_count == 1) else $error("Observed excess swacc events: %0d", event_count);
|
||||
|
||||
|
||||
// Verify that hwif changes 1 cycle after swmod
|
||||
fork
|
||||
begin
|
||||
##0;
|
||||
forever begin
|
||||
assert(cb.hwif_out.r2.f.value == 20);
|
||||
if(cb.hwif_out.r2.f.swmod) break;
|
||||
@cb;
|
||||
end
|
||||
@cb;
|
||||
forever begin
|
||||
assert(cb.hwif_out.r2.f.value == 21);
|
||||
assert(cb.hwif_out.r2.f.swmod == 0);
|
||||
@cb;
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
cpuif.write('h1, 21);
|
||||
@cb;
|
||||
end
|
||||
join_any
|
||||
disable fork;
|
||||
|
||||
// Verify that hwif changes 1 cycle after swmod
|
||||
fork
|
||||
begin
|
||||
##0;
|
||||
forever begin
|
||||
assert(cb.hwif_out.r3.f.value == 30);
|
||||
if(cb.hwif_out.r3.f.swmod) break;
|
||||
@cb;
|
||||
end
|
||||
@cb;
|
||||
forever begin
|
||||
assert(cb.hwif_out.r3.f.value == 0);
|
||||
assert(cb.hwif_out.r3.f.swmod == 0);
|
||||
@cb;
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
cpuif.assert_read('h2, 30);
|
||||
@cb;
|
||||
end
|
||||
join_any
|
||||
disable fork;
|
||||
|
||||
{% endblock %}
|
||||
5
tests/test_swacc_swmod/testcase.py
Normal file
5
tests/test_swacc_swmod/testcase.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
|
||||
class Test(SimTestCase):
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
0
tests/test_swwe/__init__.py
Normal file
0
tests/test_swwe/__init__.py
Normal file
66
tests/test_swwe/regblock.rdl
Normal file
66
tests/test_swwe/regblock.rdl
Normal file
@@ -0,0 +1,66 @@
|
||||
addrmap top {
|
||||
default regwidth = 8;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} r3_swwe[0:0] = 1;
|
||||
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} r4_swwel[1:1] = 0;
|
||||
} lock;
|
||||
|
||||
//---------------------------------
|
||||
// via inferred signal
|
||||
//---------------------------------
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
swwe;
|
||||
} f[8] = 0x11;
|
||||
} r1;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
swwel;
|
||||
} f[8] = 0x22;
|
||||
} r2;
|
||||
|
||||
//---------------------------------
|
||||
// via lock register
|
||||
//---------------------------------
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} f[8] = 0x33;
|
||||
} r3;
|
||||
r3.f->swwe = lock.r3_swwe;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} f[8] = 0x44;
|
||||
} r4;
|
||||
r4.f->swwel = lock.r4_swwel;
|
||||
|
||||
//---------------------------------
|
||||
// via prop ref chaining
|
||||
//---------------------------------
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} f[8] = 0x55;
|
||||
} r5;
|
||||
r5.f->swwe = r3.f->swwe;
|
||||
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=na;
|
||||
} f[8] = 0x66;
|
||||
} r6;
|
||||
r6.f->swwe = r4.f->swwel; // intentionally opposite!
|
||||
};
|
||||
63
tests/test_swwe/tb_template.sv
Normal file
63
tests/test_swwe/tb_template.sv
Normal file
@@ -0,0 +1,63 @@
|
||||
{% extends "lib/tb_base.sv" %}
|
||||
|
||||
{% block seq %}
|
||||
{% sv_line_anchor %}
|
||||
##1;
|
||||
cb.rst <= '0;
|
||||
##1;
|
||||
|
||||
// r1 swwe = true
|
||||
cpuif.assert_read('h1, 'h11);
|
||||
cb.hwif_in.r1.f.swwe <= '0;
|
||||
cpuif.write ('h1, 'h12);
|
||||
cpuif.assert_read('h1, 'h11);
|
||||
cb.hwif_in.r1.f.swwe <= '1;
|
||||
cpuif.write ('h1, 'h13);
|
||||
cpuif.assert_read('h1, 'h13);
|
||||
|
||||
// r2 swwel = true
|
||||
cpuif.assert_read('h2, 'h22);
|
||||
cb.hwif_in.r2.f.swwel <= '1;
|
||||
cpuif.write ('h2, 'h23);
|
||||
cpuif.assert_read('h2, 'h22);
|
||||
cb.hwif_in.r2.f.swwel <= '0;
|
||||
cpuif.write ('h2, 'h24);
|
||||
cpuif.assert_read('h2, 'h24);
|
||||
|
||||
// r3 swwe = lock.r3_swwe
|
||||
cpuif.assert_read('h3, 'h33);
|
||||
cpuif.write ('h0, 'h0);
|
||||
cpuif.write ('h3, 'h32);
|
||||
cpuif.assert_read('h3, 'h33);
|
||||
cpuif.write ('h0, 'h1);
|
||||
cpuif.write ('h3, 'h34);
|
||||
cpuif.assert_read('h3, 'h34);
|
||||
|
||||
// r4 swwel = lock.r4_swwel
|
||||
cpuif.assert_read('h4, 'h44);
|
||||
cpuif.write ('h0, 'h2);
|
||||
cpuif.write ('h4, 'h40);
|
||||
cpuif.assert_read('h4, 'h44);
|
||||
cpuif.write ('h0, 'h0);
|
||||
cpuif.write ('h4, 'h45);
|
||||
cpuif.assert_read('h4, 'h45);
|
||||
|
||||
// r5 swwe = r3->swwe = lock.r3_swwe
|
||||
cpuif.assert_read('h5, 'h55);
|
||||
cpuif.write ('h0, 'h0);
|
||||
cpuif.write ('h5, 'h52);
|
||||
cpuif.assert_read('h5, 'h55);
|
||||
cpuif.write ('h0, 'h1);
|
||||
cpuif.write ('h5, 'h54);
|
||||
cpuif.assert_read('h5, 'h54);
|
||||
|
||||
// r6 swwe = r4->swwel = lock.r4_swwel
|
||||
cpuif.assert_read('h6, 'h66);
|
||||
cpuif.write ('h0, 'h0);
|
||||
cpuif.write ('h6, 'h60);
|
||||
cpuif.assert_read('h6, 'h66);
|
||||
cpuif.write ('h0, 'h2);
|
||||
cpuif.write ('h6, 'h65);
|
||||
cpuif.assert_read('h6, 'h65);
|
||||
|
||||
{% endblock %}
|
||||
5
tests/test_swwe/testcase.py
Normal file
5
tests/test_swwe/testcase.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from ..lib.sim_testcase import SimTestCase
|
||||
|
||||
class Test(SimTestCase):
|
||||
def test_dut(self):
|
||||
self.run_test()
|
||||
0
tests/test_user_cpuif/__init__.py
Normal file
0
tests/test_user_cpuif/__init__.py
Normal file
7
tests/test_user_cpuif/regblock.rdl
Normal file
7
tests/test_user_cpuif/regblock.rdl
Normal file
@@ -0,0 +1,7 @@
|
||||
addrmap top {
|
||||
reg {
|
||||
field {
|
||||
sw=rw; hw=r;
|
||||
} f = 0;
|
||||
} r1;
|
||||
};
|
||||
49
tests/test_user_cpuif/testcase.py
Normal file
49
tests/test_user_cpuif/testcase.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import os
|
||||
|
||||
from peakrdl.regblock.cpuif.apb3 import APB3_Cpuif
|
||||
from ..lib.cpuifs.apb3 import APB3
|
||||
from ..lib.base_testcase import BaseTestCase
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
class ClassOverride_Cpuif(APB3_Cpuif):
|
||||
@property
|
||||
def port_declaration(self) -> str:
|
||||
return "user_apb3_intf.slave s_apb"
|
||||
|
||||
class ClassOverride_cpuiftestmode(APB3):
|
||||
cpuif_cls = ClassOverride_Cpuif
|
||||
|
||||
|
||||
class Test_class_override(BaseTestCase):
|
||||
cpuif = ClassOverride_cpuiftestmode()
|
||||
|
||||
def test_override_success(self):
|
||||
output_file = os.path.join(self.get_run_dir(), "regblock.sv")
|
||||
with open(output_file, "r") as f:
|
||||
self.assertIn(
|
||||
"user_apb3_intf.slave s_apb",
|
||||
f.read()
|
||||
)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
class TemplateOverride_Cpuif(APB3_Cpuif):
|
||||
# contains the text "USER TEMPLATE OVERRIDE"
|
||||
template_path = "user_apb3_tmpl.sv"
|
||||
|
||||
class TemplateOverride_cpuiftestmode(APB3):
|
||||
cpuif_cls = TemplateOverride_Cpuif
|
||||
|
||||
|
||||
class Test_template_override(BaseTestCase):
|
||||
cpuif = TemplateOverride_cpuiftestmode()
|
||||
|
||||
def test_override_success(self):
|
||||
output_file = os.path.join(self.get_run_dir(), "regblock.sv")
|
||||
with open(output_file, "r") as f:
|
||||
self.assertIn(
|
||||
"USER TEMPLATE OVERRIDE",
|
||||
f.read()
|
||||
)
|
||||
1
tests/test_user_cpuif/user_apb3_tmpl.sv
Normal file
1
tests/test_user_cpuif/user_apb3_tmpl.sv
Normal file
@@ -0,0 +1 @@
|
||||
// USER TEMPLATE OVERRIDE
|
||||
Reference in New Issue
Block a user