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 39

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
 
90 2 JonasDC
begin
91 3 JonasDC
 
92 2 JonasDC
        -- WARNING: Very Important!
93
        -- wea & web signals must never be high at the same time !!
94
        -- web has priority 
95
        write_operand_i <= write_operand and not write_result;
96
        web(0) <= write_result;
97
        collision <= write_operand and write_result;
98
 
99
        -- the dual port ram has a depth of 4 (each layer contains an operand)
100
        -- result is always stored in position 3
101
        -- doutb is always result
102
        with write_operand_i select
103
                addra <= operand_in_sel & operand_addr(3 downto 0) when '1',
104
                         operand_out_sel & "0000" when others;
105
 
106
        with operand_addr(5 downto 4) select
107 3 JonasDC
                part_enable <=  "0001" when "00",
108
                                "0010" when "01",
109
                                            "0100" when "10",
110
                                            "1000" when others;
111 2 JonasDC
 
112
        with write_operand_i select
113
                wea <= part_enable when '1',
114
                       "0000" when others;
115
 
116
        -- we can only read back from the result (stored in result_dest_op)
117
        addrb <= result_dest_op & operand_addr(3 downto 0);
118
 
119 3 JonasDC
 
120 2 JonasDC
        with operand_addr(5 downto 4) select
121
                result_out <= doutb0 when "00",
122
                              doutb1 when "01",
123 39 JonasDC
                                          doutb2 when others;
124 2 JonasDC
 
125 3 JonasDC
        -- 3 instances of a dual port ram to store the parts of the operand
126
  op_0 : operand_dp
127
  port map (
128
    clka  => clk,
129
    wea   => wea(0 downto 0),
130
    addra => addra,
131
    dina  => operand_in,
132
    douta => operand_out(511 downto 0),
133
    clkb  => clk,
134
    web   => web,
135
    addrb => addrb,
136
    dinb  => result_in(511 downto 0),
137
    doutb => doutb0
138
  );
139 2 JonasDC
 
140 3 JonasDC
  op_1 : operand_dp
141
  port map (
142
    clka  => clk,
143
    wea   => wea(1 downto 1),
144
    addra => addra,
145
    dina  => operand_in,
146
    douta => operand_out(1023 downto 512),
147
    clkb  => clk,
148
    web   => web,
149
    addrb => addrb,
150
    dinb  => result_in(1023 downto 512),
151
    doutb => doutb1
152
  );
153
 
154
  op_2 : operand_dp
155
  port map (
156
    clka  => clk,
157
    wea   => wea(2 downto 2),
158
    addra => addra,
159
    dina  => operand_in,
160
    douta => operand_out(1535 downto 1024),
161
    clkb  => clk,
162
    web   => web,
163
    addrb => addrb,
164
    dinb  => result_in(1535 downto 1024),
165
    doutb => doutb2
166
  );
167
 
168 2 JonasDC
end Behavioral;

powered by: WebSVN 2.1.0

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