@Jorge Marin: Sorry, I have not written a tutorial for the device generator. You can work from example from the Tcl code for the sky130 technology, although much of it is probably not very easy to understand at a glance. Each device has a "draw" routine, although that routine is typically broken into a single device drawing routine, and a higher-up routine that draws N x M devices in an array. I use some simple extra Tcl-scripted routines "pushbox" and "popbox" to save and recall the position of the cursor box in a stack-like manner (last in, first out). Each device has a "defaults" routine that declares parameters that are useful for the device, and generates a Tcl dictionary of parameter key:value pairs, which gets passed to all routines. Along the way, the parameters dictionary gets merged with other dictionaries, such as one that contains a lot of common dimensions like minimum width and spacing rules. So the drawing routine is mostly just a lot of geometry math, figuring out how much space to allow for guard rings and contacts and such, then configuring the cursor box and calling magic's basic paint and erase commands. Most of the drawing routines could be more cleanly written if I spent some time to work on them.