OSDN Git Service

re-commit
[fpga-leon-mjpeg/leon-mjpeg.git] / grlib-gpl-1.0.22-b4095 / lib / kuri / mjpeg / huff.vhd.bak
index 39316f0..0d6cc5b 100644 (file)
@@ -632,6 +632,8 @@ end if;
     end if;
 
 -- Through bit & skip counter calculation
+-- This part is for "motion"-JPEG".
+-- It's not beautiful implementation, but.....
     if(r.fetch_state = ffcheck and r.preg.through_bit = '1' and  vbytedata = "11011010")then
         v.cntdown := '1';
         v.capture := "10";
@@ -658,6 +660,7 @@ end if;
             v.skipcnt := (others => '0');
         end if;
     end if;
+    
 -- State machine transition (fetch part)  
     case r.fetch_state is
     when  memwait =>
@@ -739,6 +742,8 @@ end if;
    end if;
 
     v.valuebit := std_logic_vector(to_unsigned((to_integer(unsigned(r.valuebit)) + vint_plusv - vint_minusv), 6));
+  
+  -- Padding bit for Markers
    if(r.fetch_state =  markermode or r.preg.through_bit = '1') then
        if((r.valuebit = "000001" and r.fetch_reg(0) = '1')
            or (r.valuebit = "000010" and r.fetch_reg(1 downto 0) = "11")
@@ -768,7 +773,6 @@ end if;
    end if;
  
  -- shiftnum calculation
-
    vint_valuebit := to_integer(unsigned(r.valuebit));
    vint_valbkp := to_integer(unsigned(r.valbit_keep));
    vint_sercnt := to_integer(unsigned(r.serial_counter));
@@ -787,11 +791,13 @@ end if;
    elsif(r.dec_state = serialwait)then
        vintshift := 1 + vint_valuebit - vint_sercnt;
    end if;
-   vshiftnum :=  std_logic_vector(to_unsigned(vintshift,5));    
+   vshiftnum :=  std_logic_vector(to_unsigned(vintshift,5)); 
+      
 -- shifter instantiation
 debug_shiftnum <= vshiftnum;
    vtmpshiftout := std_logic_vector(shift_right(unsigned(r.fetch_reg), vintshift));
    vshiftout := vtmpshiftout(15 downto 0);
+   
 -- write memory address generation
    if (r.dec_state = symcheck and unsigned(vcache_symbit) <= unsigned(r.valuebit) and vcache_symbit /= "00000")then
        va := '1';
@@ -951,6 +957,7 @@ debug_vcache_valbit <= vcache_valbit;
        or (r.dec_state = serialcheck and vserial_judge = '1')then 
        v.serial_counter := r.serial_counter + 1;
    end if;
+   
  -- Sign extention & zigzag memory access
  debug_sign_exin <= vshiftout(10 downto 0);
    vkdata := sign_ex(vshiftout(10 downto 0), r.valbit_keep );
@@ -980,11 +987,24 @@ end if;
 
 -- Decord part state-machine
 -- state = symreq, symcheck, valout, symng, symokvalng, serialwait, serialcheck, serialfinish, standby
-   vint_csymbit := to_integer(unsigned(vcache_symbit));
-   vint_reqbitkp := to_integer(unsigned(r.reqbit_keep));
-   vint_cvalbit := to_integer(unsigned(vcache_valbit));
-   vint_sersym := to_integer(unsigned(vserial_symbit));
-   vint_serval := to_integer(unsigned(vserial_valbit));
+   vint_csymbit := 0; vint_reqbitkp := 0; vint_cvalbit := 0;
+   vint_sersym := 0; vint_serval := 0;
+
+   if notx(vcache_symbit) then 
+       vint_csymbit := to_integer(unsigned(vcache_symbit)); 
+   end if;
+   if notx(r.reqbit_keep) then
+       vint_reqbitkp := to_integer(unsigned(r.reqbit_keep));
+   end if;
+   if notx(vcache_valbit) then
+       vint_cvalbit := to_integer(unsigned(vcache_valbit));
+   end if;
+   if notx(vserial_symbit) then
+       vint_sersym := to_integer(unsigned(vserial_symbit));
+   end if;
+   if notx(vserial_valbit) then
+       vint_serval := to_integer(unsigned(vserial_valbit));
+   end if;
    
    case r.dec_state is
    when  standby =>