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

Subversion Repositories nand_controller

[/] [nand_controller/] [trunk/] [VHDL/] [testbench.vhd] - Blame information for rev 13

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 pradd
-------------------------------------------------------------------------------------------------
2
-------------------------------------------------------------------------------------------------
3
-- Title                                                        : ONFI compliant NAND interface
4
-- File                                                 : testbench.vhd
5
-- Author                                               : Alexey Lyashko <pradd@opencores.org>
6
-- License                                              : LGPL
7
-------------------------------------------------------------------------------------------------
8
-- Description:
9
-- This is the testbench file for the NAND_MASTER module
10
-------------------------------------------------------------------------------------------------
11
-------------------------------------------------------------------------------------------------
12
 
13
library ieee;
14
use ieee.std_logic_1164.all;
15
use ieee.numeric_std.all;
16
use work.onfi.all;
17
 
18
entity tb is
19
        --port
20
        --(
21
        --);
22
end tb;
23
 
24
architecture test of tb is
25
        component nand_master
26
                port
27
                (
28
                        -- System clock
29
                        clk                                     : in    std_logic;
30
                        -- NAND chip control hardware interface. These signals should be bound to physical pins.
31
                        nand_cle                                : out   std_logic := '0';
32
                        nand_ale                                : out   std_logic := '0';
33
                        nand_nwe                                : out   std_logic := '1';
34
                        nand_nwp                                : out   std_logic := '0';
35
                        nand_nce                                : out   std_logic := '1';
36
                        nand_nre                                : out std_logic := '1';
37
                        nand_rnb                                : in    std_logic;
38
                        -- NAND chip data hardware interface. These signals should be boiund to physical pins.
39
                        nand_data                       : inout std_logic_vector(15 downto 0);
40
 
41
                        -- Component interface
42
                        nreset                          : in    std_logic := '1';
43
                        data_out                                : out   std_logic_vector(7 downto 0);
44
                        data_in                         : in    std_logic_vector(7 downto 0);
45
                        busy                                    : out   std_logic := '0';
46
                        activate                                : in    std_logic := '0';
47
                        cmd_in                          : in    std_logic_vector(7 downto 0)
48
                );
49
        end component;
50
        -- Internal interface
51
        signal nand_cle : std_logic;
52
        signal nand_ale : std_logic;
53
        signal nand_nwe : std_logic;
54
        signal nand_nwp : std_logic;
55
        signal nand_nce :       std_logic;
56
        signal nand_nre : std_logic;
57
        signal nand_rnb : std_logic := '1';
58
        signal nand_data: std_logic_vector(15 downto 0);
59
        signal nreset   : std_logic := '1';
60
        signal data_out : std_logic_vector(7 downto 0);
61
        signal data_in  : std_logic_vector(7 downto 0);
62
        signal busy     : std_logic;
63
        signal activate : std_logic;
64
        signal cmd_in   : std_logic_vector(7 downto 0);
65
        signal clk      : std_logic := '1';
66
begin
67
        NM:nand_master
68
        port map
69
        (
70
                clk => clk,
71
                nand_cle => nand_cle,
72
                nand_ale => nand_ale,
73
                nand_nwe => nand_nwe,
74
                nand_nwp => nand_nwp,
75
                nand_nce => nand_nce,
76
                nand_nre => nand_nre,
77
                nand_rnb => nand_rnb,
78
                nand_data=> nand_data,
79
                nreset   => nreset,
80
                data_out => data_out,
81
                data_in  => data_in,
82
                busy     => busy,
83
                activate => activate,
84
                cmd_in   => cmd_in
85
        );
86
 
87
        CLOCK:process
88
        begin
89
                clk <= '1';
90
                wait for 1.25ns;
91
                clk <= '0';
92
                wait for 1.25ns;
93
        end process;
94
 
95
        TP: process
96
        begin
97
                activate <= '0';
98
                nreset <= '1';
99
                nand_data <= "ZZZZZZZZZZZZZZZZ";
100
 
101
                -- Enable the chip
102
                wait for 5ns;
103
                cmd_in <= x"09";
104
                activate <= '1';
105
                wait for 2.5ns;
106
                activate <= '0';
107
 
108
 
109
                -- Read JEDEC ID
110
                data_in <= x"00";
111
                cmd_in <= x"03";
112
                wait for 5ns;
113
                activate <= '1';
114
                wait for 2.5ns;
115
                activate <= '0';
116
 
117
                -- Provide ID
118
                wait for 155ns;
119
                nand_data <= x"002c";
120
                wait for 32.5ns;
121
                nand_data <= x"00e5";
122
                wait for 32.5ns;
123
                nand_data <= x"00ff";
124
                wait for 32.5ns;
125
                nand_data <= x"0003";
126
                wait for 32.5ns;
127
                nand_data <= x"0086";
128
                wait for 32.5ns;
129
                nand_data <= "ZZZZZZZZZZZZZZZZ";
130
                wait for 5ns;
131
 
132
                -- Read the bytes of the ID
133
                cmd_in <= x"0e";
134
                -- 1
135
                activate <= '1';
136
                wait for 2.5ns;
137
                activate <= '0';
138
                wait for 2.5ns;
139
                -- 2
140
                activate <= '1';
141
                wait for 2.5ns;
142
                activate <= '0';
143
                wait for 2.5ns;
144
                -- 3
145
                activate <= '1';
146
                wait for 2.5ns;
147
                activate <= '0';
148
                wait for 2.5ns;
149
                -- 4
150
                activate <= '1';
151
                wait for 2.5ns;
152
                activate <= '0';
153
                wait for 2.5ns;
154
                -- 5
155
                activate <= '1';
156
                wait for 2.5ns;
157
                activate <= '0';
158
 
159
                cmd_in <= x"08";
160
                wait for 2.5ns;
161
                activate <= '1';
162
                wait for 2.5ns;
163
                activate <= '0';
164
 
165
 
166
                wait;
167
        end process;
168
 
169
end test;

powered by: WebSVN 2.1.0

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