This repository was archived by the owner on Dec 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScratchRAM.vhd
More file actions
59 lines (51 loc) · 2.04 KB
/
ScratchRAM.vhd
File metadata and controls
59 lines (51 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
--------------------------------------------------------------------------------
-- Team: Tyler Heucke & Matt Hennes
--
-- Create Date: 14:07:52 10/14/2014
-- Module Name: ScratchRAM - Behavioral
-- Project Name: RAT MCU
--------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity ScratchRAM is
Port ( REG_DY_OUT : in STD_LOGIC_VECTOR (7 downto 0);
INST_REG_7_0 : in STD_LOGIC_VECTOR (7 downto 0);
SP_OUT : in STD_LOGIC_VECTOR (7 downto 0);
SP_OUT_DECREMENT : in STD_LOGIC_VECTOR (7 downto 0);
SCR_ADDR_SEL : in STD_LOGIC_VECTOR (1 downto 0);
SCR_OE : in STD_LOGIC;
SCR_WR : in STD_LOGIC;
CLK : in STD_LOGIC;
MULTI_BUS : inout STD_LOGIC_VECTOR (9 downto 0));
end ScratchRAM;
architecture Behavioral of ScratchRAM is
TYPE memory is array (0 to 255) of std_logic_vector (9 downto 0);
signal BD_RAM : memory := (others => (others => '0'));
signal scr_addr : STD_LOGIC_VECTOR(7 downto 0);
begin
multiplexer : process( SCR_ADDR_SEL, REG_DY_OUT, INST_REG_7_0, SP_OUT, SP_OUT_DECREMENT )
begin
case( SCR_ADDR_SEL ) is
when "00" => scr_addr <= REG_DY_OUT;
when "01" => scr_addr <= INST_REG_7_0;
when "10" => scr_addr <= SP_OUT;
when "11" => scr_addr <= SP_OUT_DECREMENT;
when others => scr_addr <= "00000000";
end case ;
end process ; -- multiplexer
instructions : process( scr_addr, SCR_OE, SCR_WR, CLK, MULTI_BUS, BD_RAM )
begin
if (SCR_WR = '1') then
if (rising_edge(CLK)) then
BD_RAM(conv_integer(scr_addr)) <= MULTI_BUS;
end if;
else
if (SCR_OE = '1') then
MULTI_BUS <= BD_RAM(conv_integer(scr_addr));
else
MULTI_BUS <= (others => 'Z');
end if;
end if;
end process; -- instructions
end Behavioral;