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

Subversion Repositories astron_ram

[/] [astron_ram/] [trunk/] [common_ram_crw_crw.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 danv
-------------------------------------------------------------------------------
2
--
3 3 danv
-- Copyright 2020
4 2 danv
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6 3 danv
-- 
7
-- Licensed under the Apache License, Version 2.0 (the "License");
8
-- you may not use this file except in compliance with the License.
9
-- You may obtain a copy of the License at
10
-- 
11
--     http://www.apache.org/licenses/LICENSE-2.0
12
-- 
13
-- Unless required by applicable law or agreed to in writing, software
14
-- distributed under the License is distributed on an "AS IS" BASIS,
15
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
-- See the License for the specific language governing permissions and
17
-- limitations under the License.
18 2 danv
--
19
-------------------------------------------------------------------------------
20
 
21 4 danv
LIBRARY IEEE, common_pkg_lib, common_components_lib;
22 2 danv
USE IEEE.std_logic_1164.ALL;
23
USE common_pkg_lib.common_pkg.ALL;
24
USE work.common_ram_pkg.ALL;
25 4 danv
--USE technology_lib.technology_select_pkg.ALL;
26 2 danv
 
27
ENTITY common_ram_crw_crw IS
28
  GENERIC (
29 4 danv
    g_technology     : NATURAL := 0;
30 2 danv
    g_ram            : t_c_mem := c_mem_ram;
31
    g_init_file      : STRING  := "UNUSED";
32
    g_true_dual_port : BOOLEAN := TRUE
33
  );
34
  PORT (
35
    rst_a     : IN  STD_LOGIC := '0';
36
    rst_b     : IN  STD_LOGIC := '0';
37
    clk_a     : IN  STD_LOGIC;
38
    clk_b     : IN  STD_LOGIC;
39
    clken_a   : IN  STD_LOGIC := '1';
40
    clken_b   : IN  STD_LOGIC := '1';
41
    wr_en_a   : IN  STD_LOGIC := '0';
42
    wr_en_b   : IN  STD_LOGIC := '0';
43
    wr_dat_a  : IN  STD_LOGIC_VECTOR(g_ram.dat_w-1 DOWNTO 0) := (OTHERS=>'0');
44
    wr_dat_b  : IN  STD_LOGIC_VECTOR(g_ram.dat_w-1 DOWNTO 0) := (OTHERS=>'0');
45
    adr_a     : IN  STD_LOGIC_VECTOR(g_ram.adr_w-1 DOWNTO 0) := (OTHERS=>'0');
46
    adr_b     : IN  STD_LOGIC_VECTOR(g_ram.adr_w-1 DOWNTO 0) := (OTHERS=>'0');
47
    rd_en_a   : IN  STD_LOGIC := '1';
48
    rd_en_b   : IN  STD_LOGIC := '1';
49
    rd_dat_a  : OUT STD_LOGIC_VECTOR(g_ram.dat_w-1 DOWNTO 0);
50
    rd_dat_b  : OUT STD_LOGIC_VECTOR(g_ram.dat_w-1 DOWNTO 0);
51
    rd_val_a  : OUT STD_LOGIC;
52
    rd_val_b  : OUT STD_LOGIC
53
  );
54
END common_ram_crw_crw;
55
 
56
 
57
ARCHITECTURE str OF common_ram_crw_crw IS
58
 
59
  CONSTANT c_rd_latency : NATURAL := sel_a_b(g_ram.latency<2,            g_ram.latency,              2);  -- handle read latency 1 or 2 in RAM
60
  CONSTANT c_pipeline   : NATURAL := sel_a_b(g_ram.latency>c_rd_latency, g_ram.latency-c_rd_latency, 0);  -- handle rest of read latency > 2 in pipeline
61
 
62
  -- Intermediate signal for extra pipelining
63
  SIGNAL ram_rd_dat_a   : STD_LOGIC_VECTOR(rd_dat_a'RANGE);
64
  SIGNAL ram_rd_dat_b   : STD_LOGIC_VECTOR(rd_dat_b'RANGE);
65
 
66
  -- Map sl to single bit slv for rd_val pipelining
67
  SIGNAL ram_rd_en_a    : STD_LOGIC_VECTOR(0 DOWNTO 0);
68
  SIGNAL ram_rd_en_b    : STD_LOGIC_VECTOR(0 DOWNTO 0);
69
  SIGNAL ram_rd_val_a   : STD_LOGIC_VECTOR(0 DOWNTO 0);
70
  SIGNAL ram_rd_val_b   : STD_LOGIC_VECTOR(0 DOWNTO 0);
71
 
72
BEGIN
73
 
74
  ASSERT g_ram.latency >= 1
75
    REPORT "common_ram_crw_crw : only support read latency >= 1"
76
    SEVERITY FAILURE;
77
 
78
  -- memory access
79
  gen_true_dual_port : IF g_true_dual_port = TRUE GENERATE
80 4 danv
    u_ram : ENTITY work.tech_memory_ram_crw_crw
81 2 danv
    GENERIC MAP (
82
      g_technology => g_technology,
83
      g_adr_w      => g_ram.adr_w,
84
      g_dat_w      => g_ram.dat_w,
85
      g_nof_words  => g_ram.nof_dat,
86
      g_rd_latency => c_rd_latency,
87
      g_init_file  => g_init_file
88
    )
89
    PORT MAP (
90
      clock_a     => clk_a,
91
      clock_b     => clk_b,
92
      enable_a    => clken_a,
93
      enable_b    => clken_b,
94
      wren_a      => wr_en_a,
95
      wren_b      => wr_en_b,
96
      data_a      => wr_dat_a,
97
      data_b      => wr_dat_b,
98
      address_a   => adr_a,
99
      address_b   => adr_b,
100
      q_a         => ram_rd_dat_a,
101
      q_b         => ram_rd_dat_b
102
    );
103
  END GENERATE;
104
 
105
  gen_simple_dual_port : IF g_true_dual_port = FALSE GENERATE
106 4 danv
    u_ram : ENTITY work.tech_memory_ram_cr_cw
107 2 danv
    GENERIC MAP (
108
      g_technology => g_technology,
109
      g_adr_w      => g_ram.adr_w,
110
      g_dat_w      => g_ram.dat_w,
111
      g_nof_words  => g_ram.nof_dat,
112
      g_rd_latency => c_rd_latency,
113
      g_init_file  => g_init_file
114
    )
115
    PORT MAP
116
    (
117
      wrclock   => clk_a,
118
      wrclocken => clken_a,
119
      wren      => wr_en_a,
120
      wraddress => adr_a,
121
      data      => wr_dat_a,
122
      rdclock   => clk_b,
123
      rdclocken => clken_b,
124
      rdaddress => adr_b,
125
      q         => ram_rd_dat_b
126
    );
127
  END GENERATE;
128
 
129
  -- read output
130
  u_pipe_a : ENTITY common_components_lib.common_pipeline
131
  GENERIC MAP (
132
    g_pipeline   => c_pipeline,
133
    g_in_dat_w   => g_ram.dat_w,
134
    g_out_dat_w  => g_ram.dat_w
135
  )
136
  PORT MAP (
137
    clk     => clk_a,
138
    clken   => clken_a,
139
    in_dat  => ram_rd_dat_a,
140
    out_dat => rd_dat_a
141
  );
142
 
143
  u_pipe_b : ENTITY common_components_lib.common_pipeline
144
  GENERIC MAP (
145
    g_pipeline   => c_pipeline,
146
    g_in_dat_w   => g_ram.dat_w,
147
    g_out_dat_w  => g_ram.dat_w
148
  )
149
  PORT MAP (
150
    clk     => clk_b,
151
    clken   => clken_b,
152
    in_dat  => ram_rd_dat_b,
153
    out_dat => rd_dat_b
154
  );
155
 
156
  -- rd_val control
157
  ram_rd_en_a(0) <= rd_en_a;
158
  ram_rd_en_b(0) <= rd_en_b;
159
 
160
  rd_val_a <= ram_rd_val_a(0);
161
  rd_val_b <= ram_rd_val_b(0);
162
 
163
  u_rd_val_a : ENTITY common_components_lib.common_pipeline
164
  GENERIC MAP (
165
    g_pipeline   => g_ram.latency,
166
    g_in_dat_w   => 1,
167
    g_out_dat_w  => 1
168
  )
169
  PORT MAP (
170
    clk     => clk_a,
171
    clken   => clken_a,
172
    in_dat  => ram_rd_en_a,
173
    out_dat => ram_rd_val_a
174
  );
175
 
176
  u_rd_val_b : ENTITY common_components_lib.common_pipeline
177
  GENERIC MAP (
178
    g_pipeline   => g_ram.latency,
179
    g_in_dat_w   => 1,
180
    g_out_dat_w  => 1
181
  )
182
  PORT MAP (
183
    clk     => clk_b,
184
    clken   => clken_b,
185
    in_dat  => ram_rd_en_b,
186
    out_dat => ram_rd_val_b
187
  );
188
 
189
END str;

powered by: WebSVN 2.1.0

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