1 |
2 |
jcastillo |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// MD5 header ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the SystemC MD5 ////
|
6 |
|
|
//// ////
|
7 |
|
|
//// Description: ////
|
8 |
|
|
//// MD5 top file header ////
|
9 |
|
|
//// ////
|
10 |
|
|
//// To Do: ////
|
11 |
|
|
//// - done ////
|
12 |
|
|
//// ////
|
13 |
|
|
//// Author(s): ////
|
14 |
|
|
//// - Javier Castillo, jcastilo@opencores.org ////
|
15 |
|
|
//// ////
|
16 |
|
|
//////////////////////////////////////////////////////////////////////
|
17 |
|
|
//// ////
|
18 |
|
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
19 |
|
|
//// ////
|
20 |
|
|
//// This source file may be used and distributed without ////
|
21 |
|
|
//// restriction provided that this copyright statement is not ////
|
22 |
|
|
//// removed from the file and that any derivative work contains ////
|
23 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
24 |
|
|
//// ////
|
25 |
|
|
//// This source file is free software; you can redistribute it ////
|
26 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
27 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
28 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
29 |
|
|
//// later version. ////
|
30 |
|
|
//// ////
|
31 |
|
|
//// This source is distributed in the hope that it will be ////
|
32 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
33 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
34 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
35 |
|
|
//// details. ////
|
36 |
|
|
//// ////
|
37 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
38 |
|
|
//// Public License along with this source; if not, download it ////
|
39 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
40 |
|
|
//// ////
|
41 |
|
|
//////////////////////////////////////////////////////////////////////
|
42 |
|
|
//
|
43 |
|
|
// CVS Revision History
|
44 |
|
|
//
|
45 |
|
|
// $Log: not supported by cvs2svn $
|
46 |
|
|
|
47 |
|
|
#include "systemc.h"
|
48 |
|
|
|
49 |
|
|
SC_MODULE (md5)
|
50 |
|
|
{
|
51 |
|
|
|
52 |
|
|
sc_in < bool > clk;
|
53 |
|
|
sc_in < bool > reset;
|
54 |
|
|
|
55 |
|
|
sc_in < bool > load_i;
|
56 |
|
|
sc_out < bool > ready_o;
|
57 |
|
|
sc_in < bool > newtext_i;
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
//Input must be padded and in little endian mode
|
61 |
|
|
sc_in < sc_biguint < 128 > >data_i;
|
62 |
|
|
sc_out < sc_biguint < 128 > >data_o;
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
//Signals
|
66 |
|
|
sc_signal < sc_uint < 32 > >ar, br, cr, dr;
|
67 |
|
|
sc_signal < sc_uint < 32 > >next_ar, next_br, next_cr, next_dr;
|
68 |
|
|
sc_signal < sc_uint < 32 > >A, B, C, D;
|
69 |
|
|
sc_signal < sc_uint < 32 > >next_A, next_B, next_C, next_D;
|
70 |
|
|
|
71 |
|
|
sc_signal < bool > next_ready_o;
|
72 |
|
|
sc_signal < sc_biguint < 128 > >next_data_o;
|
73 |
|
|
|
74 |
|
|
sc_signal < sc_biguint < 512 > >message, next_message;
|
75 |
|
|
sc_signal < bool > generate_hash, hash_generated, next_generate_hash;
|
76 |
|
|
|
77 |
|
|
sc_signal < sc_uint < 3 > >getdata_state, next_getdata_state;
|
78 |
|
|
|
79 |
|
|
sc_signal < sc_uint < 2 > >round, next_round;
|
80 |
|
|
sc_signal < sc_uint < 6 > >round64, next_round64;
|
81 |
|
|
|
82 |
|
|
sc_signal < sc_uint < 44 > >t;
|
83 |
|
|
|
84 |
|
|
sc_signal < sc_uint < 32 > >func_out;
|
85 |
|
|
|
86 |
|
|
void md5_getdata ();
|
87 |
|
|
void reg_signal ();
|
88 |
|
|
void round64FSM ();
|
89 |
|
|
void md5_rom ();
|
90 |
|
|
void funcs ();
|
91 |
|
|
|
92 |
|
|
SC_CTOR (md5)
|
93 |
|
|
{
|
94 |
|
|
|
95 |
|
|
SC_METHOD (reg_signal);
|
96 |
|
|
sensitive_pos << clk;
|
97 |
|
|
sensitive_neg << reset;
|
98 |
|
|
|
99 |
|
|
SC_METHOD (md5_getdata);
|
100 |
|
|
sensitive << newtext_i << data_i << load_i << getdata_state <<
|
101 |
|
|
hash_generated << message;
|
102 |
|
|
sensitive << func_out << A << B << C << D << ar << br << cr << dr <<
|
103 |
|
|
generate_hash;
|
104 |
|
|
|
105 |
|
|
SC_METHOD (round64FSM);
|
106 |
|
|
sensitive << newtext_i << round << round64 << ar << br << cr << dr <<
|
107 |
|
|
generate_hash << func_out;
|
108 |
|
|
sensitive << getdata_state << A << B << C << D;
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
SC_METHOD (md5_rom);
|
112 |
|
|
sensitive << round64;
|
113 |
|
|
|
114 |
|
|
SC_METHOD (funcs);
|
115 |
|
|
sensitive << t << ar << br << cr << dr << round << message << func_out;
|
116 |
|
|
|
117 |
|
|
}
|
118 |
|
|
};
|