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] - Diff between revs 39 and 89

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 39 Rev 89
----------------------------------------------------------------------  
----------------------------------------------------------------------  
----  operand_ram                                                 ---- 
----  operand_ram                                                 ---- 
----                                                              ---- 
----                                                              ---- 
----  This file is part of the                                    ----
----  This file is part of the                                    ----
----    Modular Simultaneous Exponentiation Core project          ---- 
----    Modular Simultaneous Exponentiation Core project          ---- 
----    http://www.opencores.org/cores/mod_sim_exp/               ---- 
----    http://www.opencores.org/cores/mod_sim_exp/               ---- 
----                                                              ---- 
----                                                              ---- 
----  Description                                                 ---- 
----  Description                                                 ---- 
----    BRAM memory and logic to the store 4 (1536-bit) operands  ----
----    BRAM memory and logic to the store 4 (1536-bit) operands  ----
----    for the montgomery multiplier                             ----            
----    for the montgomery multiplier                             ----            
----                                                              ---- 
----                                                              ---- 
----  Dependencies:                                               ----
----  Dependencies:                                               ----
----    - operand_dp (coregen)                                    ----
----    - operand_dp (coregen)                                    ----
----                                                              ----
----                                                              ----
----  Authors:                                                    ----
----  Authors:                                                    ----
----      - Geoffrey Ottoy, DraMCo research group                 ----
----      - Geoffrey Ottoy, DraMCo research group                 ----
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
----                                                              ---- 
----                                                              ---- 
---------------------------------------------------------------------- 
---------------------------------------------------------------------- 
----                                                              ---- 
----                                                              ---- 
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
----                                                              ---- 
----                                                              ---- 
---- This source file may be used and distributed without         ---- 
---- This source file may be used and distributed without         ---- 
---- restriction provided that this copyright statement is not    ---- 
---- restriction provided that this copyright statement is not    ---- 
---- removed from the file and that any derivative work contains  ---- 
---- removed from the file and that any derivative work contains  ---- 
---- the original copyright notice and the associated disclaimer. ---- 
---- the original copyright notice and the associated disclaimer. ---- 
----                                                              ---- 
----                                                              ---- 
---- This source file is free software; you can redistribute it   ---- 
---- This source file is free software; you can redistribute it   ---- 
---- and/or modify it under the terms of the GNU Lesser General   ---- 
---- and/or modify it under the terms of the GNU Lesser General   ---- 
---- Public License as published by the Free Software Foundation; ---- 
---- Public License as published by the Free Software Foundation; ---- 
---- either version 2.1 of the License, or (at your option) any   ---- 
---- either version 2.1 of the License, or (at your option) any   ---- 
---- later version.                                               ---- 
---- later version.                                               ---- 
----                                                              ---- 
----                                                              ---- 
---- This source is distributed in the hope that it will be       ---- 
---- This source is distributed in the hope that it will be       ---- 
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
---- details.                                                     ---- 
---- details.                                                     ---- 
----                                                              ---- 
----                                                              ---- 
---- You should have received a copy of the GNU Lesser General    ---- 
---- You should have received a copy of the GNU Lesser General    ---- 
---- Public License along with this source; if not, download it   ---- 
---- Public License along with this source; if not, download it   ---- 
---- from http://www.opencores.org/lgpl.shtml                     ---- 
---- from http://www.opencores.org/lgpl.shtml                     ---- 
----                                                              ---- 
----                                                              ---- 
----------------------------------------------------------------------
----------------------------------------------------------------------
 
 
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_unsigned.all;
 
 
library mod_sim_exp;
library mod_sim_exp;
use mod_sim_exp.mod_sim_exp_pkg.all;
use mod_sim_exp.mod_sim_exp_pkg.all;
 
 
 
 
entity operand_ram is
entity operand_ram is
  port( -- write_operand_ack voorzien?
  port( -- write_operand_ack voorzien?
    -- global ports
    -- global ports
    clk       : in std_logic;
 
    collision : out std_logic;
    collision : out std_logic;
    -- bus side connections (32-bit serial)
    -- bus side connections (32-bit serial)
 
    bus_clk        : in std_logic;
    operand_addr   : in std_logic_vector(5 downto 0);
    operand_addr   : in std_logic_vector(5 downto 0);
    operand_in     : in std_logic_vector(31 downto 0);
    operand_in     : in std_logic_vector(31 downto 0);
    operand_in_sel : in std_logic_vector(1 downto 0);
    operand_in_sel : in std_logic_vector(1 downto 0);
    result_out     : out std_logic_vector(31 downto 0);
    result_out     : out std_logic_vector(31 downto 0);
    write_operand  : in std_logic;
    write_operand  : in std_logic;
    -- multiplier side connections (1536 bit parallel)
    -- multiplier side connections (1536 bit parallel)
 
    core_clk        : in std_logic;
    result_dest_op  : in std_logic_vector(1 downto 0);
    result_dest_op  : in std_logic_vector(1 downto 0);
    operand_out     : out std_logic_vector(1535 downto 0);
    operand_out     : out std_logic_vector(1535 downto 0);
    operand_out_sel : in std_logic_vector(1 downto 0); -- controlled by bus side
    operand_out_sel : in std_logic_vector(1 downto 0); -- controlled by bus side
    write_result    : in std_logic;
    write_result    : in std_logic;
    result_in       : in std_logic_vector(1535 downto 0)
    result_in       : in std_logic_vector(1535 downto 0)
  );
  );
end operand_ram;
end operand_ram;
 
 
 
 
architecture Behavioral of operand_ram is
architecture Behavioral of operand_ram is
  -- port a signals
  -- port a signals
  signal addra           : std_logic_vector(5 downto 0);
  signal addra           : std_logic_vector(5 downto 0);
  signal part_enable     : std_logic_vector(3 downto 0);
  signal part_enable     : std_logic_vector(3 downto 0);
  signal wea             : std_logic_vector(3 downto 0);
  signal wea             : std_logic_vector(3 downto 0);
  signal write_operand_i : std_logic;
  signal write_operand_i : std_logic;
 
 
  -- port b signals
  -- port b signals
  signal addrb  : std_logic_vector(5 downto 0);
  signal addrb  : std_logic_vector(1 downto 0);
  signal web    : std_logic_vector(0 downto 0);
  signal web    : std_logic_vector(0 downto 0);
  signal doutb0 : std_logic_vector(31 downto 0);
  signal douta0 : std_logic_vector(31 downto 0);
  signal doutb1 : std_logic_vector(31 downto 0);
  signal douta1 : std_logic_vector(31 downto 0);
  signal doutb2 : std_logic_vector(31 downto 0);
  signal douta2 : std_logic_vector(31 downto 0);
 
 
begin
begin
 
 
        -- WARNING: Very Important!
        -- WARNING: Very Important!
        -- wea & web signals must never be high at the same time !!
        -- wea & web signals must never be high at the same time !!
        -- web has priority 
        -- web has priority 
        write_operand_i <= write_operand and not write_result;
        write_operand_i <= write_operand and not write_result;
        web(0) <= write_result;
        web(0) <= write_result;
        collision <= write_operand and write_result;
        collision <= write_operand and write_result;
 
 
        -- the dual port ram has a depth of 4 (each layer contains an operand)
        -- the dual port ram has a depth of 4 (each layer contains an operand)
        -- result is always stored in position 3
        -- result is always stored in position 3
        -- doutb is always result
        -- doutb is always result
        with write_operand_i select
        with write_result select
                addra <= operand_in_sel & operand_addr(3 downto 0) when '1',
  addrb <= result_dest_op when '1',
                         operand_out_sel & "0000" when others;
           operand_out_sel when others;
 
 
 
 
 
 
        with operand_addr(5 downto 4) select
        with operand_addr(5 downto 4) select
                part_enable <=  "0001" when "00",
                part_enable <=  "0001" when "00",
                                "0010" when "01",
                                "0010" when "01",
                                            "0100" when "10",
                                            "0100" when "10",
                                            "1000" when others;
                                            "1000" when others;
 
 
        with write_operand_i select
  with write_operand select
                wea <= part_enable when '1',
                wea <= part_enable when '1',
                       "0000" when others;
           "0000" when others;
 
 
        -- we can only read back from the result (stored in result_dest_op)
        addra <= operand_in_sel & operand_addr(3 downto 0);
        addrb <= result_dest_op & operand_addr(3 downto 0);
 
 
 
 
 
        with operand_addr(5 downto 4) select
        with operand_addr(5 downto 4) select
                result_out <= doutb0 when "00",
                result_out <= douta0 when "00",
                              doutb1 when "01",
                              douta1 when "01",
                                          doutb2 when others;
                                          douta2 when others;
 
 
        -- 3 instances of a dual port ram to store the parts of the operand
        -- 3 instances of a dual port ram to store the parts of the operand
  op_0 : operand_dp
  op_0 : operand_dp
  port map (
  port map (
    clka  => clk,
    clka  => bus_clk,
    wea   => wea(0 downto 0),
    wea   => wea(0 downto 0),
    addra => addra,
    addra => addra,
    dina  => operand_in,
    dina  => operand_in,
    douta => operand_out(511 downto 0),
    douta => douta0,
    clkb  => clk,
    clkb  => core_clk,
    web   => web,
    web   => web,
    addrb => addrb,
    addrb => addrb,
    dinb  => result_in(511 downto 0),
    dinb  => result_in(511 downto 0),
    doutb => doutb0
    doutb => operand_out(511 downto 0)
  );
  );
 
 
  op_1 : operand_dp
  op_1 : operand_dp
  port map (
  port map (
    clka  => clk,
    clka  => bus_clk,
    wea   => wea(1 downto 1),
    wea   => wea(1 downto 1),
    addra => addra,
    addra => addra,
    dina  => operand_in,
    dina  => operand_in,
    douta => operand_out(1023 downto 512),
    douta => douta1,
    clkb  => clk,
    clkb  => core_clk,
    web   => web,
    web   => web,
    addrb => addrb,
    addrb => addrb,
    dinb  => result_in(1023 downto 512),
    dinb  => result_in(1023 downto 512),
    doutb => doutb1
    doutb => operand_out(1023 downto 512)
  );
  );
 
 
  op_2 : operand_dp
  op_2 : operand_dp
  port map (
  port map (
    clka  => clk,
    clka  => bus_clk,
    wea   => wea(2 downto 2),
    wea   => wea(2 downto 2),
    addra => addra,
    addra => addra,
    dina  => operand_in,
    dina  => operand_in,
    douta => operand_out(1535 downto 1024),
    douta => douta2,
    clkb  => clk,
    clkb  => core_clk,
    web   => web,
    web   => web,
    addrb => addrb,
    addrb => addrb,
    dinb  => result_in(1535 downto 1024),
    dinb  => result_in(1535 downto 1024),
    doutb => doutb2
    doutb => operand_out(1535 downto 1024)
  );
  );
 
 
end Behavioral;
end Behavioral;
 
 

powered by: WebSVN 2.1.0

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