mandag den 12. marts 2012

Hierarki Blocks in gSchem

So, hierarki block in gschem, is not that easy as in other EDA tools.
First you have to create the subcircuit, and then you have to create the symbol, that you then can put in your overview circuit.

This is a feature that is quite useful, as then you can create a modular circuit, this mean that if you have a circuit that you will reuse, or if you just want a better overview over of your diagram.

For example, take a look at the gTAG circuit from the geda-example package on my machine it is located, at /usr/share/doc/geda-examples/examples/gTAG :
Of course I use this example, because this a uses hierarki block schematic, but as you can see this is useful when you have a big schematic, to put you circuit into smaller section. Or if you just want to reuse an "old" schematic.
The blocks attributes is shown on the following picture:
As we can see it has an attribute called "source" which directs it to "gTAG-psu.sch", this directs the gschem to the circuit represented by the symbol called, "gTAG-psu".
So if we want our schematic to have this hierarki blocks, then we need to create a symbol and a schematic before we can add it the overview schematic.
Hopeful some day, an feature to gschem is added, so you just can draw an square, slap some pins on it and it will create the symbol and underlying schematic, with the inputs and output in it.

But until further, I have created a script that, takes an schematic and creates a block symbol from it. There is some limits on this scripts, so I will name them here:

  • Use of symbol: "in-1.sym" to indicate a input port
  • Use of symbol: "out-1.sym" to indicate a output port
This scripts, will create a file called "yournameofsch.src", this file is a tragesym file, that then is need to be put through "tragesym" to create the symbol for your circuit.
Add this symbol to your schematic, open the attributes for this symbol, and add "source=yournameofsch.src" to it. This is so that it points to your circuit. 
Then you should be done, do this for all your subcircuits.

Just a warning, this script is not mean to be a permanent solution, this is only a temporary solution for this. I am also currently working on a new version, that does not rely on "tragesym" to create the symbol, but could take awhile before this is done.   

Hopes this help somebody