OpenCores
URL https://opencores.org/ocsvn/rsa_512/rsa_512/trunk

Subversion Repositories rsa_512

[/] [rsa_512/] [trunk/] [rtl/] [pe_wrapper.vhd] - Blame information for rev 5

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

Line No. Rev Author Line
1 3 jcastillo
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    19:08:19 10/29/2009 
6
-- Design Name: 
7
-- Module Name:    montgomery - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.all;
22
use IEEE.STD_LOGIC_ARITH.all;
23
use IEEE.STD_LOGIC_UNSIGNED.all;
24
 
25
---- Uncomment the following library declaration if instantiating
26
---- any Xilinx primitives in this code.
27
--library UNISIM;
28
--use UNISIM.VComponents.all;
29
 
30
entity pe_wrapper is
31
 
32
  port(
33
    clk          : in  std_logic;
34
    reset        : in  std_logic;
35
    ab_valid     : in  std_logic;
36
    valid_in     : in  std_logic;
37
    a            : in  std_logic_vector(15 downto 0);
38
    b            : in  std_logic_vector(15 downto 0);
39
    n            : in  std_logic_vector(15 downto 0);
40
    s_prev       : in  std_logic_vector(15 downto 0);
41
    n_c          : in  std_logic_vector(15 downto 0);
42
    s            : out std_logic_vector( 15 downto 0);
43
    data_ready   : out std_logic;
44
    fifo_req     : out std_logic;
45
    m_val        : out std_logic;
46
    reset_the_PE : in  std_logic);      -- estamos preparados para aceptar el siguiente dato
47
 
48
end pe_wrapper;
49
 
50
architecture Behavioral of pe_wrapper is
51
 
52
  component pe is
53
                 port ( clk          : in  std_logic;
54
                        reset        : in  std_logic;
55
                        a_j          : in  std_logic_vector(15 downto 0);
56
                        b_i          : in  std_logic_vector(15 downto 0);
57
                        s_prev       : in  std_logic_vector(15 downto 0);  --entrada de la s anterior para la suma
58
                        m            : in  std_logic_vector(15 downto 0);
59
                        n_j          : in  std_logic_vector(15 downto 0);
60
                        s_next       : out std_logic_vector(15 downto 0);  --salida con la siguiente s
61
                        aj_bi        : out std_logic_vector(15 downto 0);  --salida de multiplicador reutilizado para calcular a*b
62
                        ab_valid_in  : in  std_logic;  --indica que los datos de entrada en el multiplicador son validos
63
                        valid_in     : in  std_logic;  --todas las entradas son validas, y la m está calculada
64
                        ab_valid_out : out std_logic;  --indica que la multiplicacion de un a y b validos se ha realizado con exito
65
                        valid_out    : out std_logic;
66
                        fifo_req     : out std_logic);
67
  end component;
68
 
69
  component m_calc is
70
                     port(
71
                       clk        : in  std_logic;
72
                       reset      : in  std_logic;
73
                       ab         : in  std_logic_vector (15 downto 0);
74
                       t          : in  std_logic_vector (15 downto 0);
75
                       n_cons     : in  std_logic_vector (15 downto 0);
76
                       m          : out std_logic_vector (15 downto 0);
77
                       mult_valid : in  std_logic;
78
                       m_valid    : out std_logic);
79
  end component;
80
 
81
  signal aj_bi, m, next_m, m_out          : std_logic_vector(15 downto 0);
82
  signal mult_valid, valid_m, valid_m_reg : std_logic;  --lo registro para compararlos
83
 
84
begin
85
 
86
  pe_0 : pe port map(
87
    clk          => clk,
88
    reset        => reset,
89
    a_j          => a,
90
    b_i          => b,
91
    s_prev       => s_prev,
92
    m            => m,
93
    n_j          => n,
94
    s_next       => s,
95
    aj_bi        => aj_bi,
96
    ab_valid_in  => ab_valid,
97
    valid_in     => valid_in,
98
    ab_valid_out => mult_valid,
99
    valid_out    => data_ready,
100
    fifo_req     => fifo_req);
101
 
102
  mcons_0 : m_calc port map(
103
    clk        => clk,
104
    reset      => reset,
105
    ab         => aj_bi,
106
    t          => s_prev,
107
    n_cons     => n_c,
108
    m          => m_out,
109
    mult_valid => mult_valid,
110
    m_valid    => valid_m);
111
 
112
  process(clk, reset)
113
  begin
114
    if(clk='1' and clk'event) then
115
 
116
      if(reset='1')then
117
        m <= (others=> '0' );
118
        valid_m_reg <= '0';
119
      else
120
        m <= next_m;
121
        valid_m_reg <= valid_m;
122
      end if;
123
    end if;
124
  end process;
125
 
126
  process(m_out,valid_m, valid_m_reg, m)
127
  begin
128
    m_val <= valid_m_reg;
129
    if(valid_m = '1' and valid_m_reg ='0') then
130
      next_m <= m_out;
131
    else
132
      next_m <= m;
133
    end if;
134
  end process;
135
 
136
end Behavioral;
137
 

powered by: WebSVN 2.1.0

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