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

Subversion Repositories nand_controller

[/] [nand_controller/] [trunk/] [VHDL/] [latch_unit.vhd] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 pradd
-------------------------------------------------------------------------------------------------
2
-------------------------------------------------------------------------------------------------
3
-- Title                                                : ONFI compliant NAND interface
4
-- File                                                 : latch_unit.vhd
5
-- Author                                               : Alexey Lyashko <pradd@opencores.org>
6
-- License                                              : LGPL
7
-------------------------------------------------------------------------------------------------
8
-- Description:
9
-- This file implements command/address latch component of the NAND controller, which takes 
10
-- care of dispatching commands to a NAND chip.
11
-------------------------------------------------------------------------------------------------
12
-------------------------------------------------------------------------------------------------
13
 
14
 
15
library ieee;
16
use ieee.std_logic_1164.all;
17
use ieee.numeric_std.all;
18
use work.onfi.all;
19
 
20
 
21
entity latch_unit is
22
        generic (latch_type : latch_t);
23
        port
24
        (
25
                clk                             :       in      std_logic;
26
                activate                        :       in      std_logic;
27
                data_in                 :       in      std_logic_vector(15 downto 0);
28
 
29
                latch_ctrl              :       out std_logic := '0';
30
                write_enable    :       out std_logic := '1';
31
                busy                            :       out std_logic := '0';
32
                data_out                        :       out std_logic_vector(15 downto 0)
33
        );
34
 
35
end latch_unit;
36
 
37
 
38
architecture action of latch_unit is
39
        type latch_state_t is (LATCH_IDLE, LATCH_HOLD, LATCH_WAIT, LATCH_DELAY);
40
        signal state    : latch_state_t := LATCH_IDLE;
41
        signal n_state : latch_state_t := LATCH_IDLE;
42
        signal delay    : integer := 0;
43
begin
44
 
45
        busy <= '1' when state /= LATCH_IDLE else '0';
46
 
47
        latch_ctrl <=   '1' when state = LATCH_HOLD or
48
                                                                        (state = LATCH_DELAY and
49
                                                                        (n_state = LATCH_HOLD or
50
                                                                        n_state = LATCH_WAIT)) else
51
                                                '0';
52
 
53
        write_enable <= '0' when (state = LATCH_DELAY and n_state = LATCH_HOLD) else
54
                                                        '1' when state /= LATCH_IDLE else
55
                                                        'H';
56
 
57
        data_out        <=      data_in when (state /= LATCH_IDLE and state /= LATCH_WAIT and n_state /= LATCH_IDLE) else
58
                                        "LLLLLLLLLLLLLLLL";
59
 
60
        LATCH:process(clk, activate)
61
        begin
62
                if(rising_edge(clk))then
63
                        case state is
64
                                when LATCH_IDLE =>
65
                                        if(activate = '1')then
66
                                                n_state                 <= LATCH_HOLD;
67
                                                state                   <= LATCH_DELAY;
68
                                                delay                           <= t_wp;
69
                                        end if;
70
 
71
                                when LATCH_HOLD =>
72
                                        if(latch_type = LATCH_CMD)then
73
                                                delay                           <= t_clh;
74
                                        else
75
                                                delay                           <= t_wh;
76
                                        end if;
77
                                        n_state                         <= LATCH_WAIT;
78
                                        state                                   <= LATCH_DELAY;
79
 
80
                                when LATCH_WAIT =>
81
                                        if(latch_type = LATCH_CMD)then
82
                                                -- Delay has been commented out. It is component's responsibility to 
83
                                                --      execute proper delay on command submission.
84
--                                              state                                   <= LATCH_DELAY;
85
                                                state                                   <= LATCH_IDLE;
86
                                                n_state                                 <= LATCH_IDLE;
87
--                                              delay                                   <=      t_wb;                                           
88
                                        else
89
                                                state                                   <= LATCH_IDLE;
90
                                        end if;
91
 
92
                                when LATCH_DELAY =>
93
                                        if(delay > 1)then
94
                                                delay                   <= delay - 1;
95
                                        else
96
                                                state                   <= n_state;
97
                                        end if;
98
 
99
                                when others =>
100
                                        state                                   <=      LATCH_IDLE;
101
                        end case;
102
                end if;
103
        end process;
104
end action;

powered by: WebSVN 2.1.0

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