1 |
174 |
jshamlet |
-- Copyright (c)2013 Jeremy Seth Henry
|
2 |
|
|
-- All rights reserved.
|
3 |
|
|
--
|
4 |
|
|
-- Redistribution and use in source and binary forms, with or without
|
5 |
|
|
-- modification, are permitted provided that the following conditions are met:
|
6 |
|
|
-- * Redistributions of source code must retain the above copyright
|
7 |
|
|
-- notice, this list of conditions and the following disclaimer.
|
8 |
|
|
-- * Redistributions in binary form must reproduce the above copyright
|
9 |
|
|
-- notice, this list of conditions and the following disclaimer in the
|
10 |
|
|
-- documentation and/or other materials provided with the distribution,
|
11 |
|
|
-- where applicable (as part of a user interface, debugging port, etc.)
|
12 |
|
|
--
|
13 |
|
|
-- THIS SOFTWARE IS PROVIDED BY JEREMY SETH HENRY ``AS IS'' AND ANY
|
14 |
|
|
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
15 |
|
|
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
16 |
|
|
-- DISCLAIMED. IN NO EVENT SHALL JEREMY SETH HENRY BE LIABLE FOR ANY
|
17 |
|
|
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
18 |
|
|
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
19 |
|
|
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
20 |
|
|
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
21 |
|
|
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
22 |
|
|
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
23 |
|
|
--
|
24 |
|
|
-- VHDL Units : o8_ram_1k
|
25 |
|
|
-- Description: Provides a wrapper layer for a 1kx8 RAM model
|
26 |
|
|
|
27 |
|
|
library ieee;
|
28 |
|
|
use ieee.std_logic_1164.all;
|
29 |
|
|
use ieee.std_logic_unsigned.all;
|
30 |
|
|
use ieee.std_logic_arith.all;
|
31 |
|
|
|
32 |
|
|
library work;
|
33 |
|
|
use work.open8_pkg.all;
|
34 |
|
|
|
35 |
|
|
entity o8_ram_1k is
|
36 |
|
|
generic(
|
37 |
|
|
Reset_Level : std_logic;
|
38 |
|
|
Address : ADDRESS_TYPE
|
39 |
|
|
);
|
40 |
|
|
port(
|
41 |
|
|
Clock : in std_logic;
|
42 |
|
|
Reset : in std_logic;
|
43 |
|
|
--
|
44 |
|
|
Bus_Address : in ADDRESS_TYPE;
|
45 |
|
|
Wr_Enable : in std_logic;
|
46 |
|
|
Wr_Data : in DATA_TYPE;
|
47 |
|
|
Rd_Enable : in std_logic;
|
48 |
|
|
Rd_Data : out DATA_TYPE
|
49 |
|
|
);
|
50 |
|
|
end entity;
|
51 |
|
|
|
52 |
|
|
architecture behave of o8_ram_1k is
|
53 |
|
|
|
54 |
|
|
constant User_Addr : std_logic_vector(15 downto 10)
|
55 |
|
|
:= Address(15 downto 10);
|
56 |
|
|
alias Comp_Addr is Bus_Address(15 downto 10);
|
57 |
|
|
alias RAM_Addr is Bus_Address(9 downto 0);
|
58 |
|
|
|
59 |
|
|
signal Addr_Match : std_logic;
|
60 |
|
|
signal Wr_En : std_logic;
|
61 |
|
|
signal Rd_En : std_logic;
|
62 |
|
|
signal Rd_Data_i : DATA_TYPE;
|
63 |
|
|
|
64 |
|
|
begin
|
65 |
|
|
|
66 |
|
|
-- This decode needs to happen immediately, to give the RAM a chance to
|
67 |
|
|
-- do the lookup before we have to set Rd_Data
|
68 |
|
|
Addr_Match <= '1' when Comp_Addr = User_Addr else '0';
|
69 |
|
|
Wr_En <= Addr_Match and Wr_Enable;
|
70 |
|
|
|
71 |
|
|
-- Note that this RAM should be created without an output FF (unregistered Q)
|
72 |
|
|
U_RAM : entity work.ram_1k_core
|
73 |
|
|
port map(
|
74 |
|
|
address => RAM_Addr,
|
75 |
|
|
clock => Clock,
|
76 |
|
|
data => Wr_Data,
|
77 |
|
|
wren => Wr_En,
|
78 |
|
|
q => Rd_Data_i
|
79 |
|
|
);
|
80 |
|
|
|
81 |
|
|
RAM_proc: process( Reset, Clock )
|
82 |
|
|
begin
|
83 |
|
|
if( Reset = Reset_Level )then
|
84 |
|
|
Rd_En <= '0';
|
85 |
|
|
Rd_Data <= (others => '0');
|
86 |
|
|
elsif( rising_edge(Clock) )then
|
87 |
|
|
Rd_En <= Addr_Match and Rd_Enable;
|
88 |
|
|
Rd_Data <= (others => '0');
|
89 |
|
|
if( Rd_En = '1' )then
|
90 |
|
|
Rd_Data <= Rd_Data_i;
|
91 |
|
|
end if;
|
92 |
|
|
end if;
|
93 |
|
|
end process;
|
94 |
|
|
|
95 |
|
|
end architecture;
|