source: PROJECT_CORE_MPI/MPI_HCL/TRUNK/CORE_MPI/test_DMA.vhd @ 100

Last change on this file since 100 was 100, checked in by rolagamo, 10 years ago
File size: 8.1 KB
Line 
1--------------------------------------------------------------------------------
2-- Company:
3-- Engineer:
4--
5-- Create Date:   14:37:10 03/18/2013
6-- Design Name:   
7-- Module Name:   C:/Core MPI/CORE_MPI/test_DMA.vhd
8-- Project Name:  MPI_CORE_COMPONENTS
9-- Target Device: 
10-- Tool versions: 
11-- Description:   
12--
13-- VHDL Test Bench Created by ISE for module: DMA_ARBITER
14--
15-- Dependencies:
16--
17-- Revision:
18-- Revision 0.01 - File Created
19-- Additional Comments:
20--
21-- Notes:
22-- This testbench has been automatically generated using types std_logic and
23-- std_logic_vector for the ports of the unit under test.  Xilinx recommends
24-- that these types always be used for the top-level I/O of a design in order
25-- to guarantee that the testbench will bind correctly to the post-implementation
26-- simulation model.
27--------------------------------------------------------------------------------
28LIBRARY ieee;
29USE ieee.std_logic_1164.ALL;
30 
31-- Uncomment the following library declaration if using
32-- arithmetic functions with Signed or Unsigned values
33--USE ieee.numeric_std.ALL;
34 
35ENTITY test_DMA IS
36END test_DMA;
37 
38ARCHITECTURE behavior OF test_DMA IS 
39 
40    -- Component Declaration for the Unit Under Test (UUT)
41 
42    COMPONENT DMA_ARBITER
43    PORT(
44         dma_rd_request : IN  std_logic_vector(3 downto 0);
45         data_wr_in : IN  std_logic_vector(7 downto 0);
46         data_rd_out : OUT  std_logic_vector(7 downto 0);
47         address_rd : IN  std_logic_vector(15 downto 0);
48         address_wr : IN  std_logic_vector(15 downto 0);
49         address_out_wr : OUT  std_logic_vector(15 downto 0);
50         address_out_rd : OUT  std_logic_vector(15 downto 0);
51         ram_en : OUT  std_logic;
52         ram_we : OUT  std_logic;
53         data_wr_mem : OUT  std_logic_vector(7 downto 0);
54         data_rd_mem : IN  std_logic_vector(7 downto 0);
55         dma_wr_grant : OUT  std_logic_vector(3 downto 0);
56         hold_req : OUT  std_logic;
57         hold_ack : IN  std_logic;
58         clk : IN  std_logic;
59         reset : IN  std_logic;
60         dma_rd_grant : OUT  std_logic_vector(3 downto 0);
61         dma_wr_request : IN  std_logic_vector(3 downto 0)
62        );
63    END COMPONENT;
64   
65COMPONENT RAM_v
66  generic (width : positive;size :positive);
67        PORT(
68                clka : IN std_logic;
69                clkb : IN std_logic;
70                wea : IN std_logic;
71                ena : IN std_logic;
72                enb : IN std_logic;
73                addra : IN std_logic_vector;
74                addrb : IN std_logic_vector;
75                dia : IN std_logic_vector;         
76                dob : OUT std_logic_vector
77                );
78        END COMPONENT;
79   --Inputs
80   signal dma_rd_request : std_logic_vector(3 downto 0) := (others => '0');
81   signal data_wr_in : std_logic_vector(7 downto 0) := (others => '0');
82   signal address_rd : std_logic_vector(15 downto 0) := (others => '0');
83   signal address_wr : std_logic_vector(15 downto 0) := (others => '0');
84   signal data_rd_mem : std_logic_vector(7 downto 0) := (others => '0');
85   signal hold_ack : std_logic := '0';
86   signal clk : std_logic := '0';
87   signal reset : std_logic := '0';
88   signal dma_wr_request : std_logic_vector(3 downto 0) := (others => '0');
89       
90        --Outputs
91   signal data_rd_out : std_logic_vector(7 downto 0);
92   signal address_out_wr : std_logic_vector(15 downto 0);
93   signal address_out_rd : std_logic_vector(15 downto 0);
94   signal ram_en : std_logic;
95   signal ram_we : std_logic;
96   signal data_wr_mem : std_logic_vector(7 downto 0);
97   signal dma_wr_grant : std_logic_vector(3 downto 0);
98   signal hold_req : std_logic;
99   signal dma_rd_grant : std_logic_vector(3 downto 0);
100
101   -- Clock period definitions
102   constant clk_period : time := 10 ns;
103 
104BEGIN
105 
106        -- Instantiate the Unit Under Test (UUT)
107   uut: DMA_ARBITER PORT MAP (
108          dma_rd_request => dma_rd_request,
109          data_wr_in => data_wr_in,
110          data_rd_out => data_rd_out,
111          address_rd => address_rd,
112          address_wr => address_wr,
113          address_out_wr => address_out_wr,
114          address_out_rd => address_out_rd,
115          ram_en => ram_en,
116          ram_we => ram_we,
117          data_wr_mem => data_wr_mem,
118          data_rd_mem => data_rd_mem,
119          dma_wr_grant => dma_wr_grant,
120          hold_req => hold_req,
121          hold_ack => hold_ack,
122          clk => clk,
123          reset => reset,
124          dma_rd_grant => dma_rd_grant,
125          dma_wr_request => dma_wr_request
126        );
127
128Inst_RAM_v: RAM_v generic map(width=>8,size=>16)
129        PORT MAP(
130                clka =>clk,
131                clkb => clk,
132                wea => ram_we,
133                ena => ram_en,
134                enb => ram_en,
135                addra => address_out_wr,
136                addrb =>address_out_rd,
137                dia => data_wr_mem,
138                dob => data_rd_mem
139        );
140   -- Clock process definitions
141   clk_process :process
142   begin
143                clk <= '0';
144                wait for clk_period/2;
145                clk <= '1';
146                wait for clk_period/2;
147   end process;
148 
149
150   -- Stimulus process
151   reset_proc: process
152   begin               
153      -- hold reset state for 100 ns.
154                reset <='1';
155      wait for 100 ns; 
156                reset<='0';
157      wait for clk_period*10;
158               
159      -- insert stimulus here
160
161      wait;
162   end process;
163       
164        stim_proc: process (clk,reset) 
165        variable i,j,k,l : std_logic_vector(15 downto 0);
166        variable x: integer ; --indique le temps à partir duquel chaque
167        --permet de faire des requêtes DMA et de les valider
168   begin       
169                if rising_edge(clk) then
170                        if reset ='1' then 
171                                x:=0;
172                        else
173                                x:=x+1;
174                                if x>=1 and x<=20 then
175                                dma_rd_request<="0001";
176                                elsif x>=21 and x<=40 then
177                                dma_rd_request<="0011";
178                                elsif x>=41 and x<=60 then
179                                dma_rd_request<="0010";
180                                elsif x>=61 and x<=80 then
181                                dma_rd_request<="0110";
182                                elsif x>=81 and x<=100 then
183                                dma_rd_request<="0100";
184                                elsif x>=61 and x<=80 then
185                                dma_rd_request<="1100";
186                                elsif x>=101 and x<=120 then
187                                dma_rd_request<="1101";
188                                elsif x>=121 and x<=140 then
189                                dma_rd_request<="1001";
190                                elsif x>=141 and x<=160 then
191                                dma_rd_request<="1000";
192                                elsif x>=161 and x<=180 then
193                                dma_rd_request<="0000";
194                                elsif x>=181 and x<=200 then
195                                dma_rd_request<="0111";
196                                elsif x>=181 and x<=200 then
197                                dma_rd_request<="1111";
198                                elsif x>=181 and x<=200 then
199                                dma_rd_request<="1110";
200                                else
201                                        x:=0;
202                               
203                                end if;
204       
205                        end if;
206      end if;
207   end process;
208stim2_proc: process (clk,reset) 
209        variable i,j,k,l : std_logic_vector(15 downto 0);
210        variable x: integer ; --indique le temps à partir duquel chaque
211        --permet de faire des requêtes DMA et de les valider
212   begin       
213                if rising_edge(clk) then
214                        if reset ='1' then 
215                                x:=0;
216                        else
217                                x:=x+1;
218                                if x>=1 and x<=10 then
219                                dma_wr_request<="0001";
220                                elsif x>=11 and x<=20 then
221                                dma_wr_request<="0011";
222                                elsif x>=21 and x<=30 then
223                                dma_wr_request<="0010";
224                                elsif x>=31 and x<=40 then
225                                dma_wr_request<="0110";
226                                elsif x>=41 and x<=50 then
227                                dma_wr_request<="0100";
228                                elsif x>=51 and x<=60 then
229                                dma_wr_request<="1100";
230                                elsif x>=61 and x<=80 then
231                                dma_wr_request<="1101";
232                                elsif x>=81 and x<=90 then
233                                dma_wr_request<="1001";
234                                elsif x>=91 and x<=100 then
235                                dma_wr_request<="1000";
236                                elsif x>=101 and x<=110 then
237                                dma_wr_request<="0000";
238                                elsif x>=111 and x<=120 then
239                                dma_wr_request<="0111";
240                                elsif x>=121 and x<=130 then
241                                dma_wr_request<="1111";
242                                elsif x>=131 and x<=200 then
243                                dma_wr_request<="1110";
244                                else
245                                        x:=0;
246                               
247                                end if;
248       
249                        end if;
250      end if;
251   end process;
252liredat:process (dma_rd_grant)
253begin
254
255
256if dma_rd_grant="0001" then
257address_rd<=x"0000";
258elsif dma_rd_grant="0010" then
259address_rd<=x"0002";
260elsif dma_rd_grant="0100" then
261address_rd<=x"0004";
262elsif dma_rd_grant="1000" then
263address_rd<=x"0006";
264else
265
266 address_rd<=x"0000";
267end if;
268
269end process;
270ecriredat:process (dma_wr_grant)
271begin
272
273
274if dma_wr_grant="0001" then
275address_wr<=x"0000";
276data_wr_in<=x"0a";
277elsif dma_rd_grant="0010" then
278address_wr<=x"0002";
279data_wr_in<=x"20";
280elsif dma_rd_grant="0100" then
281address_wr<=x"0004";
282data_wr_in<=x"a0";
283elsif dma_rd_grant="1000" then
284address_wr<=x"0006";
285data_wr_in<=x"0F";
286else
287
288 address_wr<=x"0000";
289 
290end if;
291
292end process;
293Hold_ack<=Hold_req; -- toujours autoriser la gestion de la mémoire par le DMA
294
295END;
Note: See TracBrowser for help on using the repository browser.