OpenCores
URL https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.storage/] [fifos/] [fifo_mk2/] [1.0/] [vhd/] [ram_1clk.vhd] - Blame information for rev 147

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : Single clock one port RAM
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : ram_1clk.vhd
6
-- Author     : Lasse Lehtonen
7
-- Company    : 
8
-- Created    : 2011-01-13
9 147 lanttu
-- Last update: 2012-06-14
10 145 lanttu
-- Platform   : 
11
-- Standard   : VHDL'93
12
-------------------------------------------------------------------------------
13
-- Description:
14
--
15
-- Basic one port RAM with one clock, new data on read-during-write
16
--
17
-------------------------------------------------------------------------------
18
-- Copyright (c) 2011 
19
-------------------------------------------------------------------------------
20
-- Revisions  :
21
-- Date        Version  Author  Description
22
-- 2011-01-13  1.0      ase     Created
23
-------------------------------------------------------------------------------
24
 
25
library ieee;
26
use ieee.std_logic_1164.all;
27
use ieee.numeric_std.all;
28
 
29
 
30
entity ram_1clk is
31
 
32
  generic (
33
    data_width_g : positive;
34
    addr_width_g : positive;
35
    depth_g      : positive;
36
    out_reg_en_g : natural);
37
 
38
  port (
39
    clk        : in  std_logic;
40
    wr_addr_in : in  std_logic_vector(addr_width_g-1 downto 0);
41
    rd_addr_in : in  std_logic_vector(addr_width_g-1 downto 0);
42
    we_in      : in  std_logic;
43
    data_in    : in  std_logic_vector(data_width_g-1 downto 0);
44
    data_out   : out std_logic_vector(data_width_g-1 downto 0));
45
 
46
end entity ram_1clk;
47
 
48
 
49
architecture rtl of ram_1clk is
50
 
51
  type ram_type is array (0 to depth_g-1)
52
    of std_logic_vector(data_width_g-1 downto 0);
53
 
54 147 lanttu
  signal ram_r       : ram_type := (others => (others => '0'));
55 145 lanttu
  signal read_addr_r : integer range 0 to depth_g-1;
56
 
57
begin  -- architecture rtl
58
 
59
  ram_p : process (clk) is
60
  begin  -- process ram_p
61
    if clk'event and clk = '1' then     -- rising clock edge
62
 
63
      if we_in = '1' then
64
        ram_r(to_integer(unsigned(wr_addr_in))) <= data_in;
65
      end if;
66
 
67
      if out_reg_en_g = 1 then
68
        read_addr_r <= to_integer(unsigned(rd_addr_in));
69
      end if;
70
 
71
    end if;
72
  end process ram_p;
73
 
74
  out_reg_en_1: if out_reg_en_g = 1 generate
75
    data_out <= ram_r(read_addr_r);
76
  end generate out_reg_en_1;
77
 
78
  out_reg_en_0: if out_reg_en_g = 0 generate
79
    data_out <= ram_r(to_integer(unsigned(rd_addr_in)));
80
  end generate out_reg_en_0;
81
 
82
 
83
end architecture rtl;

powered by: WebSVN 2.1.0

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