diff --git a/docs/source/getting_started.md b/docs/source/getting_started.md index 4987268f..bfc5f246 100644 --- a/docs/source/getting_started.md +++ b/docs/source/getting_started.md @@ -103,12 +103,14 @@ ips: parameters: wb_ram_data_instance: depth: 0x1000 - memfile: "top_sram.init" + memfile: '"top_sram.init"' wb_ram_instr_instance: depth: 0xA000 - memfile: "bios.init" + memfile: '"bios.init"' ``` +Note that string parameters have to be wrapped in single quotation marks like this: `'"string value"'`. + - Connect desired ports of the IP cores: ```yaml diff --git a/examples/soc/project.yaml b/examples/soc/project.yaml index f779631a..1059999c 100644 --- a/examples/soc/project.yaml +++ b/examples/soc/project.yaml @@ -22,7 +22,7 @@ design: depth: 0x1000 wb_ram_instr: depth: 0xA000 - memfile: "build/bios.init" + memfile: '"build/bios.init"' ports: wb_ram_data: sys_clk: clk100 diff --git a/tests/data/data_build/interconnect/project.yml b/tests/data/data_build/interconnect/project.yml index 9351c441..fbd9074b 100644 --- a/tests/data/data_build/interconnect/project.yml +++ b/tests/data/data_build/interconnect/project.yml @@ -16,10 +16,10 @@ design: parameters: wb_ram_data: depth: 0x1000 - memfile: "top_sram.init" + memfile: '"top_sram.init"' wb_ram_instr: depth: 0xA000 - memfile: "top_rom.init" + memfile: '"top_rom.init"' ports: wb_ram_data: sys_clk: clk100 diff --git a/tests/tests_build/test_ip_wrapper.py b/tests/tests_build/test_ip_wrapper.py index 9b946399..75d3d0a8 100644 --- a/tests/tests_build/test_ip_wrapper.py +++ b/tests/tests_build/test_ip_wrapper.py @@ -45,6 +45,16 @@ def axi_dispctrl_ipw_overriden(axi_dispctrl_name, axi_dispctrl_path) -> IPWrappe ) +@pytest.fixture +def axi_dispctrl_ipw_custom_params(axi_dispctrl_name, axi_dispctrl_path) -> IPWrapper: + return IPWrapper( + axi_dispctrl_path, + axi_dispctrl_name, + axi_dispctrl_name, + {"EX_WIDTH": 8, "EVAL_WIDTH": "EX_WIDTH/2", "EX_STRING": '"STRING"'}, + ) + + # ---------------------------------------------------------------------------- # Names of ports that should be created while initializing `IPWrapper` objects # ---------------------------------------------------------------------------- @@ -169,3 +179,10 @@ def test_get_port_by_interface(self, axi_dispctrl_ipw, axi_dispctrl_interfaces): with pytest.raises(ValueError): axi_dispctrl_ipw.get_ports_of_interface("non_existing_iface_name") + + def test_params_evalutaion(self, axi_dispctrl_ipw_custom_params): + assert axi_dispctrl_ipw_custom_params._parameters == { + "p_EX_WIDTH": 8, + "p_EVAL_WIDTH": 4.0, + "p_EX_STRING": "STRING", + } diff --git a/topwrap/ipwrapper.py b/topwrap/ipwrapper.py index f6af7b3c..1b3a15ab 100644 --- a/topwrap/ipwrapper.py +++ b/topwrap/ipwrapper.py @@ -49,9 +49,10 @@ def _evaluate_parameters(params: dict): params[name] = simple_eval(param, names=params) except Exception as e: error(f"evaluating expression {name} failed with the following message: {str(e)}") + raise -def _eval_bounds(bounds, params): +def _eval_bounds(bounds, params: dict): """Replace parameter-dependent values with numbers""" result = bounds[:] for i, item in enumerate(bounds):