Difference between revisions of "FPGA Reader"

From UConn PAN
Jump to navigation Jump to search
m
m
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
:''See also [[Programming_the_Ethernet_controller|Programming the Ethernet Controller]]'' for a survey of modules and a general discussion of FPGA design approach.''
 +
 
= (011) Read Packet =
 
= (011) Read Packet =
  
This block performs the initial reading of the packet. It skips through the packet header and reads the first two bytes of the payload, which contain the target location and packet type. (The latter is not to be confused with the packet type specified in the packet header. Our packets have a separate branding convention.) Based on these, the module will reject the packet (request a "skip" of the packet in the receive FIFO buffer) if the packet's contents will not be necessary further. The Reader will return control to the [[FPGA_Idler|Idler (010)]] if the packet is not addressed to its location or the packet type is invalid. Otherwise it will yield control to the module relevant to the packet type.
+
[[Image:ReaderProcess.png|thumb|236px|Process flow of the Reader module. "my_Loc" represents either the constant 8-bit value hard-coded into the slot to which the digital board is attached or the wild card: 0xFF]]
 +
 
 +
This block performs the initial reading of the packet. It skips through the packet header and reads the first two bytes of the payload, which contain the target location and packet type. (The latter is not to be confused with the packet type specified in the packet header. Our packets have a separate branding convention.) Based on these, the module will reject the packet (request a "skip" of the packet in the receive FIFO buffer) if the packet's contents will not be necessary further. The Reader will return control to the [[FPGA_Idler|Idler (010)]] if the packet is not addressed to its location or the [[Ethernet_packets|packet type]] is invalid. Otherwise it will yield control to the module relevant to the packet type. This selection is diagrammed in the adjacent figure.
 +
 
 +
 
 +
As implied in the diagram, packet types R and Q (Reset and Query respectively) do no carry any data for the FPGA: their role is to order reset or request feedback from the sensor chips. Soft Reset and Programmer, on the other hand require certain reset/configuration data and DAC voltage values respectively, so these packets are kept. (It becomes the responsibility of these modules to dismiss these packets when finished.)
 +
 
 +
Instead of implementing MAC address filtering, necessitating a lookup table of MAC address to Energy channel group, it was seen as more convenient to include an 8-bit bus into the slots for the digital boards, each hard-wired to hold a unique location value. Knowing the number of energy channels controlled on each board, the packet addressing is straightforward. Packet filtering is also made easy for the Reader: it requires a simple 8-bit comparison between the hard-coded value and that in the first byte of the packet payload.
 +
 
 +
 
 +
== Programming Details ==
 +
 
 +
[[Image:PacketFormat.png|thumb|325px|Custom format of the packets exchanged between digital control boards and the PC.]]
 +
 
 +
The module is implemented as a counter of bytes read with the auto-read interface of the Ethernet Controller chip (EC) starting from the beginning of the header. ''AutoRd'' module is instantiated and is pulsed on each counter click. Upon reading the 15th, the location is checked for match to the board slot's hardwired location (''LocStamp'' port listed below). Upon the 16th byte, the packet type is checked. Packet rejection (skipping in the receive buffer) if performed by writing "00000010" to RXCN (0x11) control register. (See the CP220x manual for more information.) ''wrToAddr'' module is instantiated and is pulsed by the Discard signal which may be turned high at any point of the selection process.
 +
 
 +
Note that after stepping through the 14 bytes of the packet header and reading the first two bytes of the payload it leaves the receive (Rx) buffer pointer on the 17th byte (or 3rd byte of payload). The Soft Reset and Programmer modules can continue reading with the auto-read interface to access the data relevant to them.
  
[[Image:ReaderProcess.png|frame]]
 
  
Block 011 is the only block with switching between following states.  Its first task is to load the MAC data of the packet.  If filtering inside of the FPGA is required, this block is responsible for it.  The only MAC filtering likely to be needed is a check to see if the destination MAC address matches the MAC address of the CP2200/1, but the CP2200/1 should filter this itself (verify in the data sheet).  If the packet is bad, this block tells the CP2200/1 to skip the packet and returns to block 010.  The MAC filter would be the first substate.
+
=== Ports ===
  
