RE: sorry

"Zellal B" <[email protected]> Tue, 20 Jan 2004 07:13:36 +0000
Newsgroups gmane.org.handasarabia.general
Message-ID <[email protected]>
<html><div style='background-color:'><DIV class=RTE>
<P>am very sorry i have send u the wrong program.....this is the whole program and i wanted to divide it into 3 modules....i wish if u can guide me</P>
<P>-------------------------------------------------------------------------------<BR></P>
<P>library IEEE;<BR>use IEEE.std_logic_1164.all;<BR>use IEEE.std_logic_unsigned.all;<BR>use work.global_constants.all;</P>
<P>entity internet is<BR>&nbsp;&nbsp;&nbsp; port (<BR>&nbsp;&nbsp;clk: in STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- clock<BR>&nbsp;&nbsp;rstn: in STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- asynchronouse active low reset<BR>&nbsp;&nbsp;complete: in STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- control signal from ram arbitrator<BR>&nbsp;&nbsp;newFrame: in STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- new frame received from the layer below<BR>&nbsp;&nbsp;frameType: in STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- frame type = '1' for IP<BR>&nbsp;&nbsp;newFrameByte: in STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- signals a new byte in the stream<BR>&nbsp;&nbsp;frameData: in STD_LOGIC_VECTOR (7 downto 0);&nbsp;-- data is streamed in here<BR>&nbsp;&nbsp;endFrame: in STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- signals th
 e end of a frame<BR>&nbsp;&nbsp;frameValid: in STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- determines validity of frame when endFrame is high<BR>&nbsp;&nbsp;newDatagram: out STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- an IP datagram has been fully received<BR>&nbsp;&nbsp;bufferSelect: out STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- indicates location of data in RAM, '0' = 10000, '1' = 20000<BR>&nbsp;&nbsp;datagramSize: out STD_LOGIC_VECTOR (15 downto 0);&nbsp;-- size of the datagram received<BR>&nbsp;&nbsp;protocol: out STD_LOGIC_VECTOR (7 downto 0);&nbsp;&nbsp;-- protocol type of datagram<BR>&nbsp;&nbsp;sourceIP: out STD_LOGIC_VECTOR (31 downto 0);&nbsp;&nbsp;-- lets upper protocol know the source IP<BR>&nbsp;&nbsp;wrRAM: out STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- signal to write to the RAM<BR>&nbsp;&nbsp;wrData: out STD_LOGIC_VECTOR (7 downto 0);&nbsp;&
 nbsp;&nbsp;-- data to write to the RAM<BR>&nbsp;&nbsp;wrAddr: out STD_LOGIC_VECTOR (18 downto 0);&nbsp;&nbsp;&nbsp;-- address lines to the RAM for writing<BR>&nbsp;&nbsp;timeLED0: out STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- indicates if buffer 0 is busy<BR>&nbsp;&nbsp;timeLED1: out STD_LOGIC&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- indicates if buffer 1 is busy<BR>&nbsp;&nbsp;&nbsp; );<BR>end internet;</P>
