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

Subversion Repositories pavr

[/] [pavr/] [trunk/] [src/] [test_pavr_io_file.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 pAVR's IO File.
38
-- The following tests are performed on the IOF:
39
--    - test the IOF general write/read/bit processing port.
40
--       Test all opcodes that this port is capable of:
41
--       - wrbyte
42
--       - rdbyte
43
--       - clrbit
44
--       - setbit
45
--       - stbit
46
--       - ldbit
47
--    - test the IOF port A.
48
--       Port A is intended to offer to pAVR pin-level IO connectivity with the
49
--       outside world.
50
--       Test that Port A pins correctly take the appropriate logic values
51
--       (high, low, high Z or weak high).
52
--    - test Timer 0.
53
--       - test Timer 0 prescaler.
54
--       - test Timer 0 overflow.
55
--       - test Timer 0 interrupt.
56
--    - test External Interrupt 0.
57
--       External Interrupt 0 is mapped on port A pin 0.
58
--       Test if each possible configuration (activation on low level, rising edge
59
--       or falling edge) correctly triggers External Interrupt 0.
60
-- </File info>
61
 
62
 
63
 
64
-- <File body>
65
library ieee;
66
use ieee.std_logic_1164.all;
67
library work;
68
use work.std_util.all;
69
use work.pavr_util.all;
70
use work.pavr_constants.all;
71
 
72
 
73
 
74
entity test_pavr_iof is
75
end;
76
 
77
 
78
 
79
architecture test_pavr_iof_arch of test_pavr_iof is
80
   signal clk, res, syncres: std_logic;
81
 
82
   -- Clock counter
83
   signal cnt: std_logic_vector(20 downto 0);
84
 
85
   -- IOF general read and write port
86
   signal pavr_iof_opcode  : std_logic_vector(pavr_iof_opcode_w - 1 downto 0);
87
   signal pavr_iof_addr    : std_logic_vector(5 downto 0);
88
   signal pavr_iof_di      : std_logic_vector(7 downto 0);
89
   signal pavr_iof_do      : std_logic_vector(7 downto 0);
90
   signal pavr_iof_bitaddr : std_logic_vector(2 downto 0);
91
   signal pavr_iof_bitout  : std_logic;
92
 
93
   -- SREG port
94
   signal pavr_iof_sreg    : std_logic_vector(7 downto 0);
95
   signal pavr_iof_sreg_wr : std_logic;
96
   signal pavr_iof_sreg_di : std_logic_vector(7 downto 0);
97
 
98
   -- SP port
99
   signal pavr_iof_spl     : std_logic_vector(7 downto 0);
100
   signal pavr_iof_spl_wr  : std_logic;
101
   signal pavr_iof_spl_di  : std_logic_vector(7 downto 0);
102
 
103
   signal pavr_iof_sph     : std_logic_vector(7 downto 0);
104
   signal pavr_iof_sph_wr  : std_logic;
105
   signal pavr_iof_sph_di  : std_logic_vector(7 downto 0);
106
 
107
   -- RAMPX port
108
   signal pavr_iof_rampx      : std_logic_vector(7 downto 0);
109
   signal pavr_iof_rampx_wr   : std_logic;
110
   signal pavr_iof_rampx_di   : std_logic_vector(7 downto 0);
111
 
112
   -- RAMPY port
113
   signal pavr_iof_rampy      : std_logic_vector(7 downto 0);
114
   signal pavr_iof_rampy_wr   : std_logic;
115
   signal pavr_iof_rampy_di   : std_logic_vector(7 downto 0);
116
 
117
   -- RAMPZ port
118
   signal pavr_iof_rampz      : std_logic_vector(7 downto 0);
119
   signal pavr_iof_rampz_wr   : std_logic;
120
   signal pavr_iof_rampz_di   : std_logic_vector(7 downto 0);
121
 
122
   -- RAMPD port
123
   signal pavr_iof_rampd      : std_logic_vector(7 downto 0);
124
   signal pavr_iof_rampd_wr   : std_logic;
125
   signal pavr_iof_rampd_di   : std_logic_vector(7 downto 0);
126
 
127
   -- EIND port
128
   signal pavr_iof_eind       : std_logic_vector(7 downto 0);
129
   signal pavr_iof_eind_wr    : std_logic;
130
   signal pavr_iof_eind_di    : std_logic_vector(7 downto 0);
131
 
132
   -- Port A
133
   signal pavr_iof_pa         : std_logic_vector(7 downto 0);
134
 
135
   -- Interrupt-related interface signals to control module (to the pipeline).
136
   signal pavr_disable_int    : std_logic;
137
   signal pavr_int_rq         : std_logic;
138
   signal pavr_int_vec        : std_logic_vector(21 downto 0);
139
 
140
   -- Declare the IO File.
141
   component pavr_iof
142
   port(
143
      pavr_iof_clk      : in std_logic;
144
      pavr_iof_res      : in std_logic;
145
      pavr_iof_syncres  : in std_logic;
146
 
147
      -- General IO file port
148
      pavr_iof_opcode   : in  std_logic_vector(pavr_iof_opcode_w - 1 downto 0);
149
      pavr_iof_addr     : in  std_logic_vector(5 downto 0);
150
      pavr_iof_di       : in  std_logic_vector(7 downto 0);
151
      pavr_iof_do       : out std_logic_vector(7 downto 0);
152
      pavr_iof_bitout   : out std_logic;
153
      pavr_iof_bitaddr  : in  std_logic_vector(2 downto 0);
154
 
155
      -- AVR kernel register ports
156
      -- Status register (SREG)
157
      pavr_iof_sreg     : out std_logic_vector(7 downto 0);
158
      pavr_iof_sreg_wr  : in  std_logic;
159
      pavr_iof_sreg_di  : in  std_logic_vector(7 downto 0);
160
 
161
      -- Stack pointer (SP = SPH&SPL)
162
      pavr_iof_sph      : out std_logic_vector(7 downto 0);
163
      pavr_iof_sph_wr   : in  std_logic;
164
      pavr_iof_sph_di   : in  std_logic_vector(7 downto 0);
165
      pavr_iof_spl      : out std_logic_vector(7 downto 0);
166
      pavr_iof_spl_wr   : in  std_logic;
167
      pavr_iof_spl_di   : in  std_logic_vector(7 downto 0);
168
 
169
      -- Pointer registers extensions (RAMPX, RAMPY, RAMPZ)
170
      pavr_iof_rampx    : out std_logic_vector(7 downto 0);
171
      pavr_iof_rampx_wr : in  std_logic;
172
      pavr_iof_rampx_di : in  std_logic_vector(7 downto 0);
173
 
174
      pavr_iof_rampy    : out std_logic_vector(7 downto 0);
175
      pavr_iof_rampy_wr : in  std_logic;
176
      pavr_iof_rampy_di : in  std_logic_vector(7 downto 0);
177
 
178
      pavr_iof_rampz    : out std_logic_vector(7 downto 0);
179
      pavr_iof_rampz_wr : in  std_logic;
180
      pavr_iof_rampz_di : in  std_logic_vector(7 downto 0);
181
 
182
      -- Data Memory extension address register (RAMPD)
183
      pavr_iof_rampd    : out std_logic_vector(7 downto 0);
184
      pavr_iof_rampd_wr : in  std_logic;
185
      pavr_iof_rampd_di : in  std_logic_vector(7 downto 0);
186
 
187
      -- Program Memory extension address register (EIND)
188
      pavr_iof_eind     : out std_logic_vector(7 downto 0);
189
      pavr_iof_eind_wr  : in  std_logic;
190
      pavr_iof_eind_di  : in  std_logic_vector(7 downto 0);
191
 
192
      -- AVR non-kernel (feature) register ports
193
      -- Port A
194
      pavr_iof_pa : inout std_logic_vector(7 downto 0);
195
 
196
      -- Interrupt-related interface signals to control module (to the pipeline).
197
      pavr_disable_int  : in  std_logic;
198
      pavr_int_rq       : out std_logic;
199
      pavr_int_vec      : out std_logic_vector(21 downto 0)
200
   );
201
   end component;
202
   for all: pavr_iof use entity work.pavr_iof(pavr_iof_arch);
203
 
204
begin
205
 
206
   -- Instantiate the IO File.
207
   pavr_iof_instance1: pavr_iof
208
   port map(
209
      clk,
210
      res,
211
      syncres,
212
 
213
      -- General IO file port
214
      pavr_iof_opcode,
215
      pavr_iof_addr,
216
      pavr_iof_di,
217
      pavr_iof_do,
218
      pavr_iof_bitout,
219
      pavr_iof_bitaddr,
220
 
221
      -- AVR kernel register ports
222
      -- Status register (SREG)
223
      pavr_iof_sreg,
224
      pavr_iof_sreg_wr,
225
      pavr_iof_sreg_di,
226
 
227
      -- Stack pointer (SP = SPH&SPL)
228
      pavr_iof_sph,
229
      pavr_iof_sph_wr,
230
      pavr_iof_sph_di,
231
      pavr_iof_spl,
232
      pavr_iof_spl_wr,
233
      pavr_iof_spl_di,
234
 
235
      -- Pointer registers extensions (RAMPX, RAMPY, RAMPZ)
236
      pavr_iof_rampx,
237
      pavr_iof_rampx_wr,
238
      pavr_iof_rampx_di,
239
 
240
      pavr_iof_rampy,
241
      pavr_iof_rampy_wr,
242
      pavr_iof_rampy_di,
243
 
244
      pavr_iof_rampz,
245
      pavr_iof_rampz_wr,
246
      pavr_iof_rampz_di,
247
 
248
      -- Data Memory extension address register (RAMPD)
249
      pavr_iof_rampd,
250
      pavr_iof_rampd_wr,
251
      pavr_iof_rampd_di,
252
 
253
      -- Program Memory extension address register (EIND)
254
      pavr_iof_eind,
255
      pavr_iof_eind_wr,
256
      pavr_iof_eind_di,
257
 
258
      -- AVR non-kernel (feature) register ports
259
      -- Port A
260
      pavr_iof_pa,
261
 
262
      -- Interrupt-related interface signals to control module (to the pipeline).
263
      pavr_disable_int,
264
      pavr_int_rq,
265
      pavr_int_vec
266
   );
267
 
268
 
269
   generate_clock:
270
   process
271
   begin
272
      clk <= '1';
273
      wait for 50 ns;
274
      clk <= '0';
275
      wait for 50 ns;
276
   end process generate_clock;
277
 
278
 
279
   generate_reset:
280
   process
281
   begin
282
      res <= '0';
283
      wait for 100 ns;
284
      res <= '1';
285
      wait for 110 ns;
286
      res <= '0';
287
      wait for 1 ms;
288
   end process generate_reset;
289
 
290
 
291
   generate_sync_reset:
292
   process
293
   begin
294
      syncres <= '0';
295
      wait for 300 ns;
296
      syncres <= '1';
297
      wait for 110 ns;
298
      syncres <= '0';
299
      wait for 1 ms;
300
   end process generate_sync_reset;
301
 
302
 
303
   test_main:
304
   process(clk, res, syncres,
305
           cnt,
306
           pavr_iof_opcode, pavr_iof_addr, pavr_iof_di, pavr_iof_bitaddr,
307
           pavr_iof_sreg_di,
308
           pavr_iof_spl_di,
309
           pavr_iof_sph_di,
310
           pavr_iof_rampx_di,
311
           pavr_iof_rampy_di,
312
           pavr_iof_rampz_di,
313
           pavr_iof_rampd_di,
314
           pavr_iof_eind_di,
315
 
316
           pavr_iof_rampy
317
          )
318
   begin
319
      if res='1' then
320
         -- Async reset
321
         -- The IO File should take care of reseting its registers. Check this.
322
         cnt <= int_to_std_logic_vector(0, cnt'length);
323
      elsif clk'event and clk='1' then
324
         -- Clock counter
325
         cnt <= cnt+1;
326
 
327
         -- Initialize inputs.
328
         pavr_iof_opcode      <= int_to_std_logic_vector(0, pavr_iof_opcode'length);
329
         pavr_iof_addr        <= int_to_std_logic_vector(0, pavr_iof_addr'length);
330
         pavr_iof_di          <= int_to_std_logic_vector(0, pavr_iof_di'length);
331
         pavr_iof_bitaddr     <= int_to_std_logic_vector(0, pavr_iof_bitaddr'length);
332
 
333
         pavr_iof_sreg_wr     <= '0';
334
         pavr_iof_sreg_di     <= int_to_std_logic_vector(0, pavr_iof_sreg_di'length);
335
 
336
         pavr_iof_spl_wr      <= '0';
337
         pavr_iof_spl_di      <= int_to_std_logic_vector(0, pavr_iof_spl_di'length);
338
 
339
         pavr_iof_sph_wr      <= '0';
340
         pavr_iof_sph_di      <= int_to_std_logic_vector(0, pavr_iof_sph_di'length);
341
 
342
         pavr_iof_rampx_wr    <= '0';
343
         pavr_iof_rampx_di    <= int_to_std_logic_vector(0, pavr_iof_rampx_di'length);
344
 
345
         pavr_iof_rampy_wr    <= '0';
346
         pavr_iof_rampy_di    <= int_to_std_logic_vector(0, pavr_iof_rampy_di'length);
347
 
348
         pavr_iof_rampz_wr    <= '0';
349
         pavr_iof_rampz_di    <= int_to_std_logic_vector(0, pavr_iof_rampz_di'length);
350
 
351
         pavr_iof_rampd_wr    <= '0';
352
         pavr_iof_rampd_di    <= int_to_std_logic_vector(0, pavr_iof_rampd_di'length);
353
 
354
         pavr_iof_eind_wr     <= '0';
355
         pavr_iof_eind_di     <= int_to_std_logic_vector(0, pavr_iof_eind_di'length);
356
 
357
         pavr_disable_int     <= '0';
358
 
359
         case std_logic_vector_to_nat(cnt) is
360
            -- TEST 1. Test IO general port.
361
            -- IOF opcode = wrbyte. Write RAMPY.
362
            when 3 =>
363
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
364
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_rampy_addr, pavr_iof_addr'length);
365
               pavr_iof_di       <= int_to_std_logic_vector(16#C5#, pavr_iof_di'length);
366
            -- IOF opcode = rdbyte. Read RAMPY.
367
            when 4 =>
368
               pavr_iof_opcode   <= pavr_iof_opcode_rdbyte;
369
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_rampy_addr, pavr_iof_addr'length);
370
            -- IOF opcode = clrbit. Clear bit 2 of RAMPY.
371
            when 5 =>
372
               pavr_iof_opcode   <= pavr_iof_opcode_clrbit;
373
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_rampy_addr, pavr_iof_addr'length);
374
               pavr_iof_di       <= pavr_iof_rampy;
375
               pavr_iof_bitaddr  <= int_to_std_logic_vector(2, pavr_iof_bitaddr'length);
376
            -- IOF opcode = setbit. Set bit 3 of RAMPY.
377
            when 6 =>
378
               pavr_iof_opcode   <= pavr_iof_opcode_setbit;
379
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_rampy_addr, pavr_iof_addr'length);
380
               pavr_iof_di       <= pavr_iof_rampy;
381
               pavr_iof_bitaddr  <= int_to_std_logic_vector(3, pavr_iof_bitaddr'length);
382
            -- IOF opcode = stbit. Store bit 4 of input into T flag.
383
            when 7 =>
384
               pavr_iof_opcode   <= pavr_iof_opcode_stbit;
385
               pavr_iof_di       <= int_to_std_logic_vector(16#93#, pavr_iof_di'length);
386
               pavr_iof_bitaddr  <= int_to_std_logic_vector(4, pavr_iof_bitaddr'length);
387
            -- IOF opcode = ldbit. Load T flag into bit 5 of output.
388
            when 8 =>
389
               pavr_iof_opcode   <= pavr_iof_opcode_ldbit;
390
               pavr_iof_di       <= int_to_std_logic_vector(16#93#, pavr_iof_di'length);
391
               pavr_iof_bitaddr  <= int_to_std_logic_vector(5, pavr_iof_bitaddr'length);
392
 
393
 
394
            -- TEST 2. Write some of the IOF registers that have dedicated write
395
            --    ports.
396
            when 9 =>
397
               pavr_iof_sph_wr   <= '1';
398
               pavr_iof_sph_di   <= int_to_std_logic_vector(16#5E#, 8);
399
               pavr_iof_eind_wr  <= '1';
400
               pavr_iof_eind_di  <= int_to_std_logic_vector(16#A2#, 8);
401
 
402
 
403
            -- TEST 3. Test Port A.
404
            -- The idea is:
405
            --    - 1. set some bits in PORTA
406
            --    - 2. set some bits in DDRA
407
            --    Now check the output pins PA to see which is Hi Z input, weakly
408
            --       pulled hi input, or output low/hi.
409
            --    - 3. read PINA and see if IOF data out gets all those HiZ/H/0/1
410
            --       lines.
411
            -- Write PORTA.
412
            when 20 =>
413
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
414
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_porta_addr, pavr_iof_addr'length);
415
               pavr_iof_di       <= int_to_std_logic_vector(16#0F#, pavr_iof_di'length);
416
               -- Set port pins into Hi Z (nobody sources or sink into/from them
417
               --    from outside). Note that a 3 state latch is generated.
418
               pavr_iof_pa <= "ZZZZZZZZ";
419
            -- Write DDRA.
420
            when 21 =>
421
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
422
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_ddra_addr, pavr_iof_addr'length);
423
               pavr_iof_di       <= int_to_std_logic_vector(16#33#, pavr_iof_di'length);
424
            -- Read PINA.
425
            when 22 =>
426
               pavr_iof_opcode   <= pavr_iof_opcode_rdbyte;
427
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_pina_addr, pavr_iof_addr'length);
428
            -- Now clear the Port A mess for next tests (remember that PA also has
429
            --    alternate functions: int 0 and timer 0, that will be tested
430
            --    below). Thus, set PA as Hi Z input (DDRA=0 and PORTA=0).
431
            when 23 =>
432
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
433
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_ddra_addr, pavr_iof_addr'length);
434
               pavr_iof_di       <= int_to_std_logic_vector(16#00#, pavr_iof_di'length);
435
               pavr_iof_pa <= "ZZZZZZZZ";
436
            when 24 =>
437
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
438
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_porta_addr, pavr_iof_addr'length);
439
               pavr_iof_di       <= int_to_std_logic_vector(16#00#, pavr_iof_di'length);
440
 
441
 
442
            -- TEST 4. Test timer 0 prescaler options.
443
            -- Timer 0 clock = main clock.
444
            when 30 =>
445
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
446
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_tccr0_addr, pavr_iof_addr'length);
447
               pavr_iof_di       <= int_to_std_logic_vector(16#01#, pavr_iof_di'length);
448
            -- Timer 0 clock = main clock / 8.
449
            when 40 =>
450
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
451
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_tccr0_addr, pavr_iof_addr'length);
452
               pavr_iof_di       <= int_to_std_logic_vector(16#02#, pavr_iof_di'length);
453
            -- Timer 0 clock = main clock / 64.
454
            when 100 =>
455
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
456
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_tccr0_addr, pavr_iof_addr'length);
457
               pavr_iof_di       <= int_to_std_logic_vector(16#03#, pavr_iof_di'length);
458
            -- Timer 0 clock = main clock / 256.
459
            when 250 =>
460
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
461
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_tccr0_addr, pavr_iof_addr'length);
462
               pavr_iof_di       <= int_to_std_logic_vector(16#04#, pavr_iof_di'length);
463
            -- Timer 0 clock = main clock / 1024.
464
            when 1000 =>
465
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
466
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_tccr0_addr, pavr_iof_addr'length);
467
               pavr_iof_di       <= int_to_std_logic_vector(16#05#, pavr_iof_di'length);
468
            -- Timer 0 clock = dedicated external input PINA(1), negative edge.
469
            when 5000 =>
470
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
471
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_tccr0_addr, pavr_iof_addr'length);
472
               pavr_iof_di       <= int_to_std_logic_vector(16#06#, pavr_iof_di'length);
473
               pavr_iof_pa(1) <= '0';
474
            when 5001 | 5002 =>
475
               pavr_iof_pa(1) <= '0';
476
            when 5003 | 5004 =>
477
               pavr_iof_pa(1) <= '1';
478
            when 5005 | 5006 | 5007 =>
479
               pavr_iof_pa(1) <= '0';
480
            when 5008 | 5009 =>
481
               pavr_iof_pa(1) <= '1';
482
            when 5010 | 5011 | 5012 =>
483
               pavr_iof_pa(1) <= '0';
484
            when 5013 | 5014 | 5015 | 5016 | 5017 | 5018 | 5019 =>
485
               pavr_iof_pa(1) <= '1';
486
            when 5020 =>
487
               pavr_iof_pa(1) <= '0';
488
            -- Timer 0 clock = dedicated external input PINA(1), positive edge.
489
            when 5030 =>
490
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
491
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_tccr0_addr, pavr_iof_addr'length);
492
               pavr_iof_di       <= int_to_std_logic_vector(16#07#, pavr_iof_di'length);
493
            when 5031 | 5032 =>
494
               pavr_iof_pa(1) <= '0';
495
            when 5033 | 5034 =>
496
               pavr_iof_pa(1) <= '1';
497
            when 5035 | 5036 | 5037 =>
498
               pavr_iof_pa(1) <= '0';
499
            when 5038 | 5039 =>
500
               pavr_iof_pa(1) <= '1';
501
            when 5040 | 5041 | 5042 =>
502
               pavr_iof_pa(1) <= '0';
503
            when 5043 | 5044 | 5045 | 5046 | 5047 | 5048 | 5049 =>
504
               pavr_iof_pa(1) <= '1';
505
            when 5050 =>
506
               pavr_iof_pa(1) <= '0';
507
 
508
 
509
            -- TEST 5. Test timer 0 overflow.
510
            -- Check if timer 0 overflows and if the overflow event is captured in
511
            --    TIFR(1). Set timer 0 clock to main clock, to count faster.
512
            when 5100 =>
513
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
514
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_tccr0_addr, pavr_iof_addr'length);
515
               pavr_iof_di       <= int_to_std_logic_vector(16#01#, pavr_iof_di'length);
516
 
517
 
518
            -- TEST 6. Test timer 0 overflow interrupt.
519
            -- Enable interrupts globally, by setting set SREG(7).
520
            when 5500 =>
521
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
522
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_sreg_addr, pavr_iof_addr'length);
523
               pavr_iof_di       <= int_to_std_logic_vector(16#80#, pavr_iof_di'length);
524
            -- Enable timer 0 overflow interrupt, by setting TIMSK(1).
525
            when 5501 =>
526
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
527
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_timsk_addr, pavr_iof_addr'length);
528
               pavr_iof_di       <= int_to_std_logic_vector(16#02#, pavr_iof_di'length);
529
            -- Set timer 0 clock to system clock (highest speed).
530
            when 5502 =>
531
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
532
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_tccr0_addr, pavr_iof_addr'length);
533
               pavr_iof_di       <= int_to_std_logic_vector(16#01#, pavr_iof_di'length);
534
            -- Disable timer 0 overflow interrupt, to keep the timer 0 `quiet'
535
            --    during next tests.
536
            when 5503 =>
537
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
538
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_timsk_addr, pavr_iof_addr'length);
539
               pavr_iof_di       <= int_to_std_logic_vector(16#00#, pavr_iof_di'length);
540
 
541
 
542
            -- TEST 7. Test external interrupt 0.
543
            -- Enable external interrupt 0.
544
            when 5799 =>
545
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
546
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_gimsk_addr, pavr_iof_addr'length);
547
               pavr_iof_di       <= int_to_std_logic_vector(16#40#, pavr_iof_di'length);
548
               pavr_iof_pa(0)    <= '1';
549
            -- Check if external interrupt 0 event is captured in GIFR(6).
550
            -- External interrupt 0 triggers on low PA(0).
551
            when 5800 =>
552
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
553
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_mcucr_addr, pavr_iof_addr'length);
554
               pavr_iof_di       <= int_to_std_logic_vector(16#00#, pavr_iof_di'length);
555
               pavr_iof_pa(0)    <= '1';
556
            when 5801 =>
557
               pavr_iof_pa(0)    <= '0';
558
            -- External interrupt 0 triggers on negative edge of PA(0).
559
            when 5802 | 5803 =>
560
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
561
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_mcucr_addr, pavr_iof_addr'length);
562
               pavr_iof_di       <= int_to_std_logic_vector(16#02#, pavr_iof_di'length);
563
               pavr_iof_pa(0)    <= '0';
564
            when 5804 | 5805 =>
565
               pavr_iof_pa(0)    <= '1';
566
            when 5806 | 5807 =>
567
               pavr_iof_pa(0)    <= '0';
568
            when 5808 | 5809 | 5810 | 5811 =>
569
               pavr_iof_pa(0)    <= '1';
570
            -- External interrupt 0 triggers on positive edge of PA(0).
571
            when 5812 | 5813 =>
572
               pavr_iof_opcode   <= pavr_iof_opcode_wrbyte;
573
               pavr_iof_addr     <= int_to_std_logic_vector(pavr_mcucr_addr, pavr_iof_addr'length);
574
               pavr_iof_di       <= int_to_std_logic_vector(16#03#, pavr_iof_di'length);
575
               pavr_iof_pa(0)    <= '0';
576
            when 5814 | 5815 =>
577
               pavr_iof_pa(0)    <= '1';
578
            when 5816 | 5817 =>
579
               pavr_iof_pa(0)    <= '0';
580
            when 5818 | 5819 =>
581
               pavr_iof_pa(0)    <= '1';
582
 
583
 
584
            -- That's all about testing IO File.
585
            when others =>
586
               null;
587
         end case;
588
 
589
         if syncres='1' then
590
            -- Sync reset
591
            -- The IO File should take care of reseting its registers. Check this.
592
            cnt <= int_to_std_logic_vector(0, cnt'length);
593
         end if;
594
      end if;
595
   end process test_main;
596
 
597
 
598
end;
599
-- </File body>

powered by: WebSVN 2.1.0

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