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

Subversion Repositories viterbi_decoder_axi4s

[/] [viterbi_decoder_axi4s/] [trunk/] [src/] [generic_sp_ram.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mfehrenz
--!
2
--! Copyright (C) 2010 - 2012 Creonic GmbH
3
--!
4
--! This file is part of the Creonic Viterbi Decoder, which is distributed
5
--! under the terms of the GNU General Public License version 2.
6
--!
7
--! @file
8
--! @brief  Generic single port RAM with a single read/write port
9
--! @author Matthias Alles
10
--! @date   2010/09/28
11
--!
12
 
13
library ieee;
14
use ieee.std_logic_1164.all;
15
use ieee.numeric_std.all;
16
use ieee.std_logic_unsigned.all;
17
 
18
library dec_viterbi;
19
use dec_viterbi.pkg_helper.all;
20
 
21
 
22
entity generic_sp_ram is
23
        generic(
24
                DISTR_RAM  : boolean := false;
25
                WORDS      : integer := 8;
26
                BITWIDTH   : integer := 8
27
        );
28
        port(
29
                clk : in std_logic;
30
                rst : in std_logic;
31
 
32
                wen : in  std_logic;
33
                en  : in  std_logic;
34
 
35
                a   : in  std_logic_vector(no_bits_natural(WORDS - 1) - 1 downto 0);
36
                d   : in  std_logic_vector(BITWIDTH - 1 downto 0);
37
                q   : out std_logic_vector(BITWIDTH - 1 downto 0)
38
        );
39
end generic_sp_ram;
40
 
41
 
42
architecture rtl of generic_sp_ram is
43
 
44
        type t_ram is array(WORDS - 1 downto 0) of
45
                              std_logic_vector(BITWIDTH - 1 downto 0);
46
        signal sp_ram : t_ram := (others => (others => '0'));
47
 
48
        function get_ram_style_xilinx(dist_ram : in boolean) return string is
49
        begin
50
                if dist_ram then
51
                        return "pipe_distributed";
52
                else
53
                        return "block";
54
                end if;
55
        end function;
56
 
57
        function get_ram_style_altera(dist_ram : in boolean) return string is
58
        begin
59
                if dist_ram then
60
                        return "MLAB, no_rw_check";
61
                else
62
                        return "AUTO";
63
                end if;
64
        end function;
65
 
66
        attribute RAM_STYLE : string;
67
        attribute RAM_STYLE of sp_ram : signal is get_ram_style_xilinx(DISTR_RAM);
68
 
69
        attribute ramstyle : string;
70
        attribute ramstyle of sp_ram : signal is get_ram_style_altera(DISTR_RAM);
71
 
72
begin
73
 
74
        --
75
        -- Do not register the address for reading, since the synthesis doesn't
76
        -- recognize then that this is a single-port RAM.
77
        --
78
        pr_sp_ram_rw: process(clk)
79
        begin
80
        if rising_edge(clk) then
81
                if en = '1' then
82
                        if wen =  '1' then
83
                                sp_ram(conv_integer(a)) <= d;
84
                        else
85
                                q <= sp_ram(conv_integer(a));
86
                        end if;
87
                end if;
88
        end if;
89
        end process pr_sp_ram_rw;
90
 
91
end rtl;

powered by: WebSVN 2.1.0

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