<<

API

Internal

This section contains internal documentation - that is the bits that make up the ethercat controller.

mii_ethercat_ports

Structure containing all the ports of an MII PHY.

Structure Members:

clock clk_mii_rx

RX Clock Block.

clock clk_mii_tx

TX Clock Block.

port p_mii_rxclk

MII RX clock wire.

in buffered port:8 p_mii_rxd

MII RX data wire.

in port p_mii_rxdv

MII RX data valid wire.

port p_mii_txclk

MII TX clock wire.

out buffered port:8 p_mii_txd

MII TX data wire.

out port p_mii_txen

MII TX enable wire.

void ethercat_port_init(mii_ethercat_ports &m)

Function that initialises the ports and clockblocks that control the PHY.

This needs to be called once for each PHY.

Parameters:
  • m – port structure.
void rxProcessS(in port dataValid, buffered in port:8 rxData, streaming chanend toProtocol, int &destinationChannel)

Function that receives data on the master port.

Only frames arriving on this port are interpreted. This function reads byte from the input port (guarded by the datavalid port), and outputs them on the channel. The data stream is opened with control token 3 (indicating that a valid CRC will eb transmitted at the end of the stream) and terminated with two control tokens. One control token to signal the CRC status (15: CRC error, 0: CRC good), and an END token.

Parameters:
  • dataValid – port that signals whether rxData contains valid data.
  • rxData – port on which data arrives, must be byte buffered
  • toProtocol – channel end on which packet is transmitted
  • destinationChannel – channelend to use as destination - can be modified on the fly
void txProcess(buffered out port:8 txData, streaming chanend fromProtocol)

Function that transmits data on an mii port.

This function reads bytes from an input channel, and outputs them one byte at a time. Data should arrive fast enough to prevent a gap in the packet.

The first token is a control token: a zero control token indicates that the transmitter should append a CRC; a non-zero control token indicates that a valid CRC is included at the end of the message. After the initial control token, a stream of data bytes are expected on the channel, terminated by a control token. The terminating token is either 0 or 0xF depending on whether the CRC on the incoming packet was valid or not. If the TX function was asked to add a valid CRC, and the incoming CRC was deemed invalid, then it will knacker the outgoing CRC too. Just to be consistent. Finally a ‘1’ control token is read closing the stream.

Parameters:
  • txData – port on which data is transmitted, must be byte buffered.
  • fromProtocol – channel on which data arrives
void frameProcess(streaming chanend fromRx, streaming chanend toTx, int &destination, short memory[])

Function that processes all frames.

Frames are streamed in over fromRx and streamed out over toTx. The data streams are opened with control token 3 and terminated with two control tokens. One control token to signal the CRC status (15: CRC error, 0: CRC good), and an END token.

Parameters:
  • fromRx – stream into the process, comes from rxProcessS()
  • toTx – stream into the process, goes to txProcess()
  • destination – channel end where to send to.
  • memory – array of words that contains the Ethercat memory.

Ethercat