-- Testbench fuer die System-Simulation -- Version 2.1 / Lars H. Hahn 12.02.99 -- Es wird die Datei 'eingabe.data' eingelesen -- die Datei 'ausgabe.data' wird erzeugt Library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; use std.textio.all; use work.chips.all; entity tb_system is end; architecture tb of tb_system is signal one, zero, hold_snd_medium : std_logic; signal nrst, clk, to_flex_rec, send_rec, request_rec, busy_rec, hold_rec : std_logic; signal to_flex_snd, send_snd, request_snd, busy_snd, hold_snd : std_logic; signal ab_data_rec, ba_data_rec, ab_send_request_rec, ba_send_request_rec, ab_busy_hold_rec, ba_busy_hold_rec : std_logic; signal ab_data_snd, ba_data_snd, ab_send_request_snd, ba_send_request_snd, ab_busy_hold_snd, ba_busy_hold_snd : std_logic; signal char_inout_rec, char_inout_snd: std_logic_vector(7 downto 0); file r_datei: text is in "eingabe.data"; file w_datei: text is out "ausgabe.data"; function char2slv(zeichen: character) return std_logic_vector is variable result: std_logic_vector(7 downto 0); begin case zeichen is when ' ' => result := "00100000"; -- Space when 'A' => result := "01000001"; -- A when 'B' => result := "01000010"; -- B when 'C' => result := "01000011"; -- C when 'D' => result := "01000100"; -- D when 'E' => result := "01000101"; -- E when 'F' => result := "01000110"; -- F when 'G' => result := "01000111"; -- G when 'H' => result := "01001000"; -- H when 'I' => result := "01001001"; -- I when 'J' => result := "01001010"; -- J when 'K' => result := "01001011"; -- K when 'L' => result := "01001100"; -- L when 'M' => result := "01001101"; -- M when 'N' => result := "01001110"; -- N when 'O' => result := "01001111"; -- O when 'P' => result := "01010000"; -- P when 'Q' => result := "01010001"; -- Q when 'R' => result := "01010010"; -- R when 'S' => result := "01010011"; -- S when 'T' => result := "01010100"; -- T when 'U' => result := "01010101"; -- U when 'V' => result := "01010110"; -- V when 'W' => result := "01010111"; -- W when 'X' => result := "01011000"; -- X when 'Y' => result := "01011001"; -- Y when 'Z' => result := "01011010"; -- Z when '.' => result := "00101110"; -- Punkt when ',' => result := "00101100"; -- Komma when others => result := "XXXXXXXX"; end case; return result; end; function slv2char(vec: std_logic_vector(7 downto 0)) return character is variable result: character; begin case vec is when "00100000" => result := ' '; when "01000001" => result := 'A'; when "01000010" => result := 'B'; when "01000011" => result := 'C'; when "01000100" => result := 'D'; when "01000101" => result := 'E'; when "01000110" => result := 'F'; when "01000111" => result := 'G'; when "01001000" => result := 'H'; when "01001001" => result := 'I'; when "01001010" => result := 'J'; when "01001011" => result := 'K'; when "01001100" => result := 'L'; when "01001101" => result := 'M'; when "01001110" => result := 'N'; when "01001111" => result := 'O'; when "01010000" => result := 'P'; when "01010001" => result := 'Q'; when "01010010" => result := 'R'; when "01010011" => result := 'S'; when "01010100" => result := 'T'; when "01010101" => result := 'U'; when "01010110" => result := 'V'; when "01010111" => result := 'W'; when "01011000" => result := 'X'; when "01011001" => result := 'Y'; when "01011010" => result := 'Z'; when "00101110" => result := '.'; when "00101100" => result := ','; when others => result := '*'; end case; return result; end; begin my_snd_a: epf10k10lc84a port map -- Kompressor (nrst => nrst, clk => clk, nsend_receive => zero, to_flex => to_flex_snd, request => request_snd, send => send_snd, hold => hold_snd, busy => busy_snd, request_rsa => ab_send_request_snd, send_rsa => ba_send_request_snd, hold_rsa => ab_busy_hold_snd, busy_rsa => ba_busy_hold_snd, char_inout => char_inout_snd, data_in => ba_data_snd, data_out => ab_data_snd); my_snd_b: epf10k10lc84b port map -- RSA-Verschlüsseln (nrst => nrst, clk => clk, nsend_receive => zero, to_flex => to_flex_snd, request => ab_send_request_snd, send => ba_send_request_snd, hold => ab_busy_hold_snd, busy => ba_busy_hold_snd, char_inout => char_inout_snd, data_in => ab_data_snd, data_out => ba_data_snd); my_rec_a: epf10k10lc84a port map -- Dekompressor (nrst => nrst, clk => clk, nsend_receive => one, to_flex => to_flex_rec, request => request_rec, send => send_rec, hold => hold_rec, busy => busy_rec, request_rsa => ab_send_request_rec, send_rsa => ba_send_request_rec, hold_rsa => ab_busy_hold_rec, busy_rsa => ba_busy_hold_rec, char_inout => char_inout_rec, data_in => ba_data_rec, data_out => ab_data_rec); my_rec_b: epf10k10lc84b port map -- RSA-Entschlüsseln (nrst => nrst, clk => clk, nsend_receive => one, to_flex => to_flex_rec, request => ab_send_request_rec, send => ba_send_request_rec, hold => ab_busy_hold_rec, busy => ba_busy_hold_rec, char_inout => char_inout_rec, data_in => ab_data_rec, data_out => ba_data_rec); zero <= '0'; one <= '1'; hold_snd <= hold_snd_medium; -- hold_snd <= hold_snd_medium or to_flex_snd; -- PROBLEM: Doppeltes Senden, wenn hold zur gleichen Zeit wie request!!!!! SENDER: process variable in_line: line; variable c: character; begin wait until(nrst = '1'); while not (endfile(r_datei)) loop readline(r_datei, in_line); while not endline(in_line) loop read(in_line, c); char_inout_snd <= "ZZZZZZZZ"; to_flex_snd <= '0'; request_snd <= '0'; wait for 40 us; wait until(clk'event and clk = '1'); char_inout_snd <= char2slv(c); to_flex_snd <= '1'; request_snd <= '1'; wait until(clk'event and clk = '1'); end loop; end loop; wait; end process; EMPFAENGER: process variable out_line: line; variable c: character; variable i: integer; begin wait until(nrst = '1'); while (TRUE) loop i := 0; while (i < 79) loop hold_rec <= '0'; wait until(send_rec'event and send_rec = '1'); c := slv2char(char_inout_rec); write(out_line, c); i := i + 1; wait until(clk'event and clk = '1'); hold_rec <= '1'; wait for 10 us; end loop; writeline(w_datei, out_line); end loop; end process; MEDIUM: process variable puffer: std_logic_vector(7 downto 0); begin wait until(nrst = '1'); while (TRUE) loop char_inout_rec <= "ZZZZZZZZ"; request_rec <= '0'; hold_snd_medium <= '0'; to_flex_rec <= '0'; wait until(send_snd'event and send_snd = '1'); puffer := char_inout_snd; wait until(clk'event and clk = '1'); hold_snd_medium <= '1'; wait for 5 us; wait until(clk'event and clk = '1'); request_rec <= '1'; to_flex_rec <= '1'; char_inout_rec <= puffer; wait until(clk'event and clk = '1'); request_rec <= '0'; to_flex_rec <= '0'; char_inout_rec <= "ZZZZZZZZ"; wait for 5 us; end loop; end process; -- Taktfrequenz = 16,67 MHz clk_pro: process begin clk <= '0'; wait for 30 ns; clk <= '1'; wait for 30 ns; end process; nrst_pro: process begin nrst <= '0'; wait for 141 ns; nrst <= '1'; wait; end process; end tb; configuration cfg_tb_system of tb_system is for tb end for; end;