<P>architecture internet_arch of internet is</P>
<P>-- signal declarations<BR>-- FSM states<BR>type STATETYPE is (stIdle, stGetHeaderLen, stGetHeaderByte, stStoreHeaderByte, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stGetDataByte, stSetupWriteDataByte, stCompleteFragment, stDoWrite, stgetNewByte);<BR>signal presState: STATETYPE;<BR>signal nextState: STATETYPE;<BR>signal returnState: STATETYPE;&nbsp;-- Used to return from RAM 'subroutines' </P>
<P>signal headerLen: STD_LOGIC_VECTOR (5 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;-- IP datagram header length<BR>signal nextHeaderLen: STD_LOGIC_VECTOR (5 downto 0);&nbsp;&nbsp;&nbsp;-- signal for the next header lengh<BR>signal datagramLen: STD_LOGIC_VECTOR (10 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;-- IP datagram total length in bytes<BR>signal nextDatagramLen: STD_LOGIC_VECTOR (10 downto 0);&nbsp;&nbsp;&nbsp;-- signal for the next datagram length<BR>signal dataLen: STD_LOGIC_VECTOR (10 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- IP datagram data length in bytes<BR>signal nextDataLen: STD_LOGIC_VECTOR (10 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;-- signal for the next data length</P>
<P>signal incCnt: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- increments byte address counter<BR>signal rstCnt: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- resets byte address counter<BR>signal cnt: STD_LOGIC_VECTOR (10 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- byte address counter for the frame received</P>
<P>signal incWrCnt: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- increments the write address counter<BR>signal rstWrCnt: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- resets the write address counter<BR>signal wrCnt: STD_LOGIC_VECTOR (15 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- write address counter for storing that data</P>
<P>signal doWrite: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- tell RAM controller to write data<BR>signal getNewByte: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- wait for new data on the stream</P>
<P>signal latchFrameData: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- latch in the data from the stream<BR>signal frameDataLatch: STD_LOGIC_VECTOR (7 downto 0);&nbsp;&nbsp;&nbsp;-- register to hold latched data</P>
<P>signal targetIP: STD_LOGIC_VECTOR (31 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;-- stores target IP (destination)<BR>signal shiftInTargetIP: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- signal to shift in target IP</P>
<P>signal shiftInSourceIP: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- stores source IP<BR>signal latchProtocol: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- signal to shift in source IP</P>
<P>-- checksum signals<BR>signal checkState : STD_LOGIC;<BR>CONSTANT stMSB : STD_LOGIC := '0';<BR>CONSTANT stLSB : STD_LOGIC := '1';</P>
<P>signal checksumLong : STD_LOGIC_VECTOR (16 downto 0);&nbsp;&nbsp;&nbsp;-- stores 2's complement sum<BR>signal checksumInt : STD_LOGIC_VECTOR (15 downto 0);&nbsp;&nbsp;&nbsp;-- stores 1's complement sum</P>
<P>signal latchMSB : STD_LOGIC_VECTOR (7 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;-- latch in first byte</P>
<P><BR>signal newHeader: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- resets checksum<BR>signal newByte: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- indicate new byte<BR>signal lastNewByte : STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- detect changes in newByte</P>
<P>signal inByte: STD_LOGIC_VECTOR (7 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- byte to calculate</P>
<P>signal checksum: STD_LOGIC_VECTOR (15 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;-- current checksum</P>
<P>-- bufferSelect is used both to indicate&nbsp; which area in RAM to write to<BR>-- and to indicate which buffer control ssignals are to operate on<BR>signal nextBufferSelect: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- allows memory of bufferSelect<BR>signal bufferSelectSig : STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- allows memory of bufferSelect</P>
<P>signal identification: STD_LOGIC_VECTOR (15 downto 0);&nbsp; &nbsp;&nbsp;-- identification field<BR>signal shiftInIdentification: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- signal to shift in identification</P>
<P>signal fragmentOffset: STD_LOGIC_VECTOR (12 downto 0);&nbsp;&nbsp;&nbsp;-- fragment offset field<BR>signal shiftInFragmentOffset: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- signal to shift in offset<BR>signal moreFragments : STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- more fragments flag<BR>signal latchMoreFragments : STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- signal to determine MF flag</P>
<P>-- The ident signals are of the form "souurce IP : protocol : identification" and<BR>-- are used in reassembly.<BR>signal targetIdent: STD_LOGIC_VECTOR (55 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;-- incoming frame's ident<BR>signal ident0: STD_LOGIC_VECTOR (55 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- current ident for buffer 0<BR>signal ident1: STD_LOGIC_VECTOR (55 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- current ident for buffer 1<BR>signal latchIdent: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- latch targetIdent into specified buffer ident<BR>signal resetIdent: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- clear ident of specified buffer to indicate a vacant buffer</P>
<P>signal position0: STD_LOGIC_VECTOR (15 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;-- stores expected offset of next fragment<BR>signal position1: STD_LOGIC_VECTOR (15 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;-- stores expected offset of next fragment<BR>signal updatePosition: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- add dataLen to current position<BR>signal resetPosition: STD_LOGIC;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- set position to be dataLen</P>
<P>constant TIMERWIDTH : INTEGER := 30;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- can be used to vary timeout length</P>
<P>signal timeout0: STD_LOGIC_VECTOR (TIMERWIDTH - 1&nbsp; downto 0);&nbsp;-- timeout counter<BR>signal timeout1: STD_LOGIC_VECTOR (TIMERWIDTH - 1&nbsp; downto 0);&nbsp;-- timeout counter<BR>signal resetTimeout: STD_LOGIC;&nbsp;&nbsp;-- start timeout counter</P>
<P>constant FULLTIME: STD_LOGIC_VECTOR (TIMERWIDTH - 1 downto 0) := (others =&gt; '1'); -- last value of timeout counter</P>
<P>signal sourceIPSig : STD_LOGIC_VECTOR (31 downto 0);&nbsp;&nbsp;&nbsp;-- internal signal for output<BR>signal protocolSig : STD_LOGIC_VECTOR (7 downto 0);&nbsp;&nbsp;&nbsp;&nbsp;-- internal signal for output&nbsp;</P>
<P>begin<BR>&nbsp;-- These signals are used instead of buffer ports<BR>&nbsp;sourceIP &lt;= sourceIPSig;<BR>&nbsp;protocol &lt;= protocolSig;<BR>&nbsp;bufferSelect &lt;= bufferSelectSig;<BR>&nbsp;<BR>&nbsp;-- Indicate when buffers are busy<BR>&nbsp;timeLED0 &lt;= '0' when timeout0 = FULLTIME or ident0 = 0 else '1';<BR>&nbsp;timeLED1 &lt;= '0' when timeout1 = FULLTIME or ident1 = 0 else '1';<BR>&nbsp;<BR>&nbsp;-- Some definitions to make further code simpler<BR>&nbsp;targetIdent &lt;= sourceIPSig &amp; protocolSig &amp; identification;<BR>&nbsp;dataLen &lt;= datagramLen - ("00000" &amp; headerLen);<BR>&nbsp;<BR>&nbsp;-- main clocked process<BR>&nbsp;process (rstn, clk)<BR>&nbsp;begin<BR>&nbsp;&nbsp;if rstn = '0' then&nbsp; -- only need to reset required signals<BR>&nbsp;&nbsp;&nbsp;presState &lt;= stIdle;<BR>&nbsp;&nbsp;&nbsp;returnState &lt;= stIdle;<BR>&nbsp;&nbsp;&nbsp;ident0 &lt;= (ot
 hers =&gt; '0');<BR>&nbsp;&nbsp;&nbsp;ident1 &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;&nbsp;timeout0 &lt;= FULLTIME;<BR>&nbsp;&nbsp;&nbsp;timeout1 &lt;= FULLTIME;</P>
<P>&nbsp;&nbsp;elsif clk'event and clk = '1' then</P>
<P>&nbsp;&nbsp;&nbsp;-- Go to next state wither directly or via a RAM state.<BR>&nbsp;&nbsp;&nbsp;-- If a RAM write or a new byte from the data stream are requested,<BR>&nbsp;&nbsp;&nbsp;-- the state machine stores nextState in returnState and goes to the<BR>&nbsp;&nbsp;&nbsp;-- required state.&nbsp; After completion, the state machine will go to <BR>&nbsp;&nbsp;&nbsp;-- returnState. This is like a 'subroutine' in the state machine.<BR>&nbsp;&nbsp;&nbsp;if doWrite = '1' then&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;presState &lt;= stDoWrite;<BR>&nbsp;&nbsp;&nbsp;&nbsp;returnState &lt;= nextState;<BR>&nbsp;&nbsp;&nbsp;elsif getNewByte = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;presState &lt;= stGetNewByte;<BR>&nbsp;&nbsp;&nbsp;&nbsp;returnState &lt;= nextState;<BR>&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;presState &lt;= nextState;<BR>&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;<BR>&n
 bsp;&nbsp;&nbsp;-- increment and reset the counter synchronously to avoid race conditions<BR>&nbsp;&nbsp;&nbsp;if incCnt = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;cnt &lt;= cnt + 1;<BR>&nbsp;&nbsp;&nbsp;elsif rstCnt = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;cnt &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;-- increment and reset the write address counter synchronously<BR>&nbsp;&nbsp;&nbsp;if incWrCnt = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;wrCnt &lt;= wrCnt + 1;<BR>&nbsp;&nbsp;&nbsp;elsif rstWrCnt = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;wrCnt &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;-- latch data read from RAM<BR>&nbsp;&nbsp;&nbsp;if latchFrameData = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;frameDataLatch &lt;= frameData;<BR>&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;--
  these signals must remember their values once set<BR>&nbsp;&nbsp;&nbsp;headerLen &lt;= nextHeaderLen;<BR>&nbsp;&nbsp;&nbsp;datagramLen &lt;= nextDatagramLen;</P>
<P>&nbsp;&nbsp;&nbsp;-- shift registers and latches to hold important data<BR>&nbsp;&nbsp;&nbsp;if shiftInSourceIP = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;sourceIPSig &lt;= sourceIPSig(23 downto 0) &amp; frameDataLatch;<BR>&nbsp;&nbsp;&nbsp;end if;</P>
<P>&nbsp;&nbsp;&nbsp;if shiftInTargetIP = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;TargetIP &lt;= TargetIP(23 downto 0) &amp; frameDataLatch;<BR>&nbsp;&nbsp;&nbsp;end if;</P>
<P>&nbsp;&nbsp;&nbsp;if latchProtocol = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;protocolSig &lt;= frameDataLatch;<BR>&nbsp;&nbsp;&nbsp;end if;&nbsp;&nbsp;&nbsp;</P>
<P>&nbsp;&nbsp;&nbsp;if shiftInFragmentOffset = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;fragmentOffset &lt;= fragmentOffset (4 downto 0) &amp; frameDataLatch;<BR>&nbsp;&nbsp;&nbsp;end if;</P>
<P>&nbsp;&nbsp;&nbsp;if latchMoreFragments = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;moreFragments &lt;= frameDataLatch(5);<BR>&nbsp;&nbsp;&nbsp;end if;</P>
<P>&nbsp;&nbsp;&nbsp;if shiftInIdentification = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;identification &lt;= identification (7 downto 0) &amp; frameDataLatch;<BR>&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;-- bufferSelect will remember its previous value<BR>&nbsp;&nbsp;&nbsp;bufferSelectSig &lt;= nextBufferSelect;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;-- handle timeout counters, resetTimeout will only reset the current buffer<BR>&nbsp;&nbsp;&nbsp;if resetTimeout = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;if bufferSelectSig = '0' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timeout0 &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timeout1 &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- increment timeout counters but don't let them overflow<BR>&nbsp;&nbsp;&nbsp;&nbs
 p;if timeout0 /= FULLTIME then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timeout0 &lt;= timeout0 + 1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timeout0 &lt;= FULLTIME;<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;&nbsp;if timeout1 /= FULLTIME then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timeout1 &lt;= timeout1 + 1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timeout1 &lt;= FULLTIME;<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;-- the following signals will operate only on the current buffer which<BR>&nbsp;&nbsp;&nbsp;-- is chosen with bufferSelect.<BR>&nbsp;&nbsp;&nbsp;if bufferSelectSig = '0' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- manage the ident register of the buffer<BR>&nbsp;&nbsp;&nbsp;&nbsp;if latchIdent = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ident0 &lt;= targetIdent;&nbsp;<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;elsif resetIdent = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ident0 &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;-- manage the position register of the buffer<BR>&nbsp;&nbsp;&nbsp;&nbsp;if resetPosition = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;position0 &lt;= "00000" &amp; dataLen;<BR>&nbsp;&nbsp;&nbsp;&nbsp;elsif updatePosition = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;position0 &lt;= position0 + dataLen;<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if;</P>
<P>&nbsp;&nbsp;&nbsp;else&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- manage the ident register of the buffer<BR>&nbsp;&nbsp;&nbsp;&nbsp;if latchIdent = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ident1 &lt;= targetIdent;<BR>&nbsp;&nbsp;&nbsp;&nbsp;elsif resetIdent = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ident1 &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- manage the position register of the buffer&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;if resetPosition = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;position1 &lt;= "00000" &amp; dataLen;<BR>&nbsp;&nbsp;&nbsp;&nbsp;elsif updatePosition = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;position1 &lt;= position1 + dataLen;<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if;&nbsp;<BR>&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;end if;<BR>&nbsp;end process;</P>
<P>-- IP datagram header format<BR>--<BR>--&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 19&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 24&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 31<BR>--&nbsp;---------------------------------------------------------------------------------------------<BR>--&nbsp;| Version&nbsp; | *Header&nbsp; |&nbsp;&nbsp;&nbsp; Service Typpe&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Total Length including header&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;|&nbsp;&nbsp; (4)&nbsp;&nbsp;&nbsp; 
 |&nbsp; Length&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; (ignored)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (in bytes)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;---------------------------------------------------------------------------------------------<BR>--&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Identification&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Flags |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fragment Offset&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (in 32 bit words)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;---------------------------------------------------------------------------------------------<BR>--&nbsp;|&nbsp;&nbsp;&nbsp; Time To Live&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Protocoll&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header Checksum&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp; (ignored)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;---------------------------------------------------------------------------------------------<BR>--&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Soource IP Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
 bsp;&nbsp;&nbsp; |<BR>--&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;---------------------------------------------------------------------------------------------<BR>--&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Desttination I
 P Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;---------------------------------------------------------------------------------------------<BR>--&nbsp;|&nbsp;&nbs
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Options (iff any - ignored)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Padding&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (if needed)&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;-----------------------------------------------------------
 ----------------------------------<BR>--&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;---------------------------------------------------------------------------------------------<BR>--&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ....&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>--&nbsp;---------------------------------------------------------------------------------------------<BR>--<BR>-- * - in 32 bit words </P>
<P>&nbsp;process (presState, returnState, cnt, frameDataLatch, datagramLen, headerLen, dataLen, newFrame, wrCnt,<BR>&nbsp;&nbsp;&nbsp;complete, frameType, checksum, targetIP, bufferSelectSig, targetIdent,<BR>&nbsp;&nbsp;&nbsp;position0, position1, ident0, ident1, fragmentOffset, moreFragments, timeout0, timeout1,<BR>&nbsp;&nbsp;&nbsp;endFrame, newFrameByte, frameValid)<BR>&nbsp;begin<BR>&nbsp;&nbsp;-- signal defaults<BR>&nbsp;&nbsp;wrRAM &lt;= '0';<BR>&nbsp;&nbsp;wrData &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;wrAddr &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;datagramSize &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;incCnt &lt;= '0';<BR>&nbsp;&nbsp;rstCnt &lt;= '0';<BR>&nbsp;&nbsp;incWrCnt &lt;= '0';<BR>&nbsp;&nbsp;rstWrCnt &lt;= '0';<BR>&nbsp;&nbsp;newDataGram &lt;= '0';<BR>&nbsp;&nbsp;-- the following two signals remember their previous value if not reassigned<BR>&nbsp;&nbsp;nextHeaderLen &l
 t;= headerLen;<BR>&nbsp;&nbsp;nextDatagramLen &lt;= datagramLen;<BR>&nbsp;&nbsp;doWrite &lt;= '0';<BR>&nbsp;&nbsp;getNewByte &lt;= '0';<BR>&nbsp;&nbsp;latchFrameData &lt;= '0';<BR>&nbsp;&nbsp;shiftInSourceIP &lt;= '0';<BR>&nbsp;&nbsp;shiftInTargetIP &lt;= '0';<BR>&nbsp;&nbsp;latchProtocol &lt;= '0';<BR>&nbsp;&nbsp;newHeader &lt;= '0';<BR>&nbsp;&nbsp;newByte &lt;= '0';<BR>&nbsp;&nbsp;inByte &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;latchMoreFragments &lt;= '0';<BR>&nbsp;&nbsp;shiftInFragmentOffset &lt;= '0';</P>
<P>&nbsp;&nbsp;shiftInIdentification &lt;= '0';&nbsp;&nbsp;<BR>&nbsp;&nbsp;nextBufferSelect &lt;= bufferSelectSig;<BR>&nbsp;&nbsp;latchIdent &lt;= '0';<BR>&nbsp;&nbsp;resetIdent &lt;= '0';<BR>&nbsp;&nbsp;updatePosition &lt;= '0';<BR>&nbsp;&nbsp;resetPosition &lt;= '0';<BR>&nbsp;&nbsp;resetTimeout &lt;= '0';<BR>&nbsp;<BR>&nbsp;&nbsp;case presState is<BR>&nbsp;&nbsp;&nbsp;when stIdle =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- wait for the arrival of a new frame that has a frameType of 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;if newFrame = '0' or frameType = '0' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stIdle;<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- reset the counters for the next datagram<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rstCnt &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rstWrCnt &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newHeader &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nb
 sp;&nbsp;nextState &lt;= stGetHeaderLen;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- get header length and version information<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getNewByte &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if;</P>
<P>&nbsp;&nbsp;&nbsp;when stGetHeaderLen =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- check ip version<BR>&nbsp;&nbsp;&nbsp;&nbsp;if frameDataLatch (7 downto 4) /= 4 then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stIdle;<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stGetHeaderByte;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- send data to checksum machine<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inByte &lt;= frameDataLatch;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newByte &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- get the header length in bytes, rather than 32-bit words<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextHeaderLen &lt;= frameDataLatch (3 downto 0) &amp; "00";<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;when stGetHeaderByte =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- if we've finished getting the headers and processing them, start on the data<BR>&n
 bsp;&nbsp;&nbsp;&nbsp;-- once finished, refragmenting will come next<BR>&nbsp;&nbsp;&nbsp;&nbsp;if cnt = headerLen then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- only operate on data meant for us, or broadcast data<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if checksum = 0 and (targetIP = DEVICE_IP or targetIP = x"FFFFFFFF") then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- determine which buffer should be used to handle the data<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ident0 = targetIdent and timeout0 /= FULLTIME then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- the ident matches and the timeout counter has not expired<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextBufferSelect &lt;= '0';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- accept the frame if its offset matches what we think it should be<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- this drops out 
 of order and duplicate frames.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if position0 = fragmentOffset &amp; "000" then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stGetDataByte;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stIdle;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end if;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elsif ident1 = targetIdent and timeout1 /= FULLTIME then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- the ident matches and the timeout counter has not expired&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextBufferSelect &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- accept the frame if its offset matches what we think it should be<BR>&nbsp;&nb
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- this drops out of order and duplicate frames.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if position1 = fragmentOffset &amp; "000" then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stGetDataByte;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stIdle;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end if;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elsif (ident0 = 0 or timeout0 = FULLTIME) and fragmentOffset = 0 then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- The ident doesn't match either of the buffers so check if buffer 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- is free.&nbsp; If ident = 0 or the timeout has expired then the buffer is free<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
 bsp;-- This must be the first fragment if it is to go here so also check the offset<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stGetDataByte;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextBufferSelect &lt;= '0';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elsif (ident1 = 0 or timeout1 = FULLTIME) and fragmentOffset = 0 then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- The ident doesn't match either of the buffers so check if buffer 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- is free.&nbsp; If ident = 0 or the timeout has expired then the buffer is free<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- This must be the first fragment if it is to go here so also check the offset<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stGetDataByte;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextBufferSelect &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e
 lse<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stIdle;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- ignore frame as it wasn't for us<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stIdle;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- otherwise get the next header byte from RAM<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stStoreHeaderByte;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getNewByte &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;when stStoreHeaderByte =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stGetHeaderByte;<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- operate on each value of the header received according to count<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- c
 ount will be one higher than the last byte received, as it is incremented<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- at the same time as the data is streamed in, so<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- when the data is seen to be available, count should also be one higher<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- Send data to checksum process<BR>&nbsp;&nbsp;&nbsp;&nbsp;newByte &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;inByte &lt;= frameDataLatch;<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- Operate on data in the header<BR>&nbsp;&nbsp;&nbsp;&nbsp;case cnt(4 downto 0) is&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when "00011" =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextDatagramLen (10 downto 8) &lt;= frameDataLatch (2 downto 0);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when "00100" =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextDatagramLen (7 downto 0) &lt;= frameDataL
 atch;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when "00101" | "00110" =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shiftInIdentification &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when "00111" =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shiftInFragmentOffset &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;latchMoreFragments &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when "01000" =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shiftInFragmentOffset &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when "01010" =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;latchProtocol &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when "01101" | "01110" | "01111" | "10000" =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shiftInSourceIP &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when "10001" | "10010" | "10011" | "10100" =&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shiftInTargetIP &lt;= '1';
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when others =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;end case;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;when stGetDataByte =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- if we haven't finished receiving the data, then<BR>&nbsp;&nbsp;&nbsp;&nbsp;if cnt /= datagramLen then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stSetupWriteDataByte;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- read an IP data byte from the data stream...<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getNewByte &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;elsif endFrame = '1' and frameValid = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- this means that the frame is finished and was valid<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- so update the buffer data and go to final state<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stCompleteFragment;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resetTimeout &lt;= '1';&nbsp;-- start/restart timer<BR
 >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;latchIdent &lt;= '1';&nbsp;&nbsp;-- allocate buffer to data<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if fragmentOffset = 0 then&nbsp;-- check if this is the first fragment<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resetPosition &lt;= '1';&nbsp;-- give position initial value<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;updatePosition &lt;= '1';&nbsp; -- or add to the amount of data stored<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;&nbsp;elsif endFrame = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- the frame is complete but not valid so ignore it<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stIdle;<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- the frame is not complete so keep looping until it is<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stGetDataByte;<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if
 ;<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;when stSetupWriteDataByte =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stGetDataByte;<BR>&nbsp;&nbsp;&nbsp;&nbsp;--Set up to write the byte that was read in stGetDataByte to RAM<BR>&nbsp;&nbsp;&nbsp;&nbsp;doWrite &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;wrData &lt;= frameDataLatch;</P>
<P>&nbsp;&nbsp;&nbsp;when stCompleteFragment =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- Signal the transport protocols if the datagram is finished<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- or await next frame.<BR>&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stIdle;<BR>&nbsp;&nbsp;&nbsp;&nbsp;if moreFragments = '0' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Last frame so :<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newDatagram &lt;= '1';&nbsp;&nbsp;-- notify higher protocols it's ready<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resetIdent &lt;= '1';&nbsp;&nbsp;-- free buffer for next time<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if bufferSelectSig = '0' then&nbsp;-- output datagram size from correct buffer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;datagramSize &lt;= position0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;datagramSize &lt;= position1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;&
 nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;when stDoWrite =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;-- Wait for RAM write request to be serviced<BR>&nbsp;&nbsp;&nbsp;&nbsp;if complete = '0' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- keep signals asserted until complete is high<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stDoWrite;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wrRAM &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- The address is based on the fragment offset and buffer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if bufferSelectSig = '0' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wrAddr &lt;= "001" &amp; (wrCnt + (fragmentOffset &amp; "000"));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wrAddr &lt;= "010" &amp; (wrCnt + (fragmentOffset &amp; "000"));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wrData &lt;= frameDataLatch;
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- when write is finished, go to returnState<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= returnState;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;incWrCnt &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if;</P>
<P>&nbsp;&nbsp;&nbsp;when stGetNewByte =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;if newFrameByte = '0' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- wait for new byte to arrive<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= stgetNewByte;<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- latch new byte and go to returnState<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextState &lt;= returnState;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;incCnt &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;latchFrameData &lt;= '1';<BR>&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;when others =&gt;<BR>&nbsp;&nbsp;end case;<BR>&nbsp;end process;<BR>&nbsp;<BR>&nbsp;-- Perform 2's complement to one's complement conversion, and invert output<BR>&nbsp;checksumInt &lt;= checksumLong(15 downto 0) + checksumLong(16);<BR>&nbsp;checksum &lt;= NOT checksumInt;</P>
<P>&nbsp;process (clk,rstn)<BR>&nbsp;begin<BR>&nbsp;&nbsp;if rstn = '0' then<BR>&nbsp;&nbsp;&nbsp;checkState &lt;= stMSB;<BR>&nbsp;&nbsp;&nbsp;latchMSB &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;&nbsp;checkSumLong &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;&nbsp;lastNewByte &lt;= '0';<BR>&nbsp;&nbsp;elsif clk'event and clk = '1' then<BR>&nbsp;&nbsp;&nbsp;-- this is used to check only for positive transitions<BR>&nbsp;&nbsp;&nbsp;lastNewByte &lt;= newByte;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;case checkState is<BR>&nbsp;&nbsp;&nbsp;&nbsp;when stMSB =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if newHeader = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- reset calculation<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkState &lt;= stMSB;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkSumLong &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elsif newByte = '1' and lastNewByte
  = '0' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- latch MSB of 16 bit data<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkState &lt;= stLSB;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;latchMSB &lt;= inByte;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkState &lt;= stMSB;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;&nbsp;when stLSB =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if newHeader = '1' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- reset calculation<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkState &lt;= stMSB;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkSumLong &lt;= (others =&gt; '0');<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elsif newByte = '1' and lastnewByte = '0' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- add with 2's complement arithmetic (convert to 1's above)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkState &lt;= stMSB;<BR>&nbs
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkSumLong &lt;= ('0' &amp; checkSumInt) + ('0' &amp; latchMSB &amp; inByte);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkState &lt;= stLSB;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end if;<BR>&nbsp;&nbsp;&nbsp;&nbsp;when others =&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkState &lt;= stMSB;<BR>&nbsp;&nbsp;&nbsp;end case;<BR>&nbsp;&nbsp;end if;<BR>&nbsp;end process;&nbsp;<BR>end internet_arch;</P>
<P>&nbsp;</P></DIV></div><br clear=all><hr>Add photos to your e-mail with <a href="http://g.msn.com/8HMAEN/2746??PS=">MSN 8.</a> Get 2 months FREE*.</html>

----------------------------------
General Handasa Arabia Mailinglist
http://www.handasarabia.org
[email protected] for help

Message number 72