Adressable SPI

Sometimes I wish that SPI slaves have an address similar to I2C devices. Then I could connect all SPI devices to the same 4 lines: SCK, MOSI, MISO and SS. This would save all but one salve select lines. Pull SS low, send address, the addressed device listens and enables its MISO, the rest as usual. When finished talking to the selected device raise SS.

A long time ago I was talking to a friend about this idea, and if it is possible to put this into a GAL. The answer is yes.

Please excuse but I forgot the Jedec notation. And ofcourse the following code is untested.

Inputs:
  A0..A7 - SPI address
  MMOSI - Master MOSI
  MSCLK - Master SCLK
  SMISO - Slave MISO
  SS - Slave Select Input
Outputs:
  ADBOK - Address Bit OK
  ADOK - Address OK = Slave Select Output
  ADNOK - Address NOK
  C0..C2 - Counter
  MMISO - Master MISO

OLMCs in combinatorial mode:

ADBOK = /C0*/C1*/C2* A0* MMOSI + /C0*/C1*/C2*/A0*/MMOSI
      + C0*/C1*/C2* A1* MMOSI + C0*/C1*/C2*/A1*/MMOSI
      + /C0* C1*/C2* A2* MMOSI + /C0* C1*/C2*/A2*/MMOSI
      + C0* C1*/C2* A3* MMOSI + C0* C1*/C2*/A3*/MMOSI
      + /C0*/C1* C2* A4* MMOSI + /C0*/C1* C2*/A4*/MMOSI
      + C0*/C1* C2* A5* MMOSI + C0*/C1* C2*/A5*/MMOSI
      + /C0* C1* C2* A6* MMOSI + /C0* C1* C2*/A6*/MMOSI
      + C0* C1* C2* A7* MMOSI + C0* C1* C2*/A7*/MMOSI
MMISO = SMISO
MMISO.OE = /ADOK
ASYNC_RESET = /SS

OLMCs in registered mode:

C0 := /C0* ADBOK*/ADNOK
C1 := C0*/C1* ADBOK*/ADNOK
    + /C0* C1* ADBOK*/ADNOK
C2 := C0* C1*/C2*ADBOK*/ADNOK
    + /C0* C2*ADBOK*/ADNOK
    + /C1* C2*ADBOK*/ADNOK
/ADOK := C0* C1* C2*ADBOK*/ADNOK + ADOK
ADNOK := /ADBOK + ADNOK

This fits into a GAL22V10. I’m not 100% sure but I think it would also fit into a GAL16V8 but the ADBOK terms would have to be put into two OLMCs.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>