1 |
66 |
JonasDC |
----------------------------------------------------------------------
|
2 |
|
|
---- tdpramblock_asym ----
|
3 |
|
|
---- ----
|
4 |
|
|
---- This file is part of the ----
|
5 |
|
|
---- Modular Simultaneous Exponentiation Core project ----
|
6 |
|
|
---- http://www.opencores.org/cores/mod_sim_exp/ ----
|
7 |
|
|
---- ----
|
8 |
|
|
---- Description ----
|
9 |
|
|
---- structural description of an asymmetric true dual port ----
|
10 |
|
|
---- ram with one 32-bit read/write port and one (width)-bit ----
|
11 |
|
|
---- read/write port. ----
|
12 |
|
|
---- ----
|
13 |
|
|
---- Dependencies: tdpram_asym ----
|
14 |
|
|
---- ----
|
15 |
|
|
---- Authors: ----
|
16 |
|
|
---- - Geoffrey Ottoy, DraMCo research group ----
|
17 |
|
|
---- - Jonas De Craene, JonasDC@opencores.org ----
|
18 |
|
|
---- ----
|
19 |
|
|
----------------------------------------------------------------------
|
20 |
|
|
---- ----
|
21 |
|
|
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG ----
|
22 |
|
|
---- ----
|
23 |
|
|
---- This source file may be used and distributed without ----
|
24 |
|
|
---- restriction provided that this copyright statement is not ----
|
25 |
|
|
---- removed from the file and that any derivative work contains ----
|
26 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
27 |
|
|
---- ----
|
28 |
|
|
---- This source file is free software; you can redistribute it ----
|
29 |
|
|
---- and/or modify it under the terms of the GNU Lesser General ----
|
30 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
31 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
32 |
|
|
---- later version. ----
|
33 |
|
|
---- ----
|
34 |
|
|
---- This source is distributed in the hope that it will be ----
|
35 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
36 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
37 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
38 |
|
|
---- details. ----
|
39 |
|
|
---- ----
|
40 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
41 |
|
|
---- Public License along with this source; if not, download it ----
|
42 |
|
|
---- from http://www.opencores.org/lgpl.shtml ----
|
43 |
|
|
---- ----
|
44 |
|
|
----------------------------------------------------------------------
|
45 |
|
|
|
46 |
|
|
library ieee;
|
47 |
|
|
use ieee.std_logic_1164.all;
|
48 |
|
|
use ieee.std_logic_unsigned.all;
|
49 |
|
|
use ieee.std_logic_arith.all;
|
50 |
|
|
|
51 |
|
|
library mod_sim_exp;
|
52 |
|
|
use mod_sim_exp.std_functions.all;
|
53 |
83 |
JonasDC |
use mod_sim_exp.mod_sim_exp_pkg.all;
|
54 |
66 |
JonasDC |
|
55 |
|
|
-- altera infers ramblocks from a depth of 9 (or 2 with any ram size recognition option on)
|
56 |
|
|
-- and width 64,128,256,512
|
57 |
|
|
-- xilinx infers ramblocks from a depth of 2 and width 32,64,128,256,512
|
58 |
|
|
entity tdpramblock_asym is
|
59 |
|
|
generic (
|
60 |
|
|
depth : integer := 4; -- nr of (width)-bit words
|
61 |
|
|
width : integer := 512; -- width of portB
|
62 |
|
|
device : string := "xilinx"
|
63 |
|
|
);
|
64 |
90 |
JonasDC |
port (
|
65 |
|
|
clk : in std_logic;
|
66 |
66 |
JonasDC |
-- port A 32-bit
|
67 |
|
|
addrA : in std_logic_vector(log2((width*depth)/32)-1 downto 0);
|
68 |
|
|
weA : in std_logic;
|
69 |
|
|
dinA : in std_logic_vector(31 downto 0);
|
70 |
|
|
doutA : out std_logic_vector(31 downto 0);
|
71 |
|
|
-- port B (width)-bit
|
72 |
|
|
addrB : in std_logic_vector(log2(depth)-1 downto 0);
|
73 |
|
|
weB : in std_logic;
|
74 |
|
|
dinB : in std_logic_vector(width-1 downto 0);
|
75 |
|
|
doutB : out std_logic_vector(width-1 downto 0)
|
76 |
|
|
);
|
77 |
|
|
end tdpramblock_asym;
|
78 |
|
|
|
79 |
|
|
architecture structural of tdpramblock_asym is
|
80 |
|
|
-- constants
|
81 |
|
|
constant nrRAMs : integer := width/32;
|
82 |
|
|
constant RAMwidthA : integer := 32/nrRAMs;
|
83 |
|
|
|
84 |
|
|
-- interconnection signals
|
85 |
|
|
type word_array is array (nrRAMs-1 downto 0) of std_logic_vector(31 downto 0);
|
86 |
|
|
signal doutB_RAM : word_array;
|
87 |
|
|
signal dinB_RAM : word_array;
|
88 |
|
|
begin
|
89 |
|
|
|
90 |
|
|
ramblocks : for i in 0 to nrRAMs-1 generate
|
91 |
83 |
JonasDC |
ramblock : tdpram_asym
|
92 |
66 |
JonasDC |
generic map(
|
93 |
|
|
widthA => RAMwidthA,
|
94 |
|
|
depthB => depth,
|
95 |
|
|
device => device
|
96 |
|
|
)
|
97 |
|
|
port map(
|
98 |
90 |
JonasDC |
clk => clk,
|
99 |
66 |
JonasDC |
-- port A (widthA)-bit
|
100 |
|
|
addrA => addrA,
|
101 |
|
|
weA => weA,
|
102 |
|
|
dinA => dinA((i+1)*RAMwidthA-1 downto RAMwidthA*i),
|
103 |
|
|
doutA => doutA((i+1)*RAMwidthA-1 downto RAMwidthA*i),
|
104 |
|
|
-- port B 32-bit
|
105 |
|
|
addrB => addrB,
|
106 |
|
|
weB => weB,
|
107 |
|
|
dinB => dinB_RAM(i),
|
108 |
|
|
doutB => doutB_RAM(i)
|
109 |
|
|
);
|
110 |
|
|
|
111 |
|
|
map_ioB : for j in 0 to nrRAMs-1 generate
|
112 |
|
|
-- output
|
113 |
|
|
doutB(j*32+(i+1)*RAMwidthA-1 downto j*32+i*RAMwidthA)
|
114 |
|
|
<= doutB_RAM(i)((j+1)*RAMwidthA-1 downto j*RAMwidthA);
|
115 |
|
|
-- input
|
116 |
|
|
dinB_RAM(i)((j+1)*RAMwidthA-1 downto j*RAMwidthA)
|
117 |
|
|
<= dinB(j*32+(i+1)*RAMwidthA-1 downto j*32+i*RAMwidthA);
|
118 |
|
|
end generate;
|
119 |
|
|
end generate;
|
120 |
|
|
|
121 |
|
|
end structural;
|
122 |
|
|
|