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

Subversion Repositories highload

[/] [highload/] [trunk/] [ram_buf.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alexadmin
-- High load test project.
2
-- Alexey Fedorov, 2014
3
-- email: FPGA@nerudo.com
4
--
5
-- It implements a number of RAM bits depends on given parameters.
6
 
7
LIBRARY ieee;
8
USE ieee.std_logic_1164.all;
9
USE ieee.numeric_std.all;
10
 
11
 
12
ENTITY ram_buf IS
13
        generic (
14
                DATA_WIDTH: positive := 12;
15
                DEPTH_LOG2: positive := 10
16
                );
17
  port(
18
    clk    : in  std_logic;         -- input data clock
19
--    ena    : in  std_logic;         -- input data enable
20
    din    : in  std_logic_vector(DATA_WIDTH-1 downto 0);
21
    delay  : in  std_logic_vector(DEPTH_LOG2-1 downto 0);
22
    dout   : out std_logic_vector(DATA_WIDTH-1 downto 0)
23
    );
24
END ENTITY ram_buf;
25
 
26
 
27
ARCHITECTURE rtl OF ram_buf IS
28
 
29
type TDelayRam is array (0 to 2**DEPTH_LOG2-1) of std_logic_vector(DATA_WIDTH-1 downto 0);
30
signal delayram : TDelayRam := (others => (others => '0'));
31
 
32
signal buf_waddr, buf_raddr : unsigned(DEPTH_LOG2-1 downto 0) := (others => '0');
33
 
34
 
35
begin
36
 
37
delay_p: process(clk) -- , reset
38
begin
39
if(rising_edge(clk)) then
40
--      if(ena = '1') then
41
                delayram(to_integer(buf_waddr)) <= din;
42
                buf_waddr <= buf_waddr + 1;
43
--      end if;
44
        -- On a read during a write to the same address, the read will
45
        -- return the OLD data at the address
46
        dout <= delayram(to_integer(buf_raddr));
47
        buf_raddr <= buf_waddr - unsigned(delay);
48
end if;
49
--if reset = '1' then
50
--      buf_waddr <= (others => '0');
51
--end if;
52
end process;
53
 
54
 
55
 
56
end rtl;

powered by: WebSVN 2.1.0

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