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 3

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

Line No. Rev Author Line
1 3 JonasDC
----------------------------------------------------------------------  
2
----  operand_ram                                                 ---- 
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
----    BRAM memory and logic to the store 4 (1536-bit) operands  ----
10
----    for the montgomery multiplier                             ----            
11
----                                                              ---- 
12
----  Dependencies:                                               ----
13
----    - operand_dp (coregen)                                    ----
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 2 JonasDC
 
46 3 JonasDC
library ieee;
47
use ieee.std_logic_1164.all;
48
use ieee.std_logic_arith.all;
49
use ieee.std_logic_unsigned.all;
50 2 JonasDC
 
51 3 JonasDC
library mod_sim_exp;
52
use mod_sim_exp.mod_sim_exp_pkg.all;
53
 
54
 
55 2 JonasDC
entity operand_ram is
56 3 JonasDC
  port( -- write_operand_ack voorzien?
57
    -- global ports
58
    clk       : in std_logic;
59
    collision : out std_logic;
60
    -- bus side connections (32-bit serial)
61
    operand_addr   : in std_logic_vector(5 downto 0);
62
    operand_in     : in std_logic_vector(31 downto 0);
63
    operand_in_sel : in std_logic_vector(1 downto 0);
64
    result_out     : out std_logic_vector(31 downto 0);
65
    write_operand  : in std_logic;
66
    -- multiplier side connections (1536 bit parallel)
67
    result_dest_op  : in std_logic_vector(1 downto 0);
68
    operand_out     : out std_logic_vector(1535 downto 0);
69
    operand_out_sel : in std_logic_vector(1 downto 0); -- controlled by bus side
70
    write_result    : in std_logic;
71
    result_in       : in std_logic_vector(1535 downto 0)
72
  );
73 2 JonasDC
end operand_ram;
74
 
75 3 JonasDC
 
76 2 JonasDC
architecture Behavioral of operand_ram is
77 3 JonasDC
  -- port a signals
78
  signal addra           : std_logic_vector(5 downto 0);
79
  signal part_enable     : std_logic_vector(3 downto 0);
80
  signal wea             : std_logic_vector(3 downto 0);
81
  signal write_operand_i : std_logic;
82
 
83
  -- port b signals
84
  signal addrb  : std_logic_vector(5 downto 0);
85
  signal web    : std_logic_vector(0 downto 0);
86
  signal doutb0 : std_logic_vector(31 downto 0);
87
  signal doutb1 : std_logic_vector(31 downto 0);
88
  signal doutb2 : std_logic_vector(31 downto 0);
89
  signal doutb3 : std_logic_vector(31 downto 0);
90
 
91 2 JonasDC
begin
92 3 JonasDC
 
93 2 JonasDC
        -- WARNING: Very Important!
94
        -- wea & web signals must never be high at the same time !!
95
        -- web has priority 
96
        write_operand_i <= write_operand and not write_result;
97
        web(0) <= write_result;
98
        collision <= write_operand and write_result;
99
 
100
        -- the dual port ram has a depth of 4 (each layer contains an operand)
101
        -- result is always stored in position 3
102
        -- doutb is always result
103
        with write_operand_i select
104
                addra <= operand_in_sel & operand_addr(3 downto 0) when '1',
105
                         operand_out_sel & "0000" when others;
106
 
107
        with operand_addr(5 downto 4) select
108 3 JonasDC
                part_enable <=  "0001" when "00",
109
                                "0010" when "01",
110
                                            "0100" when "10",
111
                                            "1000" when others;
112 2 JonasDC
 
113
        with write_operand_i select
114
                wea <= part_enable when '1',
115
                       "0000" when others;
116
 
117
        -- we can only read back from the result (stored in result_dest_op)
118
        addrb <= result_dest_op & operand_addr(3 downto 0);
119
 
120 3 JonasDC
 
121 2 JonasDC
        with operand_addr(5 downto 4) select
122
                result_out <= doutb0 when "00",
123
                              doutb1 when "01",
124 3 JonasDC
                                          doutb2 when "10",
125
                                          doutb3 when others;
126 2 JonasDC
 
127 3 JonasDC
        -- 3 instances of a dual port ram to store the parts of the operand
128
  op_0 : operand_dp
129
  port map (
130
    clka  => clk,
131
    wea   => wea(0 downto 0),
132
    addra => addra,
133
    dina  => operand_in,
134
    douta => operand_out(511 downto 0),
135
    clkb  => clk,
136
    web   => web,
137
    addrb => addrb,
138
    dinb  => result_in(511 downto 0),
139
    doutb => doutb0
140
  );
141 2 JonasDC
 
142 3 JonasDC
  op_1 : operand_dp
143
  port map (
144
    clka  => clk,
145
    wea   => wea(1 downto 1),
146
    addra => addra,
147
    dina  => operand_in,
148
    douta => operand_out(1023 downto 512),
149
    clkb  => clk,
150
    web   => web,
151
    addrb => addrb,
152
    dinb  => result_in(1023 downto 512),
153
    doutb => doutb1
154
  );
155
 
156
  op_2 : operand_dp
157
  port map (
158
    clka  => clk,
159
    wea   => wea(2 downto 2),
160
    addra => addra,
161
    dina  => operand_in,
162
    douta => operand_out(1535 downto 1024),
163
    clkb  => clk,
164
    web   => web,
165
    addrb => addrb,
166
    dinb  => result_in(1535 downto 1024),
167
    doutb => doutb2
168
  );
169
 
170 2 JonasDC
end Behavioral;

powered by: WebSVN 2.1.0

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