@@ -175,6 +175,9 @@ def export(self, node: Union[RootNode, AddrmapNode], output_dir:str, **kwargs: A
175175 context = {
176176 "cpuif" : self .cpuif ,
177177 "hwif" : self .hwif ,
178+ "module_has_parameters" : self .module_has_parameters ,
179+ "get_module_parameter_list" : self .get_module_parameter_list ,
180+ "get_module_port_list" : self .get_module_port_list ,
178181 "write_buffering" : self .write_buffering ,
179182 "read_buffering" : self .read_buffering ,
180183 "get_resetsignal" : self .dereferencer .get_resetsignal ,
@@ -206,6 +209,47 @@ def export(self, node: Union[RootNode, AddrmapNode], output_dir:str, **kwargs: A
206209 if hwif_report_file :
207210 hwif_report_file .close ()
208211
212+ def module_has_parameters (self ) -> bool :
213+ return bool (self .cpuif .parameters )
214+
215+ def get_module_parameter_list (self ) -> str :
216+ return ",\n " .join (self .cpuif .parameters )
217+
218+ def get_module_port_list (self ) -> str :
219+ groups = []
220+
221+ # Main clock & reset
222+ clkrst = [
223+ "input wire clk" ,
224+ f"input wire { self .dereferencer .default_resetsignal_name } "
225+ ]
226+ groups .append (",\n " .join (clkrst ))
227+
228+ # Signals that were declared outside of the hierarchy of the addrmap
229+ # being exported
230+ out_of_hier_signals = []
231+ for signal in self .ds .out_of_hier_signals .values ():
232+ if signal .width == 1 :
233+ out_of_hier_signals .append (f"input wire { kwf (signal .inst_name )} " )
234+ else :
235+ out_of_hier_signals .append (f"input wire [{ signal .width - 1 } :0] { kwf (signal .inst_name )} " )
236+ if out_of_hier_signals :
237+ groups .append (",\n " .join (out_of_hier_signals ))
238+
239+ # Parity check error output
240+ if self .ds .has_paritycheck :
241+ groups .append ("output logic parity_error" )
242+
243+ # CPU interface ports
244+ groups .append (self .cpuif .port_declaration )
245+
246+ if self .hwif .has_input_struct or self .hwif .has_output_struct :
247+ groups .append (self .hwif .port_declaration )
248+
249+ return ",\n \n " .join (groups )
250+
251+
252+
209253
210254class DesignState :
211255 """
0 commit comments