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

Subversion Repositories pavr

[/] [pavr/] [trunk/] [src/] [test_pavr_data_mem.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
-- Test the Data Memory.
38
-- A trivial read-write test.
39
-- </File info>
40
 
41
 
42
 
43
-- <File body>
44
library ieee;
45
use ieee.std_logic_1164.all;
46
library work;
47
use work.std_util.all;
48
use work.pavr_util.all;
49
use work.pavr_constants.all;
50
 
51
 
52
entity test_pavr_dm is
53
end;
54
 
55
 
56
architecture test_pavr_dm_arch of test_pavr_dm is
57
   signal clk, res: std_logic;
58
 
59
   -- Clock counter
60
   signal cnt: std_logic_vector(7 downto 0);
61
 
62
   -- DM connectivity
63
   signal pavr_dm_do    : std_logic_vector(7 downto 0);
64
   signal pavr_dm_wr    : std_logic;
65
   signal pavr_dm_addr  : std_logic_vector(pavr_dm_addr_w - 1 downto 0);
66
   signal pavr_dm_di    : std_logic_vector(7 downto 0);
67
 
68
   -- Declare the Data Memory
69
   component pavr_dm
70
   port(
71
      pavr_dm_clk:  in  std_logic;
72
      pavr_dm_wr:   in  std_logic;
73
      pavr_dm_addr: in  std_logic_vector(pavr_dm_addr_w - 1 downto 0);
74
      pavr_dm_di:   in  std_logic_vector(7 downto 0);
75
      pavr_dm_do:   out std_logic_vector(7 downto 0)
76
   );
77
   end component;
78
   for all: pavr_dm use entity work.pavr_dm(pavr_dm_arch);
79
 
80
begin
81
 
82
   -- Instantiate the Data Memory
83
   pavr_dm_instance1: pavr_dm
84
   port map(
85
      clk,
86
      pavr_dm_wr,
87
      pavr_dm_addr,
88
      pavr_dm_di,
89
      pavr_dm_do
90
   );
91
 
92
   generate_clock:
93
   process
94
   begin
95
      clk <= '1';
96
      wait for 50 ns;
97
      clk <= '0';
98
      wait for 50 ns;
99
   end process generate_clock;
100
 
101
 
102
   generate_reset:
103
   process
104
   begin
105
      res <= '0';
106
      wait for 100 ns;
107
      res <= '1';
108
      wait for 110 ns;
109
      res <= '0';
110
      wait for 1 ms;
111
   end process generate_reset;
112
 
113
 
114
   test_main:
115
   process(clk, res,
116
           cnt,
117
           pavr_dm_addr, pavr_dm_di
118
          )
119
   begin
120
      if res='1' then
121
         -- Async reset
122
         cnt <= int_to_std_logic_vector(0, cnt'length);
123
      elsif clk'event and clk='1' then
124
         -- Clock counter
125
         cnt <= cnt+1;
126
 
127
         -- Initialize inputs.
128
         pavr_dm_wr <= '0';
129
         pavr_dm_addr <= int_to_std_logic_vector(0, pavr_dm_addr'length);
130
         pavr_dm_di <= int_to_std_logic_vector(0, pavr_dm_di'length);
131
 
132
         case std_logic_vector_to_nat(cnt) is
133
            -- TEST 1. Write DM.
134
            when 3 =>
135
               pavr_dm_wr <= '1';
136
               pavr_dm_addr <= int_to_std_logic_vector(24, pavr_dm_addr'length);
137
               pavr_dm_di <= int_to_std_logic_vector(16#A9#, pavr_dm_di'length);
138
 
139
            -- TEST 2. Read DM.
140
            when 4 =>
141
               pavr_dm_wr <= '0';
142
               pavr_dm_addr <= int_to_std_logic_vector(24, pavr_dm_addr'length);
143
 
144
            when others =>
145
               null;
146
         end case;
147
      end if;
148
   end process test_main;
149
 
150
 
151
end;
152
-- </File body>

powered by: WebSVN 2.1.0

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