Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------------------------------
- -- Company:
- -- Engineer:
- --
- -- Create Date: 13:23:08 02/15/2016
- -- Design Name:
- -- Module Name: C:/VHDL/lab5/test5.vhd
- -- Project Name: lab5
- -- Target Device:
- -- Tool versions:
- -- Description:
- --
- -- VHDL Test Bench Created by ISE for module: lab5
- --
- -- 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;
- USE ieee.std_logic_unsigned.ALL;
- USE STD.TEXTIO.all;
- -- Uncomment the following library declaration if using
- -- arithmetic functions with Signed or Unsigned values
- --USE ieee.numeric_std.ALL;
- ENTITY test5 IS
- END test5;
- ARCHITECTURE behavior OF test5 IS
- -- Component Declaration for the Unit Under Test (UUT)
- COMPONENT lab5
- PORT(
- A : IN std_logic_vector(3 downto 0);
- B : IN std_logic_vector(3 downto 0);
- C : OUT std_logic_vector(4 downto 0)
- );
- END COMPONENT;
- --Inputs
- signal A : std_logic_vector(3 downto 0) := (others => '0');
- signal B : std_logic_vector(3 downto 0) := (others => '0');
- --Outputs
- signal C : std_logic_vector(4 downto 0);
- -- No clocks detected in port list. Replace <clock> below with
- -- appropriate port name
- BEGIN
- -- Instantiate the Unit Under Test (UUT)
- uut: lab5 PORT MAP (
- A => A,
- B => B,
- C => C
- );
- process
- FILE fileInput : TEXT IS IN "data_ABC.txt";
- FILe fileOutput : TEXT IS OUT "data_SUM.txt";
- variable line_ABCin : LINE;
- variable line_SUM : LINE;
- variable Ain,Bin,Cin,Cout : integer;
- variable SUM : std_logic_vector(4 downto 0);
- variable str : string(1 to 2);
- variable outStr : string (1 to 9);
- begin
- while NOT ENDFILE(fileInput) loop
- READLINE(fileInput, line_ABCin);
- READ(line_ABCin, Ain);
- READ(line_ABCin, Bin);
- READ(line_ABCin, Cin);
- A <= conv_std_logic_vector(Ain, 4);
- B <= conv_std_logic_vector(Bin, 4);
- SUM := conv_std_logic_vector(Cin, 5);
- wait for 10 ns;
- Cout := conv_integer(C);
- case C(4) is
- when '0' => str(1) := '0';
- when others => str(1) := '1';
- end case;
- case C(3 downto 0) is
- when "0000" => str(2) := '0';
- when "0001" => str(2) := '1';
- when "0010" => str(2) := '2';
- when "0011" => str(2) := '3';
- when "0100" => str(2) := '4';
- when "0101" => str(2) := '5';
- when "0110" => str(2) := '6';
- when "0111" => str(2) := '7';
- when "1000" => str(2) := '8';
- when "1001" => str(2) := '9';
- when "1010" => str(2) := 'A';
- when "1011" => str(2) := 'B';
- when "1100" => str(2) := 'C';
- when "1101" => str(2) := 'D';
- when "1110" => str(2) := 'E';
- when others => str(2) := 'F';
- end case;
- WRITE(line_SUM, str);
- WRITELINE(fileOutput, line_SUM);
- -- start Line 1
- outStr(5) := ' ';
- case C(4) is
- when '0' => outStr(1 to 4) := "****";
- when others => outStr(1 to 4) := " *";
- end case;
- case C(3 downto 0) is
- when "0000" => outStr(6 to 9) := "****";
- when "0001" => outStr(6 to 9) := " *";
- when "0010" => outStr(6 to 9) := "****";
- when "0011" => outStr(6 to 9) := "****";
- when "0100" => outStr(6 to 9) := "* *";
- when "0101" => outStr(6 to 9) := "****";
- when "0110" => outStr(6 to 9) := "****";
- when "0111" => outStr(6 to 9) := "****";
- when "1000" => outStr(6 to 9) := "****";
- when "1001" => outStr(6 to 9) := "****";
- when "1010" => outStr(6 to 9) := "****";
- when "1011" => outStr(6 to 9) := "* ";
- when "1100" => outStr(6 to 9) := "****";
- when "1101" => outStr(6 to 9) := " *";
- when "1110" => outStr(6 to 9) := "****";
- when others => outStr(6 to 9) := "****";
- end case;
- WRITE(line_SUM, outStr);
- WRITELINE(fileOutput, line_SUM);
- -- end Line 1
- -- start Line 2
- outStr(5) := ' ';
- case C(4) is
- when '0' => outStr(1 to 4) := "* *";
- when others => outStr(1 to 4) := " *";
- end case;
- case C(3 downto 0) is
- when "0000" => outStr(6 to 9) := "* *"; -- 0
- when "0001" => outStr(6 to 9) := " *"; -- 1
- when "0010" => outStr(6 to 9) := " *"; -- 2
- when "0011" => outStr(6 to 9) := " *"; -- 3
- when "0100" => outStr(6 to 9) := "* *"; -- 4
- when "0101" => outStr(6 to 9) := "* "; -- 5
- when "0110" => outStr(6 to 9) := "* "; -- 6
- when "0111" => outStr(6 to 9) := " *"; -- 7
- when "1000" => outStr(6 to 9) := "* *"; -- 8
- when "1001" => outStr(6 to 9) := "* *"; -- 9
- when "1010" => outStr(6 to 9) := "* *"; -- A
- when "1011" => outStr(6 to 9) := "* "; -- B
- when "1100" => outStr(6 to 9) := "* *"; -- C
- when "1101" => outStr(6 to 9) := " *"; -- D
- when "1110" => outStr(6 to 9) := "* *"; -- E
- when others => outStr(6 to 9) := "* "; -- F
- end case;
- WRITE(line_SUM, outStr);
- WRITELINE(fileOutput, line_SUM);
- -- end Line 2
- -- start Line 3
- outStr(5) := ' ';
- case C(4) is
- when '0' => outStr(1 to 4) := "* *";
- when others => outStr(1 to 4) := " *";
- end case;
- case C(3 downto 0) is
- when "0000" => outStr(6 to 9) := "* *"; -- 0
- when "0001" => outStr(6 to 9) := " *"; -- 1
- when "0010" => outStr(6 to 9) := "****"; -- 2
- when "0011" => outStr(6 to 9) := "****"; -- 3
- when "0100" => outStr(6 to 9) := "****"; -- 4
- when "0101" => outStr(6 to 9) := "****"; -- 5
- when "0110" => outStr(6 to 9) := "****"; -- 6
- when "0111" => outStr(6 to 9) := " *"; -- 7
- when "1000" => outStr(6 to 9) := "****"; -- 8
- when "1001" => outStr(6 to 9) := "****"; -- 9
- when "1010" => outStr(6 to 9) := "****"; -- A
- when "1011" => outStr(6 to 9) := "****"; -- B
- when "1100" => outStr(6 to 9) := "* "; -- C
- when "1101" => outStr(6 to 9) := "****"; -- D
- when "1110" => outStr(6 to 9) := "****"; -- E
- when others => outStr(6 to 9) := "****"; -- F
- end case;
- WRITE(line_SUM, outStr);
- WRITELINE(fileOutput, line_SUM);
- -- end Line 3
- -- start Line 4
- outStr(5) := ' ';
- case C(4) is
- when '0' => outStr(1 to 4) := "* *";
- when others => outStr(1 to 4) := " *";
- end case;
- case C(3 downto 0) is
- when "0000" => outStr(6 to 9) := "* *"; -- 0
- when "0001" => outStr(6 to 9) := " *"; -- 1
- when "0010" => outStr(6 to 9) := "* "; -- 2
- when "0011" => outStr(6 to 9) := " *"; -- 3
- when "0100" => outStr(6 to 9) := " *"; -- 4
- when "0101" => outStr(6 to 9) := " *"; -- 5
- when "0110" => outStr(6 to 9) := "* *"; -- 6
- when "0111" => outStr(6 to 9) := " *"; -- 7
- when "1000" => outStr(6 to 9) := "* *"; -- 8
- when "1001" => outStr(6 to 9) := " *"; -- 9
- when "1010" => outStr(6 to 9) := "* *"; -- A
- when "1011" => outStr(6 to 9) := "* *"; -- B
- when "1100" => outStr(6 to 9) := "* "; -- C
- when "1101" => outStr(6 to 9) := "* *"; -- D
- when "1110" => outStr(6 to 9) := "* "; -- E
- when others => outStr(6 to 9) := "* "; -- F
- end case;
- WRITE(line_SUM, outStr);
- WRITELINE(fileOutput, line_SUM);
- -- end Line 4
- -- start Line 5
- outStr(5) := ' ';
- case C(4) is
- when '0' => outStr(1 to 4) := "****";
- when others => outStr(1 to 4) := " *";
- end case;
- case C(3 downto 0) is
- when "0000" => outStr(6 to 9) := "****"; -- 0
- when "0001" => outStr(6 to 9) := " *"; -- 1
- when "0010" => outStr(6 to 9) := "****"; -- 2
- when "0011" => outStr(6 to 9) := "****"; -- 3
- when "0100" => outStr(6 to 9) := " *"; -- 4
- when "0101" => outStr(6 to 9) := "****"; -- 5
- when "0110" => outStr(6 to 9) := "****"; -- 6
- when "0111" => outStr(6 to 9) := " *"; -- 7
- when "1000" => outStr(6 to 9) := "****"; -- 8
- when "1001" => outStr(6 to 9) := "****"; -- 9
- when "1010" => outStr(6 to 9) := "* *"; -- A
- when "1011" => outStr(6 to 9) := "****"; -- B
- when "1100" => outStr(6 to 9) := "****"; -- C
- when "1101" => outStr(6 to 9) := "****"; -- D
- when "1110" => outStr(6 to 9) := "****"; -- E
- when others => outStr(6 to 9) := "* "; -- F
- end case;
- WRITE(line_SUM, outStr);
- WRITELINE(fileOutput, line_SUM);
- -- end Line 5
- assert C = SUM REPORT "Test fail" SEVERITY error;
- wait for 30 ns;
- end loop;
- wait;
- end process;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement