Electronic – Sending data to CPLD

verilog

I have a small board that I designed myself containing a XC2C64A cpld that has 8 LEDS connected to output, and 2 input. It's not what I would have designed for this project but it's what I already have as I made it for another learning project to learn how to design and get pcb's manufactured.

I've connected the inputs to my Raspberry PI's GPIO ports and using one the pins as a clock (as there is no clock available on my board) and another for data and I can make it do things, so I know that everything is working electrically and it can read and write data between the two devices.

However I want to be able to send it a few commands over the single pin I have available. For example setting an LED on, setting an LED off, shifting them left, shifting the right, setting an auto-left rotate etc.

My question is what is the best way to do this? My first attempt was to write some verilog which expected 3 bits for a pin number followed bit on or off to handle the simple case of setting an LED. Now that works, sort of, but there is no way to synchronise it, I can't tell the difference between 000 – 0 to turn off LED0 and just being idle!

Has anyone got any suggestions how best to send my data over this single pin? It needs to be very simple as there isn't much space for logic on the CPLD once I've added in logic for the LED control.

Thanks for any suggestions 🙂

Best Answer

Some suggestions:

1) Implement I2C or SPI. You may be able to find free Verilog for this already.

2) If you just want to fix your existing protocol, then you need some sort of start condition. Putting '10' on the front might be sufficient. You may also want to define '000' as 'idle' if your clock is continuously running.