| 1 |
15 |
pradd |
library ieee;
|
| 2 |
|
|
use ieee.std_logic_1164.all;
|
| 3 |
|
|
use ieee.numeric_std.all;
|
| 4 |
|
|
|
| 5 |
|
|
entity nand_avalon is
|
| 6 |
|
|
port
|
| 7 |
|
|
(
|
| 8 |
|
|
clk : in std_logic := '0';
|
| 9 |
|
|
resetn : in std_logic := '0';
|
| 10 |
|
|
readdata : out std_logic_vector(31 downto 0);
|
| 11 |
|
|
writedata : in std_logic_vector(31 downto 0) := x"00000000";
|
| 12 |
|
|
pread : in std_logic := '1';
|
| 13 |
|
|
pwrite : in std_logic := '1';
|
| 14 |
|
|
address : in std_logic_vector(1 downto 0);
|
| 15 |
|
|
|
| 16 |
|
|
-- NAND chip control hardware interface. These signals should be bound to physical pins.
|
| 17 |
|
|
nand_cle : out std_logic := '0';
|
| 18 |
|
|
nand_ale : out std_logic := '0';
|
| 19 |
|
|
nand_nwe : out std_logic := '1';
|
| 20 |
|
|
nand_nwp : out std_logic := '0';
|
| 21 |
|
|
nand_nce : out std_logic := '1';
|
| 22 |
|
|
nand_nre : out std_logic := '1';
|
| 23 |
|
|
nand_rnb : in std_logic;
|
| 24 |
|
|
-- NAND chip data hardware interface. These signals should be boiund to physical pins.
|
| 25 |
|
|
nand_data : inout std_logic_vector(15 downto 0)
|
| 26 |
|
|
|
| 27 |
|
|
);
|
| 28 |
|
|
end nand_avalon;
|
| 29 |
|
|
|
| 30 |
|
|
architecture action of nand_avalon is
|
| 31 |
|
|
component nand_master
|
| 32 |
|
|
port
|
| 33 |
|
|
(
|
| 34 |
|
|
nand_cle, nand_ale, nand_nwe, nand_nwp, nand_nce, nand_nre, busy : out std_logic;
|
| 35 |
|
|
clk, enable, nand_rnb, nreset, activate : in std_logic;
|
| 36 |
|
|
data_out : out std_logic_vector(7 downto 0);
|
| 37 |
|
|
data_in, cmd_in : in std_logic_vector(7 downto 0);
|
| 38 |
|
|
nand_data : inout std_logic_vector(15 downto 0)
|
| 39 |
|
|
);
|
| 40 |
|
|
end component;
|
| 41 |
|
|
signal nreset : std_logic;
|
| 42 |
|
|
signal n_data_out : std_logic_vector(7 downto 0);
|
| 43 |
|
|
signal n_data_in : std_logic_vector(7 downto 0);
|
| 44 |
|
|
signal n_busy : std_logic;
|
| 45 |
|
|
signal n_activate : std_logic;
|
| 46 |
|
|
signal n_cmd_in : std_logic_vector(7 downto 0);
|
| 47 |
|
|
signal prev_pwrite : std_logic;
|
| 48 |
|
|
signal prev_address : std_logic_vector(1 downto 0);
|
| 49 |
|
|
begin
|
| 50 |
|
|
NANDA: nand_master
|
| 51 |
|
|
port map
|
| 52 |
|
|
(
|
| 53 |
|
|
clk => clk, enable => '0',
|
| 54 |
|
|
nand_cle => nand_cle, nand_ale => nand_ale, nand_nwe => nand_nwe, nand_nwp => nand_nwp, nand_nce => nand_nce, nand_nre => nand_nre,
|
| 55 |
|
|
nand_rnb => nand_rnb, nand_data => nand_data,
|
| 56 |
|
|
nreset => resetn, data_out => n_data_out, data_in => n_data_in, busy => n_busy, activate => n_activate, cmd_in => n_cmd_in
|
| 57 |
|
|
);
|
| 58 |
|
|
|
| 59 |
|
|
-- Registers:
|
| 60 |
|
|
-- 0x00: Data IO
|
| 61 |
|
|
-- 0x04: Command input
|
| 62 |
|
|
-- 0x08: Status output
|
| 63 |
|
|
|
| 64 |
|
|
readdata(7 downto 0) <= n_data_out when address = "00" else
|
| 65 |
|
|
"0000000"&n_busy when address = "10" else
|
| 66 |
|
|
"00000000";
|
| 67 |
|
|
|
| 68 |
|
|
n_activate <= '1' when (prev_address = "01" and prev_pwrite = '0' and pwrite = '1' and n_busy = '0') else
|
| 69 |
|
|
'0';
|
| 70 |
|
|
|
| 71 |
|
|
CONTROL_INPUTS:process(clk, address, pwrite, writedata)
|
| 72 |
|
|
begin
|
| 73 |
|
|
if(rising_edge(clk))then
|
| 74 |
|
|
if(pwrite = '0' and address = "00")then
|
| 75 |
|
|
n_data_in <= writedata(7 downto 0);
|
| 76 |
|
|
elsif(pwrite = '0' and address = "01")Then
|
| 77 |
|
|
n_cmd_in <= writedata(7 downto 0);
|
| 78 |
|
|
end if;
|
| 79 |
|
|
end if;
|
| 80 |
|
|
end process;
|
| 81 |
|
|
|
| 82 |
|
|
TRACK_ADDRESS:process(clk, address, pwrite)
|
| 83 |
|
|
begin
|
| 84 |
|
|
if(rising_edge(clk))then
|
| 85 |
|
|
prev_address <= address;
|
| 86 |
|
|
prev_pwrite <= pwrite;
|
| 87 |
|
|
end if;
|
| 88 |
|
|
end process;
|
| 89 |
|
|
|
| 90 |
|
|
end action;
|