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

Subversion Repositories rsa_512

[/] [rsa_512/] [trunk/] [rtl/] [pe.vhd] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 jcastillo
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    20:36:31 10/27/2009 
6
-- Design Name: 
7
-- Module Name:    PE - 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 is
31
  port ( clk          : in  std_logic;
32
         reset        : in  std_logic;
33
         a_j          : in  std_logic_vector(15 downto 0);
34
         b_i          : in  std_logic_vector(15 downto 0);
35
         s_prev       : in  std_logic_vector(15 downto 0);  --entrada de la s anterior para la suma
36
         m            : in  std_logic_vector(15 downto 0);
37
         n_j          : in  std_logic_vector(15 downto 0);
38
         s_next       : out std_logic_vector(15 downto 0);  --salida con la siguiente s
39
         aj_bi        : out std_logic_vector(15 downto 0);  --salida de multiplicador reutilizado para calcular a*b
40
         ab_valid_in  : in  std_logic;  --indica que los datos de entrada en el multiplicador son validos
41
         valid_in     : in  std_logic;  --todas las entradas son validas, y la m está calculada
42
         ab_valid_out : out std_logic;  --indica que la multiplicacion de un a y b validos se ha realizado con exito
43
         valid_out    : out std_logic;
44
         fifo_req     : out std_logic);  --peticion de las siguientes entradas a, b, s, m
45
end pe;
46
 
47
architecture Behavioral of pe is
48
 
49
  signal prod_aj_bi, next_prod_aj_bi, mult_aj_bi                     : std_logic_vector(31 downto 0);  -- registros para la primera mult
50
  signal prod_nj_m, next_prod_nj_m, mult_nj_m, mult_nj_m_reg         : std_logic_vector(31 downto 0);
51
  signal sum_1, next_sum_1                                           : std_logic_vector(31 downto 0);
52
  signal sum_2, next_sum_2                                           : std_logic_vector(31 downto 0);
53
  signal ab_valid_reg, valid_out_reg, valid_out_reg2, valid_out_reg3 : std_logic;
54
  signal n_reg, next_n_reg, s_prev_reg, next_s_prev_reg, ab_out_reg  : std_logic_vector(15 downto 0);
55
  --signal prod_aj_bi_out, next_prod_aj_bi_out : std_logic_vector(15 downto 0);
56
 
57
begin
58
 
59
 
60
  mult_aj_bi <= a_j * b_i;
61
  mult_nj_m  <= n_reg *m;
62
 
63
 
64
  process(clk, reset)
65
  begin
66
 
67
    if(clk = '1' and clk'event)
68
    then
69
      if(reset = '1') then
70
        prod_aj_bi     <= (others => '0');
71
        prod_nj_m      <= (others => '0');
72
        sum_1          <= (others => '0');
73
        sum_2          <= (others => '0');
74
        ab_valid_reg   <= '0';
75
        n_reg          <= (others => '0');
76
        valid_out_reg  <= '0';
77
        valid_out_reg2 <= '0';
78
        valid_out_reg3 <= '0';
79
        s_prev_reg     <= (others => '0');
80
      else
81
        --prod_aj_bi_out <= next_prod_aj_bi_out;
82
        prod_aj_bi     <= next_prod_aj_bi;
83
        prod_nj_m      <= next_prod_nj_m;
84
        sum_1          <= next_sum_1;
85
        sum_2          <= next_sum_2;
86
        ab_valid_reg   <= ab_valid_in;
87
        ab_out_reg     <= mult_aj_bi(15 downto 0);
88
        n_reg          <= next_n_reg;
89
        valid_out_reg  <= valid_in;     --registramos el valid out para sacarle al tiempo de los datos validos
90
        valid_out_reg2 <= valid_out_reg;
91
        valid_out_reg3 <= valid_out_reg2;
92
        s_prev_reg     <= next_s_prev_reg;
93
        --mult_nj_m_reg <= mult_nj_m;
94
      end if;
95
    end if;
96
 
97
  end process;
98
 
99
  process(s_prev, prod_aj_bi, prod_nj_m, sum_1, sum_2, mult_aj_bi, mult_nj_m, valid_in, ab_valid_reg, n_j, n_reg, valid_out_reg3, s_prev_reg, ab_out_reg)
100
  begin
101
    ab_valid_out      <= ab_valid_reg;
102
    aj_bi             <= ab_out_reg(15 downto 0);  --Sacamos uno de los dos registros de la multiplicacion fuera para el calculo de la constante
103
    s_next            <= sum_2(15 downto 0);  --salida de la pipe
104
    fifo_req          <= valid_in;
105
    valid_out         <= valid_out_reg3;
106
    next_sum_1        <= sum_1;
107
    next_sum_2        <= sum_2;
108
    next_prod_nj_m    <= prod_nj_m;
109
    next_prod_aj_bi   <= prod_aj_bi;
110
    next_n_reg        <= n_reg;
111
    next_s_prev_reg   <= s_prev_reg;
112
    if(valid_in = '1') then
113
      next_s_prev_reg <= s_prev;
114
      next_n_reg      <= n_j;
115
      next_prod_aj_bi <= mult_aj_bi;
116
      next_prod_nj_m  <= mult_nj_m;     --registramos la multiplicacion de n_j,m
117
      next_sum_1      <= prod_aj_bi+sum_1(31 downto 16)+s_prev_reg;
118
      next_sum_2      <= prod_nj_m+sum_2(31 downto 16) + sum_1(15 downto 0);
119
    else
120
      next_s_prev_reg <= (others => '0');
121
      next_n_reg      <= (others => '0');
122
      next_prod_aj_bi <= (others => '0');
123
      next_prod_nj_m  <= (others => '0');
124 9 jcastillo
      next_sum_1      <= (others => '0');
125
      next_sum_2      <= (others => '0');
126 3 jcastillo
    end if;
127 9 jcastillo
 
128
 
129
 
130 3 jcastillo
  end process;
131
 
132
end Behavioral;
133
 

powered by: WebSVN 2.1.0

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