More testcases & documentation
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
{% sv_line_anchor %}
|
||||
apb3_intf #(
|
||||
.DATA_WIDTH({{exporter.cpuif.data_width}}),
|
||||
.ADDR_WIDTH({{exporter.cpuif.addr_width}})
|
||||
@@ -11,6 +12,7 @@ apb3_intf_driver #(
|
||||
.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;
|
||||
|
||||
@@ -6,6 +6,8 @@ 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 ..regblock_testcase import RegblockTestCase
|
||||
@@ -30,13 +32,17 @@ class CpuifTestMode:
|
||||
|
||||
|
||||
def get_tb_inst(self, tb_cls: 'RegblockTestCase', exporter: 'RegblockExporter') -> str:
|
||||
class_dir = os.path.dirname(inspect.getfile(self.__class__))
|
||||
|
||||
# For consistency, make the template root path relative to the test dir
|
||||
template_root_path = os.path.join(os.path.dirname(__file__), "../..")
|
||||
|
||||
loader = jj.FileSystemLoader(
|
||||
os.path.join(class_dir)
|
||||
template_root_path
|
||||
)
|
||||
jj_env = jj.Environment(
|
||||
loader=loader,
|
||||
undefined=jj.StrictUndefined,
|
||||
extensions=[SVLineAnchor],
|
||||
)
|
||||
|
||||
context = {
|
||||
@@ -46,5 +52,11 @@ class CpuifTestMode:
|
||||
"type": type,
|
||||
}
|
||||
|
||||
template = jj_env.get_template(self.tb_template)
|
||||
# template paths are relative to their class.
|
||||
# transform to be relative to the root path
|
||||
class_dir = os.path.dirname(inspect.getfile(self.__class__))
|
||||
template_local_path = os.path.join(class_dir, self.tb_template)
|
||||
template_path = os.path.relpath(template_local_path, template_root_path)
|
||||
template = jj_env.get_template(template_path)
|
||||
|
||||
return template.render(context)
|
||||
|
||||
Reference in New Issue
Block a user