1 | entity Mem_IF is
|
2 |
|
3 | Port (
|
4 | RO_Register_0 : in STD_LOGIC_VECTOR(15 downto 0);
|
5 | RO_Register_1 : in STD_LOGIC_VECTOR(15 downto 0);
|
6 | RO_Register_2 : in STD_LOGIC_VECTOR(15 downto 0);
|
7 |
|
8 | BCLK : in STD_LOGIC;
|
9 | n_Reset: in STD_LOGIC;
|
10 | n_OE : in STD_LOGIC;
|
11 | n_WE: in STD_LOGIC;
|
12 | ALE: in STD_LOGIC;
|
13 | Bus_Wait: out STD_LOGIC;
|
14 | n_WP: in STD_LOGIC;
|
15 | n_CS_0: in STD_LOGIC;
|
16 |
|
17 | WR_Register_0 : out STD_LOGIC_VECTOR(15 downto 0);
|
18 | WR_Register_1 : out STD_LOGIC_VECTOR(15 downto 0);
|
19 | WR_Register_2 : out STD_LOGIC_VECTOR(15 downto 0);
|
20 |
|
21 | Add_Data: inout STD_LOGIC_VECTOR(15 downto 0)
|
22 |
|
23 | );
|
24 |
|
25 | end Mem_IF;
|
26 |
|
27 | architecture Behavioral of Mem_IF is
|
28 |
|
29 | signal latched_addr : std_logic_vector (15 downto 0);
|
30 | signal data_out : std_logic_vector (15 downto 0);
|
31 |
|
32 | begin
|
33 |
|
34 | Add_Data <= data_out when (n_CS_0 = '0' and n_OE = '0' and n_WE = '1') else (others=>'Z');
|
35 |
|
36 | latch_addr : process (BCLK, n_Reset) is
|
37 | begin
|
38 | if(n_reset = '0') then
|
39 | latched_addr <= (others=>'0');
|
40 |
|
41 | elsif (rising_edge(BCLK)) then
|
42 | if (n_CS_0 = '0' and ALE = '1') then
|
43 |
|
44 | latched_addr <= Add_Data;
|
45 | end if;
|
46 | end if;
|
47 | end process latch_addr;
|
48 |
|
49 |
|
50 | MEM_READ : process (BCLK, n_Reset) is
|
51 | begin
|
52 | if(n_reset = '0') then
|
53 | Bus_Wait <= '0';
|
54 | data_out <= (others=>'0');
|
55 |
|
56 | elsif (falling_edge(BCLK)) then
|
57 | if (n_CS_0 = '0' and n_WE = '1' and n_OE = '0' and ALE = '0') then
|
58 | CASE (latched_addr) IS
|
59 |
|
60 | WHEN H"00" => data_out <= RO_Register_0;
|
61 | WHEN H"01" => data_out <= RO_Register_1;
|
62 | WHEN H"02" => data_out <= RO_Register_2;
|
63 |
|
64 | WHEN OTHERS => data_out <= (others=>'0');
|
65 |
|
66 |
|
67 | END CASE;
|
68 |
|
69 | Bus_Wait <= '1';
|
70 | end if;
|
71 | end if;
|
72 | end process MEM_READ;
|
73 |
|
74 |
|
75 | MEM_WRITE : process (BCLK, n_Reset) is
|
76 | begin
|
77 | if(n_Reset = '0') then
|
78 | Bus_Wait <= '0';
|
79 | data_out <= (others=>'0');
|
80 |
|
81 | elsif (falling_edge(BCLK)) then
|
82 | if (n_CS_0 = '0' and n_WE = '0' and n_OE = '1' and n_WP = '1' and ALE = '0') then
|
83 |
|
84 | Bus_Wait <= '0';
|
85 |
|
86 | CASE (latched_addr) IS
|
87 |
|
88 | WHEN H"10" => WR_Register_0 <= Add_Data;
|
89 | WHEN H"10" => WR_Register_1 <= Add_Data;
|
90 | WHEN H"10" => WR_Register_2 <= Add_Data;
|
91 |
|
92 | WHEN OTHERS => data_out <= (others=>'0');
|
93 |
|
94 |
|
95 | END CASE;
|
96 | end if;
|
97 | end if;
|
98 | end process MEM_WRITE;
|
99 |
|
100 | end Behavioral;
|