?? huffman.vhd
字號:
bitpos := conv_std_logic_vector((conv_integer(bitpos) + linbits),13);
end if;
else
temppos:=conv_integer(bitpos);
temphuff:= 8191 - temppos+1;
y:=y+conv_integer(valuebuffer(temppos to 8191) & valuebuffer(0 to linbits-temphuff-1));
bitpos:=(others=>'0');
tempcount1:='1';
bitpos:=conv_std_logic_vector((linbits-temphuff),13);
end if;
end if;
if y > 0 then
if conv_integer(valuebuffer(conv_integer(bitpos)))=1 then
y := -y;
end if;
if conv_integer(bitpos)=8191 then
bitpos:=(others=>'0');
tempcount1:='1';
else
bitpos := bitpos + '1';
end if;
end if;
isg(line) <= x;
isg(line+1) <= y;
line := line +2;
if (line >= bigvalues*2 ) then
temp:=0;
tempvector:=(others=>'0');
if gr='0' then
start_bit1 := conv_integer(frm.sideinfo.main_data)*8;
if tempcount1='0' then
count1s:=conv_integer(frm.sideinfo.part2_3_length)-(conv_integer(bitpos)-start_bit1);
else
count1s:=conv_integer(frm.sideinfo.part2_3_length)-(8191-start_bit1+conv_integer(bitpos)+1);
tempcount1:='0';
end if;
else
if tempcount1='0' then
count1s:=conv_integer(frm.sideinfo.part2_3_length)-(conv_integer(bitpos)-start_bit2);
else
count1s:=conv_integer(frm.sideinfo.part2_3_length)-(8191-start_bit2+conv_integer(bitpos)+1);
tempcount1:='0';
end if;
end if;
ns<= HUFFCOUNT1;
else
ns<= HUFFBIGVALUE;
end if;
when HUFFCOUNT1 =>
if count1s>0 and line< 576 then
start_bit := conv_integer(bitpos);
ns<= TABLELOOKUP2;
else
ns<=HUFFEND;
end if;
when TABLELOOKUP2 =>
if conv_integer(frm.sideinfo.count1table_select)=0 then
level1 :=0;
loop
temp := get_value(32,level1,0);
if temp=0 then
value := get_value(32,level1,1);
end if;
exit when temp=0;
if conv_integer(valuebuffer(conv_integer(bitpos)))=1 then
level1 := level1+ get_value(32,level1,1);
else
level1 := level1+ get_value(32,level1,0);
end if;
if conv_integer(bitpos)=8191 then
bitpos:=(others=>'0');
tempcount1:='1';
else
bitpos := bitpos + '1';
end if;
end loop;
else
if 8191-conv_integer(bitpos)+1>= 4 then
value := 15- conv_integer(valuebuffer(conv_integer(bitpos) to conv_integer(bitpos)+3));
if 8191-conv_integer(bitpos)+1= 4 then
bitpos:=(others=>'0');
tempcount1:='1';
else
bitpos := bitpos+"100";
end if;
else
temppos:=conv_integer(bitpos);
temphuff:= 8191 - temppos+1;
value:=15- conv_integer(valuebuffer(temppos to 8191)& valuebuffer(0 to 3-temphuff));
bitpos:=(others=>'0');
tempcount1:='1';
bitpos:=conv_std_logic_vector((4-temphuff),13);
end if;
end if;
tempvector1 := conv_std_logic_vector(value,4);
u := conv_integer(tempvector1(3));
w := conv_integer(tempvector1(2));
x := conv_integer(tempvector1(1));
y := conv_integer(tempvector1(0));
if u>0 then
if conv_integer(valuebuffer(conv_integer(bitpos)))=1 then
u := -u;
end if;
if conv_integer(bitpos)=8191 then
bitpos:=(others=>'0');
tempcount1:='1';
else
bitpos := bitpos + '1';
end if;
end if;
if w>0 then
if conv_integer(valuebuffer(conv_integer(bitpos)))=1 then
w := -w;
end if;
if conv_integer(bitpos)=8191 then
bitpos:=(others=>'0');
tempcount1:='1';
else
bitpos := bitpos + '1';
end if;
end if;
if x>0 then
if conv_integer(valuebuffer(conv_integer(bitpos)))=1 then
x := -x;
end if;
if conv_integer(bitpos)=8191 then
bitpos:=(others=>'0');
tempcount1:='1';
else
bitpos := bitpos + '1';
end if;
end if;
if y>0 then
if conv_integer(valuebuffer(conv_integer(bitpos)))=1 then
y := -y;
end if;
if conv_integer(bitpos)=8191 then
bitpos:=(others=>'0');
tempcount1:='1';
else
bitpos := bitpos + '1';
end if;
end if;
if tempcount1='0' then
count1s :=count1s-(conv_integer(bitpos)-start_bit);
else
count1s :=count1s-(8191-start_bit+conv_integer(bitpos)+1);
tempcount1:='0';
end if;
isg(line) <= u;
isg(line+1) <= w;
isg(line+2) <= x;
isg(line+3) <= y;
line :=line+4;
ns<= HUFFCOUNT1;
when HUFFEND =>
-- if gr='0' then
-- tempbit:=conv_integer(bitpos) - start_bit1 - conv_integer(frm.sideinfo.part2_3_length);
--else
-- tempbit:=conv_integer(bitpos) - start_bit2 - conv_integer(frm.sideinfo.part2_3_length);
--end if;
--if (tempbit<0) then
-- bitpos:=conv_std_logic_vector((conv_integer(bitpos)-tempbit),13);
--end if;
--if tempbit>0 then
--bitpos:=conv_std_logic_vector((conv_integer(bitpos)+tempbit),13);
-- end if;
loop
isg(line) <=0;
line := line+1;
exit when line >= 576;
end loop;
ns<= DATAREADY;
when DATAREADY =>
memc.en <= '1'; -- active high
memc.oe <= '0'; -- active high
memc.we <= '1'; -- active high
memc.addr <= memaddrcount;
ns<= READY;
when READY =>
dout <= conv_std_logic_vector(isg(line1),32);
line1 :=line1+1;
memaddrcount := memaddrcount+1;
if line1 >=576 then
done <= '1';
ns<= IDLE2;
else
ns<= DATAREADY;
end if;
when others => null;
end case;
sco <= scout; -- output scale factors
end process;
process(clk,rst)
begin
if rst='1' then
cs<=IDLE1;
elsif rising_edge(clk) then
cs<=ns;
end if;
end process;
end;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -