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/] [modulus_ram_gen.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
----  modulus_ram_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 store the modulus, due to the    ----
10
----    achitecture, a minimum depth of 2 is needed for this      ----
11
----    module to be inferred into blockram                       ----
12
----                                                              ---- 
13
----  Dependencies:                                               ----
14
----    - dpram_generic                                           ----
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
-- behavorial description of a RAM to hold the modulus, with 
57
-- adjustable width and depth(nr of moduluses)
58
entity modulus_ram_gen is
59
  generic(
60
    width : integer := 1536;  -- must be a multiple of 32
61
    depth : integer := 2      -- nr of moduluses
62
  );
63
  port(
64
    clk            : in std_logic;
65
      -- bus side
66
    write_modulus  : in std_logic; -- write enable
67
    modulus_in_sel : in std_logic_vector(log2(depth)-1 downto 0); -- modulus operand to write to
68
    modulus_addr   : in std_logic_vector(log2((width)/32)-1 downto 0); -- modulus word(32-bit) address
69
    modulus_in     : in std_logic_vector(31 downto 0); -- modulus word data in
70
    modulus_sel    : in std_logic_vector(log2(depth)-1 downto 0); -- selects the modulus to use for multiplications
71
      -- multiplier side
72
    modulus_out    : out std_logic_vector(width-1 downto 0)
73
  );
74
end modulus_ram_gen;
75
 
76
architecture Behavioral of modulus_ram_gen is
77
  --- constants
78
  constant nrRAMs       : integer := width/32;
79
  constant RAMselect_aw : integer := log2(nrRAMs);
80
  constant RAMdepth_aw  : integer := log2(depth);
81
  constant total_aw     : integer := RAMdepth_aw+RAMselect_aw;
82
 
83
  -- interconnection signals
84
  signal modulus_rdaddr : std_logic_vector(RAMdepth_aw-1 downto 0);
85
  signal modulus_wraddr : std_logic_vector(total_aw-1 downto 0);
86
  signal we : std_logic_vector(nrRAMs-1 downto 0);
87
begin
88
        modulus_wraddr(RAMselect_aw-1 downto 0) <= modulus_addr;
89
        modulus_wraddr(total_aw-1 downto RAMselect_aw) <= modulus_in_sel;
90
 
91
        -- generate (width/32) blocks of 32-bit ram with a given depth
92
        -- these rams outputs are concatenated to a width-bit signal
93
  ramblocks : for i in 0 to nrRAMs-1 generate
94
    ramblock: dpram_generic
95
    generic map(
96
      depth => depth
97
    )
98
    port map(
99
      clk => clk,
100
      -- write port
101
      waddr => modulus_wraddr(total_aw-1 downto RAMselect_aw),
102
      we    => we(i),
103
      din   => modulus_in,
104
      -- read port
105
      raddr => modulus_rdaddr,
106
      dout  => modulus_out(((i+1)*32)-1 downto i*32)
107
    );
108
    -- connect the w
109
    process (write_modulus, modulus_wraddr)
110
    begin
111
      if modulus_wraddr(RAMselect_aw-1 downto 0) = conv_std_logic_vector(i,RAMselect_aw) then
112
        we(i) <= write_modulus;
113
      else
114
        we(i) <= '0';
115
      end if;
116
    end process;
117
  end generate;
118
  modulus_rdaddr <= modulus_sel;
119
 
120
end Behavioral;

powered by: WebSVN 2.1.0

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