//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// MD5 main implementation file ////
|
//// MD5 main implementation file ////
|
//// ////
|
//// ////
|
//// This file is part of the SystemC MD5 ////
|
//// This file is part of the SystemC MD5 ////
|
//// ////
|
//// ////
|
//// Description: ////
|
//// Description: ////
|
//// MD5 main implementation file ////
|
//// MD5 main implementation file ////
|
//// ////
|
//// ////
|
//// To Do: ////
|
//// To Do: ////
|
//// - done ////
|
//// - done ////
|
//// ////
|
//// ////
|
//// Author(s): ////
|
//// Author(s): ////
|
//// - Javier Castillo, jcastilo@opencores.org ////
|
//// - Javier Castillo, jcastilo@opencores.org ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
//// ////
|
//// ////
|
//// This source file may be used and distributed without ////
|
//// This source file may be used and distributed without ////
|
//// restriction provided that this copyright statement is not ////
|
//// restriction provided that this copyright statement is not ////
|
//// removed from the file and that any derivative work contains ////
|
//// removed from the file and that any derivative work contains ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// ////
|
//// ////
|
//// This source file is free software; you can redistribute it ////
|
//// This source file is free software; you can redistribute it ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// later version. ////
|
//// later version. ////
|
//// ////
|
//// ////
|
//// This source is distributed in the hope that it will be ////
|
//// This source is distributed in the hope that it will be ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// details. ////
|
//// details. ////
|
//// ////
|
//// ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// Public License along with this source; if not, download it ////
|
//// Public License along with this source; if not, download it ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
// Revision 1.1.1.1 2004/09/08 16:24:49 jcastillo
|
// Revision 1.1.1.1 2004/09/08 16:24:49 jcastillo
|
// Initial release
|
// Initial release
|
//
|
//
|
|
|
#include "md5.h"
|
#include "md5.h"
|
|
|
|
|
void
|
void
|
md5::md5_rom ()
|
md5::md5_rom ()
|
{
|
{
|
switch (round64.read ())
|
switch (round64.read ())
|
{
|
{
|
case 0:
|
case 0:
|
t.write (0xD76AA478070);
|
t.write (0xD76AA478070);
|
break;
|
break;
|
case 1:
|
case 1:
|
t.write (0xE8C7B7560C1);
|
t.write (0xE8C7B7560C1);
|
break;
|
break;
|
case 2:
|
case 2:
|
t.write (0x242070DB112);
|
t.write (0x242070DB112);
|
break;
|
break;
|
case 3:
|
case 3:
|
t.write (0xC1BDCEEE163);
|
t.write (0xC1BDCEEE163);
|
break;
|
break;
|
case 4:
|
case 4:
|
t.write (0xF57C0FAF074);
|
t.write (0xF57C0FAF074);
|
break;
|
break;
|
case 5:
|
case 5:
|
t.write (0x4787C62A0C5);
|
t.write (0x4787C62A0C5);
|
break;
|
break;
|
case 6:
|
case 6:
|
t.write (0xA8304613116);
|
t.write (0xA8304613116);
|
break;
|
break;
|
case 7:
|
case 7:
|
t.write (0xFD469501167);
|
t.write (0xFD469501167);
|
break;
|
break;
|
case 8:
|
case 8:
|
t.write (0x698098D8078);
|
t.write (0x698098D8078);
|
break;
|
break;
|
case 9:
|
case 9:
|
t.write (0x8B44F7AF0C9);
|
t.write (0x8B44F7AF0C9);
|
break;
|
break;
|
case 10:
|
case 10:
|
t.write (0xFFFF5BB111A);
|
t.write (0xFFFF5BB111A);
|
break;
|
break;
|
case 11:
|
case 11:
|
t.write (0x895CD7BE16B);
|
t.write (0x895CD7BE16B);
|
break;
|
break;
|
case 12:
|
case 12:
|
t.write (0x6B90112207C);
|
t.write (0x6B90112207C);
|
break;
|
break;
|
case 13:
|
case 13:
|
t.write (0xFD9871930CD);
|
t.write (0xFD9871930CD);
|
break;
|
break;
|
case 14:
|
case 14:
|
t.write (0xA679438E11E);
|
t.write (0xA679438E11E);
|
break;
|
break;
|
case 15:
|
case 15:
|
t.write (0x49B4082116F);
|
t.write (0x49B4082116F);
|
break;
|
break;
|
|
|
case 16:
|
case 16:
|
t.write (0xf61e2562051);
|
t.write (0xf61e2562051);
|
break;
|
break;
|
case 17:
|
case 17:
|
t.write (0xc040b340096);
|
t.write (0xc040b340096);
|
break;
|
break;
|
case 18:
|
case 18:
|
t.write (0x265e5a510EB);
|
t.write (0x265e5a510EB);
|
break;
|
break;
|
case 19:
|
case 19:
|
t.write (0xe9b6c7aa140);
|
t.write (0xe9b6c7aa140);
|
break;
|
break;
|
case 20:
|
case 20:
|
t.write (0xd62f105d055);
|
t.write (0xd62f105d055);
|
break;
|
break;
|
case 21:
|
case 21:
|
t.write (0x0244145309A);
|
t.write (0x0244145309A);
|
break;
|
break;
|
case 22:
|
case 22:
|
t.write (0xd8a1e6810EF);
|
t.write (0xd8a1e6810EF);
|
break;
|
break;
|
case 23:
|
case 23:
|
t.write (0xe7d3fbc8144);
|
t.write (0xe7d3fbc8144);
|
break;
|
break;
|
case 24:
|
case 24:
|
t.write (0x21e1cde6059);
|
t.write (0x21e1cde6059);
|
break;
|
break;
|
case 25:
|
case 25:
|
t.write (0xc33707d609E);
|
t.write (0xc33707d609E);
|
break;
|
break;
|
case 26:
|
case 26:
|
t.write (0xf4d50d870E3);
|
t.write (0xf4d50d870E3);
|
break;
|
break;
|
case 27:
|
case 27:
|
t.write (0x455a14ed148);
|
t.write (0x455a14ed148);
|
break;
|
break;
|
case 28:
|
case 28:
|
t.write (0xa9e3e90505D);
|
t.write (0xa9e3e90505D);
|
break;
|
break;
|
case 29:
|
case 29:
|
t.write (0xfcefa3f8092);
|
t.write (0xfcefa3f8092);
|
break;
|
break;
|
case 30:
|
case 30:
|
t.write (0x676f02d90E7);
|
t.write (0x676f02d90E7);
|
break;
|
break;
|
case 31:
|
case 31:
|
t.write (0x8d2a4c8a14C);
|
t.write (0x8d2a4c8a14C);
|
break;
|
break;
|
|
|
case 32:
|
case 32:
|
t.write (0xfffa3942045);
|
t.write (0xfffa3942045);
|
break;
|
break;
|
case 33:
|
case 33:
|
t.write (0x8771f6810B8);
|
t.write (0x8771f6810B8);
|
break;
|
break;
|
case 34:
|
case 34:
|
t.write (0x6d9d612210B);
|
t.write (0x6d9d612210B);
|
break;
|
break;
|
case 35:
|
case 35:
|
t.write (0xfde5380c17E);
|
t.write (0xfde5380c17E);
|
break;
|
break;
|
case 36:
|
case 36:
|
t.write (0xa4beea44041);
|
t.write (0xa4beea44041);
|
break;
|
break;
|
case 37:
|
case 37:
|
t.write (0x4bdecfa90B4);
|
t.write (0x4bdecfa90B4);
|
break;
|
break;
|
case 38:
|
case 38:
|
t.write (0xf6bb4b60107);
|
t.write (0xf6bb4b60107);
|
break;
|
break;
|
case 39:
|
case 39:
|
t.write (0xbebfbc7017A);
|
t.write (0xbebfbc7017A);
|
break;
|
break;
|
case 40:
|
case 40:
|
t.write (0x289b7ec604D);
|
t.write (0x289b7ec604D);
|
break;
|
break;
|
case 41:
|
case 41:
|
t.write (0xeaa127fa0B0);
|
t.write (0xeaa127fa0B0);
|
break;
|
break;
|
case 42:
|
case 42:
|
t.write (0xd4ef3085103);
|
t.write (0xd4ef3085103);
|
break;
|
break;
|
case 43:
|
case 43:
|
t.write (0x04881d05176);
|
t.write (0x04881d05176);
|
break;
|
break;
|
case 44:
|
case 44:
|
t.write (0xd9d4d039049);
|
t.write (0xd9d4d039049);
|
break;
|
break;
|
case 45:
|
case 45:
|
t.write (0xe6db99e50BC);
|
t.write (0xe6db99e50BC);
|
break;
|
break;
|
case 46:
|
case 46:
|
t.write (0x1fa27cf810F);
|
t.write (0x1fa27cf810F);
|
break;
|
break;
|
case 47:
|
case 47:
|
t.write (0xc4ac5665172);
|
t.write (0xc4ac5665172);
|
break;
|
break;
|
|
|
case 48:
|
case 48:
|
t.write (0xf4292244060);
|
t.write (0xf4292244060);
|
break;
|
break;
|
case 49:
|
case 49:
|
t.write (0x432aff970A7);
|
t.write (0x432aff970A7);
|
break;
|
break;
|
case 50:
|
case 50:
|
t.write (0xab9423a70FE);
|
t.write (0xab9423a70FE);
|
break;
|
break;
|
case 51:
|
case 51:
|
t.write (0xfc93a039155);
|
t.write (0xfc93a039155);
|
break;
|
break;
|
case 52:
|
case 52:
|
t.write (0x655b59c306C);
|
t.write (0x655b59c306C);
|
break;
|
break;
|
case 53:
|
case 53:
|
t.write (0x8f0ccc920A3);
|
t.write (0x8f0ccc920A3);
|
break;
|
break;
|
case 54:
|
case 54:
|
t.write (0xffeff47d0FA);
|
t.write (0xffeff47d0FA);
|
break;
|
break;
|
case 55:
|
case 55:
|
t.write (0x85845dd1151);
|
t.write (0x85845dd1151);
|
break;
|
break;
|
case 56:
|
case 56:
|
t.write (0x6fa87e4f068);
|
t.write (0x6fa87e4f068);
|
break;
|
break;
|
case 57:
|
case 57:
|
t.write (0xfe2ce6e00AF);
|
t.write (0xfe2ce6e00AF);
|
break;
|
break;
|
case 58:
|
case 58:
|
t.write (0xa30143140F6);
|
t.write (0xa30143140F6);
|
break;
|
break;
|
case 59:
|
case 59:
|
t.write (0x4e0811a115D);
|
t.write (0x4e0811a115D);
|
break;
|
break;
|
case 60:
|
case 60:
|
t.write (0xf7537e82064);
|
t.write (0xf7537e82064);
|
break;
|
break;
|
case 61:
|
case 61:
|
t.write (0xbd3af2350AB);
|
t.write (0xbd3af2350AB);
|
break;
|
break;
|
case 62:
|
case 62:
|
t.write (0x2ad7d2bb0F2);
|
t.write (0x2ad7d2bb0F2);
|
break;
|
break;
|
case 63:
|
case 63:
|
t.write (0xeb86d391159);
|
t.write (0xeb86d391159);
|
break;
|
break;
|
|
|
}
|
}
|
}
|
}
|
|
|
|
|
void
|
void
|
md5::funcs ()
|
md5::funcs ()
|
{
|
{
|
sc_uint < 32 > aux, fr_var, tr_var, rotate1, rotate2;
|
sc_uint < 32 > aux, fr_var, tr_var, rotate1, rotate2;
|
sc_uint < 8 > s_var;
|
sc_uint < 8 > s_var;
|
sc_uint < 4 > nblock;
|
sc_uint < 4 > nblock;
|
sc_uint < 32 > message_var[16];
|
sc_uint < 32 > message_var[16];
|
|
|
message_var[0]=message.read().range(511,480);
|
message_var[0]=message.read().range(511,480);
|
message_var[1]=message.read().range(479,448);
|
message_var[1]=message.read().range(479,448);
|
message_var[2]=message.read().range(447,416);
|
message_var[2]=message.read().range(447,416);
|
message_var[3]=message.read().range(415,384);
|
message_var[3]=message.read().range(415,384);
|
message_var[4]=message.read().range(383,352);
|
message_var[4]=message.read().range(383,352);
|
message_var[5]=message.read().range(351,320);
|
message_var[5]=message.read().range(351,320);
|
message_var[6]=message.read().range(319,288);
|
message_var[6]=message.read().range(319,288);
|
message_var[7]=message.read().range(287,256);
|
message_var[7]=message.read().range(287,256);
|
message_var[8]=message.read().range(255,224);
|
message_var[8]=message.read().range(255,224);
|
message_var[9]=message.read().range(223,192);
|
message_var[9]=message.read().range(223,192);
|
message_var[10]=message.read().range(191,160);
|
message_var[10]=message.read().range(191,160);
|
message_var[11]=message.read().range(159,128);
|
message_var[11]=message.read().range(159,128);
|
message_var[12]=message.read().range(127,96);
|
message_var[12]=message.read().range(127,96);
|
message_var[13]=message.read().range(95,64);
|
message_var[13]=message.read().range(95,64);
|
message_var[14]=message.read().range(63,32);
|
message_var[14]=message.read().range(63,32);
|
message_var[15]=message.read().range(31,0);
|
message_var[15]=message.read().range(31,0);
|
|
|
fr_var = 0;
|
fr_var = 0;
|
|
|
switch (round.read ())
|
switch (round.read ())
|
{
|
{
|
case 0:
|
case 0:
|
fr_var = ((br.read () & cr.read ()) | (~br.read () & dr.read ()));
|
fr_var = ((br.read () & cr.read ()) | (~br.read () & dr.read ()));
|
break;
|
break;
|
case 1:
|
case 1:
|
fr_var = ((br.read () & dr.read ()) | (cr.read () & (~dr.read ())));
|
fr_var = ((br.read () & dr.read ()) | (cr.read () & (~dr.read ())));
|
break;
|
break;
|
case 2:
|
case 2:
|
fr_var = (br.read () ^ cr.read () ^ dr.read ());
|
fr_var = (br.read () ^ cr.read () ^ dr.read ());
|
break;
|
break;
|
case 3:
|
case 3:
|
fr_var = (cr.read () ^ (br.read () | ~dr.read ()));
|
fr_var = (cr.read () ^ (br.read () | ~dr.read ()));
|
break;
|
break;
|
default:
|
default:
|
break;
|
break;
|
}
|
}
|
|
|
tr_var = t.read ().range (43, 12);
|
tr_var = t.read ().range (43, 12);
|
s_var = t.read ().range (11, 4);
|
s_var = t.read ().range (11, 4);
|
nblock = t.read ().range (3, 0);
|
nblock = t.read ().range (3, 0);
|
|
|
aux = (ar.read () + fr_var + message_var[(int) nblock] + tr_var);
|
aux = (ar.read () + fr_var + message_var[(int) nblock] + tr_var);
|
|
|
//cout << (int)round64.read() << " " << (int)fr_var << " " << (int)aux << " " << (int)nblock << " " << (int)message_var[(int)nblock] << endl;
|
//cout << (int)round64.read() << " " << (int)fr_var << " " << (int)aux << " " << (int)nblock << " " << (int)message_var[(int)nblock] << endl;
|
|
|
rotate1 = aux << (int) s_var;
|
rotate1 = aux << (int) s_var;
|
rotate2 = aux >> (int) (32 - s_var);
|
rotate2 = aux >> (int) (32 - s_var);
|
func_out.write (br.read () + (rotate1 | rotate2));
|
func_out.write (br.read () + (rotate1 | rotate2));
|
|
|
}
|
}
|
|
|
void
|
void
|
md5::round64FSM ()
|
md5::round64FSM ()
|
{
|
{
|
|
|
next_ar.write (ar.read ());
|
next_ar.write (ar.read ());
|
next_br.write (br.read ());
|
next_br.write (br.read ());
|
next_cr.write (cr.read ());
|
next_cr.write (cr.read ());
|
next_dr.write (dr.read ());
|
next_dr.write (dr.read ());
|
next_round64.write (round64.read ());
|
next_round64.write (round64.read ());
|
next_round.write (round.read ());
|
next_round.write (round.read ());
|
hash_generated.write (0);
|
hash_generated.write (0);
|
|
|
if (generate_hash.read () != 0)
|
if (generate_hash.read () != 0)
|
{
|
{
|
next_ar.write (dr.read ());
|
next_ar.write (dr.read ());
|
next_br.write (func_out.read ());
|
next_br.write (func_out.read ());
|
next_cr.write (br.read ());
|
next_cr.write (br.read ());
|
next_dr.write (cr.read ());
|
next_dr.write (cr.read ());
|
}
|
}
|
|
|
switch (round64.read ())
|
switch (round64.read ())
|
{
|
{
|
|
|
case 0:
|
case 0:
|
next_round.write (0);
|
next_round.write (0);
|
if (generate_hash.read ())
|
if (generate_hash.read ())
|
{
|
{
|
next_round64.write (1);
|
next_round64.write (1);
|
}
|
}
|
break;
|
break;
|
case 15:
|
case 15:
|
case 31:
|
case 31:
|
case 47:
|
case 47:
|
next_round.write (round.read () + 1);
|
next_round.write (round.read () + 1);
|
next_round64.write (round64.read () + 1);
|
next_round64.write (round64.read () + 1);
|
break;
|
break;
|
case 63:
|
case 63:
|
next_round.write (0);
|
next_round.write (0);
|
next_round64.write (0);
|
next_round64.write (0);
|
hash_generated.write (1);
|
hash_generated.write (1);
|
break;
|
break;
|
default:
|
default:
|
next_round64.write (round64.read () + 1);
|
next_round64.write (round64.read () + 1);
|
break;
|
break;
|
}
|
}
|
|
|
if (newtext_i.read ())
|
if (newtext_i.read ())
|
{
|
{
|
next_ar.write (0x67452301);
|
next_ar.write (0x67452301);
|
next_br.write (0xEFCDAB89);
|
next_br.write (0xEFCDAB89);
|
next_cr.write (0x98BADCFE);
|
next_cr.write (0x98BADCFE);
|
next_dr.write (0x10325476);
|
next_dr.write (0x10325476);
|
next_round.write (0);
|
next_round.write (0);
|
next_round64.write (0);
|
next_round64.write (0);
|
}
|
}
|
|
|
if (getdata_state.read () == 0)
|
if (getdata_state.read () == 0)
|
{
|
{
|
next_ar.write (A.read ());
|
next_ar.write (A.read ());
|
next_br.write (B.read ());
|
next_br.write (B.read ());
|
next_cr.write (C.read ());
|
next_cr.write (C.read ());
|
next_dr.write (D.read ());
|
next_dr.write (D.read ());
|
}
|
}
|
}
|
}
|
|
|
void
|
void
|
md5::reg_signal ()
|
md5::reg_signal ()
|
{
|
{
|
if (!reset)
|
if (!reset)
|
{
|
{
|
ready_o.write (0);
|
ready_o.write (0);
|
data_o.write (0);
|
data_o.write (0);
|
message.write (0);
|
message.write (0);
|
|
|
ar.write (0x67452301);
|
ar.write (0x67452301);
|
br.write (0xEFCDAB89);
|
br.write (0xEFCDAB89);
|
cr.write (0x98BADCFE);
|
cr.write (0x98BADCFE);
|
dr.write (0x10325476);
|
dr.write (0x10325476);
|
|
|
getdata_state.write (0);
|
getdata_state.write (0);
|
generate_hash.write (0);
|
generate_hash.write (0);
|
|
|
round.write (0);
|
round.write (0);
|
round64.write (0);
|
round64.write (0);
|
|
|
A.write (0x67452301);
|
A.write (0x67452301);
|
B.write (0xEFCDAB89);
|
B.write (0xEFCDAB89);
|
C.write (0x98BADCFE);
|
C.write (0x98BADCFE);
|
D.write (0x10325476);
|
D.write (0x10325476);
|
|
|
}
|
}
|
else
|
else
|
{
|
{
|
ready_o.write (next_ready_o.read ());
|
ready_o.write (next_ready_o.read ());
|
data_o.write (next_data_o.read ());
|
data_o.write (next_data_o.read ());
|
message.write (next_message.read ());
|
message.write (next_message.read ());
|
|
|
ar.write (next_ar.read ());
|
ar.write (next_ar.read ());
|
br.write (next_br.read ());
|
br.write (next_br.read ());
|
cr.write (next_cr.read ());
|
cr.write (next_cr.read ());
|
dr.write (next_dr.read ());
|
dr.write (next_dr.read ());
|
|
|
A.write (next_A.read ());
|
A.write (next_A.read ());
|
B.write (next_B.read ());
|
B.write (next_B.read ());
|
C.write (next_C.read ());
|
C.write (next_C.read ());
|
D.write (next_D.read ());
|
D.write (next_D.read ());
|
|
|
generate_hash.write (next_generate_hash.read ());
|
generate_hash.write (next_generate_hash.read ());
|
getdata_state.write (next_getdata_state.read ());
|
getdata_state.write (next_getdata_state.read ());
|
|
|
round.write (next_round.read ());
|
round.write (next_round.read ());
|
round64.write (next_round64.read ());
|
round64.write (next_round64.read ());
|
|
|
}
|
}
|
|
|
}
|
}
|
|
|
|
|
void
|
void
|
md5::md5_getdata ()
|
md5::md5_getdata ()
|
{
|
{
|
|
|
sc_biguint < 128 > data_o_var;
|
sc_biguint < 128 > data_o_var;
|
sc_biguint < 512 > aux;
|
sc_biguint < 512 > aux;
|
|
|
sc_uint < 32 > A_t, B_t, C_t, D_t;
|
sc_uint < 32 > A_t, B_t, C_t, D_t;
|
|
|
next_A.write (A.read ());
|
next_A.write (A.read ());
|
next_B.write (B.read ());
|
next_B.write (B.read ());
|
next_C.write (C.read ());
|
next_C.write (C.read ());
|
next_D.write (D.read ());
|
next_D.write (D.read ());
|
|
|
next_generate_hash.write (0);
|
next_generate_hash.write (0);
|
next_ready_o.write (0);
|
next_ready_o.write (0);
|
next_data_o.write (0);
|
next_data_o.write (0);
|
|
|
aux = message.read ();
|
aux = message.read ();
|
next_message.write (message.read ());
|
next_message.write (message.read ());
|
next_getdata_state.write (getdata_state.read ());
|
next_getdata_state.write (getdata_state.read ());
|
|
|
if (newtext_i.read ())
|
if (newtext_i.read ())
|
{
|
{
|
next_A.write (0x67452301);
|
next_A.write (0x67452301);
|
next_B.write (0xEFCDAB89);
|
next_B.write (0xEFCDAB89);
|
next_C.write (0x98BADCFE);
|
next_C.write (0x98BADCFE);
|
next_D.write (0x10325476);
|
next_D.write (0x10325476);
|
next_getdata_state.write (0);
|
next_getdata_state.write (0);
|
}
|
}
|
|
|
switch (getdata_state.read ())
|
switch (getdata_state.read ())
|
{
|
{
|
|
|
case 0:
|
case 0:
|
if (load_i.read ())
|
if (load_i.read ())
|
{
|
{
|
aux.range (511, 384) = data_i.read ();
|
aux.range (511, 384) = data_i.read ();
|
next_message.write (aux);
|
next_message.write (aux);
|
next_getdata_state.write (1);
|
next_getdata_state.write (1);
|
}
|
}
|
break;
|
break;
|
case 1:
|
case 1:
|
if (load_i.read ())
|
if (load_i.read ())
|
{
|
{
|
aux.range (383, 256) = data_i.read ();
|
aux.range (383, 256) = data_i.read ();
|
next_message.write (aux);
|
next_message.write (aux);
|
next_getdata_state.write (2);
|
next_getdata_state.write (2);
|
}
|
}
|
break;
|
break;
|
case 2:
|
case 2:
|
if (load_i.read ())
|
if (load_i.read ())
|
{
|
{
|
aux.range (255, 128) = data_i.read ();
|
aux.range (255, 128) = data_i.read ();
|
next_message.write (aux);
|
next_message.write (aux);
|
next_getdata_state.write (3);
|
next_getdata_state.write (3);
|
}
|
}
|
break;
|
break;
|
case 3:
|
case 3:
|
if (load_i.read ())
|
if (load_i.read ())
|
{
|
{
|
aux.range (127, 0) = data_i.read ();
|
aux.range (127, 0) = data_i.read ();
|
next_message.write (aux);
|
next_message.write (aux);
|
next_getdata_state.write (4);
|
next_getdata_state.write (4);
|
next_generate_hash.write (1);
|
next_generate_hash.write (1);
|
}
|
}
|
break;
|
break;
|
case 4:
|
case 4:
|
next_generate_hash.write (1);
|
next_generate_hash.write (1);
|
|
|
A_t = dr.read () + A.read ();
|
A_t = dr.read () + A.read ();
|
B_t = func_out.read () + B.read ();
|
B_t = func_out.read () + B.read ();
|
C_t = br.read () + C.read ();
|
C_t = br.read () + C.read ();
|
D_t = cr.read () + D.read ();
|
D_t = cr.read () + D.read ();
|
|
|
data_o_var.range (127, 96) = A_t;
|
data_o_var.range (127, 96) = A_t;
|
data_o_var.range (95, 64) = B_t;
|
data_o_var.range (95, 64) = B_t;
|
data_o_var.range (63, 32) = C_t;
|
data_o_var.range (63, 32) = C_t;
|
data_o_var.range (31, 0) = D_t;
|
data_o_var.range (31, 0) = D_t;
|
next_data_o.write (data_o_var);
|
next_data_o.write (data_o_var);
|
|
|
|
|
if (hash_generated.read ())
|
if (hash_generated.read ())
|
{
|
{
|
next_A.write (A_t);
|
next_A.write (A_t);
|
next_B.write (B_t);
|
next_B.write (B_t);
|
next_C.write (C_t);
|
next_C.write (C_t);
|
next_D.write (D_t);
|
next_D.write (D_t);
|
next_getdata_state.write (0);
|
next_getdata_state.write (0);
|
next_ready_o.write (1);
|
next_ready_o.write (1);
|
next_generate_hash.write (0);
|
next_generate_hash.write (0);
|
}
|
}
|
break;
|
break;
|
}
|
}
|
|
|
}
|
}
|
|
|