OpenCores
URL https://opencores.org/ocsvn/pavr/pavr/trunk

Subversion Repositories pavr

[/] [pavr/] [trunk/] [src/] [test_std_util.vhd] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 doru
-- <File header>
2
-- Project
3
--    pAVR (pipelined AVR) is an 8 bit RISC controller, compatible with Atmel's
4
--    AVR core, but about 3x faster in terms of both clock frequency and MIPS.
5
--    The increase in speed comes from a relatively deep pipeline. The original
6
--    AVR core has only two pipeline stages (fetch and execute), while pAVR has
7
--    6 pipeline stages:
8
--       1. PM    (read Program Memory)
9
--       2. INSTR (load Instruction)
10
--       3. RFRD  (decode Instruction and read Register File)
11
--       4. OPS   (load Operands)
12
--       5. ALU   (execute ALU opcode or access Unified Memory)
13
--       6. RFWR  (write Register File)
14
-- Version
15
--    0.32
16
-- Date
17
--    2002 August 07
18
-- Author
19
--    Doru Cuturela, doruu@yahoo.com
20
-- License
21
--    This program is free software; you can redistribute it and/or modify
22
--    it under the terms of the GNU General Public License as published by
23
--    the Free Software Foundation; either version 2 of the License, or
24
--    (at your option) any later version.
25
--    This program is distributed in the hope that it will be useful,
26
--    but WITHOUT ANY WARRANTY; without even the implied warranty of
27
--    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
--    GNU General Public License for more details.
29
--    You should have received a copy of the GNU General Public License
30
--    along with this program; if not, write to the Free Software
31
--    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
32
-- </File header>
33
 
34
 
35
 
36
-- <File info>
37
-- This tests the utilities defined in `std_util.vhd':
38
--    - cmp_std_logic_vector  (asynchronous function)
39
--    - sign_extend           (asynchronous function)
40
--    - zero_extend           (asynchronous function)
41
-- </File info>
42
 
43
 
44
 
45
-- <File body>
46
library ieee;
47
use ieee.std_logic_1164.all;
48
library work;
49
use work.std_util.all;
50
 
51
 
52
entity test_std_util is
53
end;
54
 
55
 
56
architecture arch_test_std_util of test_std_util is
57
   signal clk: std_logic;
58
   -- Comparision output
59
   signal flag1: std_logic;
60
   -- Candidates to sign/zero extension and comparision
61
   signal v2_1,  v2_2,  v2_3:  std_logic_vector( 1 downto 0);
62
   signal v50_1, v50_2, v50_3: std_logic_vector(49 downto 0);
63
begin
64
 
65
   generate_clock:
66
   process
67
   begin
68
      clk <= '1';
69
      wait for 50 ns;
70
      clk <= '0';
71
      wait for 50 ns;
72
   end process generate_clock;
73
 
74
 
75
   test_main:
76
   process
77
   begin
78
      -- Set up default inputs.
79
      v2_1  <= "10";
80
      v2_2  <= "01";
81
      for i in 0 to 49 loop
82
         v50_1(i) <= '0';
83
         v50_2(i) <= '0';
84
      end loop;
85
      v50_1(49) <= '1';
86
      v50_1(3 downto 0) <= "1001";
87
      v50_2(3 downto 0) <= "1010";
88
      wait for 110 ns;
89
 
90
      -- TEST 1
91
      -- Test function `cmp_std_logic_vector'
92
      -- Try to compare 2 vectors with different lengths; this should assert the dedicated error.
93
      --flag1 <= cmp_std_logic_vector(v2_1, v50_1);
94
      --wait until clk'event and clk='1';
95
      -- Typical situations
96
      -- Shouldn't match
97
      flag1 <= cmp_std_logic_vector(v50_1, v50_2);
98
      wait until clk'event and clk='1';
99
      -- Should match
100
      flag1 <= cmp_std_logic_vector(v50_1, v50_1);
101
      wait until clk'event and clk='1';
102
      -- Shouldn't match
103
      flag1 <= cmp_std_logic_vector(sign_extend(v2_1, v50_1'length), zero_extend(v2_1, v50_1'length));
104
      wait until clk'event and clk='1';
105
      -- Should match
106
      flag1 <= cmp_std_logic_vector(sign_extend(v2_2, v50_1'length), zero_extend(v2_2, v50_1'length));
107
      wait until clk'event and clk='1';
108
 
109
      -- TEST 2
110
      -- Test function `sign_extend' and `zero_extend', negative input.
111
      -- Extremal case that should work. For length 2, typical case = extremal case.
112
      v2_3 <= sign_extend(v2_1, v2_3'length);
113
      wait until clk'event and clk='1';
114
      v2_3 <= zero_extend(v2_1, v2_3'length);
115
      wait until clk'event and clk='1';
116
      -- Some stupid length that should generate an error
117
      --v2_3 <= sign_extend(v2_1, 7);
118
      --wait until clk'event and clk='1';
119
      --v2_3 <= zero_extend(v2_1, 7);
120
      --wait until clk'event and clk='1';
121
      -- The same with width 50
122
      -- Typical case
123
      v50_3 <= sign_extend(v2_1, v50_3'length);
124
      wait until clk'event and clk='1';
125
      v50_3 <= zero_extend(v2_1, v50_3'length);
126
      wait until clk'event and clk='1';
127
      -- Extremal case that should work
128
      v50_3 <= sign_extend(v50_1, v50_3'length);
129
      wait until clk'event and clk='1';
130
      v50_3 <= zero_extend(v50_1, v50_3'length);
131
      wait until clk'event and clk='1';
132
      -- Some stupid length that should generate an error
133
      --v50_3 <= sign_extend(v50_1, 7);
134
      --wait until clk'event and clk='1';
135
      --v50_3 <= zero_extend(v50_1, 7);
136
      --wait until clk'event and clk='1';
137
 
138
      -- TEST 1
139
      -- Test function `sign_extend' and `zero_extend', positive input.
140
      -- Extremal case that should work. For length 2, typical case = extremal case.
141
      v2_3 <= sign_extend(v2_2, v2_3'length);
142
      wait until clk'event and clk='1';
143
      v2_3 <= zero_extend(v2_2, v2_3'length);
144
      wait until clk'event and clk='1';
145
      -- Some stupid length that should generate an error
146
      --v2_3 <= sign_extend(v2_2, 7);
147
      --wait until clk'event and clk='1';
148
      --v2_3 <= zero_extend(v2_2, 7);
149
      --wait until clk'event and clk='1';
150
      -- The same with width 50
151
      -- Typical case
152
      v50_3 <= sign_extend(v2_2, v50_3'length);
153
      wait until clk'event and clk='1';
154
      v50_3 <= zero_extend(v2_2, v50_3'length);
155
      wait until clk'event and clk='1';
156
      -- Extremal case that should work
157
      v50_3 <= sign_extend(v50_2, v50_3'length);
158
      wait until clk'event and clk='1';
159
      v50_3 <= zero_extend(v50_2, v50_3'length);
160
      wait until clk'event and clk='1';
161
      -- Some stupid length that should generate an error
162
      --v50_3 <= sign_extend(v50_2, 7);
163
      --wait until clk'event and clk='1';
164
      --v50_3 <= zero_extend(v50_2, 7);
165
      --wait until clk'event and clk='1';
166
   end process test_main;
167
 
168
end;
169
-- </File body>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.