Hierarchical sheets and PCB


I am searching for a way to manage some hierarchical sheets as reusable components. For example I have a DC/DC + LDO circuit prerouted on an individual sheet, it’s well tested and works well with this layout so I want to reuse it exactly the same way in several other boards.

Importing the sheet as a hierarchical sheet inside another project is pretty easy, now it becomes a lot harder when I also want the associated layout to be imported too inside my project. I searched and tried several ways but struggled to find a straightforward way to do this.

Is there a way to achieve such thing easily with kicad?

A direct way does not (yet) exist in kicad. If you start pcb_new in standalone mode you can append another pcb_file. Which means you could save your reusable part as a pcb_new file and append that to the current project.

You could also create a personal template that has your prerouted stuff already on it.

1 Like

Is there something in progress or is it something somewhere in a TODO list? :stuck_out_tongue:
In the same way there is hierarchical sheets it would be so great to have hierarchical PCB

I took a look on templates, this is too far away from what I need (somehow interesting, I didn’t known this functionality).

I found this in the roadmap for v6 (But i’m not sure how up to date this document is. Also v6 is a few years away from today. And this roadmap entry is only a prerequirement for reusable modules.):

Provide a way to allow external objects such as footprints to be externally linked in the board file so that changes in the footprint are automatically updated. This will allow a one to many object relationship which can pave the way for reusable board modules.

I found a method based upon parts timestamps:
Once a module is ready to be reused I copy the <module>.sch inside a subfolder in my project.
Then I create a hierarchical sheet in my project and uses as filename the <folder>/<module>.sch I just added. I can import it as many times I want.
For each hierarchical sheet I created I copy in <folder> the <module>.pcb and inside I replace each line containing:
path /<timestamp>
path /<sheet timestamp>/<timestamp>

Then I can start a standalone pcbnew and use the File/Append Board functionality (only available if started this way) to import each module pcb I created.

I can then import nets and every part should be well identified by its timestamp.

I will edit a script to make it more simple.

1 Like

@Rene_Poschl Thanks for pointing out the roadmap and the snippet on reusable board modules.

@turdusmerula First of all thank you for posting your findings. The steps you describe work perfectly. By looping through your steps ascendingly for each hierarchical tier, I was able to conjoin 22 sheets structured into a five tier hierarchical pcb (all without losing a trace). Think of it as a five sided pyramidal merge that resulted in a production ready pcb panel, Awesome!

With the success of a complex compilation, I’m lead to believe this process is in fact scriptable. Perhaps using python and the BOM generator plugins in Eeschema one could generate the .kicad_pcb copies?

I made a simple bash script on the back of an envelope as a proof of concept, had not yet the time to pythonise it as a kicad plugin.
You can find it on my repo pcbmodule.
It handles the process of creating each sheet pcb ready to be imported in kicad from a module. It works event if you add several times the same hierarchical sheet inside your design.

I didn’t had the idea to use nested hierarchical sheets so it will probably not work in your case, I will improve it later.

1 Like

I admit I’ve got a very complex project. Even so, the simple prepending of /<sheet timestamp> is all that’s needed for an Op to compose nested hierarchical sheets, and/or panel layouts to their desired result.

I’ll have a go at converting to py when time permits, and If I’m successful I’ll give it a push and post back here.

Thanks again for the input and the bash script.

Hi @turdusmerula, I’m trying to use your module to append multiple time the already routed module. Would you explain me (more step-by-step) how to use it?
I am follow the steps printed by the file but getting multiple sed: couldn't edit ./: not a regular file and cp: target '/FOLDER/).kicad_pcb' is not a directory.

1 Like