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_mem.vhd] - Blame information for rev 63

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

Line No. Rev Author Line
1 63 JonasDC
----------------------------------------------------------------------  
2
----  operand_mem_gen                                             ---- 
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
----    and the modulus for the montgomery multiplier             ----            
11
----                                                              ---- 
12
----  Dependencies:                                               ----
13
----    - operand_ram_gen                                         ----
14
----    - modulus_ram_gen                                         ----
15
----                                                              ----
16
----  Authors:                                                    ----
17
----      - Geoffrey Ottoy, DraMCo research group                 ----
18
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
19
----                                                              ---- 
20
---------------------------------------------------------------------- 
21
----                                                              ---- 
22
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
23
----                                                              ---- 
24
---- This source file may be used and distributed without         ---- 
25
---- restriction provided that this copyright statement is not    ---- 
26
---- removed from the file and that any derivative work contains  ---- 
27
---- the original copyright notice and the associated disclaimer. ---- 
28
----                                                              ---- 
29
---- This source file is free software; you can redistribute it   ---- 
30
---- and/or modify it under the terms of the GNU Lesser General   ---- 
31
---- Public License as published by the Free Software Foundation; ---- 
32
---- either version 2.1 of the License, or (at your option) any   ---- 
33
---- later version.                                               ---- 
34
----                                                              ---- 
35
---- This source is distributed in the hope that it will be       ---- 
36
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
37
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
38
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
39
---- details.                                                     ---- 
40
----                                                              ---- 
41
---- You should have received a copy of the GNU Lesser General    ---- 
42
---- Public License along with this source; if not, download it   ---- 
43
---- from http://www.opencores.org/lgpl.shtml                     ---- 
44
----                                                              ---- 
45
----------------------------------------------------------------------
46
 
47
library ieee;
48
use ieee.std_logic_1164.all;
49
use ieee.std_logic_arith.all;
50
use ieee.std_logic_unsigned.all;
51
 
52
library mod_sim_exp;
53
use mod_sim_exp.mod_sim_exp_pkg.all;
54
use mod_sim_exp.std_functions.all;
55
 
56
-- address structure:
57
-- bit: highest   ->  '1': modulus
58
--                    '0': operands
59
-- bits: (highest-1)-log2(width/32) -> operand_in_sel in case of highest bit = '0'
60
--                                     modulus_in_sel in case of highest bit = '1'
61
-- bits: (log2(width/32)-1)-0 -> modulus_addr / operand_addr resp.
62
-- 
63
entity operand_mem_gen is
64
  generic(
65
    width : integer := 1536; -- width of the operands
66
    nr_op : integer := 4; -- nr of operand storages, has to be greater than nr_m
67
    nr_m  : integer := 2  -- nr of modulus storages
68
  );
69
  port(
70
    -- system clock
71
    clk : in std_logic;
72
    -- data interface (plb side)
73
    data_in      : in std_logic_vector(31 downto 0);
74
    data_out     : out std_logic_vector(31 downto 0);
75
    rw_address   : in std_logic_vector(log2(nr_op)+log2(width/32) downto 0);
76
    write_enable : in std_logic;
77
    -- operand interface (multiplier side)
78
    op_sel    : in std_logic_vector(log2(nr_op)-1 downto 0);
79
    xy_out    : out std_logic_vector((width-1) downto 0);
80
    m         : out std_logic_vector((width-1) downto 0);
81
    result_in : in std_logic_vector((width-1) downto 0);
82
    -- control signals
83
    load_result    : in std_logic;
84
    result_dest_op : in std_logic_vector(log2(nr_op)-1 downto 0);
85
    collision      : out std_logic;
86
    modulus_sel    : in std_logic_vector(log2(nr_m)-1 downto 0)
87
  );
88
end operand_mem_gen;
89
 
90
architecture Behavioral of operand_mem_gen is
91
  constant wordaddr_aw : integer := log2(width/32);
92
  constant opaddr_aw   : integer := log2(nr_op);
93
  constant maddr_aw       : integer := log2(nr_m);
94
  constant total_aw    : integer := 1+opaddr_aw+wordaddr_aw;
95
 
96
  signal xy_data_i        : std_logic_vector(31 downto 0);
97
  signal xy_addr_i        : std_logic_vector(wordaddr_aw-1 downto 0);
98
  signal operand_in_sel_i : std_logic_vector(opaddr_aw-1 downto 0);
99
  signal modulus_in_sel_i : std_logic_vector(maddr_aw-1 downto 0);
100
 
101
  signal load_op : std_logic;
102
 
103
  signal m_addr_i  : std_logic_vector(wordaddr_aw-1 downto 0);
104
  signal load_m    : std_logic;
105
  signal m_data_i  : std_logic_vector(31 downto 0);
106
 
107
begin
108
 
109
        -- map inputs
110
        xy_addr_i <= rw_address(wordaddr_aw-1 downto 0);
111
        m_addr_i <= rw_address(wordaddr_aw-1 downto 0);
112
        operand_in_sel_i <= rw_address(total_aw-2 downto wordaddr_aw);
113
        modulus_in_sel_i <= rw_address(wordaddr_aw+maddr_aw-1 downto wordaddr_aw);
114
        xy_data_i <= data_in;
115
        m_data_i <= data_in;
116
 
117
        load_op <= write_enable when (rw_address(total_aw-1) = '0') else '0';
118
  load_m <= write_enable when (rw_address(total_aw-1) = '1') else '0';
119
 
120
  -- xy operand storage
121
  xy_ram : operand_ram_gen
122
  generic map(
123
    width => width,
124
    depth => nr_op
125
  )
126
  port map(
127
    clk             => clk,
128
    collision       => collision,
129
    operand_addr    => xy_addr_i,
130
    operand_in      => xy_data_i,
131
    operand_in_sel  => operand_in_sel_i,
132
    result_out      => data_out,
133
    write_operand   => load_op,
134
    operand_out     => xy_out,
135
    operand_out_sel => op_sel,
136
    result_dest_op  => result_dest_op,
137
    write_result    => load_result,
138
    result_in       => result_in
139
  );
140
 
141
  -- modulus storage
142
  m_ram : modulus_ram_gen
143
  generic map(
144
    width => width,
145
    depth => nr_m
146
  )
147
  port map(
148
    clk            => clk,
149
    modulus_in_sel => modulus_in_sel_i,
150
    modulus_addr   => m_addr_i,
151
    write_modulus  => load_m,
152
    modulus_in     => m_data_i,
153
    modulus_out    => m,
154
    modulus_sel    => modulus_sel
155
  );
156
 
157
end Behavioral;

powered by: WebSVN 2.1.0

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