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

Subversion Repositories mod_sim_exp

[/] [mod_sim_exp/] [trunk/] [rtl/] [vhdl/] [core/] [operand_ram.vhd] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 JonasDC
------------------------------------------------------------------------------------ 
2
--                      
3
-- Geoffrey Ottoy - DraMCo research group
4
--
5
-- Module Name: operand_mem.vhd / entity operand_mem
6
-- 
7
-- Last Modified:       25/04/2012 
8
-- 
9
-- Description:         BRAM memory and logic to the store 4 (1536-bit) operands and the
10
--                modulus for the montgomery multiplier
11
--
12
--
13
-- Dependencies: operand_dp (coregen)
14
--
15
-- Revision: 
16
-- Revision 1.01 - added "result_dest_op" input
17
-- Revision 1.00 - Architecture
18
-- Revision 0.01 - File Created
19
-- Additional Comments: 
20
--
21
--
22
------------------------------------------------------------------------------------
23
--
24
-- NOTICE:
25
--
26
-- Copyright DraMCo research group. 2011. This code may be contain portions patented
27
-- by other third parties!
28
--
29
------------------------------------------------------------------------------------
30
library IEEE;
31
use IEEE.STD_LOGIC_1164.ALL;
32
use IEEE.STD_LOGIC_ARITH.ALL;
33
use IEEE.STD_LOGIC_UNSIGNED.ALL;
34
 
35
---- Uncomment the following library declaration if instantiating
36
---- any Xilinx primitives in this code.
37
--library UNISIM;
38
--use UNISIM.VComponents.all;
39
 
40
entity operand_ram is
41
        port( -- write_operand_ack voorzien?
42
                -- global ports
43
                clk : in std_logic;
44
                collision : out std_logic;
45
                -- bus side connections (32-bit serial)
46
                operand_addr : in std_logic_vector(5 downto 0);
47
                operand_in : in std_logic_vector(31 downto 0);
48
                operand_in_sel : in std_logic_vector(1 downto 0);
49
                result_out : out std_logic_vector(31 downto 0);
50
                write_operand : in std_logic;
51
                -- multiplier side connections (+1024 bit parallel)
52
                result_dest_op : in std_logic_vector(1 downto 0);
53
                operand_out : out std_logic_vector(1535 downto 0);
54
                operand_out_sel : in std_logic_vector(1 downto 0); -- controlled by bus side :)
55
                write_result : in std_logic;
56
                result_in : in std_logic_vector(1535 downto 0)
57
        );
58
end operand_ram;
59
 
60
architecture Behavioral of operand_ram is
61
        -- dual port blockram to store and update operands
62
        component operand_dp
63
                port (
64
                clka: in std_logic;
65
                wea: in std_logic_vector(0 downto 0);
66
                addra: in std_logic_vector(5 downto 0);
67
                dina: in std_logic_vector(31 downto 0);
68
                douta: out std_logic_vector(511 downto 0);
69
                clkb: in std_logic;
70
                web: IN std_logic_VECTOR(0 downto 0);
71
                addrb: IN std_logic_VECTOR(5 downto 0);
72
                dinb: IN std_logic_VECTOR(511 downto 0);
73
                doutb: OUT std_logic_VECTOR(31 downto 0));
74
        end component;
75
 
76
        -- port a signals
77
        signal addra : std_logic_vector(5 downto 0);
78
        signal part_enable : std_logic_vector(3 downto 0);
79
        signal wea : std_logic_vector(3 downto 0);
80
        signal write_operand_i : std_logic;
81
 
82
        -- port b signals
83
        signal addrb : std_logic_vector(5 downto 0);
84
        signal web : std_logic_vector(0 downto 0);
85
        signal doutb0 : std_logic_vector(31 downto 0);
86
        signal doutb1 : std_logic_vector(31 downto 0);
87
        signal doutb2 : std_logic_vector(31 downto 0);
88
        signal doutb3 : std_logic_vector(31 downto 0);
89
 
90
begin
91
        -- WARNING: Very Important!
92
        -- wea & web signals must never be high at the same time !!
93
        -- web has priority 
94
        write_operand_i <= write_operand and not write_result;
95
        web(0) <= write_result;
96
        collision <= write_operand and write_result;
97
 
98
        -- the dual port ram has a depth of 4 (each layer contains an operand)
99
        -- result is always stored in position 3
100
        -- doutb is always result
101
        with write_operand_i select
102
                addra <= operand_in_sel & operand_addr(3 downto 0) when '1',
103
                         operand_out_sel & "0000" when others;
104
 
105
        with operand_addr(5 downto 4) select
106
                part_enable <= "0001" when "00",
107
                               "0010" when "01",
108
                                         "0100" when "10",
109
                                         "1000" when others;
110
 
111
        with write_operand_i select
112
                wea <= part_enable when '1',
113
                       "0000" when others;
114
 
115
        -- we can only read back from the result (stored in result_dest_op)
116
        addrb <= result_dest_op & operand_addr(3 downto 0);
117
 
118
--      register_output_proc: process(clk)
119
--      begin
120
--              if rising_edge(clk) then
121
--                      case operand_addr(5 downto 4) is
122
--                              when "00" =>
123
--                                      result_out <= doutb0;
124
--                              when "01" =>
125
--                                      result_out <= doutb1;
126
--                              when "10" =>
127
--                                      result_out <= doutb2;
128
--                              when others =>
129
--                                      result_out <= doutb3;
130
--                      end case;
131
--              end if;
132
--      end process;
133
        with operand_addr(5 downto 4) select
134
                result_out <= doutb0 when "00",
135
                              doutb1 when "01",
136
                                        doutb2 when "10",
137
                                        doutb3 when others;
138
 
139
        -- 4 instances of a dual port ram to store the parts of the operand
140
        op_0 : operand_dp
141
        port map (
142
                clka => clk,
143
                wea => wea(0 downto 0),
144
                addra => addra,
145
                dina => operand_in,
146
                douta => operand_out(511 downto 0),
147
                clkb => clk,
148
                web => web,
149
                addrb => addrb,
150
                dinb => result_in(511 downto 0),
151
                doutb => doutb0
152
        );
153
 
154
        op_1 : operand_dp
155
        port map (
156
                clka => clk,
157
                wea => wea(1 downto 1),
158
                addra => addra,
159
                dina => operand_in,
160
                douta => operand_out(1023 downto 512),
161
                clkb => clk,
162
                web => web,
163
                addrb => addrb,
164
                dinb => result_in(1023 downto 512),
165
                doutb => doutb1
166
        );
167
 
168
        op_2 : operand_dp
169
        port map (
170
                clka => clk,
171
                wea => wea(2 downto 2),
172
                addra => addra,
173
                dina => operand_in,
174
                douta => operand_out(1535 downto 1024),
175
                clkb => clk,
176
                web => web,
177
                addrb => addrb,
178
                dinb => result_in(1535 downto 1024),
179
                doutb => doutb2
180
        );
181
 
182
--      op_3 : operand_dp
183
--      port map (
184
--              clka => clk,
185
--              wea => wea(3 downto 3),
186
--              addra => addra,
187
--              dina => operand_in,
188
--              douta => operand_out(2047 downto 1536),
189
--              clkb => clk,
190
--              web => web,
191
--              addrb => addrb,
192
--              dinb => result_in(2047 downto 1536),
193
--              doutb => doutb3
194
--      );
195
 
196
end Behavioral;
197
 

powered by: WebSVN 2.1.0

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