OpenCores
URL https://opencores.org/ocsvn/am9080_cpu_based_on_microcoded_am29xx_bit-slices/am9080_cpu_based_on_microcoded_am29xx_bit-slices/trunk

Subversion Repositories am9080_cpu_based_on_microcoded_am29xx_bit-slices

[/] [am9080_cpu_based_on_microcoded_am29xx_bit-slices/] [trunk/] [simpleram.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 zpekic
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    11:56:00 11/12/2017 
6
-- Design Name: 
7
-- Module Name:    simpleram - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
 
23
-- Uncomment the following library declaration if using
24
-- arithmetic functions with Signed or Unsigned values
25
use IEEE.NUMERIC_STD.ALL;
26
 
27
-- Uncomment the following library declaration if instantiating
28
-- any Xilinx primitives in this code.
29
--library UNISIM;
30
--use UNISIM.VComponents.all;
31
 
32
entity simpleram is
33
         generic (
34
                address_size: positive := 16;
35
                default_value: STD_LOGIC_VECTOR(7 downto 0) := X"FF");
36
    Port (
37
                          clk: in STD_LOGIC;
38
                          D : inout  STD_LOGIC_VECTOR (7 downto 0);
39
           A : in  STD_LOGIC_VECTOR ((address_size - 1) downto 0);
40
           nRead : in  STD_LOGIC;
41
           nWrite : in  STD_LOGIC;
42
           nSelect : in  STD_LOGIC);
43
end simpleram;
44
 
45
-- Using RAM from Xilinx IPCore library
46
--architecture structural of simpleram is
47
--
48
--component ram4kx8 IS
49
--  PORT (
50
--    clka : IN STD_LOGIC;
51
--    ena : IN STD_LOGIC;
52
--    wea : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
53
--    addra : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
54
--    dina : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
55
--    douta : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
56
--  );
57
--end component;
58
--
59
--signal d_out: std_logic_vector(7 downto 0);
60
--signal ena: std_logic;
61
--signal wr: std_logic_vector(0 downto 0);
62
--
63
--begin
64
--
65
--ena <= not nSelect;
66
--wr <= "" & not nWrite;
67
--D <= d_out when (nRead = '0' and nSelect = '0') else "ZZZZZZZZ";
68
--
69
--inner_ram: ram4kx8 port map
70
--      (
71
--    clka => clk,
72
--    ena => ena,
73
--    wea => wr,
74
--    addra => A,
75
--    dina => D,
76
--    douta => d_out
77
--  );
78
--  
79
--end structural;
80
 
81
-- Using standard abstract VHDL  
82
architecture Behavioral of simpleram is
83
 
84
type bytememory is array(0 to (2 ** address_size) - 1) of std_logic_vector(7 downto 0);
85
signal d_out: std_logic_vector(7 downto 0);
86
signal control: std_logic_vector(2 downto 0);
87
 
88
signal ram: bytememory := (others => default_value);
89
attribute ram_style: string;
90
attribute ram_style of ram: signal is "block";
91
 
92
begin
93
 
94
control <= nSelect & nRead & nWrite;
95
D <= d_out when (nRead = '0' and nSelect = '0') else "ZZZZZZZZ";
96
 
97
readwrite: process(clk, control, A, D, ram)
98
begin
99
        case control is
100
                when "010" => -- write 
101
                        if (rising_edge(clk)) then
102
                                ram(to_integer(unsigned(A))) <= D;
103
                        end if;
104
                when "001" => -- read
105
                        d_out <= ram(to_integer(unsigned(A)));
106
                when others =>
107
                        null;
108
        end case;
109
end process;
110
 
111
end Behavioral;
112
 

powered by: WebSVN 2.1.0

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