|
Message
From: cvs at opencores.org<cvs@o...>
Date: Fri Aug 18 16:29:36 CEST 2006
Subject: [cvs-checkins] MODIFIED: dirac ...
Date: 00/06/08 18:16:29 Modified: dirac/src/testbench ArithmeticCoderTestbench.prj ArithmeticCoderTestbench.vhd Added: dirac/src/testbench test1.ctx.bz2 test1.dr0 test1.dr1 Log: Complete implementation of adaptive arithmetic coding, suitable for Dirac 0.5.3 Revision Changes Path 1.3 dirac/src/testbench/ArithmeticCoderTestbench.prj http://www.opencores.org/cvsweb.shtml/dirac/src/testbench/ArithmeticCoderTestbench.prj.diff?r1=1.2&r2=1.3 (In the diff below, changes in quantity of whitespace are not shown.) Index: ArithmeticCoderTestbench.prj =================================================================== RCS file: /cvsroot/petebleackley/dirac/src/testbench/ArithmeticCoderTestbench.prj,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- ArithmeticCoderTestbench.prj 27 May 2005 16:00:30 -0000 1.2 +++ ArithmeticCoderTestbench.prj 18 Aug 2006 14:29:35 -0000 1.3 @@ -3,11 +3,12 @@ vhdl work ../encoder/LIMIT_REGISTER.vhd vhdl work ../common/ARITHMETIC_UNIT.vhd vhdl work ../common/CONVERGENCE_CHECK.vhd +vhdl work ../common/UPDATER.vhd +vhdl work ../common/HALVING_MANAGER.vhd +vhdl work ../common/Divider.vhd vhdl work ../common/CONTEXT_MANAGER.vhd vhdl work ../encoder/FOLLOW_COUNTER.vhd vhdl work ../encoder/OUTPUT_UNIT.vhd vhdl work ../encoder.ARITHMETICCODER.vhd -vhdl work ../decoder/STORAGE_REGISTER.vhd -vhdl work ../decoder/SYMBOL_DETECTOR.vhd -vhdl work ../decoder/ARITHMETICDECODER.vhd +vhdl work ../expgolomb/EXP_GOLOMB_COUNTER.vhd vhdl work ArithmeticCoderTestbench.vhd 1.4 dirac/src/testbench/ArithmeticCoderTestbench.vhd http://www.opencores.org/cvsweb.shtml/dirac/src/testbench/ArithmeticCoderTestbench.vhd.diff?r1=1.3&r2=1.4 (In the diff below, changes in quantity of whitespace are not shown.) Index: ArithmeticCoderTestbench.vhd =================================================================== RCS file: /cvsroot/petebleackley/dirac/src/testbench/ArithmeticCoderTestbench.vhd,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- ArithmeticCoderTestbench.vhd 27 May 2005 16:00:30 -0000 1.3 +++ ArithmeticCoderTestbench.vhd 18 Aug 2006 14:29:35 -0000 1.4 @@ -1,49 +1,39 @@ -- ***** BEGIN LICENSE BLOCK ***** -- --- $Id: ArithmeticCoderTestbench.vhd,v 1.3 2005/05/27 16:00:30 petebleackley Exp $ $Name: $ --- * --- * Version: MPL 1.1/GPL 2.0/LGPL 2.1 --- * --- * The contents of this file are subject to the Mozilla Public License --- * Version 1.1 (the "License"); you may not use this file except in compliance --- * with the License. You may obtain a copy of the License at --- * http://www.mozilla.org/MPL/ --- * --- * Software distributed under the License is distributed on an "AS IS" basis, --- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for --- * the specific language governing rights and limitations under the License. --- * --- * The Original Code is BBC Research and Development code. --- * --- * The Initial Developer of the Original Code is the British Broadcasting --- * Corporation. --- * Portions created by the Initial Developer are Copyright (C) 2004. --- * All Rights Reserved. --- * --- * Contributor(s): Peter Bleackley (Original author) --- * --- * Alternatively, the contents of this file may be used under the terms of --- * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser --- * Public License Version 2.1 (the "LGPL"), in which case the provisions of --- * the GPL or the LGPL are applicable instead of those above. If you wish to --- * allow use of your version of this file only under the terms of the either --- * the GPL or LGPL and not to allow others to use your version of this file --- * under the MPL, indicate your decision by deleting the provisions above --- * and replace them with the notice and other provisions required by the GPL --- * or LGPL. If you do not delete the provisions above, a recipient may use --- * your version of this file under the terms of any one of the MPL, the GPL --- * or the LGPL. --- * ***** END LICENSE BLOCK ***** */ - --- VHDL Test Bench Created from source file arithmeticcoder.vhd -- 13:44:22 01/05/2005 -- --- Notes: --- This testbench has been automatically generated using types std_logic and --- std_logic_vector for the ports of the unit under test. Xilinx recommends --- that these types always be used for the top-level I/O of a design in order --- to guarantee that the testbench will bind correctly to the post-implementation --- simulation model.
+-- Version: MPL 1.1/GPL 2.0/LGPL 2.1
+--
+-- The contents of this file are subject to the Mozilla Public License
+-- Version 1.1 (the "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+-- http://www.mozilla.org/MPL/
+--
+-- Software distributed under the License is distributed on an "AS IS" basis,
+-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+-- the specific language governing rights and limitations under the License.
+--
+-- The Original Code is BBC Research and Development code.
+--
+-- The Initial Developer of the Original Code is the British Broadcasting
+-- Corporation.
+-- Portions created by the Initial Developer are Copyright (C) 2006.
+-- All Rights Reserved.
+--
+-- Contributor(s): Peter Bleackley (Original author)
--
+-- Alternatively, the contents of this file may be used under the terms of
+-- the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
+-- Public License Version 2.1 (the "LGPL"), in which case the provisions of
+-- the GPL or the LGPL are applicable instead of those above. If you wish to
+-- allow use of your version of this file only under the terms of the either
+-- the GPL or LGPL and not to allow others to use your version of this file
+-- under the MPL, indicate your decision by deleting the provisions above
+-- and replace them with the notice and other provisions required by the GPL
+-- or LGPL. If you do not delete the provisions above, a recipient may use
+-- your version of this file under the terms of any one of the MPL, the GPL
+-- or the LGPL.
+-- * ***** END LICENSE BLOCK ***** */
+
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
@@ -58,222 +48,397 @@
ARCHITECTURE behavior OF arithmeticcoder_ArithmeticCoderTestbench_vhd_tb IS
COMPONENT arithmeticcoder
--- generic(
--- PROB : std_logic_vector (9 downto 0));
PORT(
ENABLE : IN std_logic;
DATA_IN : IN std_logic;
CONTEXT_ENABLE : in std_logic;
CONTEXT_IN : in std_logic_vector (5 downto 0);
+ HALVECOUNTS_IN : in std_logic;
+ FLUSH : in std_logic;
RESET : IN std_logic;
CLOCK : IN std_logic;
SENDING : OUT std_logic;
- DATA_OUT : OUT std_logic
+ DATA_OUT : OUT std_logic;
+ FLUSH_COMPLETE : out std_logic
);
END COMPONENT;
- component ARITHMETICDECODER
- port (ENABLE : in std_logic;
- DATA_IN : in std_logic;
- NEWCONTEXT : in std_logic;
- CONTEXT_SELECT : in std_logic_vector (5 downto 0);
+ component EXP_GOLOMB_COUNTER
+ port( DATA_IN : in std_logic_vector (31 downto 0);
+ TEST : in std_logic;
RESET : in std_logic;
CLOCK : in std_logic;
- SENDING : out std_logic;
+ COUNTING : out std_logic;
DATA_OUT : out std_logic);
- end component ARITHMETICDECODER;
- component FIFO
- generic (RANK : integer range 0 to 16;
- WIDTH : integer range 1 to 16);
- port ( WRITE_ENABLE : in std_logic;
- DATA_IN: in std_logic_vector (WIDTH - 1 downto 0);
- READ_ENABLE : in std_logic;
- RESET : in std_logic;
- CLOCK : in std_logic;
- DATA_OUT : out std_logic_vector (WIDTH - 1 downto 0);
- EMPTY : out std_logic);
- end component FIFO;
+ end component EXP_GOLOMB_COUNTER;
+
SIGNAL ENABLE : std_logic;
SIGNAL DATA_IN : std_logic := '0';
- SIGNAL RESET : std_logic;
+ SIGNAL RESET : std_logic := '1';
SIGNAL CLOCK : std_logic := '0';
+ signal FLUSH : std_logic := '0';
+ signal HALVECOUNTS : std_logic := '0';
SIGNAL SENDING : std_logic;
SIGNAL DATA_OUT : std_logic;
signal TRANSMIT : std_logic;
signal DATA_TRANSFER : std_logic;
+ signal FLUSH_COMPLETE : std_logic;
signal DATA_IN2 : std_logic_vector (0 downto 0);
signal BUFFERED2 : std_logic_vector (0 downto 0);
--- signal FINISHED : std_logic := '0';
signal FIFO_EMPTY : std_logic;
signal BUFFERED : std_logic;
- constant PERIOD : time := 10 ns;
+ constant PERIOD : time := 16 ns;
signal CONTEXT_ENABLE : std_logic;
signal DECODER_CONTEXT_ENABLE : std_logic;
- signal CONTEXT : std_logic_vector (5 downto 0) := "000000";
+ signal NUMBITS : std_logic_vector (31 downto 0) := "00000000000000000000000000000000";
+ signal NEXTNUMBITS : std_logic_vector (31 downto 0);
+ signal NUMBYTES : std_logic_vector (28 downto 0);
+ signal CONTEXT_IN : std_logic_vector (5 downto 0) := "000000";
signal DECODER_CONTEXT : std_logic_vector (5 downto 0) := "000000";
- file TESTDATA : text open read_mode is "testseq";
- file RESULTS : text open write_mode is "results";
- type TABLE is array (30 downto 0) of std_logic_vector (5 downto 0);
- constant NCONTEXT0 : TABLE := ("111101","111011","111001","110111",
- "110101","110011","110001","101111","101101","101011","101001",
- "100111","100101","100011","100001","011111","011101","011011",
- "011001","010111","010101","010011","010001","001111","001101",
- "001011","001001","000111","000101","000011","000001");
- constant NCONTEXT1 : TABLE := ("111110","111100","111010","111000",
- "110110","110100","110010","110000","101110","101100","101010",
- "101000","100110","100100","100010","100000","011110","011100",
- "011010","011000","010110","010100","010010","010000","001110",
- "001100","001010","001000","000110","000100","000010");
-
+ signal BYTECOUNT : std_logic_vector (31 downto 0);
+ signal EXP_GOLOMB_READY : std_logic;
+ signal EXP_GOLOMB_DATA : std_logic;
+ signal BYTE_INSERT : std_logic := '0';
+ signal COMPVAL : character;
+ signal SUPPRESS_READ : std_logic := '0';
+ type ENCODER_STATUS is (INIT, INIT2, HEADERS, CODING, FLUSHING, EXP_GOLOMB, WRITE_DATA, FINISHED);
+ signal STATE : ENCODER_STATUS := INIT;
+ type RAM is array (65535 downto 0) of integer;
+ signal STORAGE : RAM;
+ type CHARFILE is file of character;
+ file raw_data : CHARFILE open read_mode is "test1.dr0";
+ file contexts : CHARFILE open read_mode is "test1.ctx";
+ file coded_stream : CHARFILE open write_mode is "test1.drc";
+ file comparison_data : CHARFILE open read_mode is "test1.dr1";
+ type INTARRAY is array (7 downto 0) of integer;
+ function CONTEXT_INTERPRET(CONTEXT : integer) return std_logic_vector is
+ variable VALUE : std_logic_vector(5 downto 0);
+ begin
+ if CONTEXT >= 128 then
+ VALUE(5) := '1';
+ else
+ VALUE(5) := '0';
+ end if;
+ if (CONTEXT mod 128) >= 64 then
+ VALUE(4) := '1';
+ else
+ VALUE(4) := '0';
+ end if;
+ if (CONTEXT mod 64) >= 32 then
+ VALUE(3) := '1';
+ else
+ VALUE(3) := '0';
+ end if;
+ if (CONTEXT mod 32) >= 16 then
+ VALUE(2) := '1';
+ else
+ VALUE(2) := '0';
+ end if;
+ if (CONTEXT mod 16) >= 8 then
+ VALUE(1) := '1';
+ else
+ VALUE(1) := '0';
+ end if;
+ if (CONTEXT mod 8) >= 4 then
+ VALUE(0) := '1';
+ else
+ VALUE(0) := '0';
+ end if;
+ return VALUE;
+ end function CONTEXT_INTERPRET;
BEGIN
uut: arithmeticcoder
--- generic map(
--- PROB => "1110010000")
PORT MAP(
ENABLE => ENABLE,
DATA_IN => DATA_IN,
CONTEXT_ENABLE => CONTEXT_ENABLE,
- CONTEXT_IN => CONTEXT,
+ CONTEXT_IN => CONTEXT_IN,
+ HALVECOUNTS_IN => HALVECOUNTS,
+ FLUSH => FLUSH,
RESET => RESET,
CLOCK => CLOCK,
SENDING => TRANSMIT,
- DATA_OUT => DATA_TRANSFER
+ DATA_OUT => DATA_TRANSFER,
+ FLUSH_COMPLETE => FLUSH_COMPLETE
);
- CLOCK <= not CLOCK after PERIOD/2;
-
- DECODER: ARITHMETICDECODER
- port map( ENABLE => TRANSMIT,
- DATA_IN => DATA_TRANSFER,
- NEWCONTEXT => DECODER_CONTEXT_ENABLE,
- CONTEXT_SELECT => DECODER_CONTEXT,
+ EGC: EXP_GOLOMB_COUNTER
+ port map(
+ DATA_IN => BYTECOUNT,
+ TEST => FLUSH_COMPLETE,
RESET => RESET,
CLOCK => CLOCK,
- SENDING => SENDING,
- DATA_OUT => DATA_OUT);
+ COUNTING => EXP_GOLOMB_READY,
+ DATA_OUT => EXP_GOLOMB_DATA);
+
+
+
+ CLOCK <= not CLOCK after PERIOD/2;
+
--*** Test Bench - User Defined Section ***
- tb : PROCESS
- variable GETLINE : line;
- variable INDATA : std_logic;
+ tb : PROCESS (CLOCK)
+ variable POSITION : integer;
+ variable EGPOSITION : integer;
+ variable PLACE : integer;
+ variable READVAL : character;
+ variable WRITEVAL : integer;
+ variable CONTEXT : integer;
+ variable DATA : integer;
+ variable COMPDATA : integer;
+ variable THRESHOLD : integer;
+ variable INDEX : integer range 0 to 536870911;
+ variable READ_DATA : INTARRAY := (0,0,0,0,0,0,0,0);
+ variable DUMMY : character;
+
BEGIN
- for COUNT in 0 to 5242880 loop
- wait until CLOCK'event and CLOCK = '1';
- if (COUNT < 5242900) then
- if COUNT = 0 then
+ if CLOCK'event and CLOCK = '1' then
+ if STATE = INIT then
+ if READ_DATA = ( 16#4B#, 16#57#, 16#2D#, 16#44#, 16#49#, 16#52#, 16#41#, 16#43#) then
+ STATE <= INIT2;
+ RESET <= '0';
+ else
+ READ_DATA(7 downto 1) := READ_DATA(6 downto 0);
+ read(raw_data,READVAL);
+ READ_DATA(0) := character'pos(READVAL);
+ end if;
+ elsif STATE = INIT2 then
+ if READ_DATA (7 downto 3) = ( 16#44#, 16#49#, 16#52#, 16#41#, 16#43#) then
+ STATE <= HEADERS;
+ WRITEVAL := 0;
+ EGPOSITION := 128;
+ else
+ WRITEVAL := READ_DATA(7);
+ write(coded_stream,character'val(WRITEVAL));
+ READ_DATA(7 downto 1) := READ_DATA (6 downto 0);
+ end if;
+ elsif STATE = HEADERS then
+ if READ_DATA (7 downto 3) = ( 16#42#, 16#42#, 16#43#, 16#44#, 16#AC# ) then
+ STATE <= CODING;
+ PLACE := 0;
+ POSITION := 0;
RESET <= '1';
ENABLE <= '0';
DATA_IN <= '0';
- CONTEXT_ENABLE <='0';
- elsif COUNT = 1 then
- RESET <= '0';
- CONTEXT_ENABLE <= '1';
- elsif COUNT mod 5 = 0 then
- CONTEXT_ENABLE <= '1';
- ENABLE <= '0';
- elsif (COUNT - 4) mod 5 = 0 then
+ CONTEXT_ENABLE <= '0';
+ CONTEXT_IN <= "000000";
+ HALVECOUNTS <= '0';
+ FLUSH <= '0';
+ if SUPPRESS_READ = '0' then
+ read(comparison_data,DUMMY);
+ COMPVAL <= DUMMY;
+ end if;
+ elsif READ_DATA (7 downto 3) = (16#42#, 16#42#, 16#43#, 16#44#, 16#D0# ) then
+ STATE <= FINISHED;
+ else
+ if EGPOSITION = 128 then
+ read(raw_data,READVAL);
+ READ_DATA(2) := character'pos(READVAL);
+ end if;
+ if READ_DATA(7) > 127 then
+ WRITEVAL := WRITEVAL + EGPOSITION;
+ end if;
- if (COUNT - 4) mod 160 = 0 then
- if not endfile(TESTDATA) then
- readline(TESTDATA,GETLINE);
+ for I in 7 downto 2 loop
+ if READ_DATA(I) > 127 then
+ READ_DATA(I) := (READ_DATA(I) -128) * 2;
+ else
+ READ_DATA(I) := READ_DATA(I) * 2;
end if;
+ if READ_DATA(I-1) > 127 then
+ READ_DATA(I) := READ_DATA(I) + 1;
end if;
- read(GETLINE,INDATA);
- DATA_IN <= INDATA;
- ENABLE <= '1';
- if (CONTEXT > "011110") then
- CONTEXT <= "000000";
+ end loop;
+ if EGPOSITION = 1 then
+ write(coded_stream,character'val(WRITEVAL));
+ EGPOSITION := 128;
+ WRITEVAL := 0;
+ else
+ EGPOSITION := EGPOSITION / 2;
+ end if;
+ end if;
+ elsif STATE = CODING then
+ if PLACE = 0 then
+ RESET <= '0';
+ end if;
+ if PLACE mod 5 = 0 then
+ read(contexts,READVAL);
+ CONTEXT := character'pos(READVAL);
+ CONTEXT_ENABLE <= '1';
+ if CONTEXT mod 2 = 1 then
+ CONTEXT_IN <= "000000";
+ HALVECOUNTS <= '0';
+ STATE <= FLUSHING;
+ FLUSH <= '1';
else
- if (INDATA = '1') then
- CONTEXT <= NCONTEXT1(conv_integer(CONTEXT));
+ CONTEXT_IN <= CONTEXT_INTERPRET(CONTEXT);
+ if (CONTEXT mod 4) > 1 then
+ HALVECOUNTS <= '1';
else
- CONTEXT <= NCONTEXT0(conv_integer(CONTEXT));
+ HALVECOUNTS <= '0';
+ end if;
+ FLUSH <= '0';
end if;
+ elsif PLACE mod 5 = 3 then
+ if POSITION = 0 then
+ POSITION := 128;
+ READ(raw_data,READVAL);
+ DATA := character'pos(READVAL);
end if;
+ if (DATA / POSITION) mod 2 = 1 then
+ DATA_IN <= '1';
else
+ DATA_IN <= '0';
+ end if;
+ ENABLE <= '1';
+ POSITION := POSITION / 2;
+ else
+ CONTEXT_ENABLE <= '0';
ENABLE <= '0';
+ end if;
+ PLACE := PLACE + 1;
+ elsif STATE = FLUSHING then
+ if FLUSH = '1' then
+ FLUSH <= '0';
CONTEXT_ENABLE <= '0';
end if;
- elsif (COUNT = 5242900) then
- ENABLE <= '1';
- DATA_IN <= '1';
+ if FLUSH_COMPLETE = '1' then
+ STATE <= EXP_GOLOMB;
+ PLACE := 7;
+ POSITION := 128;
+ READ_DATA(7) := 0;
+ end if;
+ elsif STATE = EXP_GOLOMB then
+ if EXP_GOLOMB_READY = '0' then
+ STATE <= WRITE_DATA;
+ INDEX := 0;
+ write(coded_stream,character'val(WRITEVAL));
+ PLACE := 7;
else
- wait; -- will wait forever
+ if EXP_GOLOMB_DATA = '1' then
+ WRITEVAL := WRITEVAL + EGPOSITION;
+ end if;
+ if EGPOSITION = 1 then
+ EGPOSITION := 128;
+ write(coded_stream,character'val(WRITEVAL));
+ WRITEVAL := 0;
+ else
+ EGPOSITION := EGPOSITION / 2;
end if;
- end loop;
- END PROCESS;
-
- OUTPUT : process
- variable OUTLINE : line;
- begin
- for WRITTEN in 0 to 1048576 loop
- wait until CLOCK'event and CLOCK = '1' and SENDING = '1';
- if WRITTEN = 1048576 then
- report "Process Complete" severity failure;
- wait;
- else
- write(OUTLINE,DATA_OUT);
- if (WRITTEN mod 32) = 31 then
- writeline(RESULTS,OUTLINE);
end if;
-
+ elsif STATE = WRITE_DATA then
+ if INDEX = (conv_integer(NUMBYTES)-1) then
+ STATE <= HEADERS;
+ WRITEVAL := 0;
+ else
+ if PLACE < 3 then
+ WRITEVAL := READ_DATA(7);
+ write(coded_stream,character'val(WRITEVAL));
+ READ_DATA (7 downto 3) := READ_DATA (6 downto 2);
+ READ_DATA (2) := STORAGE(INDEX);
+ else
+ READ_DATA (PLACE) := STORAGE(INDEX);
+ PLACE := PLACE - 1;
+ end if;
+ INDEX := INDEX + 1;
+ end if;
+ else --STATE = FINISHED
+ if READ_DATA (7 downto 3) = (0, 0, 0, 0, 0) then
+ report ("finished") severity failure;
+ else
+ WRITEVAL := READ_DATA(7);
+ write(coded_stream,character'val(WRITEVAL));
+ READ_DATA (7 downto 3) := READ_DATA (6 downto 3) & 0;
+ end if;
+ end if;
end if;
- end loop;
- end process;
-TESTBUFFER : FIFO
- generic map(RANK => 11,
- WIDTH => 1)
- port map (WRITE_ENABLE => ENABLE,
- DATA_IN => DATA_IN2,
- READ_ENABLE => SENDING,
- RESET => RESET,
- CLOCK => CLOCK,
- DATA_OUT => BUFFERED2,
- EMPTY => FIFO_EMPTY);
- DATA_IN2(0) <= DATA_IN;
- BUFFERED <= BUFFERED2(0);
-FIND_ERROR : postponed process (SENDING, DATA_OUT, BUFFERED)
- begin
- assert (( SENDING /= '1') or (DATA_OUT = BUFFERED))
- report "DIVERGENGE!!!" severity failure;
- end process FIND_ERROR;
+ END PROCESS;
--- *** End Test Bench - User Defined Section ***
-COUNT_BITS: process (CLOCK, TRANSMIT)
- variable BITS_SENT : integer range 0 to 1048576 := 0;
+COUNT_BITS: process (CLOCK)
begin
- if (CLOCK'event and CLOCK='1' and TRANSMIT='1') then
- BITS_SENT := BITS_SENT+1;
+ if (CLOCK'event and CLOCK='1') then
+ if RESET = '1' then
+ NUMBITS <= "00000000000000000000000000000000";
+ else
+ if TRANSMIT = '1' then
+ NUMBITS <= NUMBITS + "00000000000000000000000000000001";
+ end if;
+ if BYTE_INSERT = '1' then
+ NUMBITS <= NUMBITS + "00000000000000000000000000001000";
+ end if;
+ end if;
end if;
end process;
+NEXTNUMBITS <= NUMBITS + "00000000000000000000000000000111";
+NUMBYTES <= NEXTNUMBITS (31 downto 3);
-CHOOSE_DECODER_CONTEXT: process(CLOCK)
- begin
+ BYTECOUNT <= "0000000000000000" & NUMBYTES(15 downto 0);
+
+
+WRITE_MEMORY: process(CLOCK)
+ variable INCREMENT: integer;
+ variable DATA : integer;
+ variable COMPARISON : character;
+ variable COMPDATA : integer;
+ variable COMPDATA2 : integer;
+begin
if CLOCK'event and CLOCK = '1' then
if RESET = '1' then
- DECODER_CONTEXT <= "000000";
- DECODER_CONTEXT_ENABLE <= '1';
- elsif SENDING = '1' then
- if DECODER_CONTEXT > "011110" then
- DECODER_CONTEXT <= "000000";
- elsif DATA_OUT = '1' then
- DECODER_CONTEXT <= NCONTEXT1(conv_integer(DECODER_CONTEXT));
+ INCREMENT := 128;
+ BYTE_INSERT <= '0';
+ if SUPPRESS_READ = '0' then
+ COMPDATA := character'pos(COMPVAL);
+ end if;
+ COMPDATA2 := 0;
+ DATA := 0;
+ elsif TRANSMIT = '1' then
+ if (COMPDATA rem (INCREMENT*2)) >= INCREMENT then
+ COMPDATA2 := COMPDATA2 + INCREMENT;
+ end if;
+ if DATA_TRANSFER = '1' then
+ DATA := DATA + INCREMENT;
+ end if;
+ assert COMPDATA2 = DATA report "ENCODER HAS DIVERGED" severity failure;
+ if INCREMENT = 1 then
+ STORAGE(conv_integer(NUMBYTES)-1) <= DATA;
+ DATA := 0;
+ INCREMENT := 128;
+ read(comparison_data,COMPARISON);
+ COMPDATA := character'pos(COMPARISON);
+ COMPDATA2 := 0;
+ if NUMBYTES >= "00000000000000000000000000100" then
+ if STORAGE((conv_integer(NUMBYTES) -4) downto (conv_integer(NUMBYTES) - 1)) = (16#42#, 16#42#, 16#43#, 16#44#) then
+ STORAGE(conv_integer(NUMBYTES)) <= 16#FF#;
+ BYTE_INSERT <= '1';
+ end if;
+ end if;
else
- DECODER_CONTEXT <= NCONTEXT0(conv_integer(DECODER_CONTEXT));
+ INCREMENT := INCREMENT/2;
end if;
- DECODER_CONTEXT_ENABLE <= '1';
+ elsif FLUSH_COMPLETE = '1' then
+ if INCREMENT /= 128 then
+ STORAGE(conv_integer(NUMBYTES)) <= DATA;
+ if NUMBYTES >= "00000000000000000000000000100" then
+ if STORAGE((conv_integer(NUMBYTES) -3) downto (conv_integer(NUMBYTES))) = (16#42#, 16#42#, 16#43#, 16#44#) then
+ STORAGE(conv_integer(NUMBYTES)+1) <= 16#FF#;
+ BYTE_INSERT <= '1';
+ end if;
+ end if;
+ SUPPRESS_READ <= '0';
else
- DECODER_CONTEXT_ENABLE <= '0';
+ SUPPRESS_READ <= '1';
end if;
end if;
-end process CHOOSE_DECODER_CONTEXT;
-
-
+ if BYTE_INSERT = '1' then
+ BYTE_INSERT <= '0';
+ end if;
+ end if;
+end process WRITE_MEMORY;
END;
1.1 dirac/src/testbench/test1.ctx.bz2
http://www.opencores.org/cvsweb.shtml/dirac/src/testbench/test1.ctx.bz2?rev=1.1&content-type=text/x-cvsweb-markup
<<Binary file>>
1.1 dirac/src/testbench/test1.dr0
http://www.opencores.org/cvsweb.shtml/dirac/src/testbench/test1.dr0?rev=1.1&content-type=text/x-cvsweb-markup
<<Binary file>>
1.1 dirac/src/testbench/test1.dr1
http://www.opencores.org/cvsweb.shtml/dirac/src/testbench/test1.dr1?rev=1.1&content-type=text/x-cvsweb-markup
<<Binary file>>
|
 |