VHDL implementation of the SPI interface for Pmod NIC100 https://store.digilentinc.com/pmod-nic100-network-interface-controller/
After a reset, wait for busy
to go low
To send a packet
- Fill the Block RAM with the packet
- Set
tx_len
- Set
tx
- Wait for
busy
to go high - Unset
tx
- Wait for
busy
to go low
To receive a packet
- Set
rx
- Wait for
busy
to go high - Unset
rx
- Wait for
busy
to go low - Read
rx_len
bytes from Block RAM
Same as when using the simple interface. However, rx
and tx
should not be unset, as the hardware will take care of that. The following signals are mapped to the following registers:
Register | Signal | R/W |
---|---|---|
0 | busy |
R |
1 | bit0:rx, bit1:tx |
W |
2 | rx_len |
R |
3 | tx_len |
W |
The VHDL file consists of two state machines:
A controller process, which issues either read or write commands
A interface process, which communicates these read or write commands onto the pins of the Pmod NIC100
Note: in the current implementation, the controller process sends a predefined package.
The SPI interface of the Pmod NIC100 has an fmax at 14 MHz.
The status and debug signals should be ignored, as they will be removed in later iterations.
The current implementation uses a Block RAM as buffer, along with a few signals:
busy
output indicating that the controller is busy. This is pulled high during initialization, and when either sending or receiving a packet.rx
input indicating that the controller should receive a package, when pulled high.busy
should be low, otherwise this signal is ignored.rx_len
output indicating the size of the received packettx
input indicating that the controller should transmit a package, when pulled high.busy
should be low, otherwise this signal is ignored.tx_len
input indicating the size of the packet (required by the Pmod NIC100).
The second port of the Block RAM are also exposed:
ena
inputstd_logic
for enabling the Block RAMaddr
inputstd_logic_vector(10 downto 0)
for addressing the Block RAM. 11 bits were chosen, since a package can at most be 1500 bytes.wrena
inputstd_logic
for enabling writing to the Block RAM.wrdata
inputstd_logic_vector(7 downto 0)
for the data to be written to Block RAM.rddata
outputstd_logic_vector(7 downto 0)
for the data read from Block RAM.