1 |
46 |
arif_endro |
-- ------------------------------------------------------------------------
|
2 |
|
|
-- Copyright (C) 2004 Arif Endro Nugroho
|
3 |
|
|
-- All rights reserved.
|
4 |
|
|
--
|
5 |
|
|
-- Redistribution and use in source and binary forms, with or without
|
6 |
|
|
-- modification, are permitted provided that the following conditions
|
7 |
|
|
-- are met:
|
8 |
|
|
--
|
9 |
|
|
-- 1. Redistributions of source code must retain the above copyright
|
10 |
|
|
-- notice, this list of conditions and the following disclaimer.
|
11 |
|
|
-- 2. Redistributions in binary form must reproduce the above copyright
|
12 |
|
|
-- notice, this list of conditions and the following disclaimer in the
|
13 |
|
|
-- documentation and/or other materials provided with the distribution.
|
14 |
|
|
--
|
15 |
|
|
-- THIS SOFTWARE IS PROVIDED BY ARIF ENDRO NUGROHO "AS IS" AND ANY EXPRESS
|
16 |
|
|
-- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17 |
|
|
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18 |
|
|
-- DISCLAIMED. IN NO EVENT SHALL ARIF ENDRO NUGROHO BE LIABLE FOR ANY
|
19 |
|
|
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20 |
|
|
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
21 |
|
|
-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
22 |
|
|
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
23 |
|
|
-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
24 |
|
|
-- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25 |
|
|
-- POSSIBILITY OF SUCH DAMAGE.
|
26 |
|
|
--
|
27 |
|
|
-- End Of License.
|
28 |
|
|
-- ------------------------------------------------------------------------
|
29 |
2 |
arif_endro |
|
30 |
|
|
library IEEE;
|
31 |
|
|
library STD;
|
32 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
33 |
|
|
use IEEE.STD_LOGIC_arith.ALL;
|
34 |
|
|
use IEEE.STD_LOGIC_unsigned.ALL;
|
35 |
|
|
use STD.TEXTIO.ALL;
|
36 |
|
|
|
37 |
|
|
entity input is
|
38 |
|
|
port (
|
39 |
|
|
clock_out : out bit;
|
40 |
|
|
test_signal_fm : out bit_vector (07 downto 0);
|
41 |
|
|
test_signal_fmTri: out bit_vector (07 downto 0);
|
42 |
|
|
signal_fm_bit : out bit;
|
43 |
|
|
signal_fmTri_bit : out bit
|
44 |
|
|
);
|
45 |
|
|
end input;
|
46 |
|
|
|
47 |
|
|
architecture test_bench of input is
|
48 |
|
|
type char_to_stdlogic_t is array (character) of std_logic;
|
49 |
|
|
file file_pointer_fm : text open read_mode is "fm.txt";
|
50 |
|
|
file file_pointer_fmTri : text open read_mode is "fmTri.txt";
|
51 |
|
|
constant to_std_logic : char_to_stdlogic_t := (
|
52 |
|
|
'U' => 'U',
|
53 |
|
|
'X' => 'X',
|
54 |
|
|
'0' => '0',
|
55 |
|
|
'1' => '1',
|
56 |
|
|
'Z' => 'Z',
|
57 |
|
|
'W' => 'W',
|
58 |
|
|
'L' => 'L',
|
59 |
|
|
'H' => 'H',
|
60 |
|
|
'-' => '-',
|
61 |
|
|
others => 'X'
|
62 |
|
|
);
|
63 |
|
|
-- signal test_signal_fm : std_logic_vector ( 7 downto 0);
|
64 |
|
|
-- signal test_signal_fmTri : std_logic_vector ( 7 downto 0);
|
65 |
|
|
signal test_signal_fm_bit : std_logic;
|
66 |
|
|
signal test_signal_fmTri_bit : std_logic;
|
67 |
|
|
signal clock : std_logic;
|
68 |
|
|
begin
|
69 |
|
|
process
|
70 |
|
|
variable line_input_fm : line;
|
71 |
|
|
variable line_input_fmTri : line;
|
72 |
|
|
-- variable first_char : character := '#';
|
73 |
|
|
variable test_vector_fm : string(1 to 8) := " ";
|
74 |
|
|
variable test_vector_fmTri : string(1 to 8) := " ";
|
75 |
|
|
variable input_length_fm : integer;
|
76 |
|
|
variable input_length_fmTri : integer;
|
77 |
|
|
variable delay_time : time := 1 ns;
|
78 |
|
|
variable test_var_fm : std_logic_vector ( 7 downto 0);
|
79 |
|
|
variable test_var_fmTri : std_logic_vector ( 7 downto 0);
|
80 |
|
|
begin
|
81 |
|
|
while not (endfile(file_pointer_fm) and endfile(file_pointer_fmTri)) loop
|
82 |
|
|
readline(file_pointer_fm, line_input_fm);
|
83 |
|
|
readline(file_pointer_fmTri, line_input_fmTri);
|
84 |
|
|
if (line_input_fm /= NULL) and (line_input_fm'length > 0) and (line_input_fmTri /= NULL) and (line_input_fmTri'length > 0) then
|
85 |
|
|
-- read(line_number, first_char);
|
86 |
|
|
-- if (first_char /= '#') then
|
87 |
|
|
read(line_input_fm, test_vector_fm);
|
88 |
|
|
read(line_input_fmTri, test_vector_fmTri);
|
89 |
|
|
input_length_fm := test_vector_fm'length - 1;
|
90 |
|
|
input_length_fmTri := test_vector_fmTri'length - 1;
|
91 |
|
|
for a in test_vector_fm'range loop
|
92 |
|
|
test_var_fm(input_length_fm) := to_std_logic(test_vector_fm(a));
|
93 |
|
|
test_signal_fm_bit <= to_std_logic(test_vector_fm(a));
|
94 |
|
|
input_length_fm := input_length_fm - 1;
|
95 |
|
|
end loop;
|
96 |
|
|
for a in test_vector_fmTri'range loop
|
97 |
|
|
test_var_fmTri(input_length_fmTri) := to_std_logic(test_vector_fmTri(a));
|
98 |
|
|
test_signal_fmTri_bit <= to_std_logic(test_vector_fmTri(a));
|
99 |
|
|
input_length_fmTri := input_length_fmTri - 1;
|
100 |
|
|
end loop;
|
101 |
|
|
test_signal_fm <= to_bitvector(test_var_fm);-- after 1 ns;
|
102 |
|
|
test_signal_fmTri <= to_bitvector(test_var_fmTri);-- after 1 ns;
|
103 |
|
|
-- Show current progress
|
104 |
|
|
-- report "Current line input is: Vector values are : ";
|
105 |
|
|
-- end loop;
|
106 |
|
|
-- report "End of input test vector fm.txt";
|
107 |
|
|
-- wait;
|
108 |
|
|
clock <= '1';
|
109 |
|
|
wait for delay_time;
|
110 |
|
|
clock <= '0';
|
111 |
|
|
wait for delay_time;
|
112 |
|
|
-- fmTri --START HERE--
|
113 |
|
|
-- while not endfile(file_pointer_fmTri) loop
|
114 |
|
|
-- read(line_number, first_char);
|
115 |
|
|
-- if (first_char /= '#') then
|
116 |
|
|
-- clock <= '1';
|
117 |
|
|
-- wait for delay_time;
|
118 |
|
|
-- clock <= '0';
|
119 |
|
|
-- wait for delay_time;
|
120 |
|
|
-- Show current progress
|
121 |
|
|
-- report "Current line input is: Vector values are : ";
|
122 |
|
|
end if;
|
123 |
|
|
end loop;
|
124 |
|
|
-- report "End of input test vector fmTri.txt";
|
125 |
|
|
wait;
|
126 |
|
|
end process;
|
127 |
|
|
signal_fm_bit <= to_bit(test_signal_fm_bit);
|
128 |
|
|
signal_fmTri_bit <= to_bit(test_signal_fmTri_bit);
|
129 |
|
|
clock_out <= to_bit(clock);
|
130 |
|
|
end test_bench;
|