OpenCores
URL https://opencores.org/ocsvn/mkjpeg/mkjpeg/trunk

Subversion Repositories mkjpeg

[/] [mkjpeg/] [trunk/] [tb/] [vhdl/] [JPEG_TB.VHD] - Blame information for rev 51

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 mikel262
--------------------------------------------------------------------------------
2
--                                                                            --
3
--                          V H D L    F I L E                                --
4
--                          COPYRIGHT (C) 2006                                --
5
--                                                                            --
6
--------------------------------------------------------------------------------
7
--
8
-- Title       : JPEG_TB
9
-- Design      : JPEG_ENC
10
-- Author      : Michal Krepa
11
--
12
--------------------------------------------------------------------------------
13
--
14
-- File        : JPEG_TB.VHD
15
-- Created     : Sun Mar 1 2009
16
--
17
--------------------------------------------------------------------------------
18
--
19
--  Description : Testbench top-level
20
--
21
--------------------------------------------------------------------------------
22
 
23
library IEEE;
24
  use IEEE.STD_LOGIC_1164.all;
25
  use ieee.numeric_std.all;
26
  use IEEE.STD_LOGIC_TEXTIO.ALL;
27
 
28
library STD;
29
  use STD.TEXTIO.ALL;
30
 
31
library work;
32
  use work.GPL_V2_Image_Pkg.ALL;
33
  use WORK.MDCT_PKG.all;
34
  use WORK.MDCTTB_PKG.all;
35 49 mikel262
  use work.JPEG_PKG.all;
36 25 mikel262
 
37
entity JPEG_TB is
38
end JPEG_TB;
39
 
40
--**************************************************************************--
41
 
42
architecture TB of JPEG_TB is
43
 
44
  type char_file is file of character;
45
 
46
  file f_capture           : text;
47
  file f_capture_bin       : char_file;
48
  constant CAPTURE_ORAM    : string := "OUT_RAM.txt";
49
  constant CAPTURE_BIN     : string := "test_out.jpg";
50
 
51
  signal CLK               : STD_LOGIC;
52
  signal RST               : STD_LOGIC;
53
 
54
  signal ram_rdaddr        : std_logic_vector(23 downto 0);
55
  signal ram_q             : std_logic_vector(7 downto 0);
56
  signal ram_byte          : std_logic_vector(7 downto 0);
57
  signal ram_wren          : std_logic;
58
  signal ram_wraddr        : std_logic_vector(23 downto 0);
59
 
60
  signal OPB_ABus          : std_logic_vector(31 downto 0);
61
  signal OPB_BE            : std_logic_vector(3 downto 0);
62
  signal OPB_DBus_in       : std_logic_vector(31 downto 0);
63
  signal OPB_RNW           : std_logic;
64
  signal OPB_select        : std_logic;
65
  signal OPB_DBus_out      : std_logic_vector(31 downto 0);
66
  signal OPB_XferAck       : std_logic;
67
  signal OPB_retry         : std_logic;
68
  signal OPB_toutSup       : std_logic;
69
  signal OPB_errAck        : std_logic;
70
  signal iram_waddr        : std_logic_vector(19 downto 0);
71
  signal iram_raddr        : std_logic_vector(19 downto 0);
72 49 mikel262
  signal iram_wdata        : std_logic_vector(C_PIXEL_BITS-1 downto 0);
73
  signal iram_rdata        : std_logic_vector(C_PIXEL_BITS-1 downto 0);
74 25 mikel262
  signal iram_wren         : std_logic;
75
  signal iram_rden         : std_logic;
76
  signal sim_done          : std_logic;
77
  signal iram_fifo_afull   : std_logic;
78 42 mikel262
  signal outif_almost_full : std_logic;
79
  signal count1            : unsigned(15 downto 0);
80 25 mikel262
------------------------------
81
-- architecture begin
82
------------------------------
83
begin
84
 
85
 
86
 
87
 
88
  ------------------------------
89
  -- CLKGEN map
90
  ------------------------------
91
  U_ClkGen : entity work.ClkGen
92
        port map
93
  (
94
     CLK            => CLK,
95
     RST            => RST
96
        );
97
 
98
  ------------------------------
99
  -- HOST Bus Functional Model
100
  ------------------------------
101
  U_HostBFM : entity work.HostBFM
102
  port map
