gusucode.com > visionhdl工具箱matlab源码程序 > visionhdl/visionhdlutilities/@visionhdlsupport/@ImageStatistics/cgireml/recipController.m
function [ lvlTwoEn, lvlThreeEn, lvlFourEn, SEL, outEn, pipeRst,pipeEn, endFlagO, normOneFlagO countReset] = recipController(vEnd, vEndD, lvlOneCount, lvlTwoCount, lvlThreeCount, lvlFourCount, pipeCount, vStart) %#codegen persistent statState; persistent endFlag; persistent normOneFlag; persistent inFrame; persistent statusComplete; stype = numerictype(0,4,0); SEL= fi(0,0,2,0); S0 = fi(0,'numerictype',stype); S1 = fi(1,'numerictype',stype); S2 = fi(2,'numerictype',stype); S3 = fi(3,'numerictype',stype); S4 = fi(4,'numerictype',stype); S5 = fi(5,'numerictype',stype); S6 = fi(6,'numerictype',stype); S7 = fi(7,'numerictype',stype); S8 = fi(8,'numerictype',stype); S9 = fi(9,'numerictype',stype); S10 = fi(10,'numerictype',stype); if isempty(statState) statState = fi(0,'numerictype',stype); endFlag = false; normOneFlag = false; inFrame = false; statusComplete = false; end switch(statState) case S0 % IDLE State %% Idle State lvlTwoEn = false; lvlThreeEn = false; lvlFourEn = false; outEn = false; pipeEn = false; pipeRst = true; SEL(:) =0; countReset = false; if (((lvlOneCount == 63) || (vEnd == true))&& inFrame) statState(:) = 5; else statState(:) = 0; end case S1 % Save Normalized Level One %% Normalize over the [64] pixel interval lvlTwoEn = true; lvlThreeEn = false; lvlFourEn = false; outEn = false; pipeEn = false; pipeRst = true; SEL(:) =0; countReset = false; if lvlTwoCount == 63 statState(:) = 6; elseif normOneFlag == true %% lvlOneCount reached 64 less than 5 pixels before vEnd statState(:) = 9; elseif (endFlag == true) statState(:) = 6; elseif vEnd == true statState(:) = 5; elseif (lvlOneCount~=63) statState(:) = 0; else %%% First level coincident with hEnd statState(:) = 10; end if (vEnd == true) && lvlTwoCount == 63 normOneFlag = true; end case S2 % Save Normalized Level Two %% Normalize over the [64x64] pixel interval lvlTwoEn = false; lvlThreeEn = true; lvlFourEn = false; outEn = false; pipeEn = false; pipeRst = true; SEL(:) =0; countReset = false; if normOneFlag == true statState(:) = 9; elseif (endFlag == true) || (lvlThreeCount ==63) statState(:) = 7; elseif vEnd == true statState(:) = 5; elseif (lvlOneCount~=63) statState(:) = 0; else %%% First level coincident with hEnd statState(:) = 10; end if (vEnd == true) && (endFlag == false) normOneFlag = true; end case S3 % Save Normalized Level Three %% Normalize over the [64x64x64] pixel interval, enable output register. lvlTwoEn = false; lvlThreeEn = false; lvlFourEn = true; outEn = false; countReset = false; pipeEn = false; pipeRst = true; SEL(:) = 0; if endFlag||lvlFourCount ==63 statState(:) = 8; else statState(:) = 0; end statusComplete = false; case S4 % Pass Normalized Level Four to Output Register %% Normalize over the [64x64x64x64] pixel interval, enable output register. lvlTwoEn = false; lvlThreeEn = false; lvlFourEn = false; outEn = ~statusComplete; countReset = true; pipeEn = false; pipeRst = true; SEL(:) = 0; endFlag = false; statState(:) = 0; statusComplete = true; case S5 % Pipeline Wait State - lvlOne %% Pipeline Delay of lvlOne Normalization - WAIT State. lvlTwoEn = false; lvlThreeEn = false; lvlFourEn = false; outEn = false; pipeEn = true; pipeRst = false; SEL(:) = 0; countReset = false; if pipeCount == 3 statState(:) = 1; else statState(:) = 5; end if (vEnd == true) normOneFlag = true; end case S6 % Pipeline Wait State - lvlTwo %% Pipeline Delay of lvlTwo Normalization - WAIT State. lvlTwoEn = false; lvlThreeEn = false; lvlFourEn = false; outEn = false; pipeEn = true; pipeRst = false; SEL(:) = 1; countReset = false; if pipeCount == 3 statState(:) = 2; else statState(:) = 6; end if (vEnd == true) && (endFlag == false) normOneFlag = true; end case S7 % Pipeline Wait State - lvlThree %% Pipeline Delay of lvlThree Normalization - WAIT State. lvlTwoEn = false; lvlThreeEn = false; lvlFourEn = false; outEn = false; pipeEn = true; pipeRst = false; SEL(:) = 2; countReset = false; if pipeCount == 3 statState(:) = 3; else statState(:) = 7; end case S8 % Pipeline Wait State - lvlFour %% Pipeline Delay of lvlFour Normalization - WAIT State. lvlTwoEn = false; lvlThreeEn = false; lvlFourEn = false; outEn = false; pipeEn = true; pipeRst = false; SEL(:) = 3; countReset = false; if pipeCount == 3 statState(:) = 4; else statState(:) = 8; end case S9 % Pipeline Wait State - lvlOne (Second Round) %% Pipeline Delay of lvlOne Normalization - WAIT State. lvlTwoEn = false; lvlThreeEn = false; lvlFourEn = false; outEn = false; pipeEn = true; pipeRst = false; SEL(:) = 0; countReset = false; if pipeCount == 3 statState(:) = 1; normOneFlag = false; else statState(:) = 9; end case S10 % Blanking wait state %% Wait for blanking to end lvlTwoEn = false; lvlThreeEn = false; lvlFourEn = false; outEn = false; pipeEn = false; pipeRst = true; SEL(:) =0; countReset = false; if lvlOneCount ~= 63 statState(:) = 0; else statState(:) = 10; end otherwise %% Default case - vertical blanking behaviour. lvlTwoEn = false; lvlThreeEn = false; lvlFourEn = false; outEn = false; pipeEn = false; pipeRst = true; SEL(:) =0; countReset = false; end if vEnd == true && inFrame == true endFlag = true; inFrame = false; end if vStart inFrame = true; statusComplete = false; end endFlagO = endFlag; normOneFlagO = normOneFlag;