1 |
31 |
JonasDC |
----------------------------------------------------------------------
|
2 |
|
|
---- sys_first_cell_logic ----
|
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 |
|
|
---- first cell logic for use int the montogommery mulitplier ----
|
10 |
|
|
---- pipelined systolic array ----
|
11 |
|
|
---- ----
|
12 |
|
|
---- Dependencies: ----
|
13 |
|
|
---- - register_n ----
|
14 |
|
|
---- - cell_1b_adder ----
|
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_unsigned.all;
|
50 |
|
|
|
51 |
|
|
library mod_sim_exp;
|
52 |
|
|
use mod_sim_exp.mod_sim_exp_pkg.all;
|
53 |
|
|
|
54 |
|
|
-- logic needed as the first piece in the systolic array pipeline
|
55 |
|
|
-- calculates the first my_cout and generates q signal
|
56 |
|
|
entity sys_first_cell_logic is
|
57 |
|
|
port (
|
58 |
|
|
m0 : in std_logic; -- lsb from m operand
|
59 |
|
|
y0 : in std_logic; -- lsb from y operand
|
60 |
|
|
my_cout : out std_logic; -- my_cin for first stage
|
61 |
|
|
xi : in std_logic; -- xi operand input
|
62 |
|
|
xout : out std_logic; -- xin for first stage
|
63 |
|
|
qout : out std_logic; -- qin for first stage
|
64 |
|
|
cout : out std_logic; -- cin for first stage
|
65 |
|
|
a_0 : in std_logic; -- a_0 from first stage
|
66 |
|
|
red_cout : out std_logic -- red_cin for first stage
|
67 |
|
|
);
|
68 |
|
|
end sys_first_cell_logic;
|
69 |
|
|
|
70 |
|
|
architecture Behavorial of sys_first_cell_logic is
|
71 |
|
|
-- first cell signals
|
72 |
|
|
signal my0_mux_result : std_logic;
|
73 |
|
|
signal my0 : std_logic;
|
74 |
|
|
signal qout_i : std_logic;
|
75 |
|
|
begin
|
76 |
|
|
-- half adder for m0 +y0
|
77 |
|
|
my0 <= m0 xor y0;
|
78 |
|
|
my_cout <= m0 and y0; -- carry
|
79 |
|
|
|
80 |
|
|
xout <= xi;
|
81 |
|
|
qout_i <= (xi and y0) xor a_0;
|
82 |
|
|
cout <= my0_mux_result and a_0;
|
83 |
|
|
red_cout <= '1'; -- add 1 for 2s complement
|
84 |
|
|
|
85 |
|
|
my0_mux : cell_1b_mux
|
86 |
|
|
port map(
|
87 |
|
|
my => my0,
|
88 |
|
|
m => m0,
|
89 |
|
|
y => y0,
|
90 |
|
|
x => xi,
|
91 |
|
|
q => qout_i,
|
92 |
|
|
result => my0_mux_result
|
93 |
|
|
);
|
94 |
|
|
|
95 |
|
|
qout <= qout_i;
|
96 |
|
|
|
97 |
|
|
end Behavorial;
|