I have need to use programmable logic in the Alpha-X project and it was the perfect opportunity to learn some kind of HDL. I tried VHDL, but, I much prefer the Verilog variant, as it is the closest thing there is to ANSI C, and henceforth will use that rather.
The following design is beautifully simple and works every time, a simple SPI engine that uses two SPI byte transfers: [command] [data]
This means each transaction is two bytes, the first being a command code, the second being the data (if specified by the command)
For each command, an ACK or NAK is returned. And we have an asynchronous NRST input to reset the device when we boot the micro so that we initialize to a known state. The source for this module can be obtained here