1 |
3 |
gajos |
-----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- Montgomery modular multiplier and exponentiator ----
|
4 |
|
|
---- ----
|
5 |
|
|
---- This file is part of the Montgomery modular multiplier ----
|
6 |
|
|
---- and exponentiator project ----
|
7 |
|
|
---- http://opencores.org/project,mod_mult_exp ----
|
8 |
|
|
---- ----
|
9 |
|
|
---- Description: ----
|
10 |
|
|
---- Properties file for multiplier and exponentiator ----
|
11 |
|
|
---- (512 bit). ----
|
12 |
|
|
---- To Do: ----
|
13 |
|
|
---- ----
|
14 |
|
|
---- Author(s): ----
|
15 |
|
|
---- - Krzysztof Gajewski, gajos@opencores.org ----
|
16 |
|
|
---- k.gajewski@gmail.com ----
|
17 |
|
|
---- ----
|
18 |
|
|
-----------------------------------------------------------------------
|
19 |
|
|
---- ----
|
20 |
|
|
---- Copyright (C) 2014 Authors and OPENCORES.ORG ----
|
21 |
|
|
---- ----
|
22 |
|
|
---- This source file may be used and distributed without ----
|
23 |
|
|
---- restriction provided that this copyright statement is not ----
|
24 |
|
|
---- removed from the file and that any derivative work contains ----
|
25 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
26 |
|
|
---- ----
|
27 |
|
|
---- This source file is free software; you can redistribute it ----
|
28 |
|
|
---- and-or modify it under the terms of the GNU Lesser General ----
|
29 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
30 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
31 |
|
|
---- later version. ----
|
32 |
|
|
---- ----
|
33 |
|
|
---- This source is distributed in the hope that it will be ----
|
34 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
35 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
36 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
37 |
|
|
---- details. ----
|
38 |
|
|
---- ----
|
39 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
40 |
|
|
---- Public License along with this source; if not, download it ----
|
41 |
|
|
---- from http://www.opencores.org/lgpl.shtml ----
|
42 |
|
|
---- ----
|
43 |
|
|
-----------------------------------------------------------------------
|
44 |
|
|
library IEEE;
|
45 |
|
|
use IEEE.STD_LOGIC_1164.all;
|
46 |
|
|
|
47 |
|
|
package properties is
|
48 |
|
|
|
49 |
|
|
-- Declare constants
|
50 |
|
|
|
51 |
|
|
constant BYTE : INTEGER := 8;
|
52 |
|
|
|
53 |
|
|
constant WORD_LENGTH : INTEGER := 512;
|
54 |
|
|
constant WORD_INTEGER : INTEGER := 10;
|
55 |
|
|
constant WORD_INT_LOG : INTEGER := 6;
|
56 |
|
|
constant WORD_INT_LOG_STR : STD_LOGIC_VECTOR(WORD_INT_LOG - 1 downto 0) := "111111";
|
57 |
|
|
|
58 |
|
|
constant count_up : STD_LOGIC_VECTOR(1 downto 0) := "00";
|
59 |
|
|
constant count_down : STD_LOGIC_VECTOR(1 downto 0) := "01";
|
60 |
|
|
constant do_nothing : STD_LOGIC_VECTOR(1 downto 0) := "11";
|
61 |
|
|
|
62 |
|
|
type multiplier_states is (NOP, CALCULATE_START, STOP);
|
63 |
|
|
|
64 |
5 |
gajos |
type exponentiator_states is (FIRST_RUN, NOP,
|
65 |
|
|
READ_DATA_BASE, READ_DATA_MODULUS, READ_DATA_EXPONENT, READ_DATA_RESIDUUM,
|
66 |
|
|
COUNT_POWER, EXP_Z, SAVE_EXP_Z, EXP_P, SAVE_EXP_P, EXP_CONTROL, EXP_END, SAVE_EXP_MULT,
|
67 |
|
|
INFO_RESULT, SHOW_RESULT);
|
68 |
3 |
gajos |
|
69 |
|
|
type fin_data_ctrl_states is (NOP, PAD_FAIL, PAD_FAIL_NOP, PAD_FAIL_DECODE,
|
70 |
|
|
DECODE_IN, READ_DATA, DECODE_READ, DECODE_READ_PROP, MAKE_FINALIZE, OUTPUT_DATA, INFO_STATE,
|
71 |
|
|
TEMPORARY_STATE, DATA_TO_OUT_PROPAGATE, DATA_TO_OUT_PROPAGATE2, MOVE_DATA, MOVE_OUTPUT_DATA);
|
72 |
|
|
|
73 |
5 |
gajos |
---- mnemonics for exponentiator
|
74 |
|
|
constant mn_read_base : STD_LOGIC_VECTOR(2 downto 0) := "000";
|
75 |
|
|
constant mn_read_modulus : STD_LOGIC_VECTOR(2 downto 0) := "001";
|
76 |
|
|
constant mn_read_exponent : STD_LOGIC_VECTOR(2 downto 0) := "010";
|
77 |
|
|
constant mn_read_residuum : STD_LOGIC_VECTOR(2 downto 0) := "011";
|
78 |
|
|
constant mn_count_power : STD_LOGIC_VECTOR(2 downto 0) := "100";
|
79 |
|
|
constant mn_show_result : STD_LOGIC_VECTOR(2 downto 0) := "101";
|
80 |
|
|
constant mn_show_status : STD_LOGIC_VECTOR(2 downto 0) := "110";
|
81 |
|
|
constant mn_prepare_for_data : STD_LOGIC_VECTOR(2 downto 0) := "111";
|
82 |
3 |
gajos |
|
83 |
|
|
---- addresses for memory data
|
84 |
5 |
gajos |
constant addr_base : STD_LOGIC_VECTOR(3 downto 0) := "0000";
|
85 |
|
|
constant addr_modulus : STD_LOGIC_VECTOR(3 downto 0) := "0010";
|
86 |
|
|
constant addr_exponent : STD_LOGIC_VECTOR(3 downto 0) := "0100";
|
87 |
|
|
constant addr_power : STD_LOGIC_VECTOR(3 downto 0) := "0101";
|
88 |
|
|
constant addr_residuum : STD_LOGIC_VECTOR(3 downto 0) := "1000";
|
89 |
|
|
constant addr_one : STD_LOGIC_VECTOR(3 downto 0) := "1001";
|
90 |
|
|
constant addr_unused : STD_LOGIC_VECTOR(3 downto 0) := "1101";
|
91 |
|
|
constant addr_z : STD_LOGIC_VECTOR(3 downto 0) := "1110";
|
92 |
|
|
constant addr_p : STD_LOGIC_VECTOR(3 downto 0) := "1111";
|
93 |
3 |
gajos |
|
94 |
|
|
---- help_statuses_for_clarity
|
95 |
|
|
constant stat_all_data_readed : STD_LOGIC_VECTOR(5 downto 0) := "111111";
|
96 |
|
|
constant stat_clear_status : STD_LOGIC_VECTOR(5 downto 0) := "000000";
|
97 |
|
|
|
98 |
|
|
end properties;
|
99 |
|
|
|
100 |
|
|
package body properties is
|
101 |
|
|
|
102 |
|
|
end properties;
|