www.gusucode.com > visionhdl工具箱matlab源码程序 > visionhdl/visionhdlutilities/@visionhdlsupport/@MedianFilter/cgireml/memReadFSM.m
function [backPorchStart,inPorch,inFrontLine,inBackLine,endLineP,inLine] = memReadFSM(readStart,readBackcount,isEndLine,rhline_cnt,rflines_cnt,vsRst,backPorch_cnt,bSize) persistent readState stype = numerictype(0,3,0); backPorchStart = false; endLineP = false; inFrontLine = false; inPorch = false; % initStateRst = false; inLine = false; inBackLine = false; if isempty(readState) readState = fi(0,'numerictype',stype); end if vsRst readState = fi(0,'numerictype',stype); elseif readStart switch (readState) case 0 %'wait' backPorchStart = false; % initStateRst = true; inPorch = true; inLine = true; if rhline_cnt < bSize-1 readState = fi(1,'numerictype',stype); if readBackcount inBackLine = true; % front porch in backlines also considered as inBackLine end else if rflines_cnt < bSize readState = fi(2,'numerictype',stype); inFrontLine = true; elseif readBackcount readState = fi(4,'numerictype',stype); inBackLine = true; else readState = fi(3,'numerictype',stype); inFrontLine = false; end end case 1 %front porch inPorch = true; inLine = true; if rhline_cnt < bSize-1 readState = fi(1,'numerictype',stype); if readBackcount inBackLine = true; end else if rflines_cnt < bSize readState = fi(2,'numerictype',stype); inFrontLine = true; elseif readBackcount readState = fi(4,'numerictype',stype); inBackLine = true; else readState = fi(3,'numerictype',stype); inFrontLine = false; end end case 2 % front lines inFrontLine = true; inLine = true; if isEndLine inPorch = true; backPorchStart = true; readState = fi(5,'numerictype',stype); else inPorch = false; readState = fi(2,'numerictype',stype); end case 3 % lines inLine = true; if isEndLine % back proch inPorch = true; backPorchStart = true; readState = fi(5,'numerictype',stype); else inPorch = false; readState = fi(3,'numerictype',stype); end case 4 % back lines inBackLine = true; inLine = true; if isEndLine % back proch inPorch = true; backPorchStart = true; readState = fi(5,'numerictype',stype); else inPorch = false; readState = fi(4,'numerictype',stype); end case 5 % back porch inPorch = true; inLine = true; if rflines_cnt < bSize inFrontLine = true; end if readBackcount inBackLine = true; end if backPorch_cnt < bSize-1 readState = fi(5,'numerictype',stype); backPorchStart = true; else readState = fi(0,'numerictype',stype); backPorchStart = false; endLineP = true; inLine = false; end end end