103
  (
104
        CLK            => CLK,
105
        RST            => RST,
106
        -- OPB
107
        OPB_ABus       => OPB_ABus,
108
        OPB_BE         => OPB_BE,
109
        OPB_DBus_in    => OPB_DBus_in,
110
        OPB_RNW        => OPB_RNW,
111
        OPB_select     => OPB_select,
112
        OPB_DBus_out   => OPB_DBus_out,
113
        OPB_XferAck    => OPB_XferAck,
114
        OPB_retry      => OPB_retry,
115
        OPB_toutSup    => OPB_toutSup,
116
        OPB_errAck     => OPB_errAck,
117
 
118
        -- IRAM
119
        iram_wdata     => iram_wdata,
120
        iram_wren      => iram_wren,
121
        fifo_almost_full => iram_fifo_afull,
122
 
123
        sim_done       => sim_done
124
    );
125
 
126
  ------------------------------
127
  -- JPEG ENCODER
128
  ------------------------------
129
  U_JpegEnc : entity work.JpegEnc
130
  port map
131
  (
132
        CLK                => CLK,
133
        RST                => RST,
134
 
135
        -- OPB
136
        OPB_ABus           => OPB_ABus,
137
        OPB_BE             => OPB_BE,
138
        OPB_DBus_in        => OPB_DBus_in,
139
        OPB_RNW            => OPB_RNW,
140
        OPB_select         => OPB_select,
141
        OPB_DBus_out       => OPB_DBus_out,
142
        OPB_XferAck        => OPB_XferAck,
143
        OPB_retry          => OPB_retry,
144
        OPB_toutSup        => OPB_toutSup,
145
        OPB_errAck         => OPB_errAck,
146
 
147
        -- IMAGE RAM
148
        iram_wdata         => iram_wdata,
149
        iram_wren          => iram_wren,
150
        iram_fifo_afull    => iram_fifo_afull,
151
 
152
        -- OUT RAM
153
        ram_byte           => ram_byte,
154
        ram_wren           => ram_wren,
155 42 mikel262
        ram_wraddr         => ram_wraddr,
156
        outif_almost_full  => outif_almost_full
157 25 mikel262
    );
158
 
159
  -------------------------------------------------------------------
160
  -- OUT RAM
161
  -------------------------------------------------------------------
162
  U_OUT_RAM : entity work.RAMSIM
163
  generic map
164
  (
165
      RAMADDR_W     => 18,
166
      RAMDATA_W     => 8
167
  )
168
  port map
169
  (
170
        d           => ram_byte,
171
        waddr       => ram_wraddr(17 downto 0),
172
        raddr       => ram_rdaddr(17 downto 0),
173
        we          => ram_wren,
174
        clk         => CLK,
175
 
176
        q           => ram_q
177
  );
178
 
179
 
180
  p_capture : process
181
    variable fLine           : line;
182
    variable fLine_bin       : line;
183
  begin
184
    file_open(f_capture, CAPTURE_ORAM, write_mode);
185
    file_open(f_capture_bin, CAPTURE_BIN, write_mode);
186
 
187
    while sim_done /= '1' loop
188
      wait until rising_edge(CLK);
189
 
190
      if ram_wren = '1' then
191
        hwrite(fLine, ram_byte);
192
        write(fLine, string'(" "));
193
 
194
        write(f_capture_bin, CHARACTER'VAL(to_integer(unsigned(ram_byte))));
195
 
196
      end if;
197
 
198
    end loop;
199
    writeline(f_capture, fLine);
200
    --writeline(f_capture_bin, fLine_bin);
201
 
202
    file_close(f_capture);
203
    file_close(f_capture_bin);
204
 
205
    wait;
206
  end process;
207
 
208 42 mikel262
 
209
  backpressure : process(CLK, RST)
210
  begin
211
    if RST = '1' then
212
      outif_almost_full <= '0';
213
      count1 <= (others => '0');
214
    elsif CLK'event and CLK = '1' then
215 51 mikel262
      --if count1 = 10000 then
216
      --  count1 <= (others => '0');
217
      --  outif_almost_full <= not outif_almost_full;
218
      --else
219
      --  count1 <= count1 + 1;
220
      --end if;
221 42 mikel262
    end if;
222
  end process;
223 25 mikel262
 
224
end TB;
225
-----------------------------------
226
 
227
 
228
--**************************************************************************--

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.