Текст программной части на VHDL, страница 5

tempy(i+(j*2+1)*256) := (WB(i+j*256)+WB(i+(j+1)*256))*CONV_UNSIGNED(INTEGER(factor),8);         --{HIGH-PASS}

else

tempy(i+(j*2+1)*256) := WB(i+j*256)*CONV_UNSIGNED(INTEGER(factor),8);

end if;

end if;

end loop;

end loop;

for j in 0 downto SZ-1 loop

offset := j*256;

for i in 0 downto (SZ/2)-1 loop

if (tempy(i+(SZ/2)+offset) /=0 ) or (i = (SZ/2)-1) or (i = 0) or (SZ < 4) then --{!UPDATED}

tempx(i*2+offset) := (tempy(i+offset)+tempy((i+(SZ/2))+offset))*CONV_UNSIGNED(INTEGER(factor),8);     --{LOW-PASS}

tempx((i*2+1)+offset) := (tempy(i+offset)+tempy((i+(SZ/2))+offset))*CONV_UNSIGNED(INTEGER(factor),8);{HIGHPASS}

else

if (tempy(i-1+(SZ/2)+offset) =0 ) and (tempy(i+1+offset) /= tempy(i+offset)) and

((i = (SZ/2)-2) or (tempy(i+1+offset) /= tempy(i+2+offset))) then

tempy(i*2+offset) := (tempy(i+offset)+tempy(i-1+offset))*CONV_UNSIGNED(INTEGER(factor),8);                    else

tempy(i*2+offset) := tempy(i+offset)*CONV_UNSIGNED(INTEGER(factor),8);  

end if;

if (tempy(i+1+(SZ/2)+offset) = 0 ) and (tempy(i-1+offset) /= tempy(i+offset)) and

((i = 1) or (tempy(i-1+offset) /= tempy(i-2+offset))) then

tempy(i*2+1+offset) := (tempy(i+offset)+tempy(i+1+offset))*CONV_UNSIGNED(INTEGER(factor),8);             

else

tempy(i*2+1+offset) := tempy(i+offset)*CONV_UNSIGNED(INTEGER(factor),8);

end if;

end if;

end loop;

end loop;   

for i in 0 downto 65535 loop                                                                                                     --{Copy to Pic}

BRStore(i) := tempy(i);

end loop;                                         

end;                                    

--+++++++++++++++++++++++++++++++ НАЧАЛО ОСНОВНОЙ ФУНКЦИИ +++++++++++++++++++++++++++++++++++++++++

begin

INBUSY <= '0';                                                                            -- Выставляем занятость

if RESET ='0' then                                                                        -- основные сигналы RESET и CLK

UNLOADPIC<=("00000000");

ERROR<='0';     

INBUSY <= '1';

Counter1 := 0;

FlagReg  := ("000000000000000");

UNLOAD <= '1';                                                           -- нет выгрузки

elsif CLK='1' and  CLK'event  then

-------- проверяем состояние входа DIRECT -------if (FlagReg(0)  = '1') then                                                           --есть ли ошибка

-- пропускаем все пока не снимем RESET-ом

elsif  (CONTROL = 0)  then                                        -- инициализация     

INBUSY <= '1';

Counter1 := 0;                                                -- сбрасываем счетчик 1

FlagReg(0) := '0';                                            -- сбрасывем флаг

elsif  (CONTROL = 1) and (FlagReg(2)  = '0') and (LOAD = '1') then -- загрузка Red   

if (counter1 < 65536) then                                                        --не загрузили весь RED

NEXTCOLOR <= '0';

RRStore(counter1):= LOADPIC;

Counter1 := Counter1 + 1;

else

NEXTCOLOR <= '1';                      -- загрузили, можно загружать Green

FlagReg(2)  := '1';

Counter1 := 0;

end if;           

elsif  (CONTROL = 2) and (FlagReg(3)  = '0') and (LOAD = '1') then -- загрузка Green  

if (counter1 < 65536) then                                                        --не загрузили весь Green

NEXTCOLOR <= '0';

GRStore(counter1):= LOADPIC;

Counter1 := Counter1 + 1;

else

NEXTCOLOR <= '1';                      -- загрузили, можно загружать Bue

FlagReg(3)  := '1';

Counter1 := 0;

end if;           

elsif  (CONTROL = 3) and (FlagReg(4)  = '0') and (LOAD = '1') then -- загрузка Blue   

if (counter1 < 65536) then                                                        --не загрузили весь Blue

NEXTCOLOR <= '0';

BRStore(counter1):= LOADPIC;

Counter1 := Counter1 + 1;

else

NEXTCOLOR <= '1';                      -- можно загружать водяной знак

FlagReg(4)  := '1';

Counter1 := 0;

end if;

elsif  (CONTROL = 4) and (LOAD = '1') and (FlagReg(1)  = '0') then      --загрузка ЗНАКА   128*128+64*64 = 20480