Libraries and projects · 3 of 3
Project: splitter tree
The last project uses nearly everything in the tour: a splitter tree that divides one input into 2level outputs, built from 1×2 MMI splitters joined by S-bends.
MMI1x2 is given; its two outputs sit out_offset above and below its axis. The tree grows one level at a time. At each level it places a splitter on every port that still needs feeding and fans the two outputs of that splitter apart with S-bends:
- the first level has one splitter, at the input, and spreads its outputs to
spread / 2above and below its axis; - each following level has twice as many splitters and half the spread;
- after
levellevels, neighbouring outputs arepitchapart, so the first spread ispitch × 2^(level − 1).
The key is a list of ports. It starts as [self.origin]; at every level, a loop over it places the splitters and collects the outputs of their S-bends in a new list, which replaces the old one for the next level.
The S-bend that goes up shifts by spread / 2 − mmi.out_offset, since the output it starts from is already out_offset above the axis; the one that goes down shifts by the negative of that.
Exercise
Write the body of MMITree so that it builds the tree for any level and pitch, starting with a splitter at the origin.
That is the end of the tour. The language reference and the playground are good places to go on from here.