RE:
"Zellal B" <[email protected]> Mon, 19 Jan 2004 14:51:39 +0000
| Newsgroups | gmane.org.handasarabia.general |
|---|---|
| Message-ID | <[email protected]> |
<html><div style='background-color:'><DIV class=RTE>am sorry but am just a VHDL begginer.. i would like to know how to divide this process into sub-modules is anyone willing to help....</DIV> <DIV class=RTE> </DIV> <DIV class=RTE> </DIV> <DIV class=RTE>process (presState, returnState, cnt, frameDataLatch, datagramLen, headerLen, dataLen, newFrame, wrCnt,<BR> complete, frameType, checksum, targetIP, bufferSelectSig, targetIdent,<BR> position0, position1, ident0, ident1, fragmentOffset, moreFragments, timeout0, timeout1,<BR> endFrame, newFrameByte, frameValid)<BR> begin<BR> -- signal defaults<BR> wrRAM <= '0';<BR> wrData <= (others => '0');<BR> wrAddr <= (others => '0');<BR> datagramSize <= (others => '0');<BR> incCnt <= '0';<BR> rstCnt <= '0';<BR> incWrCnt <= '0';<BR> rstWrCnt <= '0';<BR> newDataGram <= '0';<BR> -- the following two signals remember their previous value if not reassigned<BR> nextHeader Len <= headerLen;<BR> nextDatagramLen <= datagramLen;<BR> doWrite <= '0';<BR> getNewByte <= '0';<BR> latchFrameData <= '0';<BR> shiftInSourceIP <= '0';<BR> shiftInTargetIP <= '0';<BR> latchProtocol <= '0';<BR> newHeader <= '0';<BR> newByte <= '0';<BR> inByte <= (others => '0');<BR> latchMoreFragments <= '0';<BR> shiftInFragmentOffset <= '0';</DIV> <DIV class=RTE> shiftInIdentification <= '0'; <BR> nextBufferSelect <= bufferSelectSig;<BR> latchIdent <= '0';<BR> resetIdent <= '0';<BR> updatePosition <= '0';<BR> resetPosition <= '0';<BR> resetTimeout <= '0';<BR> <BR> case presState is<BR> when stIdle =><BR> -- wait for the arrival of a new frame that has a frameType of 1<BR> if newFrame = '0' or frameType = '0' then<BR> nextState <= stIdle;<BR> else<BR> -- reset the counters for the next datagram<BR> rstCnt <= '1';<BR> rstWrCnt <= '1';<BR> newHeader <= '1';<BR> &nb sp; nextState <= stGetHeaderLen;<BR> -- get header length and version information<BR> getNewByte <= '1';<BR> end if;</DIV> <DIV class=RTE> when stGetHeaderLen =><BR> -- check ip version<BR> if frameDataLatch (7 downto 4) /= 4 then<BR> nextState <= stIdle;<BR> else<BR> nextState <= stGetHeaderByte;<BR> -- send data to checksum machine<BR> inByte <= frameDataLatch;<BR> newByte <= '1';<BR> -- get the header length in bytes, rather than 32-bit words<BR> nextHeaderLen <= frameDataLatch (3 downto 0) & "00";<BR> end if;<BR> <BR> when stGetHeaderByte =><BR> -- if we've finished getting the headers and processing them, start on th e data<BR> -- once finished, refragmenting will come next<BR> if cnt = headerLen then<BR> -- only operate on data meant for us, or broadcast data<BR> if checksum = 0 and (targetIP = DEVICE_IP or targetIP = x"FFFFFFFF") then<BR> <BR> -- determine which buffer should be used to handle the data<BR> if ident0 = targetIdent and timeout0 /= FULLTIME then<BR> -- the ident matches and the timeout counter has not expired<BR> nextBufferSelect <= '0';<BR> -- accept the frame if its offset matches what we think it should be<BR> -- thi s drops out of order and duplicate frames.<BR> if position0 = fragmentOffset & "000" then<BR> nextState <= stGetDataByte;<BR> else<BR> nextState <= stIdle;<BR> end if; <BR> elsif ident1 = targetIdent and timeout1 /= FULLTIME then<BR> -- the ident matches and the timeout counter has not expired <BR> nextBufferSelect <= '1';<BR> -- accept the frame if its offset matches what we think it should be< BR> -- this drops out of order and duplicate frames.<BR> if position1 = fragmentOffset & "000" then<BR> nextState <= stGetDataByte;<BR> else<BR> nextState <= stIdle;<BR> end if; <BR> elsif (ident0 = 0 or timeout0 = FULLTIME) and fragmentOffset = 0 then<BR> -- The ident doesn't match either of the buffers so check if buffer 0<BR> -- is free. If ident = 0 or the timeout has expired then the buffer is free<BR> &n bsp; -- This must be the first fragment if it is to go here so also check the offset<BR> nextState <= stGetDataByte;<BR> nextBufferSelect <= '0';<BR> elsif (ident1 = 0 or timeout1 = FULLTIME) and fragmentOffset = 0 then<BR> -- The ident doesn't match either of the buffers so check if buffer 1<BR> -- is free. If ident = 0 or the timeout has expired then the buffer is free<BR> -- This must be the first fragment if it is to go here so also check the offset<BR> nextState <= stGetDataByte;<BR> nextBufferSelect <= '1';<BR> & nbsp; else<BR> nextState <= stIdle;<BR> end if;<BR> else<BR> -- ignore frame as it wasn't for us<BR> nextState <= stIdle;<BR> end if;<BR> <BR> -- otherwise get the next header byte from RAM<BR> else<BR> nextState <= stStoreHeaderByte;<BR> getNewByte <= '1';<BR> end if;<BR> <BR> when stStoreHeaderByte =><BR> nextState <= stGetHeaderByte;<BR> -- operate on each value of the header received according to count<BR> &nbs p; -- count will be one higher than the last byte received, as it is incremented<BR> -- at the same time as the data is streamed in, so<BR> -- when the data is seen to be available, count should also be one higher<BR> <BR> -- Send data to checksum process<BR> newByte <= '1';<BR> inByte <= frameDataLatch;<BR> <BR> -- Operate on data in the header<BR> case cnt(4 downto 0) is <BR> when "00011" =><BR> nextDatagramLen (10 downto 8) <= frameDataLatch (2 downto 0);<BR> when "00100" =><BR> nextDatagramLen (7 downto 0) < = frameDataLatch;<BR> when "00101" | "00110" =><BR> shiftInIdentification <= '1';<BR> when "00111" =><BR> shiftInFragmentOffset <= '1';<BR> latchMoreFragments <= '1';<BR> when "01000" =><BR> shiftInFragmentOffset <= '1';<BR> when "01010" =><BR> latchProtocol <= '1';<BR> when "01101" | "01110" | "01111" | "10000" =><BR> shiftInSourceIP <= '1';<BR> when "10001" | "10010" | "10011" | "10100" => <BR> shiftInTargetI P <= '1';<BR> when others =><BR> end case;<BR> <BR> when stGetDataByte =><BR> -- if we haven't finished receiving the data, then<BR> if cnt /= datagramLen then<BR> nextState <= stSetupWriteDataByte;<BR> -- read an IP data byte from the data stream...<BR> getNewByte <= '1';<BR> elsif endFrame = '1' and frameValid = '1' then<BR> -- this means that the frame is finished and was valid<BR> -- so update the buffer data and go to final state<BR> nextState <= stCompleteFragment;<BR> resetTimeout <= '1'; -- start/rest art timer<BR> latchIdent <= '1'; -- allocate buffer to data<BR> if fragmentOffset = 0 then -- check if this is the first fragment<BR> resetPosition <= '1'; -- give position initial value<BR> else<BR> updatePosition <= '1'; -- or add to the amount of data stored<BR> end if;<BR> elsif endFrame = '1' then<BR> -- the frame is complete but not valid so ignore it<BR> nextState <= stIdle;<BR> else<BR> -- the frame is not complete so keep looping until it is<BR> nextState <= stGetDataByte;<BR> end if;<BR> <BR> when stSetupWriteDataByte =><BR> nextState <= stGetDataByte;<BR> --Set up to write the byte that was read in stGetDataByte to RAM<BR> doWrite <= '1';<BR> wrData <= frameDataLatch;</DIV> <DIV class=RTE> when stCompleteFragment =><BR> -- Signal the transport protocols if the datagram is finished<BR> -- or await next frame.<BR> nextState <= stIdle;<BR> if moreFragments = '0' then<BR> -- Last frame so :<BR> newDatagram <= '1'; -- notify higher protocols it's ready<BR> resetIdent <= '1'; -- free buffer for next time<BR> if bufferSelectSig = '0' then -- output datagram size from correct buffer<BR> datagramSize <= position0;<BR> else<BR> datagramSize <= position1;<BR> end if;<BR> & nbsp; end if;<BR> <BR> when stDoWrite =><BR> -- Wait for RAM write request to be serviced<BR> if complete = '0' then<BR> -- keep signals asserted until complete is high<BR> nextState <= stDoWrite;<BR> wrRAM <= '1';<BR> -- The address is based on the fragment offset and buffer<BR> if bufferSelectSig = '0' then<BR> wrAddr <= "001" & (wrCnt + (fragmentOffset & "000"));<BR> else<BR> wrAddr <= "010" & (wrCnt + (fragmentOffset & "000"));<BR> end if;<BR> wrData <= fra meDataLatch;<BR> else<BR> -- when write is finished, go to returnState<BR> nextState <= returnState;<BR> incWrCnt <= '1';<BR> end if;</DIV> <DIV class=RTE> when stGetNewByte =><BR> if newFrameByte = '0' then<BR> -- wait for new byte to arrive<BR> nextState <= stgetNewByte;<BR> else<BR> -- latch new byte and go to returnState<BR> nextState <= returnState;<BR> incCnt <= '1';<BR> latchFrameData <= '1';<BR> end if;<BR> when others =><BR> end case;<BR> end process;</DIV></div><br clear=all><hr>Add photos to your e-mail with <a href="http://g.msn.com/8HMBEN/2746??PS=">MSN 8.</a> Get 2 months FREE*.</html> ---------------------------------- General Handasa Arabia Mailinglist http://www.handasarabia.org [email protected] for help Message number 71