After MAC filtering comes the second substate (or the only substate if MAC filtering is found to be unnecessary).  This reads the first byte of the packet's data and uses it as a switch to determine the transition to the next state:
+
* ''Clk'': [in] clock
{| align="center" cellpadding="4" border="0" cellspacing="0" style="text-align:center"
+
* ''Rst'': [in] asynchronous reset
! ASCII
 
|   
 
! Next State
 
|-
 
| R ||      || 000
 
|-
 
| Q ||      || 100
 
|-
 
| P ||      || 110
 
|-
 
| other ||      || 010
 
|}
 
Anything other than the three defined packets is considered a bad packet and is discarded in the CP2200/1 before transitioning back to state 010.  An "R" packet obtains the reset mask from the second byte then discards the packet before transitioning to state 000.  State 000 assumes that the reset mask is held, so this output needs to be latched in place until the next time this block activates.  A query has no switches or masks on it, so a "Q" packet will be discarded from the CP2200/1 before continuing on.  A "P" packet has a large amount of data attached to it, so that is the only packet not discarded before continuing to the next state.  This allows later states to access the packet data, but also puts on those later states the responsibility for discarding the packet once finished with it.
 
  
  
Stepping through the 14 bytes of the packet header and reading the first two bytes of the payload it leaves the receive (Rx) buffer pointer on the 17th byte (or 3rd byte of payload).
+
[[FPGA_Registers#State_Register|State Register]] Control Lines
 +
* ''state_En'': [out] state register enable (write) signal
 +
* ''state_D'': [out] (3-bit) state register input
 +
* ''state_Q'': [in] (3-bit) state register output
  
  
inputs
+
* ''LocStamp'': [in] 8-bit board location value as hard-coded into the board's slot
* ''Clk'': clock
 
* ''/Rst'': asynchronous, active-low reset
 
* ''State'': 3-bit state value
 
* - transceiver control lines -
 
  
internal signals
 
* ''S_En'': state enable, ''S_En'' <= not (''St(2)'' or ''St(1)'' or ''St(0)'')
 
* ''Go'': when ''S_En'' goes high ''Go'' pulses for one cycle
 
  
blocks
+
[[FPGA_Transceiver|Transceiver]] Control Lines
* '''MAC Filter'''
+
* ''TxRx_Go'': [out] "Go" signal to read/write an EC control register byte
** This block checks that the MAC address in the packet destination field is the same as the MAC address of the board.  If not the packet is discarded, if so then the MAC data (destination and source MAC address, packet length) are discarded and processing continues.
+
* ''TxRx_RiW'': [out] active-high read, active-low write flag
** inputs
+
* ''TxRx_Aout'': [out] EC control register address (8-bit)
*** ''Clk'': clock
+
* ''TxRx_Dout'': [out] EC control register write value
*** ''/Rst'': asynchronous, active-low reset
+
* ''TxRx_Din'': [in] EC control register return value
*** ''Go'': pulse to begin
+
* ''TxRx_Done'': [in] "Done" signal from [[FPGA_Transceiver|Transceiver]]
*** - transceiver control lines -
 
** outputs
 
*** ''Discard'': pulse to State Advance to discard packet and return to 010
 
*** ''Continue'': pulse to Switch to continue processing
 
*** - transceiver control lines -
 
* '''Switch'''
 
** This block reads the first data byte of the packet and uses it as a switch to direct the state machine to the appropriate next step.
 
** inputs
 
*** ''Clk'': clock
 
*** ''/Rst'': asynchronous, active-low reset
 
*** ''Go'': pulse to begin
 
*** - transceiver control lines -
 
** outputs
 
*** ''Discard'': pulse to State Advance to discard packet and return to 010
 
*** ''Reset_000'': pulse to State Advance to discard packet and go to 000
 
*** ''Query'': pulse to State Advance to discard packet and go to 100
 
*** ''Program'': pulse to State Advance to keep packet and go to 110
 
*** - transceiver control lines -
 
* '''State Advance'''
 
** This block has several ''Go'' lines and based on which is pulsed the next state is set up by loading a new state value into the state register.  It also discards packets other than "P".
 
** inputs
 
*** ''Clk'': clock
 
*** ''/Rst'': asynchronous, active-low reset
 
*** ''Discard'': pulse to discard packet and return to 010
 
*** ''Reset_000'': pulse to discard packet and go to 000
 
*** ''Query'': pulse to discard packet and go to 100
 
*** ''Program'': pulse to keep packet and go to 110
 
*** - transceiver control lines -
 
** outputs
 
*** ''Done'': pulse to signal completion; connects to state register enable
 
*** ''New_St'': new state to load to state register; goes to 000, 010, 100, or 110 when ''Done'' is high depending on switching
 
*** - transceiver control lines -
 

Latest revision as of 00:15, 3 June 2008

See also Programming the Ethernet Controller for a survey of modules and a general discussion of FPGA design approach.

(011) Read Packet

Process flow of the Reader module. "my_Loc" represents either the constant 8-bit value hard-coded into the slot to which the digital board is attached or the wild card: 0xFF

This block performs the initial reading of the packet. It skips through the packet header and reads the first two bytes of the payload, which contain the target location and packet type. (The latter is not to be confused with the packet type specified in the packet header. Our packets have a separate branding convention.) Based on these, the module will reject the packet (request a "skip" of the packet in the receive FIFO buffer) if the packet's contents will not be necessary further. The Reader will return control to the Idler (010) if the packet is not addressed to its location or the packet type is invalid. Otherwise it will yield control to the module relevant to the packet type. This selection is diagrammed in the adjacent figure.


As implied in the diagram, packet types R and Q (Reset and Query respectively) do no carry any data for the FPGA: their role is to order reset or request feedback from the sensor chips. Soft Reset and Programmer, on the other hand require certain reset/configuration data and DAC voltage values respectively, so these packets are kept. (It becomes the responsibility of these modules to dismiss these packets when finished.)

Instead of implementing MAC address filtering, necessitating a lookup table of MAC address to Energy channel group, it was seen as more convenient to include an 8-bit bus into the slots for the digital boards, each hard-wired to hold a unique location value. Knowing the number of energy channels controlled on each board, the packet addressing is straightforward. Packet filtering is also made easy for the Reader: it requires a simple 8-bit comparison between the hard-coded value and that in the first byte of the packet payload.


Programming Details

Custom format of the packets exchanged between digital control boards and the PC.

The module is implemented as a counter of bytes read with the auto-read interface of the Ethernet Controller chip (EC) starting from the beginning of the header. AutoRd module is instantiated and is pulsed on each counter click. Upon reading the 15th, the location is checked for match to the board slot's hardwired location (LocStamp port listed below). Upon the 16th byte, the packet type is checked. Packet rejection (skipping in the receive buffer) if performed by writing "00000010" to RXCN (0x11) control register. (See the CP220x manual for more information.) wrToAddr module is instantiated and is pulsed by the Discard signal which may be turned high at any point of the selection process.

Note that after stepping through the 14 bytes of the packet header and reading the first two bytes of the payload it leaves the receive (Rx) buffer pointer on the 17th byte (or 3rd byte of payload). The Soft Reset and Programmer modules can continue reading with the auto-read interface to access the data relevant to them.


Ports

  • Clk: [in] clock
  • Rst: [in] asynchronous reset


State Register Control Lines

  • state_En: [out] state register enable (write) signal
  • state_D: [out] (3-bit) state register input
  • state_Q: [in] (3-bit) state register output


  • LocStamp: [in] 8-bit board location value as hard-coded into the board's slot


Transceiver Control Lines

  • TxRx_Go: [out] "Go" signal to read/write an EC control register byte
  • TxRx_RiW: [out] active-high read, active-low write flag
  • TxRx_Aout: [out] EC control register address (8-bit)
  • TxRx_Dout: [out] EC control register write value
  • TxRx_Din: [in] EC control register return value
  • TxRx_Done: [in] "Done" signal from Transceiver