source: PROJECT_CORE_MPI/MPI_HCL/BRANCHES/v2.1/Timer_Par/mpi_test.vhd @ 160

Last change on this file since 160 was 157, checked in by rolagamo, 10 years ago
File size: 5.3 KB
Line 
1--------------------------------------------------------------------------------
2-- Company:
3-- Engineer:
4--
5-- Create Date:   07:29:14 03/26/2013
6-- Design Name:   
7-- Module Name:   C:/Core MPI/CORE_MPI/mpi_test.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: MultiMPITest
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--------------------------------------------------------------------------------
28use std.textio.all;
29LIBRARY ieee;
30USE ieee.std_logic_1164.ALL;
31USE  ieee.std_logic_textio.ALL; 
32 
33-- Uncomment the following library declaration if using
34-- arithmetic functions with Signed or Unsigned values
35USE ieee.numeric_std.ALL;
36library NocLib ;
37
38use NocLib.CoreTypes.all; 
39ENTITY mpi_test IS
40END mpi_test;
41 
42ARCHITECTURE behavior OF mpi_test IS 
43 signal clk,reset : std_logic:='0';
44 signal led : std_logic_vector(15 downto 0);
45 signal sw : std_logic_vector(15 downto 0);
46 signal COM_RX : std_logic := '0';
47 signal COM_TX : std_logic := '0';
48    -- Component Declaration for the Unit Under Test (UUT)
49 
50    COMPONENT MPI_template is
51   
52         port (clk100Mhz : in std_logic;
53                rstN : in std_logic;
54                sw : in std_logic_vector(15 downto 0);
55                Led : out std_logic_vector(15 downto 0);
56                RsRX      : in  STD_LOGIC;
57                RsTX     : out STD_LOGIC);
58    END COMPONENT;
59   
60 
61 type memory is array( integer range <>) of std_logic_vector(7 downto 0);
62 constant period  : time := 68 ns ;
63 constant   BITperiod :  time := 4340 ns ; -- 10ns*100Mhz/115200 ; 9600--
64  signal  RSData :std_logic_vector (7 downto 0):=x"00";
65
66 signal n,m : natural:=0;
67   constant clk_period : time := 10 ns;
68   CONSTANT DSIZE :NATURAL:=8000;
69   CONSTANT RSIZE :NATURAL:=1023;
70 function init_mem(size : natural) return memory is
71variable dt: memory(0 to size-1);
72 begin
73 for i in 0 to size-1 loop
74 if i<32 then
75 dt(i):=std_logic_vector(to_unsigned(i+32,WORD));
76 else
77 dt(i):=std_logic_vector(to_unsigned(i,WORD));
78 end if;
79 end loop;
80 return dt;
81 end function;
82  signal Data_to_send :memory(0 to DSIZE-1);--:=init_mem(DSIZE);
83  signal Data_receiv : memory(0 to RSIZE);
84BEGIN
85 
86        -- Instantiate the Unit Under Test (UUT)
87   uut: MPI_template PORT MAP (
88                clk100Mhz=>clk,
89                rstN=>reset, --RESET NEGATIF
90                led=>led,
91                sw=>sw,
92                RsRX => Com_rx,   
93                RsTX    => Com_tx
94        );
95
96   -- Clock process definitions
97   clk_process :process
98   begin
99                clk <= '0';
100                wait for clk_period/2;
101                clk <= '1';
102                wait for clk_period/2;
103   end process;
104 
105  --reset
106  res_proc:process --test du reset
107  begin         
108      -- hold reset state for 100 ns.
109      --reset<='1';
110     -- wait for 100 us;
111      reset<='0';
112      wait for 250 ns;
113      reset<='1';
114--      wait for 1 ms;
115--      reset<='0';
116--      wait for 150 ns;
117--      reset<='1';
118--      wait for 100 us;
119--      reset<='0';
120--      wait for 150 ns;
121--      reset<='1';
122      wait;
123end process;
124   -- Stimulus process
125  sw_proc: process --test des switch
126   begin               
127
128      sw<=x"0000"; --application s'exécute
129      wait for 100 us;
130                  sw<=x"000b"; --envoie des données sur le port série
131                  wait for 100 ns;
132                  sw<=x"001a";--fin de la commande d'envoie des données
133                  wait for 50 ns;
134                  sw<=x"002b"; --activation de la commande pour spawn
135                   wait for 300 ns;
136                  sw<=x"005a";--
137                  wait for 50 ns;
138                                  sw<=x"006b"; --activation de la commande pour spawn
139                   wait for 3 us;
140                                  sw<=x"005a";--
141                  wait for 50 ns;
142                                  sw<=x"004b"; --activation de la commande pour spawn
143                   wait for 5 us;
144                                  sw<=x"005a";--
145      wait for 50 ns;--
146                                  sw<=x"005b"; --envoie des données à travers le port série
147                  wait for  3 us;
148                  sw<=x"0008";
149                  wait for 5 ms;
150                  sw<=x"0000";
151                  wait;
152        end process;
153   stim_proc: process
154   begin               
155     wait for 10 ns;
156    if led(14)='1' then --attendre le début de spawn
157                loop 
158      Com_Rx <= '1'; -- Idle
159             if n<Dsize then
160            RsData<=Data_to_send(n);
161          else
162            wait; ---fin de l'envoie !
163         end if; 
164       
165 wait for 100 * period;
166        com_Rx <= '0'; -- Start bit
167 wait for BITperiod;
168 for i in 0 to 7 loop
169 com_Rx <= RSData(i);  wait for BITperiod ;
170 end loop;
171 com_Rx <= '1'; -- Stop bit
172  n<=n+1;
173 wait for BITperiod;
174end loop;
175end if;
176   end process;
177recv_p:process
178 Variable L : line;
179 Variable MOT : std_logic_vector (7 downto 0);
180
181begin
182loop
183 wait until com_Tx ='0'; -- get falling edge ='0'; -- get falling edge
184 wait for (0.5 * BITperiod); -- Middle of Start bit ;
185 assert  com_Tx ='0'
186 report "Start Bit Error ???" severity warning;
187 wait for BITperiod ; -- First Data Bit
188 for i in 0 to 7 loop -- Get word
189 MOT(i):= com_Tx ; wait for BITperiod;--last wait is for stop bit
190 end loop;
191-- wait for BITperiod ;--stop bit
192 Data_receiv(m)<=Mot;--stocker le mot reçu en mémoire
193 m<=m+1;
194 if m=RSize then 
195    m<=0;
196end if;
197 assert com_Tx ='1'
198 report "Stop bit Error ???" severity warning;
199 WRITE (L,string'("Character received (hex) = "));
200 HWRITE (L,MOT); -- trace :
201 WRITELINE (output,L); -- char -> transcript
202 end loop;
203end process recv_p;
204
205END;
Note: See TracBrowser for help on using the repository browser.