OpenCores
URL https://opencores.org/ocsvn/hf-risc/hf-risc/trunk

Subversion Repositories hf-risc

[/] [hf-risc/] [trunk/] [hf-riscv/] [platform/] [rams/] [ram.vhd] - Blame information for rev 16

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 serginhofr
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.STD_LOGIC_ARITH.ALL;
4
use IEEE.STD_LOGIC_UNSIGNED.ALL;
5
use ieee.std_logic_textio.all;
6
use std.textio.all;
7
 
8
entity bram is
9
        generic(memory_file : string := "code.txt";
10
                data_width: integer := 8;                       -- data width (fixed)
11
                address_width: integer := 16;                   -- address width
12
                bank: integer := 0);                                     -- memory bank (0,1,2,3)
13
        port(
14
        clk : in std_logic;                                     --clock
15
        addr : in std_logic_vector(address_width - 1 downto 2);         --address bus
16
        cs_n : in std_logic;                                    --chip select
17
        we_n : in std_logic;                                    --write enable
18
        data_i: in std_logic_vector(data_width - 1 downto 0);    --write data bus
19
        data_o: out std_logic_vector(data_width - 1 downto 0)    --read data bus
20
        );
21
end bram;
22
 
23
architecture memory of bram is
24
 
25
type ram is array(2 ** address_width -1 downto 0) of std_logic_vector(data_width - 1 downto 0);
26
signal ram1 : ram := (others => (others => '0'));
27
 
28
begin
29
        process(clk)
30
        begin
31
                if (clk'event and clk = '1') then
32
                        if(cs_n = '0') then
33
                                if(we_n = '0') then
34
                                        ram1(conv_integer(addr(address_width -1 downto 2))) <= data_i;
35
                                else
36
                                        data_o <= ram1(conv_integer(addr(address_width -1 downto 2)));
37
                                end if;
38
                        end if;
39
                end if;
40
 
41
        end process;
42
 
43
end memory;
44
 

powered by: WebSVN 2.1.0

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