refactor: refactor tests to replace RIBP references with APB4 equivalents

- Updated test files to change instances of ribp_if to apb4_if in various test cases, ensuring consistency with the new APB4 interface.
- Modified assertions and checks in tests to reflect the new APB4 naming conventions, including changes in expected output and input files.
- Adjusted the test descriptions to accurately represent the APB4 functionality being tested, particularly in timer, UART, and GPIO tests.
- Ensured that all relevant paths and file names in the tests are updated to point to the new APB4 implementations, maintaining the integrity of the test suite.
This commit is contained in:
maksyuki committed 2026-08-16 21:19:20 +08:00
1 parent 06e2b9c4de
commit 6eedacd2f7
153 files changed
+5566 -3744

No files matched your search

+39 -40
View File
@@ -57,8 +57,8 @@ def write_invalid_topology(tmp_path: Path, document: dict[str, object]) -> Path:
def test_topology_generates_complete_rib_apb_and_gpio_bindings(tmp_path: Path) -> None:
generate(tmp_path)
interfaces = (tmp_path / "rtl/ribp_interfaces.svh").read_text(encoding="utf-8")
routes = (tmp_path / "rtl/ribp_routes.svh").read_text(encoding="utf-8")
interfaces = (tmp_path / "rtl/apb4_periph_interfaces.svh").read_text(encoding="utf-8")
routes = (tmp_path / "rtl/apb4_periph_select_routes.svh").read_text(encoding="utf-8")
gpio = (tmp_path / "rtl/soc_gpio_alt_bindings.svh").read_text(encoding="utf-8")
apb_interfaces = (tmp_path / "rtl/soc_apb_interfaces.svh").read_text(encoding="utf-8")
apb_declarations = (tmp_path / "rtl/soc_apb_declarations.svh").read_text(encoding="utf-8")
@@ -68,20 +68,19 @@ def test_topology_generates_complete_rib_apb_and_gpio_bindings(tmp_path: Path) -
bus_fabric = (tmp_path / "rtl/soc_bus_fabric.svh").read_text(encoding="utf-8")
apb_system_fabric = (tmp_path / "rtl/soc_apb4_system_fabric.svh").read_text(encoding="utf-8")
irq_config = (tmp_path / "rtl/soc_irq_config.svh").read_text(encoding="utf-8")
rib_irq = (tmp_path / "rtl/ribp_irq_bindings.svh").read_text(encoding="utf-8")
rib_irq = (tmp_path / "rtl/soc_apb4_irq_bindings.svh").read_text(encoding="utf-8")
apb_irq = (tmp_path / "rtl/soc_apb_irq_bindings.svh").read_text(encoding="utf-8")
irq_wiring = (tmp_path / "rtl/soc_irq_wiring.svh").read_text(encoding="utf-8")
irq_sva = (tmp_path / "rtl/soc_irq_sva.svh").read_text(encoding="utf-8")
filelist = (tmp_path / "soc_topology.fl").read_text(encoding="utf-8")
assert interfaces.count("ribp_if u_") == 17
assert interfaces.count("apb4_if u_") == 17
assert "nmi_if" not in interfaces
assert "soc_nmi" not in interfaces
assert "assign s_slv_sel_d[17] = u_i2c1_ribp_if.valid;" in routes
assert "assign s_slv_resp_err[17] = u_i2c1_ribp_if.resp_err;" in routes
assert "assign ribp.resp_err = |(s_slv_sel_q & s_slv_ready & s_slv_resp_err);" in routes
assert "assign s_psel_comb[17] = `SOC_ADDR_IS_APB4_I2C1(s_decode_addr);" in routes
assert "assign s_psel_comb[1] = `SOC_ADDR_IS_APB4_GPIO(s_decode_addr) || `SOC_ADDR_IS_APB4_GPIO_ADMIN(s_decode_addr);" in routes
assert "SOC_ADDR_FLASH" not in routes
assert "assign u_sdio_ribp_if.valid = 1'b0;" in routes
assert "assign s_psel_comb[15] = 1'b0;" in routes
assert gpio.count("// GPIO") == 64
assert "u_uart1_if" not in gpio
assert "assign u_uart0_if.cts_n_i = u_gpio_if.di_i[0];" in gpio
@@ -116,7 +115,7 @@ def test_topology_generates_complete_rib_apb_and_gpio_bindings(tmp_path: Path) -
assert ".axi4(u_apb_axi4_if)" in apb_system_fabric
assert "`define SOC_IRQ_VECTOR_WIDTH 32" in irq_config
assert "`define SOC_USER_IRQ_MASK 32'h000EFBFC" in irq_config
assert "`define SOC_IRQ_RIBP_WIDTH 14" in irq_config
assert "`define SOC_IRQ_APB4_WIDTH 14" in irq_config
assert "`define SOC_IRQ_APB_WIDTH 5" in irq_config
assert "assign irq_o[0] = u_clint_if.software_irq_o[0];" in rib_irq
assert "assign irq_o[10] = ws2812.irq_o;" in rib_irq
@@ -126,10 +125,10 @@ def test_topology_generates_complete_rib_apb_and_gpio_bindings(tmp_path: Path) -
assert "assign irq_o[0] = pwm.irq_o;" in apb_irq
assert "assign irq_o[4] = s_rng_irq;" in apb_irq
assert "s_irq[10]" not in irq_wiring
assert "s_irq[15] = s_ribp_irq[13];" in irq_wiring
assert "s_irq[15] = s_apb4_irq[13];" in irq_wiring
assert "s_irq[16] = s_apb_irq[4];" in irq_wiring
assert "irq_i[10] == 1'b0" in irq_sva
assert "irq_i[15] == ribp_irq_i[13]" in irq_sva
assert "irq_i[15] == apb4_irq_i[13]" in irq_sva
assert "irq_i[31] == 1'b0" in irq_sva
assert "bind retrosoc soc_irq_topology_sva" in irq_sva
assert filelist.startswith("+incdir+")
@@ -149,25 +148,25 @@ def test_topology_preserves_default_irq_compatibility_mapping() -> None:
for interrupt in document["interrupts"]
]
assert mappings == [
("clint_software", "ribp", 0, 0, "u_clint_if.software_irq_o[0]"),
("clint_timer", "ribp", 1, 1, "u_clint_if.timer_irq_o[0]"),
("uart0", "ribp", 2, 2, "uart.irq_o"),
("timer0", "ribp", 3, 3, "s_tim0_irq"),
("timer1", "ribp", 4, 4, "s_tim1_irq"),
("psram", "ribp", 5, 5, "psram.irq_o"),
("spisd", "ribp", 6, 6, "spisd.irq_o"),
("i2c0", "ribp", 7, 7, "i2c0.irq_o"),
("i2s", "ribp", 8, 8, "i2s.irq_o"),
("xpi", "ribp", 9, 9, "xpi.irq_o"),
("clint_software", "apb4", 0, 0, "u_clint_if.software_irq_o[0]"),
("clint_timer", "apb4", 1, 1, "u_clint_if.timer_irq_o[0]"),
("uart0", "apb4", 2, 2, "uart.irq_o"),
("timer0", "apb4", 3, 3, "s_tim0_irq"),
("timer1", "apb4", 4, 4, "s_tim1_irq"),
("psram", "apb4", 5, 5, "psram.irq_o"),
("spisd", "apb4", 6, 6, "spisd.irq_o"),
("i2c0", "apb4", 7, 7, "i2c0.irq_o"),
("i2s", "apb4", 8, 8, "i2s.irq_o"),
("xpi", "apb4", 9, 9, "xpi.irq_o"),
("pwm", "apb", 0, 11, "pwm.irq_o"),
("ps2", "apb", 1, 12, "ps2.irq_o"),
("rtc", "apb", 2, 13, "u_rtc_if.irq_o"),
("watchdog_early_warning", "apb", 3, 14, "u_wdg_if.irq_o"),
("rng", "apb", 4, 16, "s_rng_irq"),
("ws2812", "ribp", 10, 17, "ws2812.irq_o"),
("gpio", "ribp", 11, 18, "gpio.irq_o"),
("i2c1", "ribp", 12, 19, "i2c1.irq_o"),
("dvp", "ribp", 13, 15, "s_dvp_irq"),
("ws2812", "apb4", 10, 17, "ws2812.irq_o"),
("gpio", "apb4", 11, 18, "gpio.irq_o"),
("i2c1", "apb4", 12, 19, "i2c1.irq_o"),
("dvp", "apb4", 13, 15, "s_dvp_irq"),
]
@@ -193,27 +192,27 @@ def test_topology_always_adds_the_user_apb_target(tmp_path: Path) -> None:
def test_topology_rejects_unknown_or_non_rib_regions(tmp_path: Path) -> None:
document = json.loads(TOPOLOGY.read_text(encoding="utf-8"))
document["ribp_targets"][0]["regions"] = ["UNKNOWN"]
document["apb4_targets"][0]["regions"] = ["UNKNOWN"]
result = validate(write_invalid_topology(tmp_path, document))
assert result.returncode != 0
assert "unknown region" in result.stderr
document = json.loads(TOPOLOGY.read_text(encoding="utf-8"))
document["ribp_targets"][0]["regions"] = ["SRAM"]
document["apb4_targets"][0]["regions"] = ["SRAM"]
result = validate(write_invalid_topology(tmp_path, document))
assert result.returncode != 0
assert "not an active RIBP region" in result.stderr
assert "not an active APB4 region" in result.stderr
def test_topology_rejects_duplicate_region_and_disabled_owner(tmp_path: Path) -> None:
document = json.loads(TOPOLOGY.read_text(encoding="utf-8"))
document["ribp_targets"][1]["regions"] = ["RIBP_UART0"]
document["apb4_targets"][1]["regions"] = ["APB4_UART0"]
result = validate(write_invalid_topology(tmp_path, document))
assert result.returncode != 0
assert "multiple targets" in result.stderr
document = json.loads(TOPOLOGY.read_text(encoding="utf-8"))
document["ribp_targets"][15]["regions"] = ["RIBP_SDIO"]
document["apb4_targets"][15]["regions"] = ["APB4_SDIO"]
result = validate(write_invalid_topology(tmp_path, document))
assert result.returncode != 0
assert "disabled but declares regions" in result.stderr
@@ -261,16 +260,16 @@ def test_topology_rejects_invalid_gpio_coverage_and_expression(tmp_path: Path) -
def test_topology_rejects_invalid_irq_groups_and_bindings(tmp_path: Path) -> None:
document = json.loads(TOPOLOGY.read_text(encoding="utf-8"))
document["irq_groups"][1]["name"] = "ribp"
document["irq_groups"][1]["name"] = "apb4"
result = validate(write_invalid_topology(tmp_path, document))
assert result.returncode != 0
assert "interrupt group ribp is duplicated" in result.stderr
assert "interrupt group apb4 is duplicated" in result.stderr
document = json.loads(TOPOLOGY.read_text(encoding="utf-8"))
document["interrupts"][1]["group_bit"] = 0
result = validate(write_invalid_topology(tmp_path, document))
assert result.returncode != 0
assert "interrupt group ribp bit 0 is duplicated" in result.stderr
assert "interrupt group apb4 bit 0 is duplicated" in result.stderr
document = json.loads(TOPOLOGY.read_text(encoding="utf-8"))
document["interrupts"][1]["core_bit"] = 0
@@ -353,7 +352,7 @@ def test_generated_rib_routes_select_and_return_the_expected_target(tmp_path: Pa
topology_output = tmp_path / "topology"
generate(topology_output)
source_list = tmp_path / "ribp_topology.fl"
source_list = tmp_path / "apb4_topology.fl"
source_list.write_text(
"\n".join(
[
@@ -362,15 +361,15 @@ def test_generated_rib_routes_select_and_return_the_expected_target(tmp_path: Pa
f"+incdir+{topology_output / 'rtl'}",
f"+incdir+{ROOT / 'rtl/managed/clusterip/common/rtl'}",
f"+incdir+{ROOT / 'rtl/managed/clusterip/common/rtl/interface'}",
str(ROOT / "rtl/managed/clusterip/common/rtl/interface/ribp_if.sv"),
str(ROOT / "rtl/managed/clusterip/common/rtl/interface/apb4_if.sv"),
str(ROOT / "rtl/managed/clusterip/common/rtl/utils/register.sv"),
str(ROOT / "tests/rtl/ribp_topology_tb.sv"),
str(ROOT / "tests/rtl/apb4_topology_tb.sv"),
"",
]
),
encoding="utf-8",
)
converted = tmp_path / "ribp_topology_tb.v"
converted = tmp_path / "apb4_topology_tb.v"
subprocess.run(
[
sys.executable,
@@ -382,13 +381,13 @@ def test_generated_rib_routes_select_and_return_the_expected_target(tmp_path: Pa
],
check=True,
)
simulation = tmp_path / "ribp_topology_tb"
simulation = tmp_path / "apb4_topology_tb"
subprocess.run(
[
iverilog,
"-g2012",
"-s",
"ribp_topology_tb",
"apb4_topology_tb",
"-o",
str(simulation),
str(converted),
@@ -396,4 +395,4 @@ def test_generated_rib_routes_select_and_return_the_expected_target(tmp_path: Pa
check=True,
)
result = subprocess.run([vvp, str(simulation)], text=True, capture_output=True, check=True)
assert "SoC topology RIBP routing test passed" in result.stdout
assert "SoC topology APB4 routing test passed" in result.stdout