OSDN Git Service

Merge branch 'hw-huffdctycc' into debug-netmjpeg
[fpga-leon-mjpeg/leon-mjpeg.git] / grlib-gpl-1.0.22-b4095 / designs / work_ip / sim_upycc.vhd
1 ------------------------------------------------------------------------------
2 --  Copyright (C) 2010, Kenichi Kurimoto
3 --
4 --  This program is free software; you can redistribute it and/or modify
5 --  it under the terms of the GNU General Public License as published by
6 --  the Free Software Foundation; either version 2 of the License, or
7 --  (at your option) any later version.
8 --
9 --  This program is distributed in the hope that it will be useful,
10 --  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 --  GNU General Public License for more details.
13 --
14 --  You should have received a copy of the GNU General Public License
15 --  along with this program; if not, write to the Free Software
16 --  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
17 -----------------------------------------------------------------------------
18
19
20
21 library ieee;
22 use ieee.std_logic_1164.all;
23 use std.textio.all;
24 use ieee.std_logic_textio.all;
25 --use ieee.numeric_std.all;
26
27
28 library gaisler;
29 use gaisler.sim.all;
30 use gaisler.ambatest.all;
31 use gaisler.ahbtbp.all;
32 library techmap;
33 use techmap.gencomp.all;
34 library grlib;
35 use grlib.stdlib.all;
36 library kuri;
37 use kuri.mjpeg.all;
38
39 use work.debug.all;
40 use work.config.all;
41
42
43
44 entity sim_upycc is
45   
46   generic (
47     clkperiod : integer := 20);
48
49 end ;
50
51 architecture behav of sim_upycc is
52
53
54
55   component bus_upycc
56     port(
57       rstn : in std_ulogic;
58       clk : in std_ulogic;
59       ctrl_in1 : in ahbtbm_ctrl_in_type;
60       ctrl_out1 : out ahbtbm_ctrl_out_type
61       );
62     
63   end component;
64
65 signal clk : std_ulogic := '0';
66 signal rst : std_ulogic := '0';
67 signal ctrl1 : ahbtb_ctrl_type;
68 -- signal data_in : std_logic_vector(31 downto 0);
69
70 file in_file : text open read_mode is "in_upycc.txt";
71 file compare_file : text open read_mode is "out_upycc.txt";
72
73 begin  -- behav
74
75     b0 : bus_upycc
76     port map (rst,clk,ctrl1.i,ctrl1.o);
77    
78     tictak : process
79     begin
80         clk <= '0';
81         wait for 10 ns;
82         clk <= '1';
83         wait for 10 ns;
84     end process;
85     
86     stim: process
87        variable li : line;
88        variable lc : line;
89        variable i,j : integer;
90   --     variable ycc : std_logic_vector(23 downto 0);
91        variable eightbdata : std_logic_vector(7 downto 0);
92        variable indata : std_logic_vector(31 downto 0);
93        variable radd : std_logic_vector(31 downto 0);
94   --     variable cdata1, cdata2 : std_logic_vector(15 downto 0);
95        variable cdata32 : std_logic_vector(31 downto 0);
96        
97     begin
98
99       report " stimulus process start ";
100       
101       rst  <= '0';   
102       wait for 100 ns;
103       rst <= '1';
104
105     -- initialize
106       ahbtbminit(ctrl1);
107
108 -- Write Control registers through APB bus
109
110 ahbwrite(x"80000200", x"a0000000", "10", "10", '1', 2, false , ctrl1);
111 ahbwrite(x"80000204", x"00082464", "10", "10", '1', 2, false , ctrl1);
112 ahbwrite(x"80000208", x"04E4B504", "10", "10", '1', 2, false , ctrl1);
113 ahbwrite(x"8000020C", x"00000000", "10", "10", '1', 2, false , ctrl1);
114 ahbwrite(x"8000020C", x"ffffffff", "10", "10", '1', 2, false , ctrl1);
115
116 -- Write YCC data for IP core      
117 --      for i in 0 to 33821 loop
118       for i in 0 to 3999 loop
119         readline(in_file,li);
120         hread(li, eightbdata);
121         indata := x"000000" & eightbdata;
122         ahbwrite(x"90000000", indata, "10", "10", '1', 2, false , ctrl1);                   
123         ahbtbmidle(true, ctrl1);
124         wait for 20 ns;
125       end loop;
126       
127       radd := x"a0000000";  
128 --      for i in 0 to 79 loop
129       for i in 0 to 17 loop
130         for j in 0 to 39 loop
131           readline(compare_file, lc);
132           hread(lc, cdata32);
133           ahbread(radd, cdata32, "10", 2, false, ctrl1);
134           radd := radd + x"004";
135         end loop;
136         radd := radd + x"460";
137       end loop;
138       
139       ahbtbmidle(true,ctrl1);
140       wait for 100 ns; 
141   
142        
143       ahbtbmdone(0, ctrl1);
144       wait for 300 ns;
145
146       report "stimulus process end" severity failure;
147       wait;
148    end process;
149
150 end behav;