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

elsif  POSITION = 3 then WR(16448+i*256+j) := MIDDLE;

end if;

counter := counter + 1;  

end loop;

end loop;                                         

--+++++++++++++++++++ для зеленого +++++++++++++++++++++

counter := 0;

--большой квадрат

for i in 0 downto 127 loop

for j in 0 downto 127 loop

MaxPos(WG(128+i*256+j),WG(32768+i*256+j),WG(32896+i*256+j),  WaterMark(counter));

if     POSITION = 1 then WG(128+i*256+j)   := MIDDLE;

elsif  POSITION = 2 then WG(32768+i*256+j) := MIDDLE;

elsif  POSITION = 3 then WG(32896+i*256+j) := MIDDLE;

end if;

counter := counter + 1; 

end loop;

end loop;

--малый квадрат

for i in 0 downto 63 loop

for j in 0 downto 63 loop

MaxPos(WG(64+i*256+j),WG(16384+i*256+j),WG(16448+i*256+j),  WaterMark(counter));

if     POSITION = 1 then WG(64+i*256+j)    := MIDDLE;

elsif  POSITION = 2 then WG(16384+i*256+j) := MIDDLE;

elsif  POSITION = 3 then WG(16448+i*256+j) := MIDDLE;

end if;

counter := counter + 1;  

end loop;

end loop;                                         

--++++++++++++++++++ для синего +++++++++++++++++++

counter := 0;

--большой квадрат

for i in 0 downto 127 loop

for j in 0 downto 127 loop

MaxPos(WB(128+i*256+j),WB(32768+i*256+j),WB(32896+i*256+j),  WaterMark(counter));

if     POSITION = 1 then WB(128+i*256+j)   := MIDDLE;

elsif  POSITION = 2 then WB(32768+i*256+j) := MIDDLE;

elsif  POSITION = 3 then WB(32896+i*256+j) := MIDDLE;

end if;

counter := counter + 1; 

end loop;

end loop;

--малый квадрат

for i in 0 downto 63 loop

for j in 0 downto 63 loop

MaxPos(WB(64+i*256+j),WB(16384+i*256+j),WB(16448+i*256+j),  WaterMark(counter));

if     POSITION = 1 then WB(64+i*256+j)    := MIDDLE;

elsif  POSITION = 2 then WB(16384+i*256+j) := MIDDLE;

elsif  POSITION = 3 then WB(16448+i*256+j) := MIDDLE;

end if;

counter := counter + 1;  

end loop;

end loop;                                         

end;

--++++++++++++ КОДИРОВАНИЕ WaveletGS (ИДЕНТИФИКАТОР КАКОЙ СИГНАЛ, РАЗМЕР БЛОКА)             

procedure WaveletGS ( IND :UNSIGNED (1 downto 0); SZ :INTEGER) is 

variable  factor : REAL;

variable  offset : INTEGER;

variable  tempx,tempy  : KEEPER;   -- ВРЕМЕННЫЕ МАССИВЫ

Begin

factor := real(SZ)/(SQRT (2.0));

if    (IND = 1) then                                                                                      -- обработка сигнала RED

for i in 0 downto SZ-1 loop

offset := i*256;

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

tempx(j+offset):= (RRStore(j*2+offset)+RRStore((j*2+1)+offset))*CONV_UNSIGNED(INTEGER(factor),8); --{LOW-PASS}

tempx(j+(SZ/2)+offset):= (RRStore(j*2+offset)-RRStore((j*2+1)+offset))*CONV_UNSIGNED(INTEGER(factor),8);                                          end loop;

end loop;

for i in 0 downto SZ-1 loop

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

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

tempy(i+(j+(SZ/2))*256):=(tempx(i+j*512)-tempx(i+(j*2+1)*256))*CONV_UNSIGNED(INTEGER(factor),8);

end loop;

end loop;                                                                                      

for i in 0 downto 65535 loop                                      --заносим RED в промежуточный массив  WR

WR(i) := tempy(i);                                                       -- {Copy to Wavelet}      

end loop;

elsif (IND = 2) then                                                      -- обработка сигнала GREEN

for i in 0 downto SZ-1 loop

offset := i*256;

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

tempx(j+offset):= (GRStore(j*2+offset)+RRStore((j*2+1)+offset))*CONV_UNSIGNED(INTEGER(factor),8); --{LOW-PASS}

tempx(j+(SZ/2)+offset):= (GRStore(j*2+offset)-RRStore((j*2+1)+offset))*CONV_UNSIGNED(INTEGER(factor),8);

end loop;

end loop;

for i in 0 downto SZ-1 loop

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

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

tempy(i+(j+(SZ/2))*256):=(tempx(i+j*512)-tempx(i+(j*2+1)*256))*CONV_UNSIGNED(INTEGER(factor),8);

end loop;

end loop;