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

Subversion Repositories nand_controller

[/] [nand_controller/] [trunk/] [VHDL/] [io_unit.vhd] - Blame information for rev 15

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

Line No. Rev Author Line
1 9 pradd
-------------------------------------------------------------------------------------------------
2
-------------------------------------------------------------------------------------------------
3
-- Title                                                : ONFI compliant NAND interface
4
-- File                                                 : io_unit.vhd
5
-- Author                                               : Alexey Lyashko <pradd@opencores.org>
6
-- License                                              : LGPL
7
-------------------------------------------------------------------------------------------------
8
-- Description:
9
-- This file implements data IO unit of the controller.
10
-------------------------------------------------------------------------------------------------
11
-------------------------------------------------------------------------------------------------
12
 
13
 
14
library ieee;
15
use ieee.std_logic_1164.all;
16
use ieee.numeric_std.all;
17
use work.onfi.all;
18
 
19
entity io_unit is
20
        generic (io_type : io_t);
21
        port
22
        (
23
                clk                                     :       in      std_logic;
24
                activate                                :       in      std_logic;
25
                data_in                         :       in      std_logic_vector(15 downto 0);
26
 
27
                io_ctrl                         :       out std_logic := '1';
28
                data_out                                :       out std_logic_vector(15 downto 0);
29
                busy                                    :       out std_logic
30
        );
31
end io_unit;
32
 
33
 
34
 
35
architecture action of io_unit is
36
        type io_state_t is (IO_IDLE, IO_HOLD, IO_DELAY);
37
        signal state                    : io_state_t := IO_IDLE;
38
        signal n_state                  : io_state_t := IO_IDLE;
39
        signal delay                    : integer := 0;
40
        signal data_reg         : std_logic_vector(15 downto 0);
41
begin
42
 
43
        busy <=         '1' when state /= IO_IDLE else
44
                                '0';
45
 
46
        data_out        <=      data_reg when   (io_type = IO_WRITE and state /= IO_IDLE) or
47
                                                                                io_type = IO_READ else
48
                                                                                x"0000";
49
 
50
        io_ctrl <=      '0' when state = IO_DELAY and n_state = IO_HOLD else
51
                                        '1';
52
 
53
        IO: process(clk, activate)
54
        begin
55
                if(rising_edge(clk))then
56
                        case state is
57
                                when IO_IDLE =>
58
                                        if(io_type = IO_WRITE)then
59
                                                data_reg                                <= data_in;
60
                                        end if;
61
                                        if(activate = '1')then
62
                                                if(io_type = IO_WRITE)then
63
                                                        delay                   <= t_wp;
64
                                                else
65
                                                        delay                   <= t_rea;
66
                                                end if;
67
                                                n_state                         <= IO_HOLD;
68
                                                state                   <= IO_DELAY;
69
                                        end if;
70
 
71
                                when IO_HOLD =>
72
                                        if(io_type = IO_WRITE)then
73
                                                delay                           <= t_wh;
74
                                        else
75
                                                delay                           <= t_reh;
76
                                        end if;
77
                                        n_state                         <= IO_IDLE;
78
                                        state                                   <= IO_DELAY;
79
 
80
                                when IO_DELAY =>
81
                                        if(delay > 1)then
82
                                                delay                   <= delay - 1;
83 11 pradd
                                                if(delay = 2 and io_type = IO_READ)then
84
                                                        data_reg        <= data_in;
85
                                                end if;
86 9 pradd
                                        else
87 11 pradd
--                                              if(io_type = IO_READ and n_state = IO_IDLE)then
88
--                                                      data_reg                <= data_in;                                                                     -- This thing needs to be checked with real hardware. Assignment may be needed somewhat earlier.
89
--                                              end if;
90 9 pradd
                                                state                   <= n_state;
91
                                        end if;
92
 
93
                                when others =>
94
                                        state                           <= IO_IDLE;
95
                        end case;
96
                end if;
97
        end process;
98
end action;

powered by: WebSVN 2.1.0

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