Bifrost Development Group
Designs For Your World

From EE Times blog, "Programmable Logic Designline":

Implementing a multi-peripheral controller using a tiny mixed-signal FPGA

Max Maxfield
September 25, 2015

As you may recall from previous columns, I tend to think of Silego's
GPAK chips as being super-small mixed-signal FPGAs that you can
literally design and program in just a few minutes, and that cost only a
few cents each.
Well, the folks at Silego were so excited by the interest my columns generated within the and communities that they decided to offer 25 development kits for free (see Want a free Silego GPAK4 mixed-signal FPGA development kit?).
The idea was that and community members would email me to excite me and delight me with descriptions of the amazing hobby or work projects they might use GPAK4 devices for, thereby convincing me that they deserved to receive one of these little beauties.
Two weeks later, I sauntered into the Pleasure Dome (my office), ensconced myself in my Supreme Commander's Chair with its super-soft cuddly cushion, and selected the 25 entries that most ignited my imagination and whipped my creative juices into a frenzy (see 25 Free Silego development kits will soon be winging their way).
After this, things went quiet for a while, until earlier today when I heard from one of the lucky recipients, J.R. Stoner, who is principal engineer (and self-described "chief bottle-washer") at the Bifrost Development Group.
In his email, J.R enclosed the .gp4 (GPAK4) design file associated with his latest project, which is a multi-peripheral controller (click here to download a compressed ZIP file containing the .gp4 design file along with the images presented below). The schematic for the portion of the design featuring the GPAK4 chip (a 20-pin SLG46620 device) is shown below.
Download .GP4 file
J.R. tells me that he's verified both the digital and analog functions in
simulation -- using Silego's free GreenPak Developer application -- and
he's now working on the actual hardware. The graphical interface used
to capture the design and screenshots of some of the simulation results
are shown below.
[Update: The two GreenPak layout drawings for the digital and analog sections have been updated to better manage the clocking of the ADC output to the SPI register.  Note the addition of the P0 crossover line.
Digital logic elements and SPI register. Note the ADC and pre-amplifier is located here since these units are located in this "half" of the SLG46620.
Measured quadrature "UP" sequence.
Measured quadrature "DOWN" sequence.
SPI register count sequence.  Note the count has increased by four after a single "UP" cycle.  This is due to the four STEP pulses, one for each phase change in A and B.  The 8 MSB of the SPI are the current quadrature counter value, while the 8 LSB are the current temp sense value from the thermistor.
PWM variable-speed fan controller elements.
Theory of Operation
J.R. says that the logic is related to a common XOR method of quadrature decoding, plus the input signals are synchronized to the oversampling clock. The SPI output for both the fan PWM and the quadrature up/down counter have been confirmed at the pin level. The up/down DIR selector is derived from the XOR of one of the quadrature phases (A) and the latched other phase (B).
The four-input XOR is an odd-parity generator connected to both synchronized phases -- and their latched equivalents -- through the final pair of D flops. This is used to generate the FSM0 counter clock pulses, one for each of the four phase transitions per unit of the quadrature signal. The latch clock for DFF 1 is derived from the 25 kHz RC clock, so each phase transition (STEP) pulse width is 40 µs.
Each time a quadrature cycle is detected, the SPI counter will increment or decrement by four, which is then read out the SPI serializer as the MSB (most-significant bit). The intention is to measure all phase transitions in the SPI counter, stripping off the two LSBs (least-significant bits) of the count, thereby reducing the sampling noise by 12dB.
The /SWIN to SWOUT unit is a simple de-bouncer for the UI selector for this project.
The analog-to-digital converter (ADC) reads the temp sensor, which is loaded directly into the LSB of the SPI serializer. DLY7 is a ring oscillator delay of 7.22 µs to eliminate startup glitch from the sweep count during ADC startup. And CNT8 is a period sweep counter, which is used to gate the PWM unit.
Advantages of the GPAK4

J.R. also says that one could envisage a simpler hardware implementation involving feeding A, B, and SWxx to the MCU's GPIO pins (of which not many are likely to be available) coupled with an external DAC circuit (which would have to be used for the thermistor).  However, the GPIO pins would have to be software de-bounced, while the DAC would require yet more GPIO pins. Then separate ISR (interrupt service routines) -- or clocked polling -- would have to be written to handle the devices at a level that would consume too much time resources from the main CPU.

The biggest wins in using the GPAK4 device for these functions are (a) simplification of the interfaces to a single SPI channel, (b) intrinsic de-bounce of the mechanical inputs, (c) automatic conversion of the analog thermistor signal to a 12V PWM fan, and most importantly (d) complete asynchrony between the quadrature input device and the SPI register, which provides not only an up/down counter for the encoder, but also a non-interrupt way of detecting over-temp on the thermal sensor. Also, there is significant simplification of the board layout using one itty-bitty 4mm device.

But wait, there's more...

Well, I hope there's more LOL. I am really impressed with what I see here. Not only has J.R. used his GPAK4 development kit to implement a real-world solution, he's provided sufficient into the design to allow the rest of us to stand on his shoulders, as it were.

In the coming weeks and months, I'm hoping some of the other recipients of the GPAK4 dev kits will share the projects they've been working on using the material provided by J.R. as the standard to meet or beat (but no pressure LOL). In the meantime, what do you think of J.R.'s GPAK4 application?