From a33644a8ad3ba8c4baed3ecf60999fb5ab966be9 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Tue, 8 Aug 2017 16:09:44 -0400 Subject: Allow core instantation parameters. --- config/core_config.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'config/core_config.py') diff --git a/config/core_config.py b/config/core_config.py index 3f75243..4de8f16 100755 --- a/config/core_config.py +++ b/config/core_config.py @@ -235,6 +235,11 @@ class Core(object): self.dummy = cfg.get(self.cfg_section, "dummy") if self.dummy: self.dummy = self.dummy.replace("\n", "\n ") + "\n" + self._parameters = dict() + if cfg.has_section(self.cfg_section): + for option in cfg.options(self.cfg_section): + if option.startswith("parameter "): + self._parameters[option[len("parameter"):].upper().strip()] = cfg.get(self.cfg_section, option) @property def instance_name(self): @@ -274,6 +279,13 @@ class Core(object): def mux_error_reg(self): return "error_" + self.instance_name if self.error_wire else "0" + @property + def parameters(self): + if self._parameters: + return "#( {} ) ".format(", ".join(".{} ({})".format(k, v) for k, v in self._parameters.iteritems())) + else: + return "" + def createInstance(self): template = createInstance_template_dummy if self.dummy else createInstance_template_generic if self.blocks == 1 else createInstance_template_multi_block return template.format(core = self) @@ -325,7 +337,7 @@ createInstance_template_generic = """\ wire enable_{core.instance_name} = (addr_core_num == CORE_ADDR_{core.upper_instance_name}); wire [31: 0] read_data_{core.instance_name};{core.error_wire_decl} - {core.module_name} {core.instance_name}_inst + {core.module_name} {core.parameters}{core.instance_name}_inst ( .clk(sys_clk), .reset_n(sys_rst_n), @@ -353,7 +365,7 @@ createInstance_template_multi_block = """\ wire [31: 0] read_data_{core.instance_name};{core.error_wire_decl} wire [{core.block_bit_max}:0] {core.instance_name}_prefix = addr_core_num[{core.block_bit_max}:0] - CORE_ADDR_{core.upper_instance_name}; - {core.module_name} {core.instance_name}_inst + {core.module_name} {core.parameters}{core.instance_name}_inst ( .clk(sys_clk), .reset_n(sys_rst_n), -- cgit v1.2.3