Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------------------------------
- -- Company:
- -- Engineer:
- --
- -- Create Date: 11:47:43 12/27/2018
- -- Design Name:
- -- Module Name: /home/ise/Desktop/New Folder/Progetto_Traccia4/Tb_Controllo_lezioni_TECD.vhd
- -- Project Name: Progetto_Traccia4
- -- Target Device:
- -- Tool versions:
- -- Description:
- --
- -- VHDL Test Bench Created by ISE for module: Controllo_lezioni_TECD
- --
- -- Dependencies:
- --
- -- Revision:
- -- Revision 0.01 - File Created
- -- Additional Comments:
- --
- -- Notes:
- -- This testbench has been automatically generated using types std_logic and
- -- std_logic_vector for the ports of the unit under test. Xilinx recommends
- -- that these types always be used for the top-level I/O of a design in order
- -- to guarantee that the testbench will bind correctly to the post-implementation
- -- simulation model.
- --------------------------------------------------------------------------------
- LIBRARY ieee;
- USE ieee.std_logic_1164.ALL;
- use ieee.std_logic_arith.all;
- -- Uncomment the following library declaration if using
- -- arithmetic functions with Signed or Unsigned values
- --USE ieee.numeric_std.ALL;
- ENTITY Tb_Controllo_lezioni_TECD IS
- END Tb_Controllo_lezioni_TECD;
- ARCHITECTURE behavior OF Tb_Controllo_lezioni_TECD IS
- -- Component Declaration for the Unit Under Test (UUT)
- COMPONENT Controllo_lezioni_TECD
- PORT(
- clk : IN std_logic;
- rst : IN std_logic;
- badge : IN std_logic;
- col : IN std_logic_vector(3 downto 1);
- row : IN std_logic_vector(4 downto 1);
- state_debug: out std_logic_vector(3 downto 0);
- output : OUT std_logic_vector(2 downto 1)
- );
- END COMPONENT;
- --Inputs
- signal clk : std_logic := '0';
- signal rst : std_logic := '0';
- signal badge : std_logic := '0';
- signal col : std_logic_vector(3 downto 1) := (others => '0');
- signal row : std_logic_vector(4 downto 1) := (others => '0');
- --Outputs
- signal output : std_logic_vector(2 downto 1);
- signal state_debug: std_logic_vector(3 downto 0);
- signal vector: std_logic_vector(7 downto 0):= (others =>'0');
- -- Clock period definitions
- constant clk_period : time := 10 ns;
- BEGIN
- -- Instantiate the Unit Under Test (UUT)
- uut: Controllo_lezioni_TECD PORT MAP (
- clk => clk,
- rst => rst,
- badge => badge,
- col => col,
- row => row,
- state_debug => state_debug,
- output => output
- );
- -- Clock process definitions
- clk_process :process
- begin
- clk <= '0';
- wait for clk_period/2;
- clk <= '1';
- wait for clk_period/2;
- end process;
- -- Stimulus process
- stim_proc: process
- begin
- -- hold reset state for 100 ns.
- rst<= '1';
- wait for 10 ns;
- rst<= '0';
- wait for clk_period*10;
- -- insert stimulus here
- --testiamo tutte le combinazioni in s0
- badge<='0';
- wait for 10 ns;
- for i in 1 to 8 loop
- col<= conv_std_logic_vector(i, 3);
- for j in 1 to 16 loop
- row<= conv_std_logic_vector(j,4);
- wait for clk_period;
- end loop;
- end loop;
- --input che mi fa transitare di stato(s0->s1)
- badge<= '1';
- wait for 10 ns;
- col<= "000";
- row<= "0000";
- wait for 10 ns;
- --inserimento cancelletto
- col<= "001";
- row<= "0001";
- wait for 10 ns;
- --testiamo tutte le combinazioni errate su s1(tutte escluse cancelletto e 0)
- for i in 1 to 8 loop
- col<= conv_std_logic_vector(i, 3);
- for j in 1 to 16 loop
- row<= conv_std_logic_vector(j,4);
- wait for clk_period*10;
- end loop;
- end loop;
- --inserimento cancelletto per andare in s1
- col<= "001";
- row<= "0001";
- wait for 10 ns;
- --inserimento 0 per andare in s3
- col<= "010";
- row<= "0001";
- wait for 10 ns;
- --testiamo tutte le combinazioni errate su s3 che ci portano in s4(tranne #, 0 e 1)
- for i in 1 to 8 loop
- col<= conv_std_logic_vector(i, 3);
- for j in 1 to 16 loop
- row<= conv_std_logic_vector(j,4);
- wait for clk_period;
- end loop;
- end loop;
- --inserimento cancelletto per andare in s3
- col<= "001";
- row<= "0001";
- wait for 10 ns;
- --inserimento lezione di teoria
- col<= "100";
- row<= "1000";
- wait for 10 ns;
- --testiamo tutte le combinazioni errate su s5 che ci portano in s6(tranne #, 1 e 2)
- for i in 1 to 8 loop
- col<= conv_std_logic_vector(i, 3);
- for j in 1 to 16 loop
- row<= conv_std_logic_vector(j,4);
- wait for clk_period;
- end loop;
- end loop;
- --inserimento cancelletto per ritornare in s5
- col<= "001";
- row<= "0001";
- wait for 10 ns;
- --inserimento 2 per andare in s7(ore di lezione)
- col<= "010";
- row<= "1000";
- wait for 10 ns;
- --testiamo tutte le combinazioni errate su s7 che ci portano in s8(tranne # e *)
- for i in 1 to 8 loop
- col<= conv_std_logic_vector(i, 3);
- for j in 1 to 16 loop
- row<= conv_std_logic_vector(j,4);
- wait for clk_period;
- end loop;
- end loop;
- --inserimento cancelletto per ritornare in s7
- col<= "001";
- row<= "0001";
- wait for 10 ns;
- --inserimento * per andare in s9
- col<= "100";
- row<= "0001";
- wait for 100 ns;
- badge<='0';
- wait for 10 ns;
- wait;
- end process;
- debug: process(state_debug, clk, rst)
- variable state_col: std_logic_vector(3 downto 1);
- variable state_row: std_logic_vector(4 downto 1);
- begin
- state_col:= col;
- state_row:= row;
- if rising_edge(clk) then
- --macchina spenta
- if(rst = '1') then
- report "Macchina spenta" severity note;
- --macchina in attesa di badge in s0
- elsif(state_debug="0000" and badge='0') then
- report "Sono in s0 in attesa del badge" severity note;
- --in s0 ricevo badge=1
- elsif(state_debug="0000" and badge='1') then
- report "Badge letto. Vado in s1" severity note;
- --testiamo lo stato s1
- elsif(state_debug="0001") then
- if(badge='1') then
- --siamo in s1 e non inseriamo nessun input
- if(state_col="000" and state_row="0000") then
- report "Sono in attesa di input in s1" severity note;
- --inserimento cancelletto in s1
- elsif((state_col="001" and state_row="0001")) then
- report "# letto in s1. Resto in s1" severity note;
- --inserimento 0 in s1
- elsif(state_col="010" and state_row="0001") then
- report "0 letto in s1. Vado in s3" severity note;
- --inserimento sequenze errate
- else
- report "Combinazione errata, vado in s2" severity note;
- end if;
- else
- report "Badge=0 quindi torno in s0" severity note;
- end if;
- --testiamo lo stato s2
- elsif(state_debug="0010") then
- if(badge='1') then
- --nessun input inserito
- if(state_col="000" and state_row="0000") then
- report "Sono in attesa di input in s2" severity note;
- --inserimento cancelletto in s2
- elsif((state_col="001" and state_row="0001")) then
- report "# letto in s2. Vado in s1" severity note;
- --inserimento sequenze errate
- else
- report "Combinazione errata, resto in s2" severity note;
- end if;
- else
- report "Badge=0 quindi torno in s0" severity note;
- end if;
- -- testiamo lo stato s3
- elsif(state_debug="0011") then
- if(badge='1') then
- --nessun input inserito
- if(state_col="000" and state_row="0000") then
- report "Sono in attesa di input in s3" severity note;
- --inserimento cancelletto in s3
- elsif((state_col="001" and state_row="0001")) then
- report "# letto in s3. Resto in s3" severity note;
- --inserimento 0 o 1
- elsif((state_col="010" and state_row="0001") or(state_col="100" and state_row="1000")) then
- if(state_col="010" and state_row="0001") then
- report "0 inserito. Lezione di teoria" severity note;
- else
- report "1 inserito. Lezione di pratica" severity note;
- end if;
- --inserimento sequenze errate
- else
- report "Combinazione errata, vado in s4" severity note;
- end if;
- else
- report "Badge=0 quindi torno in s0" severity note;
- end if;
- --testiamo lo stato s4
- elsif(state_debug="0100") then
- if(badge='1') then
- --nessun input inserito
- if(state_col="000" and state_row="0000") then
- report "Sono in attesa di input in s4" severity note;
- --inserimento cancelletto in s4
- elsif((state_col="001" and state_row="0001")) then
- report "# letto in s4. Vado in s3" severity note;
- --inserimento sequenze errate
- else
- report "Combinazione errata, resto in s4" severity note;
- end if;
- else
- report "Badge=0 quindi torno in s0" severity note;
- end if;
- --testiamo lo stato s5
- elsif(state_debug="0101") then
- if(badge='1') then
- --nessun input inserito
- if(state_col="000" and state_row="0000") then
- report "Sono in attesa di input in s5" severity note;
- --inserimento cancelletto in s5
- elsif((state_col="001" and state_row="0001")) then
- report "# letto in s5. Resto in s5" severity note;
- --inserimento 0 o 1
- elsif((state_col="010" and state_row="1000") or(state_col="100" and state_row="1000")) then
- if(state_col="010" and state_row="1000") then
- report "2 inserito. Due ore di lezione" severity note;
- else
- report "1 inserito. Un'ora di lezione" severity note;
- end if;
- --inserimento sequenze errate
- else
- report "Combinazione errata, vado in s6" severity note;
- end if;
- else
- report "Badge=0 quindi torno in s0" severity note;
- end if;
- --testiamo lo stato s6
- elsif(state_debug="0110") then
- if(badge='1') then
- --nessun input inserito
- if(state_col="000" and state_row="0000") then
- report "Sono in attesa di input in s6" severity note;
- --inserimento cancelletto in s6
- elsif((state_col="001" and state_row="0001")) then
- report "# letto in s6. Vado in s5" severity note;
- --inserimento sequenze errate
- else
- report "Combinazione errata, resto in s6" severity note;
- end if;
- else
- report "Badge=0 quindi torno in s0" severity note;
- end if;
- --testiamo lo stato s7
- elsif(state_debug="0111") then
- if(badge='1') then
- --nessun input inserito
- if(state_col="000" and state_row="0000") then
- report "Sono in attesa di input in s7" severity note;
- --inserimento cancelletto in s7
- elsif((state_col="001" and state_row="0001")) then
- report "# letto in s7. Resto in s7" severity note;
- --inserimento *
- elsif(state_col="100" and state_row="0001") then
- report "* letto in s7. Vado in s9" severity note;
- --inserimento sequenze errate
- else
- report "Combinazione errata, vado in s8" severity note;
- end if;
- else
- report "Badge=0 quindi torno in s0" severity note;
- end if;
- --testiamo s8
- elsif(state_debug="1000") then
- if(badge='1') then
- --nessun input inserito
- if(state_col="000" and state_row="0000") then
- report "Sono in attesa di input in s8" severity note;
- --inserimento cancelletto in s8
- elsif((state_col="001" and state_row="0001")) then
- report "# letto in s8. Vado in s7" severity note;
- --inserimento sequenze errate
- else
- report "Combinazione errata, resto in s8" severity note;
- end if;
- else
- report "Badge=0 quindi torno in s0" severity note;
- end if;
- -- testiamo s9
- elsif(state_debug ="1001") then
- if(badge='1') then
- report "Sessione aperta" severity note;
- else
- report "Sessione chiusa, ritorno in s0" severity note;
- end if;
- end if;
- end if;
- end process debug;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement