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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [rtl/] [techmap/] [mem/] [syncram_2p_inferred.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 sergeykhbr
-----------------------------------------------------------------------------
2
--! @file
3
--! @copyright  Copyright 2015 GNSS Sensor Ltd. All right reserved.
4
--! @author     Sergey Khabarov - sergeykhbr@gmail.com
5
--! @brief      Synchronous 2-port ram, common clock
6
------------------------------------------------------------------------------
7
 
8
library ieee;
9
use ieee.std_logic_1164.all;
10
library commonlib;
11
use commonlib.types_common.all;
12
 
13
entity syncram_2p_inferred is
14
  generic (
15
    abits : integer := 8;
16
    dbits : integer := 32;
17
    sepclk: integer := 0
18
  );
19
  port (
20
    rclk : in std_ulogic;
21
    wclk : in std_ulogic;
22
    rdaddress: in std_logic_vector (abits -1 downto 0);
23
    wraddress: in std_logic_vector (abits -1 downto 0);
24
    data: in std_logic_vector (dbits -1 downto 0);
25
    wren : in std_ulogic;
26
    q: out std_logic_vector (dbits -1 downto 0)
27
  );
28
end;
29
 
30
architecture arch_syncram_2p_inferred of syncram_2p_inferred is
31
 
32
  type dregtype is array (0 to 2**abits - 1)
33
        of std_logic_vector(dbits -1 downto 0);
34
 
35
  --! This fuinction just to check with C++ reference model. Can be removed.
36
  impure function init_ram(file_name : in string) return dregtype is
37
    variable temp_mem : dregtype;
38
  begin
39
    for i in 0 to (2**abits - 1) loop
40
        if dbits = 64 then
41
           temp_mem(i) := X"0000000000000000";--X"CCCCCCCC";
42
        elsif dbits = 32 then
43
           temp_mem(i) := X"00000000";--X"CCCCCCCC";
44
        else
45
           temp_mem(i) := X"0000";--X"CCCC";
46
        end if;
47
    end loop;
48
    return temp_mem;
49
  end function;
50
 
51
  signal rfd : dregtype := init_ram("");
52
 
53
begin
54
 
55
  wp : process(wclk)
56
  begin
57
    if rising_edge(wclk) then
58
      if wren = '1' then rfd(conv_integer(wraddress)) <= data; end if;
59
    end if;
60
  end process;
61
 
62
  oneclk : if sepclk = 0 generate
63
    rp : process(wclk) begin
64
      if rising_edge(wclk) then
65
        q <= rfd(conv_integer(rdaddress));
66
      end if;
67
    end process;
68
  end generate;
69
 
70
  twoclk : if sepclk = 1 generate
71
    rp : process(rclk) begin
72
    if rising_edge(rclk) then q <= rfd(conv_integer(rdaddress)); end if;
73
    end process;
74
  end generate;
75
 
76
end;

powered by: WebSVN 2.1.0

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