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

Subversion Repositories mkjpeg

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

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

powered by: WebSVN 2.1.0

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