Help with Lucid - Structs and Globals

Hi,
I was hoping that somebody (probably at Alchitry) might feel like writing a short tutorial about how to use Structs and Globals.
I feel like they could help simplify my designs, but I am honestly at a loss for how to use them.

I bought Justin’s book (see cheesy photo), and that was a great help when I was just starting with my first projects, but the sections on structs and globals have just left me confused.

For instance, how “global” really is a globally defined struct?
Can I define it in one module, then make an instance of it in another module, and assign members to different things like a dff?
Can I even have multiple instances of the same struct?
Is that question even meaningful?
Does a struct either have to be wholly an input or wholly an output?
If something is a global (like a struct), why would I bother putting it in a module port list as an input or output, since I should just be able to refer to it from anywhere. ???

I have read the relevant sections multiple times, and attempted to just figure out structs/globals out by trial and error, but honestly, I’m just confused as hell.

I’ll keep spreading the good word about Alchitry/Lucid regardless, but any help would be greatly appreciated.

Structs are really just like arrays but with the sub-indices renamed to convenient names/shortcuts (and this is how it is actually implemented). You can apply them to any type that can be an array using the <> syntax. When you define a struct you are really just defining the naming scheme not any useable signal.

The global block is just a way to share constants and structs across files. This is important when an input or output uses a struct as it wouldn’t be defined in the module trying to access it otherwise.

Since a port declaration can only be an input, output, or inout, when you apply a struct to it it is still one of these. The struct itself is neither. It is simply a list of names applied to the input/output/inout/dff/sig.

The SDRAM tutorial has some more info on using both of these https://alchitry.com/blogs/tutorials/sdram