URL
https://opencores.org/ocsvn/systemcmd5/systemcmd5/trunk
Subversion Repositories systemcmd5
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 5 to Rev 6
- ↔ Reverse comparison
Rev 5 → Rev 6
/tags/arelease/bench/systemc/main.cpp
File deleted
/tags/arelease/bench/systemc/stimulus.cpp
File deleted
/tags/arelease/bench/systemc/transactor.h
File deleted
/tags/arelease/bench/systemc/stimulus.h
File deleted
/tags/arelease/bench/verilog/top.v
File deleted
/tags/arelease/rtl/systemc/stimulus.h
File deleted
/tags/arelease/rtl/systemc/md5.h
File deleted
/tags/arelease/rtl/systemc/Makefile.defs
File deleted
/tags/arelease/rtl/systemc/Makefile
File deleted
/tags/arelease/rtl/systemc/main.cpp
File deleted
/tags/arelease/rtl/systemc/md5.cpp
File deleted
/tags/arelease/rtl/systemc/stimulus.cpp
File deleted
/tags/arelease/rtl/systemc/transactor.h
File deleted
/tags/arelease/rtl/verilog/md5.v
File deleted
/trunk/bench/systemc/main.cpp
File deleted
/trunk/bench/systemc/stimulus.cpp
File deleted
/trunk/bench/systemc/transactor.h
File deleted
/trunk/bench/systemc/stimulus.h
File deleted
/trunk/bench/verilog/top.v
File deleted
/trunk/rtl/systemc/stimulus.h
File deleted
/trunk/rtl/systemc/md5.h
File deleted
/trunk/rtl/systemc/Makefile.defs
File deleted
/trunk/rtl/systemc/Makefile
File deleted
/trunk/rtl/systemc/main.cpp
File deleted
/trunk/rtl/systemc/md5.cpp
File deleted
/trunk/rtl/systemc/stimulus.cpp
File deleted
/trunk/rtl/systemc/transactor.h
File deleted
/trunk/rtl/verilog/md5.v
File deleted
/systemcmd5/trunk/rtl/systemc/md5.cpp
0,0 → 1,530
////////////////////////////////////////////////////////////////////// |
//// //// |
//// MD5 main implementation file //// |
//// //// |
//// This file is part of the SystemC MD5 //// |
//// //// |
//// Description: //// |
//// MD5 main implementation file //// |
//// //// |
//// To Do: //// |
//// - done //// |
//// //// |
//// Author(s): //// |
//// - Javier Castillo, jcastilo@opencores.org //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2000 Authors and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
// |
// CVS Revision History |
// |
// $Log: not supported by cvs2svn $ |
// Revision 1.1.1.1 2004/09/08 16:24:49 jcastillo |
// Initial release |
// |
|
#include "md5.h" |
|
|
void |
md5::md5_rom () |
{ |
switch (round64.read ()) |
{ |
case 0: |
t.write (0xD76AA478070); |
break; |
case 1: |
t.write (0xE8C7B7560C1); |
break; |
case 2: |
t.write (0x242070DB112); |
break; |
case 3: |
t.write (0xC1BDCEEE163); |
break; |
case 4: |
t.write (0xF57C0FAF074); |
break; |
case 5: |
t.write (0x4787C62A0C5); |
break; |
case 6: |
t.write (0xA8304613116); |
break; |
case 7: |
t.write (0xFD469501167); |
break; |
case 8: |
t.write (0x698098D8078); |
break; |
case 9: |
t.write (0x8B44F7AF0C9); |
break; |
case 10: |
t.write (0xFFFF5BB111A); |
break; |
case 11: |
t.write (0x895CD7BE16B); |
break; |
case 12: |
t.write (0x6B90112207C); |
break; |
case 13: |
t.write (0xFD9871930CD); |
break; |
case 14: |
t.write (0xA679438E11E); |
break; |
case 15: |
t.write (0x49B4082116F); |
break; |
|
case 16: |
t.write (0xf61e2562051); |
break; |
case 17: |
t.write (0xc040b340096); |
break; |
case 18: |
t.write (0x265e5a510EB); |
break; |
case 19: |
t.write (0xe9b6c7aa140); |
break; |
case 20: |
t.write (0xd62f105d055); |
break; |
case 21: |
t.write (0x0244145309A); |
break; |
case 22: |
t.write (0xd8a1e6810EF); |
break; |
case 23: |
t.write (0xe7d3fbc8144); |
break; |
case 24: |
t.write (0x21e1cde6059); |
break; |
case 25: |
t.write (0xc33707d609E); |
break; |
case 26: |
t.write (0xf4d50d870E3); |
break; |
case 27: |
t.write (0x455a14ed148); |
break; |
case 28: |
t.write (0xa9e3e90505D); |
break; |
case 29: |
t.write (0xfcefa3f8092); |
break; |
case 30: |
t.write (0x676f02d90E7); |
break; |
case 31: |
t.write (0x8d2a4c8a14C); |
break; |
|
case 32: |
t.write (0xfffa3942045); |
break; |
case 33: |
t.write (0x8771f6810B8); |
break; |
case 34: |
t.write (0x6d9d612210B); |
break; |
case 35: |
t.write (0xfde5380c17E); |
break; |
case 36: |
t.write (0xa4beea44041); |
break; |
case 37: |
t.write (0x4bdecfa90B4); |
break; |
case 38: |
t.write (0xf6bb4b60107); |
break; |
case 39: |
t.write (0xbebfbc7017A); |
break; |
case 40: |
t.write (0x289b7ec604D); |
break; |
case 41: |
t.write (0xeaa127fa0B0); |
break; |
case 42: |
t.write (0xd4ef3085103); |
break; |
case 43: |
t.write (0x04881d05176); |
break; |
case 44: |
t.write (0xd9d4d039049); |
break; |
case 45: |
t.write (0xe6db99e50BC); |
break; |
case 46: |
t.write (0x1fa27cf810F); |
break; |
case 47: |
t.write (0xc4ac5665172); |
break; |
|
case 48: |
t.write (0xf4292244060); |
break; |
case 49: |
t.write (0x432aff970A7); |
break; |
case 50: |
t.write (0xab9423a70FE); |
break; |
case 51: |
t.write (0xfc93a039155); |
break; |
case 52: |
t.write (0x655b59c306C); |
break; |
case 53: |
t.write (0x8f0ccc920A3); |
break; |
case 54: |
t.write (0xffeff47d0FA); |
break; |
case 55: |
t.write (0x85845dd1151); |
break; |
case 56: |
t.write (0x6fa87e4f068); |
break; |
case 57: |
t.write (0xfe2ce6e00AF); |
break; |
case 58: |
t.write (0xa30143140F6); |
break; |
case 59: |
t.write (0x4e0811a115D); |
break; |
case 60: |
t.write (0xf7537e82064); |
break; |
case 61: |
t.write (0xbd3af2350AB); |
break; |
case 62: |
t.write (0x2ad7d2bb0F2); |
break; |
case 63: |
t.write (0xeb86d391159); |
break; |
|
} |
} |
|
|
void |
md5::funcs () |
{ |
sc_uint < 32 > aux, fr_var, tr_var, rotate1, rotate2; |
sc_uint < 8 > s_var; |
sc_uint < 4 > nblock; |
sc_uint < 32 > message_var[16]; |
|
message_var[0]=message.read().range(511,480); |
message_var[1]=message.read().range(479,448); |
message_var[2]=message.read().range(447,416); |
message_var[3]=message.read().range(415,384); |
message_var[4]=message.read().range(383,352); |
message_var[5]=message.read().range(351,320); |
message_var[6]=message.read().range(319,288); |
message_var[7]=message.read().range(287,256); |
message_var[8]=message.read().range(255,224); |
message_var[9]=message.read().range(223,192); |
message_var[10]=message.read().range(191,160); |
message_var[11]=message.read().range(159,128); |
message_var[12]=message.read().range(127,96); |
message_var[13]=message.read().range(95,64); |
message_var[14]=message.read().range(63,32); |
message_var[15]=message.read().range(31,0); |
|
fr_var = 0; |
|
switch (round.read ()) |
{ |
case 0: |
fr_var = ((br.read () & cr.read ()) | (~br.read () & dr.read ())); |
break; |
case 1: |
fr_var = ((br.read () & dr.read ()) | (cr.read () & (~dr.read ()))); |
break; |
case 2: |
fr_var = (br.read () ^ cr.read () ^ dr.read ()); |
break; |
case 3: |
fr_var = (cr.read () ^ (br.read () | ~dr.read ())); |
break; |
default: |
break; |
} |
|
tr_var = t.read ().range (43, 12); |
s_var = t.read ().range (11, 4); |
nblock = t.read ().range (3, 0); |
|
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; |
|
rotate1 = aux << (int) s_var; |
rotate2 = aux >> (int) (32 - s_var); |
func_out.write (br.read () + (rotate1 | rotate2)); |
|
} |
|
void |
md5::round64FSM () |
{ |
|
next_ar.write (ar.read ()); |
next_br.write (br.read ()); |
next_cr.write (cr.read ()); |
next_dr.write (dr.read ()); |
next_round64.write (round64.read ()); |
next_round.write (round.read ()); |
hash_generated.write (0); |
|
if (generate_hash.read () != 0) |
{ |
next_ar.write (dr.read ()); |
next_br.write (func_out.read ()); |
next_cr.write (br.read ()); |
next_dr.write (cr.read ()); |
} |
|
switch (round64.read ()) |
{ |
|
case 0: |
next_round.write (0); |
if (generate_hash.read ()) |
{ |
next_round64.write (1); |
} |
break; |
case 15: |
case 31: |
case 47: |
next_round.write (round.read () + 1); |
next_round64.write (round64.read () + 1); |
break; |
case 63: |
next_round.write (0); |
next_round64.write (0); |
hash_generated.write (1); |
break; |
default: |
next_round64.write (round64.read () + 1); |
break; |
} |
|
if (newtext_i.read ()) |
{ |
next_ar.write (0x67452301); |
next_br.write (0xEFCDAB89); |
next_cr.write (0x98BADCFE); |
next_dr.write (0x10325476); |
next_round.write (0); |
next_round64.write (0); |
} |
|
if (getdata_state.read () == 0) |
{ |
next_ar.write (A.read ()); |
next_br.write (B.read ()); |
next_cr.write (C.read ()); |
next_dr.write (D.read ()); |
} |
} |
|
void |
md5::reg_signal () |
{ |
if (!reset) |
{ |
ready_o.write (0); |
data_o.write (0); |
message.write (0); |
|
ar.write (0x67452301); |
br.write (0xEFCDAB89); |
cr.write (0x98BADCFE); |
dr.write (0x10325476); |
|
getdata_state.write (0); |
generate_hash.write (0); |
|
round.write (0); |
round64.write (0); |
|
A.write (0x67452301); |
B.write (0xEFCDAB89); |
C.write (0x98BADCFE); |
D.write (0x10325476); |
|
} |
else |
{ |
ready_o.write (next_ready_o.read ()); |
data_o.write (next_data_o.read ()); |
message.write (next_message.read ()); |
|
ar.write (next_ar.read ()); |
br.write (next_br.read ()); |
cr.write (next_cr.read ()); |
dr.write (next_dr.read ()); |
|
A.write (next_A.read ()); |
B.write (next_B.read ()); |
C.write (next_C.read ()); |
D.write (next_D.read ()); |
|
generate_hash.write (next_generate_hash.read ()); |
getdata_state.write (next_getdata_state.read ()); |
|
round.write (next_round.read ()); |
round64.write (next_round64.read ()); |
|
} |
|
} |
|
|
void |
md5::md5_getdata () |
{ |
|
sc_biguint < 128 > data_o_var; |
sc_biguint < 512 > aux; |
|
sc_uint < 32 > A_t, B_t, C_t, D_t; |
|
next_A.write (A.read ()); |
next_B.write (B.read ()); |
next_C.write (C.read ()); |
next_D.write (D.read ()); |
|
next_generate_hash.write (0); |
next_ready_o.write (0); |
next_data_o.write (0); |
|
aux = message.read (); |
next_message.write (message.read ()); |
next_getdata_state.write (getdata_state.read ()); |
|
if (newtext_i.read ()) |
{ |
next_A.write (0x67452301); |
next_B.write (0xEFCDAB89); |
next_C.write (0x98BADCFE); |
next_D.write (0x10325476); |
next_getdata_state.write (0); |
} |
|
switch (getdata_state.read ()) |
{ |
|
case 0: |
if (load_i.read ()) |
{ |
aux.range (511, 384) = data_i.read (); |
next_message.write (aux); |
next_getdata_state.write (1); |
} |
break; |
case 1: |
if (load_i.read ()) |
{ |
aux.range (383, 256) = data_i.read (); |
next_message.write (aux); |
next_getdata_state.write (2); |
} |
break; |
case 2: |
if (load_i.read ()) |
{ |
aux.range (255, 128) = data_i.read (); |
next_message.write (aux); |
next_getdata_state.write (3); |
} |
break; |
case 3: |
if (load_i.read ()) |
{ |
aux.range (127, 0) = data_i.read (); |
next_message.write (aux); |
next_getdata_state.write (4); |
next_generate_hash.write (1); |
} |
break; |
case 4: |
next_generate_hash.write (1); |
|
A_t = dr.read () + A.read (); |
B_t = func_out.read () + B.read (); |
C_t = br.read () + C.read (); |
D_t = cr.read () + D.read (); |
|
data_o_var.range (127, 96) = A_t; |
data_o_var.range (95, 64) = B_t; |
data_o_var.range (63, 32) = C_t; |
data_o_var.range (31, 0) = D_t; |
next_data_o.write (data_o_var); |
|
|
if (hash_generated.read ()) |
{ |
next_A.write (A_t); |
next_B.write (B_t); |
next_C.write (C_t); |
next_D.write (D_t); |
next_getdata_state.write (0); |
next_ready_o.write (1); |
next_generate_hash.write (0); |
} |
break; |
} |
|
} |
/systemcmd5/trunk/rtl/systemc/stimulus.cpp
0,0 → 1,121
////////////////////////////////////////////////////////////////////// |
//// //// |
//// MD5 stimulus //// |
//// //// |
//// This file is part of the SystemC MD5 //// |
//// //// |
//// Description: //// |
//// MD5 stimulus file //// |
//// //// |
//// To Do: //// |
//// - done //// |
//// //// |
//// Author(s): //// |
//// - Javier Castillo, jcastilo@opencores.org //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2000 Authors and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
// |
// CVS Revision History |
// |
// $Log: not supported by cvs2svn $ |
// Revision 1.1.1.1 2004/09/08 16:24:49 jcastillo |
// Initial release |
// |
|
#include "stimulus.h" |
|
void |
test::tb () |
{ |
|
transactor->resetea (); |
|
transactor->wait_cycles (5); |
|
//hash of "" |
transactor->new_text (); |
transactor->hash (0x00000080, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
|
transactor->print_result (); |
|
//hash of "a" |
transactor->new_text (); |
transactor->hash (0x00008061, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x8, 0x0); |
|
transactor->print_result (); |
|
//hash of "abc" |
transactor->new_text (); |
transactor->hash (0x80636261, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x18, 0x0); |
|
transactor->print_result (); |
|
//hash of "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" |
transactor->new_text (); |
transactor->hash (0x44434241, 0x48474645, 0x4C4B4A49, 0x504F4E4D); |
transactor->hash (0x54535251, 0x58575655, 0x62615A59, 0x66656463); |
transactor->hash (0x6A696867, 0x6E6D6C6B, 0x7271706F, 0x76757473); |
transactor->hash (0x7A797877, 0x33323130, 0x37363534, 0x00803938); |
|
transactor->wait_result (); |
|
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x1f0, 0x0); |
|
transactor->print_result (); |
|
//hash of "1233456789012334567890123345678901233456789012334567890123345678901233456789012334567890" |
transactor->new_text (); |
transactor->hash (0x34333231, 0x38373635, 0x32313039, 0x36353433); |
transactor->hash (0x30393837, 0x34333231, 0x38373635, 0x32313039); |
transactor->hash (0x36353433, 0x30393837, 0x34333231, 0x38373635); |
transactor->hash (0x32313039, 0x36353433, 0x30393837, 0x34333231); |
|
transactor->wait_result(); |
|
transactor->hash (0x38373635, 0x32313039, 0x36353433, 0x30393837); |
transactor->hash (0x80, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x280, 0x0); |
|
transactor->print_result (); |
|
|
|
} |
/systemcmd5/trunk/rtl/systemc/transactor.h
0,0 → 1,162
////////////////////////////////////////////////////////////////////// |
//// //// |
//// MD5 transactor //// |
//// //// |
//// This file is part of the SystemC MD5 //// |
//// //// |
//// Description: //// |
//// MD5 transactor //// |
//// //// |
//// To Do: //// |
//// - done //// |
//// //// |
//// Author(s): //// |
//// - Javier Castillo, jcastilo@opencores.org //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2000 Authors and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
// |
// CVS Revision History |
// |
// $Log: not supported by cvs2svn $ |
// Revision 1.1.1.1 2004/09/08 16:24:49 jcastillo |
// Initial release |
// |
|
#include "systemc.h" |
|
class transactor_ports:public sc_module |
{ |
public: |
|
// Ports |
sc_in < bool > clk; |
sc_out < bool > reset; |
|
sc_out < bool > load_i; |
sc_in < bool > ready_o; |
sc_out < bool > newtext_i; |
|
//Input must be padded and in little endian mode |
sc_out < sc_biguint < 128 > >data_i; |
sc_in < sc_biguint < 128 > >data_o; |
}; |
|
|
class rw_task_if:virtual public sc_interface |
{ |
|
public: |
//Funciones para el transactor |
virtual void resetea (void) = 0; |
virtual void new_text (void) = 0; |
virtual void print_result (void) = 0; |
virtual void wait_result (void) = 0; |
virtual void hash (sc_uint < 32 > data_4, sc_uint < 32 > data_3, |
sc_uint < 32 > data_2, sc_uint < 32 > data_1) = 0; |
virtual void wait_cycles (int cycles) = 0; |
|
}; |
|
|
//Transactor |
class md5_transactor:public rw_task_if, public transactor_ports |
{ |
|
public: |
|
SC_CTOR (md5_transactor) |
{ |
|
cout.unsetf (ios::dec); |
cout.setf (ios::hex); |
cout.setf (ios::showbase); |
|
} |
|
|
|
void resetea (void) |
{ |
reset.write (0); |
wait (clk->posedge_event ()); |
reset.write (1); |
cout << "Reseteado" << endl; |
} |
|
void new_text () |
{ |
newtext_i.write (1); |
wait (clk->posedge_event ()); |
newtext_i.write (0); |
} |
|
void wait_result () |
{ |
wait (ready_o->posedge_event ()); |
} |
|
|
void print_result () |
{ |
sc_biguint < 128 > data_o_var; |
|
wait (ready_o->posedge_event ()); |
data_o_var = data_o.read (); |
|
cout << "HASH: " << (int) (sc_uint < 32 >) data_o_var.range (127,96) << " " << (int) (sc_uint < 32 >) data_o_var.range (95,64) << " " << (int) (sc_uint <32 >) |
data_o_var.range (63,32) << " " << (int) (sc_uint <32 >) data_o_var.range (31,0) <<endl; |
|
} |
|
void hash (sc_uint < 32 > data_4, sc_uint < 32 > data_3, |
sc_uint < 32 > data_2, sc_uint < 32 > data_1) |
{ |
sc_biguint < 128 > data_t; |
|
wait (clk->posedge_event ()); |
load_i.write (1); |
data_t.range (127, 96) = data_4; |
data_t.range (95, 64) = data_3; |
data_t.range (63, 32) = data_2; |
data_t.range (31, 0) = data_1; |
data_i.write (data_t); |
wait (clk->posedge_event ()); |
load_i.write (0); |
|
} |
|
|
void wait_cycles (int cycles) |
{ |
for (int i = 0; i < cycles; i++) |
{ |
wait (clk->posedge_event ()); |
} |
} |
|
}; |
/systemcmd5/trunk/rtl/systemc/main.cpp
0,0 → 1,126
////////////////////////////////////////////////////////////////////// |
//// //// |
//// MD5 main simulation file //// |
//// //// |
//// This file is part of the SystemC MD5 //// |
//// //// |
//// Description: //// |
//// MD5 main simulation file //// |
//// //// |
//// To Do: //// |
//// - done //// |
//// //// |
//// Author(s): //// |
//// - Javier Castillo, jcastilo@opencores.org //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2000 Authors and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
// |
// CVS Revision History |
// |
// $Log: not supported by cvs2svn $ |
|
|
#include "systemc.h" |
#include "iostream.h" |
#include "md5.h" |
#include "stimulus.h" |
|
int |
sc_main (int argc, char *argv[]) |
{ |
|
sc_clock clk ("clk", 20); |
|
test *t; |
md5_transactor *tr; |
md5 *md51; |
|
t = new test ("testbench"); |
tr = new md5_transactor ("md5_transactor"); |
md51 = new md5 ("md5"); |
|
t->transactor (*tr); |
|
sc_signal < bool > reset; |
sc_signal < bool > load_i; |
sc_signal < bool > newtext_i; |
sc_signal < sc_biguint < 128 > >data_i; |
sc_signal < sc_biguint < 128 > >data_o; |
sc_signal < bool > ready_o; |
|
md51->clk (clk); |
md51->reset (reset); |
md51->load_i (load_i); |
md51->newtext_i (newtext_i); |
md51->data_i (data_i); |
md51->data_o (data_o); |
md51->ready_o (ready_o); |
|
tr->clk (clk); |
tr->reset (reset); |
tr->load_i (load_i); |
tr->newtext_i (newtext_i); |
tr->data_i (data_i); |
tr->data_o (data_o); |
tr->ready_o (ready_o); |
|
|
sc_trace_file *tf = sc_create_vcd_trace_file ("md5"); |
|
sc_trace (tf, clk, "clk"); |
sc_trace (tf, reset, "reset"); |
|
sc_trace (tf, load_i, "load_i"); |
sc_trace (tf, data_i, "data_i"); |
|
sc_trace (tf, data_o, "data_o"); |
sc_trace (tf, ready_o, "ready_o"); |
|
sc_trace (tf, md51->hash_generated, "hash_generated"); |
sc_trace (tf, md51->generate_hash, "generate_hash"); |
|
sc_trace (tf, md51->round64, "round64"); |
sc_trace (tf, md51->round, "round"); |
sc_trace (tf, md51->message, "message"); |
sc_trace (tf, md51->getdata_state, "getdata_state"); |
|
sc_trace (tf, md51->ar, "ar"); |
sc_trace (tf, md51->br, "br"); |
sc_trace (tf, md51->cr, "cr"); |
sc_trace (tf, md51->dr, "dr"); |
sc_trace (tf, md51->t, "t"); |
|
sc_trace (tf, md51->func_out, "func_out"); |
|
sc_start (20, SC_US); |
|
sc_close_vcd_trace_file (tf); |
|
return 0; |
|
} |
/systemcmd5/trunk/rtl/systemc/md5.h
0,0 → 1,118
////////////////////////////////////////////////////////////////////// |
//// //// |
//// MD5 header //// |
//// //// |
//// This file is part of the SystemC MD5 //// |
//// //// |
//// Description: //// |
//// MD5 top file header //// |
//// //// |
//// To Do: //// |
//// - done //// |
//// //// |
//// Author(s): //// |
//// - Javier Castillo, jcastilo@opencores.org //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2000 Authors and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
// |
// CVS Revision History |
// |
// $Log: not supported by cvs2svn $ |
|
#include "systemc.h" |
|
SC_MODULE (md5) |
{ |
|
sc_in < bool > clk; |
sc_in < bool > reset; |
|
sc_in < bool > load_i; |
sc_out < bool > ready_o; |
sc_in < bool > newtext_i; |
|
|
//Input must be padded and in little endian mode |
sc_in < sc_biguint < 128 > >data_i; |
sc_out < sc_biguint < 128 > >data_o; |
|
|
//Signals |
sc_signal < sc_uint < 32 > >ar, br, cr, dr; |
sc_signal < sc_uint < 32 > >next_ar, next_br, next_cr, next_dr; |
sc_signal < sc_uint < 32 > >A, B, C, D; |
sc_signal < sc_uint < 32 > >next_A, next_B, next_C, next_D; |
|
sc_signal < bool > next_ready_o; |
sc_signal < sc_biguint < 128 > >next_data_o; |
|
sc_signal < sc_biguint < 512 > >message, next_message; |
sc_signal < bool > generate_hash, hash_generated, next_generate_hash; |
|
sc_signal < sc_uint < 3 > >getdata_state, next_getdata_state; |
|
sc_signal < sc_uint < 2 > >round, next_round; |
sc_signal < sc_uint < 6 > >round64, next_round64; |
|
sc_signal < sc_uint < 44 > >t; |
|
sc_signal < sc_uint < 32 > >func_out; |
|
void md5_getdata (); |
void reg_signal (); |
void round64FSM (); |
void md5_rom (); |
void funcs (); |
|
SC_CTOR (md5) |
{ |
|
SC_METHOD (reg_signal); |
sensitive_pos << clk; |
sensitive_neg << reset; |
|
SC_METHOD (md5_getdata); |
sensitive << newtext_i << data_i << load_i << getdata_state << |
hash_generated << message; |
sensitive << func_out << A << B << C << D << ar << br << cr << dr << |
generate_hash; |
|
SC_METHOD (round64FSM); |
sensitive << newtext_i << round << round64 << ar << br << cr << dr << |
generate_hash << func_out; |
sensitive << getdata_state << A << B << C << D; |
|
|
SC_METHOD (md5_rom); |
sensitive << round64; |
|
SC_METHOD (funcs); |
sensitive << t << ar << br << cr << dr << round << message << func_out; |
|
} |
}; |
/systemcmd5/trunk/rtl/systemc/stimulus.h
0,0 → 1,61
////////////////////////////////////////////////////////////////////// |
//// //// |
//// MD5 stimulus header //// |
//// //// |
//// This file is part of the SystemC MD5 //// |
//// //// |
//// Description: //// |
//// MD5 stimulus file header //// |
//// //// |
//// To Do: //// |
//// - done //// |
//// //// |
//// Author(s): //// |
//// - Javier Castillo, jcastilo@opencores.org //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2000 Authors and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
// |
// CVS Revision History |
// |
// $Log: not supported by cvs2svn $ |
|
#include "systemc.h" |
#include "transactor.h" |
|
class test:public sc_module |
{ |
public: |
void tb (); |
|
sc_port < rw_task_if > transactor; |
|
SC_CTOR (test) |
{ |
SC_THREAD (tb); |
} |
}; |
/systemcmd5/trunk/rtl/systemc/Makefile
0,0 → 1,14
TARGET_ARCH = linux |
|
CC = g++ |
OPT = -O3 |
DEBUG = -g |
OTHER = -Wall -Wno-deprecated |
EXTRA_CFLAGS = $(OPT) $(OTHER) |
# EXTRA_CFLAGS = $(DEBUG) $(OTHER) |
|
MODULE = md5 |
SRCS = md5.cpp stimulus.cpp main.cpp |
OBJS = $(SRCS:.cpp=.o) |
|
include Makefile.defs |
/systemcmd5/trunk/rtl/systemc/Makefile.defs
0,0 → 1,34
## Variable that points to SystemC installation path |
SYSTEMC = $(SYSTEMC_HOME) |
|
INCDIR = -I. -I.. -I../../bench -I$(SYSTEMC)/include |
LIBDIR = -L. -L.. -L$(SYSTEMC)/lib-$(TARGET_ARCH) |
|
# Build with maximum gcc warning level |
CFLAGS = $(PLATFORM_SPECIFIC_FLAGS) $(EXTRA_CFLAGS) |
|
LIBS = -lm -lsystemc $(EXTRA_LIBS) |
|
EXE = $(MODULE).x |
|
.SUFFIXES: .cpp .cc .o .x |
|
$(EXE): $(OBJS) $(SYSTEMC)/lib-$(TARGET_ARCH)/libsystemc.a |
$(CC) $(CFLAGS) $(INCDIR) $(LIBDIR) -o $@ $(OBJS) $(LIBS) $(SYSTEMC)/lib-$(TARGET_ARCH)/libsystemc.a 2>&1 | c++filt |
|
.cpp.o: |
$(CC) $(CFLAGS) $(INCDIR) -c $< $(USB_FLAGS) |
|
.cc.o: |
$(CC) $(CFLAGS) $(INCDIR) -c $< $(USB_FLAGS) |
|
clean:: |
rm -f $(OBJS) *~ $(EXE) |
|
ultraclean: clean |
rm -f Makefile.deps |
|
Makefile.deps: |
$(CC) $(CFLAGS) $(INCDIR) -M $(SRCS) >> Makefile.deps |
|
#include Makefile.deps |
/systemcmd5/trunk/rtl/verilog/md5.v
0,0 → 1,435
////////////////////////////////////////////////////////////////////// |
//// //// |
//// MD5 implementation //// |
//// //// |
//// This file is part of the SystemC MD5 //// |
//// //// |
//// Description: //// |
//// MD5 implementation //// |
//// //// |
//// To Do: //// |
//// - done //// |
//// //// |
//// Author(s): //// |
//// - Javier Castillo, jcastilo@opencores.org //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2000 Authors and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
// |
// CVS Revision History |
// |
// $Log: not supported by cvs2svn $ |
|
`timescale 10ns/1ns |
|
|
|
module md5(clk,reset,load_i,ready_o,newtext_i,data_i,data_o); |
|
input clk; |
input reset; |
input load_i; |
output ready_o; |
input newtext_i; |
|
|
//Input must be padded and in little endian mode |
input [127:0] data_i; |
output [127:0] data_o; |
|
reg ready_o, next_ready_o; |
reg [127:0] data_o, next_data_o; |
|
reg [5:0] round64, next_round64; |
reg [43:0] t; |
|
|
reg [31:0] ar,br,cr,dr,func_out, next_ar,next_br, next_cr, next_dr; |
reg [31:0] A,B,C,D,next_A,next_B, next_C, next_D; |
reg [511:0] message, next_message; |
reg [2:0] round,next_round; |
reg next_generate_hash,generate_hash; |
reg hash_generated; |
|
reg [2:0] next_getdata_state, getdata_state; |
|
//rom process |
always @(round64) |
begin |
|
case(round64) |
0: t = 44'hD76AA478070; |
1: t = 44'hE8C7B7560C1; |
2: t = 44'h242070DB112; |
3: t = 44'hC1BDCEEE163; |
4: t = 44'hF57C0FAF074; |
5: t = 44'h4787C62A0C5; |
6: t = 44'hA8304613116; |
7: t = 44'hFD469501167; |
8: t = 44'h698098D8078; |
9: t = 44'h8B44F7AF0C9; |
10: t = 44'hFFFF5BB111A; |
11: t = 44'h895CD7BE16B; |
12: t = 44'h6B90112207C; |
13: t = 44'hFD9871930CD; |
14: t = 44'hA679438E11E; |
15: t = 44'h49B4082116F; |
|
16: t = 44'hf61e2562051; |
17: t = 44'hc040b340096; |
18: t = 44'h265e5a510EB; |
19: t = 44'he9b6c7aa140; |
20: t = 44'hd62f105d055; |
21: t = 44'h0244145309A; |
22: t = 44'hd8a1e6810EF; |
23: t = 44'he7d3fbc8144; |
24: t = 44'h21e1cde6059; |
25: t = 44'hc33707d609E; |
26: t = 44'hf4d50d870E3; |
27: t = 44'h455a14ed148; |
28: t = 44'ha9e3e90505D; |
29: t = 44'hfcefa3f8092; |
30: t = 44'h676f02d90E7; |
31: t = 44'h8d2a4c8a14C; |
|
32: t = 44'hfffa3942045; |
33: t = 44'h8771f6810B8; |
34: t = 44'h6d9d612210B; |
35: t = 44'hfde5380c17E; |
36: t = 44'ha4beea44041; |
37: t = 44'h4bdecfa90B4; |
38: t = 44'hf6bb4b60107; |
39: t = 44'hbebfbc7017A; |
40: t = 44'h289b7ec604D; |
41: t = 44'heaa127fa0B0; |
42: t = 44'hd4ef3085103; |
43: t = 44'h04881d05176; |
44: t = 44'hd9d4d039049; |
45: t = 44'he6db99e50BC; |
46: t = 44'h1fa27cf810F; |
47: t = 44'hc4ac5665172; |
|
48: t = 44'hf4292244060; |
49: t = 44'h432aff970A7; |
50: t = 44'hab9423a70FE; |
51: t = 44'hfc93a039155; |
52: t = 44'h655b59c306C; |
53: t = 44'h8f0ccc920A3; |
54: t = 44'hffeff47d0FA; |
55: t = 44'h85845dd1151; |
56: t = 44'h6fa87e4f068; |
57: t = 44'hfe2ce6e00AF; |
58: t = 44'ha30143140F6; |
59: t = 44'h4e0811a115D; |
60: t = 44'hf7537e82064; |
61: t = 44'hbd3af2350AB; |
62: t = 44'h2ad7d2bb0F2; |
63: t = 44'heb86d391159; |
endcase |
end |
//end process rom |
|
|
//funcs process |
|
|
reg [31:0] aux31,fr_var,tr_var,rotate1,rotate2; |
reg [7:0] s_var; |
reg [3:0] nblock; |
reg [31:0] message_var[15:0]; |
|
always @(t or ar or br or cr or dr or round or message or func_out or message_var[0] or message_var[1] or message_var[2] or message_var[3] |
or message_var[4] or message_var[5] or message_var[6] or message_var[7] or message_var[8] or message_var[9] or message_var[10] |
or message_var[11] or message_var[12] or message_var[13] or message_var[14] or message_var[15]) |
begin |
|
message_var[0]=message[511:480]; |
message_var[1]=message[479:448]; |
message_var[2]=message[447:416]; |
message_var[3]=message[415:384]; |
message_var[4]=message[383:352]; |
message_var[5]=message[351:320]; |
message_var[6]=message[319:288]; |
message_var[7]=message[287:256]; |
message_var[8]=message[255:224]; |
message_var[9]=message[223:192]; |
message_var[10]=message[191:160]; |
message_var[11]=message[159:128]; |
message_var[12]=message[127:96]; |
message_var[13]=message[95:64]; |
message_var[14]=message[63:32]; |
message_var[15]=message[31:0]; |
|
fr_var=0; |
|
case(round) |
0: fr_var=((br&cr)|(~br&dr)); |
1: fr_var=((br&dr)|(cr& (~dr))); |
2: fr_var=(br^cr^dr); |
3: fr_var=(cr^(br|~dr)); |
endcase |
|
|
tr_var=t[43:12]; |
s_var=t[11:4]; |
nblock=t[3:0]; |
|
aux31=(ar+fr_var+message_var[nblock]+tr_var); |
|
rotate1=aux31 << s_var; |
rotate2=aux31 >> (32-s_var); |
func_out=br+(rotate1 | rotate2); |
|
end |
//end process funcs |
|
|
//process round64FSM |
always @(newtext_i or round or round64 or ar or br or cr or dr or generate_hash or func_out or getdata_state or A or B or C or D) |
begin |
|
next_ar=ar; |
next_br=br; |
next_cr=cr; |
next_dr=dr; |
next_round64=round64; |
next_round=round; |
hash_generated=0; |
|
if(generate_hash!=0) |
begin |
next_ar=dr; |
next_br=func_out; |
next_cr=br; |
next_dr=cr; |
end |
|
case(round64) |
0: |
begin |
next_round=0; |
if(generate_hash) next_round64=1; |
end |
|
15,31,47: |
begin |
next_round=round+1; |
next_round64=round64+1; |
end |
|
63: |
begin |
next_round=0; |
next_round64=0; |
hash_generated=1; |
end |
|
default: next_round64=round64+1; |
|
endcase |
|
|
if(newtext_i) |
begin |
next_ar=32'h67452301; |
next_br=32'hEFCDAB89; |
next_cr=32'h98BADCFE; |
next_dr=32'h10325476; |
next_round=0; |
next_round64=0; |
end |
|
if(!getdata_state) |
begin |
next_ar=A; |
next_br=B; |
next_cr=C; |
next_dr=D; |
end |
|
end |
//end round64FSM process |
|
//regsignal process |
always @(posedge clk or negedge reset) |
begin |
|
if(!reset) |
begin |
ready_o=0; |
data_o=0; |
message=0; |
|
ar=32'h67452301; |
br=32'hEFCDAB89; |
cr=32'h98BADCFE; |
dr=32'h10325476; |
|
getdata_state=0; |
generate_hash=0; |
|
round=0; |
round64=0; |
A=32'h67452301; |
B=32'hEFCDAB89; |
C=32'h98BADCFE; |
D=32'h10325476; |
|
end |
else |
begin |
ready_o=next_ready_o; |
data_o=next_data_o; |
message=next_message; |
|
ar=next_ar; |
br=next_br; |
cr=next_cr; |
dr=next_dr; |
|
A=next_A; |
B=next_B; |
C=next_C; |
D=next_D; |
|
generate_hash=next_generate_hash; |
getdata_state=next_getdata_state; |
|
round=next_round; |
round64=next_round64; |
end |
end |
//end regsignals process |
|
|
//getdata process |
|
reg [127:0] data_o_var; |
reg [511:0] aux; |
wire [31:0] A_t,B_t,C_t,D_t; |
|
assign A_t=dr+A; |
assign B_t=func_out+B; |
assign C_t=br+C; |
assign D_t=cr+D; |
|
always @(newtext_i or A_t or B_t or C_t or D_t or data_i or load_i or getdata_state or generate_hash or hash_generated or message or func_out or A or B or C or D or ar or br or cr or dr) |
begin |
|
next_A=A; |
next_B=B; |
next_C=C; |
next_D=D; |
|
next_generate_hash=generate_hash; |
next_ready_o=0; |
next_getdata_state=getdata_state; |
|
next_data_o=0; |
aux=message; |
next_message=message; |
|
if(newtext_i) |
begin |
next_A=32'h67452301; |
next_B=32'hEFCDAB89; |
next_C=32'h98BADCFE; |
next_D=32'h10325476; |
next_getdata_state=0; |
end |
|
case(getdata_state) |
|
0 : |
begin |
if(load_i) |
begin |
aux[511:384]=data_i; |
next_message=aux; |
next_getdata_state=1; |
end |
end |
|
1 : |
begin |
if(load_i) |
begin |
aux[383:256]=data_i; |
next_message=aux; |
next_getdata_state=2; |
end |
end |
|
2 : |
begin |
if(load_i) |
begin |
aux[255:128]=data_i; |
next_message=aux; |
next_getdata_state=3; |
end |
end |
|
3 : |
begin |
if(load_i) |
begin |
aux[127:0]=data_i; |
next_message=aux; |
next_getdata_state=4; |
next_generate_hash=1; |
end |
end |
|
4 : |
begin |
|
next_generate_hash=1; |
|
data_o_var[127:96]=A_t; |
data_o_var[95:64]=B_t; |
data_o_var[63:32]=C_t; |
data_o_var[31:0]=D_t; |
next_data_o=data_o_var; |
|
if(hash_generated) |
begin |
next_A=A_t; |
next_B=B_t; |
next_C=C_t; |
next_D=D_t; |
next_getdata_state=0; |
next_ready_o=1; |
next_generate_hash=0; |
end |
end |
endcase |
end |
//end getdata process |
|
|
endmodule |
/systemcmd5/trunk/bench/systemc/stimulus.cpp
0,0 → 1,121
////////////////////////////////////////////////////////////////////// |
//// //// |
//// MD5 stimulus //// |
//// //// |
//// This file is part of the SystemC MD5 //// |
//// //// |
//// Description: //// |
//// MD5 stimulus file //// |
//// //// |
//// To Do: //// |
//// - done //// |
//// //// |
//// Author(s): //// |
//// - Javier Castillo, jcastilo@opencores.org //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2000 Authors and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
// |
// CVS Revision History |
// |
// $Log: not supported by cvs2svn $ |
// Revision 1.1.1.1 2004/09/08 16:24:49 jcastillo |
// Initial release |
// |
|
#include "stimulus.h" |
|
void |
test::tb () |
{ |
|
transactor->resetea (); |
|
transactor->wait_cycles (5); |
|
//hash of "" |
transactor->new_text (); |
transactor->hash (0x00000080, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
|
transactor->print_result (); |
|
//hash of "a" |
transactor->new_text (); |
transactor->hash (0x00008061, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x8, 0x0); |
|
transactor->print_result (); |
|
//hash of "abc" |
transactor->new_text (); |
transactor->hash (0x80636261, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x18, 0x0); |
|
transactor->print_result (); |
|
//hash of "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" |
transactor->new_text (); |
transactor->hash (0x44434241, 0x48474645, 0x4C4B4A49, 0x504F4E4D); |
transactor->hash (0x54535251, 0x58575655, 0x62615A59, 0x66656463); |
transactor->hash (0x6A696867, 0x6E6D6C6B, 0x7271706F, 0x76757473); |
transactor->hash (0x7A797877, 0x33323130, 0x37363534, 0x00803938); |
|
transactor->wait_result (); |
|
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x1f0, 0x0); |
|
transactor->print_result (); |
|
//hash of "1233456789012334567890123345678901233456789012334567890123345678901233456789012334567890" |
transactor->new_text (); |
transactor->hash (0x34333231, 0x38373635, 0x32313039, 0x36353433); |
transactor->hash (0x30393837, 0x34333231, 0x38373635, 0x32313039); |
transactor->hash (0x36353433, 0x30393837, 0x34333231, 0x38373635); |
transactor->hash (0x32313039, 0x36353433, 0x30393837, 0x34333231); |
|
transactor->wait_result(); |
|
transactor->hash (0x38373635, 0x32313039, 0x36353433, 0x30393837); |
transactor->hash (0x80, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x0, 0x0); |
transactor->hash (0x0, 0x0, 0x280, 0x0); |
|
transactor->print_result (); |
|
|
|
} |
/systemcmd5/trunk/bench/systemc/transactor.h
0,0 → 1,162
////////////////////////////////////////////////////////////////////// |
//// //// |
//// MD5 transactor //// |
//// //// |
//// This file is part of the SystemC MD5 //// |
//// //// |
//// Description: //// |
//// MD5 transactor //// |
//// //// |
//// To Do: //// |
//// - done //// |
//// //// |
//// Author(s): //// |
//// - Javier Castillo, jcastilo@opencores.org //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2000 Authors and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
// |
// CVS Revision History |
// |
// $Log: not supported by cvs2svn $ |
// Revision 1.1.1.1 2004/09/08 16:24:49 jcastillo |
// Initial release |
// |
|
#include "systemc.h" |
|
class transactor_ports:public sc_module |
{ |
public: |
|
// Ports |
sc_in < bool > clk; |
sc_out < bool > reset; |
|
sc_out < bool > load_i; |
sc_in < bool > ready_o; |
sc_out < bool > newtext_i; |
|
//Input must be padded and in little endian mode |
sc_out < sc_biguint < 128 > >data_i; |
sc_in < sc_biguint < 128 > >data_o; |
}; |
|
|
class rw_task_if:virtual public sc_interface |
{ |
|
public: |
//Funciones para el transactor |
virtual void resetea (void) = 0; |
virtual void new_text (void) = 0; |
virtual void print_result (void) = 0; |
virtual void wait_result (void) = 0; |
virtual void hash (sc_uint < 32 > data_4, sc_uint < 32 > data_3, |
sc_uint < 32 > data_2, sc_uint < 32 > data_1) = 0; |
virtual void wait_cycles (int cycles) = 0; |
|
}; |
|
|
//Transactor |
class md5_transactor:public rw_task_if, public transactor_ports |
{ |
|
public: |
|
SC_CTOR (md5_transactor) |
{ |
|
cout.unsetf (ios::dec); |
cout.setf (ios::hex); |
cout.setf (ios::showbase); |
|
} |
|
|
|
void resetea (void) |
{ |
reset.write (0); |
wait (clk->posedge_event ()); |
reset.write (1); |
cout << "Reseteado" << endl; |
} |
|
void new_text () |
{ |
newtext_i.write (1); |
wait (clk->posedge_event ()); |
newtext_i.write (0); |
} |
|
void wait_result () |
{ |
wait (ready_o->posedge_event ()); |
} |
|
|
void print_result () |
{ |
sc_biguint < 128 > data_o_var; |
|
wait (ready_o->posedge_event ()); |
data_o_var = data_o.read (); |
|
cout << "HASH: " << (int) (sc_uint < 32 >) data_o_var.range (127,96) << " " << (int) (sc_uint < 32 >) data_o_var.range (95,64) << " " << (int) (sc_uint <32 >) |
data_o_var.range (63,32) << " " << (int) (sc_uint <32 >) data_o_var.range (31,0) <<endl; |
|
} |
|
void hash (sc_uint < 32 > data_4, sc_uint < 32 > data_3, |
sc_uint < 32 > data_2, sc_uint < 32 > data_1) |
{ |
sc_biguint < 128 > data_t; |
|
wait (clk->posedge_event ()); |
load_i.write (1); |
data_t.range (127, 96) = data_4; |
data_t.range (95, 64) = data_3; |
data_t.range (63, 32) = data_2; |
data_t.range (31, 0) = data_1; |
data_i.write (data_t); |
wait (clk->posedge_event ()); |
load_i.write (0); |
|
} |
|
|
void wait_cycles (int cycles) |
{ |
for (int i = 0; i < cycles; i++) |
{ |
wait (clk->posedge_event ()); |
} |
} |
|
}; |
/systemcmd5/trunk/bench/systemc/main.cpp
0,0 → 1,126
////////////////////////////////////////////////////////////////////// |
//// //// |
//// MD5 main simulation file //// |
//// //// |
//// This file is part of the SystemC MD5 //// |
//// //// |
//// Description: //// |
//// MD5 main simulation file //// |
//// //// |
//// To Do: //// |
//// - done //// |
//// //// |
//// Author(s): //// |
//// - Javier Castillo, jcastilo@opencores.org //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2000 Authors and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
// |
// CVS Revision History |
// |
// $Log: not supported by cvs2svn $ |
|
|
#include "systemc.h" |
#include "iostream.h" |
#include "md5.h" |
#include "stimulus.h" |
|
int |
sc_main (int argc, char *argv[]) |
{ |
|
sc_clock clk ("clk", 20); |
|
test *t; |
md5_transactor *tr; |
md5 *md51; |
|
t = new test ("testbench"); |
tr = new md5_transactor ("md5_transactor"); |
md51 = new md5 ("md5"); |
|
t->transactor (*tr); |
|
sc_signal < bool > reset; |
sc_signal < bool > load_i; |
sc_signal < bool > newtext_i; |
sc_signal < sc_biguint < 128 > >data_i; |
sc_signal < sc_biguint < 128 > >data_o; |
sc_signal < bool > ready_o; |
|
md51->clk (clk); |
md51->reset (reset); |
md51->load_i (load_i); |
md51->newtext_i (newtext_i); |
md51->data_i (data_i); |
md51->data_o (data_o); |
md51->ready_o (ready_o); |
|
tr->clk (clk); |
tr->reset (reset); |
tr->load_i (load_i); |
tr->newtext_i (newtext_i); |
tr->data_i (data_i); |
tr->data_o (data_o); |
tr->ready_o (ready_o); |
|
|
sc_trace_file *tf = sc_create_vcd_trace_file ("md5"); |
|
sc_trace (tf, clk, "clk"); |
sc_trace (tf, reset, "reset"); |
|
sc_trace (tf, load_i, "load_i"); |
sc_trace (tf, data_i, "data_i"); |
|
sc_trace (tf, data_o, "data_o"); |
sc_trace (tf, ready_o, "ready_o"); |
|
sc_trace (tf, md51->hash_generated, "hash_generated"); |
sc_trace (tf, md51->generate_hash, "generate_hash"); |
|
sc_trace (tf, md51->round64, "round64"); |
sc_trace (tf, md51->round, "round"); |
sc_trace (tf, md51->message, "message"); |
sc_trace (tf, md51->getdata_state, "getdata_state"); |
|
sc_trace (tf, md51->ar, "ar"); |
sc_trace (tf, md51->br, "br"); |
sc_trace (tf, md51->cr, "cr"); |
sc_trace (tf, md51->dr, "dr"); |
sc_trace (tf, md51->t, "t"); |
|
sc_trace (tf, md51->func_out, "func_out"); |
|
sc_start (20, SC_US); |
|
sc_close_vcd_trace_file (tf); |
|
return 0; |
|
} |
/systemcmd5/trunk/bench/systemc/stimulus.h
0,0 → 1,61
////////////////////////////////////////////////////////////////////// |
//// //// |
//// MD5 stimulus header //// |
//// //// |
//// This file is part of the SystemC MD5 //// |
//// //// |
//// Description: //// |
//// MD5 stimulus file header //// |
//// //// |
//// To Do: //// |
//// - done //// |
//// //// |
//// Author(s): //// |
//// - Javier Castillo, jcastilo@opencores.org //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2000 Authors and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
// |
// CVS Revision History |
// |
// $Log: not supported by cvs2svn $ |
|
#include "systemc.h" |
#include "transactor.h" |
|
class test:public sc_module |
{ |
public: |
void tb (); |
|
sc_port < rw_task_if > transactor; |
|
SC_CTOR (test) |
{ |
SC_THREAD (tb); |
} |
}; |
/systemcmd5/trunk/bench/verilog/top.v
0,0 → 1,141
////////////////////////////////////////////////////////////////////// |
//// //// |
//// MD5 main simulation file //// |
//// //// |
//// This file is part of the SystemC MD5 //// |
//// //// |
//// Description: //// |
//// MD5 main simulation file //// |
//// //// |
//// To Do: //// |
//// - done //// |
//// //// |
//// Author(s): //// |
//// - Javier Castillo, jcastilo@opencores.org //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2000 Authors and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
// |
// CVS Revision History |
// |
// $Log: not supported by cvs2svn $ |
|
`timescale 10ns/1ns |
|
module top; |
|
|
reg clk; |
reg reset; |
reg load_i; |
wire ready_o; |
reg newtext_i; |
|
reg [127:0] data_i; |
wire [127:0] data_o; |
|
md5 m1(clk,reset,load_i,ready_o,newtext_i,data_i,data_o); |
|
initial |
|
begin |
clk = 'b1; |
reset = 'b1; |
load_i = 'b0; |
newtext_i= 'b0; |
data_i=128'h00008061000000000000000000000000; |
@(posedge clk); |
reset = #1 'b0; |
@(posedge clk); |
reset = #1 'b1; |
@(posedge clk); |
load_i = #1 'b1; |
@(posedge clk); |
load_i = #1 'b0; |
data_i= 128'h0; |
@(posedge clk); |
load_i = #1 'b1; |
@(posedge clk); |
@(posedge clk); |
load_i = #1 'b0; |
data_i= 128'h800000000; |
@(posedge clk); |
load_i =#1 'b1; |
@(posedge clk); |
load_i = #1 'b0; |
|
|
$display("Running test:"); |
wait(ready_o); |
$display("Hash for \"a\":"); |
$display("%H",data_o); |
|
@(posedge clk); |
newtext_i=#1'b1; |
@(posedge clk); |
newtext_i=#1'b0; |
|
@(posedge clk); |
data_i=128'h61616161616161616161616161616161; |
@(posedge clk); |
load_i = #1 'b1; |
@(posedge clk); |
@(posedge clk); |
@(posedge clk); |
@(posedge clk); |
load_i = #1 'b0; |
wait(ready_o); |
|
@(posedge clk); |
data_i=128'h61616161616161616161616161616161; |
@(posedge clk); |
load_i = #1 'b1; |
@(posedge clk); |
@(posedge clk); |
load_i = #1 'b0; |
data_i=128'h80000000000000000000000000; |
@(posedge clk); |
load_i = #1 'b1; |
@(posedge clk); |
load_i = #1 'b0; |
data_i=128'h30000000000; |
@(posedge clk); |
load_i = #1 'b1; |
@(posedge clk); |
load_i = #1 'b0; |
wait(ready_o); |
$display("Hash for two blocks full of \"a\":"); |
$display("%H",data_o); |
|
|
$finish; |
|
end |
|
always #5 clk = !clk; |
|
endmodule |
systemcmd5/trunk
Property changes :
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: systemcmd5/web_uploads
===================================================================
--- systemcmd5/web_uploads (nonexistent)
+++ systemcmd5/web_uploads (revision 6)
systemcmd5/web_uploads
Property changes :
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: systemcmd5/branches
===================================================================
--- systemcmd5/branches (nonexistent)
+++ systemcmd5/branches (revision 6)
systemcmd5/branches
Property changes :
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: systemcmd5/tags/arelease/bench/systemc/main.cpp
===================================================================
--- systemcmd5/tags/arelease/bench/systemc/main.cpp (nonexistent)
+++ systemcmd5/tags/arelease/bench/systemc/main.cpp (revision 6)
@@ -0,0 +1,126 @@
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// MD5 main simulation file ////
+//// ////
+//// This file is part of the SystemC MD5 ////
+//// ////
+//// Description: ////
+//// MD5 main simulation file ////
+//// ////
+//// To Do: ////
+//// - done ////
+//// ////
+//// Author(s): ////
+//// - Javier Castillo, jcastilo@opencores.org ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
+//// ////
+//// This source file may be used and distributed without ////
+//// restriction provided that this copyright statement is not ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer. ////
+//// ////
+//// This source file is free software; you can redistribute it ////
+//// and/or modify it under the terms of the GNU Lesser General ////
+//// Public License as published by the Free Software Foundation; ////
+//// either version 2.1 of the License, or (at your option) any ////
+//// later version. ////
+//// ////
+//// This source is distributed in the hope that it will be ////
+//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
+//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
+//// PURPOSE. See the GNU Lesser General Public License for more ////
+//// details. ////
+//// ////
+//// You should have received a copy of the GNU Lesser General ////
+//// Public License along with this source; if not, download it ////
+//// from http://www.opencores.org/lgpl.shtml ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//
+// CVS Revision History
+//
+// $Log: not supported by cvs2svn $
+
+
+#include "systemc.h"
+#include "iostream.h"
+#include "md5.h"
+#include "stimulus.h"
+
+int
+sc_main (int argc, char *argv[])
+{
+
+ sc_clock clk ("clk", 20);
+
+ test *t;
+ md5_transactor *tr;
+ md5 *md51;
+
+ t = new test ("testbench");
+ tr = new md5_transactor ("md5_transactor");
+ md51 = new md5 ("md5");
+
+ t->transactor (*tr);
+
+ sc_signal < bool > reset;
+ sc_signal < bool > load_i;
+ sc_signal < bool > newtext_i;
+ sc_signal < sc_biguint < 128 > >data_i;
+ sc_signal < sc_biguint < 128 > >data_o;
+ sc_signal < bool > ready_o;
+
+ md51->clk (clk);
+ md51->reset (reset);
+ md51->load_i (load_i);
+ md51->newtext_i (newtext_i);
+ md51->data_i (data_i);
+ md51->data_o (data_o);
+ md51->ready_o (ready_o);
+
+ tr->clk (clk);
+ tr->reset (reset);
+ tr->load_i (load_i);
+ tr->newtext_i (newtext_i);
+ tr->data_i (data_i);
+ tr->data_o (data_o);
+ tr->ready_o (ready_o);
+
+
+ sc_trace_file *tf = sc_create_vcd_trace_file ("md5");
+
+ sc_trace (tf, clk, "clk");
+ sc_trace (tf, reset, "reset");
+
+ sc_trace (tf, load_i, "load_i");
+ sc_trace (tf, data_i, "data_i");
+
+ sc_trace (tf, data_o, "data_o");
+ sc_trace (tf, ready_o, "ready_o");
+
+ sc_trace (tf, md51->hash_generated, "hash_generated");
+ sc_trace (tf, md51->generate_hash, "generate_hash");
+
+ sc_trace (tf, md51->round64, "round64");
+ sc_trace (tf, md51->round, "round");
+ sc_trace (tf, md51->message, "message");
+ sc_trace (tf, md51->getdata_state, "getdata_state");
+
+ sc_trace (tf, md51->ar, "ar");
+ sc_trace (tf, md51->br, "br");
+ sc_trace (tf, md51->cr, "cr");
+ sc_trace (tf, md51->dr, "dr");
+ sc_trace (tf, md51->t, "t");
+
+ sc_trace (tf, md51->func_out, "func_out");
+
+ sc_start (20, SC_US);
+
+ sc_close_vcd_trace_file (tf);
+
+ return 0;
+
+}
Index: systemcmd5/tags/arelease/bench/systemc/stimulus.cpp
===================================================================
--- systemcmd5/tags/arelease/bench/systemc/stimulus.cpp (nonexistent)
+++ systemcmd5/tags/arelease/bench/systemc/stimulus.cpp (revision 6)
@@ -0,0 +1,90 @@
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// MD5 stimulus ////
+//// ////
+//// This file is part of the SystemC MD5 ////
+//// ////
+//// Description: ////
+//// MD5 stimulus file ////
+//// ////
+//// To Do: ////
+//// - done ////
+//// ////
+//// Author(s): ////
+//// - Javier Castillo, jcastilo@opencores.org ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
+//// ////
+//// This source file may be used and distributed without ////
+//// restriction provided that this copyright statement is not ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer. ////
+//// ////
+//// This source file is free software; you can redistribute it ////
+//// and/or modify it under the terms of the GNU Lesser General ////
+//// Public License as published by the Free Software Foundation; ////
+//// either version 2.1 of the License, or (at your option) any ////
+//// later version. ////
+//// ////
+//// This source is distributed in the hope that it will be ////
+//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
+//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
+//// PURPOSE. See the GNU Lesser General Public License for more ////
+//// details. ////
+//// ////
+//// You should have received a copy of the GNU Lesser General ////
+//// Public License along with this source; if not, download it ////
+//// from http://www.opencores.org/lgpl.shtml ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//
+// CVS Revision History
+//
+// $Log: not supported by cvs2svn $
+
+#include "stimulus.h"
+
+void
+test::tb ()
+{
+
+ transactor->resetea ();
+
+ transactor->wait_cycles (5);
+
+ //hash of "a"
+ transactor->hash (0x00008061, 0x0, 0x0, 0x0);
+ transactor->hash (0x0, 0x0, 0x0, 0x0);
+ transactor->hash (0x0, 0x0, 0x0, 0x0);
+ transactor->hash (0x0, 0x0, 0x8, 0x0);
+
+ transactor->print_result ();
+
+ transactor->new_text ();
+
+ //hash of lots of "a"
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+
+ transactor->print_result ();
+
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x80, 0x0, 0x0, 0x0);
+ transactor->hash (0x0, 0x0, 0x300, 0x0);
+
+ transactor->print_result ();
+
+ transactor->new_text ();
+
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+
+ transactor->print_result ();
+}
Index: systemcmd5/tags/arelease/bench/systemc/transactor.h
===================================================================
--- systemcmd5/tags/arelease/bench/systemc/transactor.h (nonexistent)
+++ systemcmd5/tags/arelease/bench/systemc/transactor.h (revision 6)
@@ -0,0 +1,158 @@
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// MD5 transactor ////
+//// ////
+//// This file is part of the SystemC MD5 ////
+//// ////
+//// Description: ////
+//// MD5 transactor ////
+//// ////
+//// To Do: ////
+//// - done ////
+//// ////
+//// Author(s): ////
+//// - Javier Castillo, jcastilo@opencores.org ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
+//// ////
+//// This source file may be used and distributed without ////
+//// restriction provided that this copyright statement is not ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer. ////
+//// ////
+//// This source file is free software; you can redistribute it ////
+//// and/or modify it under the terms of the GNU Lesser General ////
+//// Public License as published by the Free Software Foundation; ////
+//// either version 2.1 of the License, or (at your option) any ////
+//// later version. ////
+//// ////
+//// This source is distributed in the hope that it will be ////
+//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
+//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
+//// PURPOSE. See the GNU Lesser General Public License for more ////
+//// details. ////
+//// ////
+//// You should have received a copy of the GNU Lesser General ////
+//// Public License along with this source; if not, download it ////
+//// from http://www.opencores.org/lgpl.shtml ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//
+// CVS Revision History
+//
+// $Log: not supported by cvs2svn $
+
+#include "systemc.h"
+
+class transactor_ports:public sc_module
+{
+public:
+
+ // Ports
+ sc_in < bool > clk;
+ sc_out < bool > reset;
+
+ sc_out < bool > load_i;
+ sc_in < bool > ready_o;
+ sc_out < bool > newtext_i;
+
+ //Input must be padded and in little endian mode
+ sc_out < sc_biguint < 128 > >data_i;
+ sc_in < sc_biguint < 128 > >data_o;
+};
+
+
+class rw_task_if:virtual public sc_interface
+{
+
+public:
+ //Funciones para el transactor
+ virtual void resetea (void) = 0;
+ virtual void new_text (void) = 0;
+ virtual void print_result (void) = 0;
+ virtual void hash (sc_uint < 32 > data_4, sc_uint < 32 > data_3,
+ sc_uint < 32 > data_2, sc_uint < 32 > data_1) = 0;
+ virtual void wait_cycles (int cycles) = 0;
+
+};
+
+
+//Transactor
+class md5_transactor:public rw_task_if, public transactor_ports
+{
+
+public:
+
+ SC_CTOR (md5_transactor)
+ {
+
+ cout.unsetf (ios::dec);
+ cout.setf (ios::hex);
+ cout.setf (ios::showbase);
+
+ }
+
+
+
+ void resetea (void)
+ {
+ reset.write (0);
+ wait (clk->posedge_event ());
+ reset.write (1);
+ cout << "Reseteado" << endl;
+ }
+
+ void new_text ()
+ {
+ newtext_i.write (1);
+ wait (clk->posedge_event ());
+ newtext_i.write (0);
+ }
+
+ void print_result ()
+ {
+ sc_biguint < 128 > data_o_var;
+
+ wait (ready_o->posedge_event ());
+ data_o_var = data_o.read ();
+ cout << "HASH: " << (int) (sc_uint < 32 >) data_o_var.range (127,
+ 96) << " " <<
+ (int) (sc_uint < 32 >) data_o_var.range (95,
+ 64) << " " << (int) (sc_uint <
+ 32 >)
+ data_o_var.range (63,
+ 32) << " " << (int) (sc_uint <
+ 32 >) data_o_var.range (31,
+ 0) <<
+ endl;
+ }
+
+ void hash (sc_uint < 32 > data_4, sc_uint < 32 > data_3,
+ sc_uint < 32 > data_2, sc_uint < 32 > data_1)
+ {
+ sc_biguint < 128 > data_t;
+
+ wait (clk->posedge_event ());
+ load_i.write (1);
+ data_t.range (127, 96) = data_4;
+ data_t.range (95, 64) = data_3;
+ data_t.range (63, 32) = data_2;
+ data_t.range (31, 0) = data_1;
+ data_i.write (data_t);
+ wait (clk->posedge_event ());
+ load_i.write (0);
+
+ }
+
+
+ void wait_cycles (int cycles)
+ {
+ for (int i = 0; i < cycles; i++)
+ {
+ wait (clk->posedge_event ());
+ }
+ }
+
+};
Index: systemcmd5/tags/arelease/bench/systemc/stimulus.h
===================================================================
--- systemcmd5/tags/arelease/bench/systemc/stimulus.h (nonexistent)
+++ systemcmd5/tags/arelease/bench/systemc/stimulus.h (revision 6)
@@ -0,0 +1,61 @@
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// MD5 stimulus header ////
+//// ////
+//// This file is part of the SystemC MD5 ////
+//// ////
+//// Description: ////
+//// MD5 stimulus file header ////
+//// ////
+//// To Do: ////
+//// - done ////
+//// ////
+//// Author(s): ////
+//// - Javier Castillo, jcastilo@opencores.org ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
+//// ////
+//// This source file may be used and distributed without ////
+//// restriction provided that this copyright statement is not ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer. ////
+//// ////
+//// This source file is free software; you can redistribute it ////
+//// and/or modify it under the terms of the GNU Lesser General ////
+//// Public License as published by the Free Software Foundation; ////
+//// either version 2.1 of the License, or (at your option) any ////
+//// later version. ////
+//// ////
+//// This source is distributed in the hope that it will be ////
+//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
+//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
+//// PURPOSE. See the GNU Lesser General Public License for more ////
+//// details. ////
+//// ////
+//// You should have received a copy of the GNU Lesser General ////
+//// Public License along with this source; if not, download it ////
+//// from http://www.opencores.org/lgpl.shtml ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//
+// CVS Revision History
+//
+// $Log: not supported by cvs2svn $
+
+#include "systemc.h"
+#include "transactor.h"
+
+class test:public sc_module
+{
+public:
+ void tb ();
+
+ sc_port < rw_task_if > transactor;
+
+ SC_CTOR (test)
+ {
+ SC_THREAD (tb);
+ }
+};
Index: systemcmd5/tags/arelease/bench/verilog/top.v
===================================================================
--- systemcmd5/tags/arelease/bench/verilog/top.v (nonexistent)
+++ systemcmd5/tags/arelease/bench/verilog/top.v (revision 6)
@@ -0,0 +1,141 @@
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// MD5 main simulation file ////
+//// ////
+//// This file is part of the SystemC MD5 ////
+//// ////
+//// Description: ////
+//// MD5 main simulation file ////
+//// ////
+//// To Do: ////
+//// - done ////
+//// ////
+//// Author(s): ////
+//// - Javier Castillo, jcastilo@opencores.org ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
+//// ////
+//// This source file may be used and distributed without ////
+//// restriction provided that this copyright statement is not ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer. ////
+//// ////
+//// This source file is free software; you can redistribute it ////
+//// and/or modify it under the terms of the GNU Lesser General ////
+//// Public License as published by the Free Software Foundation; ////
+//// either version 2.1 of the License, or (at your option) any ////
+//// later version. ////
+//// ////
+//// This source is distributed in the hope that it will be ////
+//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
+//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
+//// PURPOSE. See the GNU Lesser General Public License for more ////
+//// details. ////
+//// ////
+//// You should have received a copy of the GNU Lesser General ////
+//// Public License along with this source; if not, download it ////
+//// from http://www.opencores.org/lgpl.shtml ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//
+// CVS Revision History
+//
+// $Log: not supported by cvs2svn $
+
+`timescale 10ns/1ns
+
+module top;
+
+
+reg clk;
+reg reset;
+reg load_i;
+wire ready_o;
+reg newtext_i;
+
+reg [127:0] data_i;
+wire [127:0] data_o;
+
+md5 m1(clk,reset,load_i,ready_o,newtext_i,data_i,data_o);
+
+ initial
+
+ begin
+ clk = 'b1;
+ reset = 'b1;
+ load_i = 'b0;
+ newtext_i= 'b0;
+ data_i=128'h00008061000000000000000000000000;
+ @(posedge clk);
+ reset = #1 'b0;
+ @(posedge clk);
+ reset = #1 'b1;
+ @(posedge clk);
+ load_i = #1 'b1;
+ @(posedge clk);
+ load_i = #1 'b0;
+ data_i= 128'h0;
+ @(posedge clk);
+ load_i = #1 'b1;
+ @(posedge clk);
+ @(posedge clk);
+ load_i = #1 'b0;
+ data_i= 128'h800000000;
+ @(posedge clk);
+ load_i =#1 'b1;
+ @(posedge clk);
+ load_i = #1 'b0;
+
+
+ $display("Running test:");
+ wait(ready_o);
+ $display("Hash for \"a\":");
+ $display("%H",data_o);
+
+ @(posedge clk);
+ newtext_i=#1'b1;
+ @(posedge clk);
+ newtext_i=#1'b0;
+
+ @(posedge clk);
+ data_i=128'h61616161616161616161616161616161;
+ @(posedge clk);
+ load_i = #1 'b1;
+ @(posedge clk);
+ @(posedge clk);
+ @(posedge clk);
+ @(posedge clk);
+ load_i = #1 'b0;
+ wait(ready_o);
+
+ @(posedge clk);
+ data_i=128'h61616161616161616161616161616161;
+ @(posedge clk);
+ load_i = #1 'b1;
+ @(posedge clk);
+ @(posedge clk);
+ load_i = #1 'b0;
+ data_i=128'h80000000000000000000000000;
+ @(posedge clk);
+ load_i = #1 'b1;
+ @(posedge clk);
+ load_i = #1 'b0;
+ data_i=128'h30000000000;
+ @(posedge clk);
+ load_i = #1 'b1;
+ @(posedge clk);
+ load_i = #1 'b0;
+ wait(ready_o);
+ $display("Hash for two blocks full of \"a\":");
+ $display("%H",data_o);
+
+
+ $finish;
+
+ end
+
+ always #5 clk = !clk;
+
+endmodule
Index: systemcmd5/tags/arelease/rtl/systemc/main.cpp
===================================================================
--- systemcmd5/tags/arelease/rtl/systemc/main.cpp (nonexistent)
+++ systemcmd5/tags/arelease/rtl/systemc/main.cpp (revision 6)
@@ -0,0 +1,126 @@
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// MD5 main simulation file ////
+//// ////
+//// This file is part of the SystemC MD5 ////
+//// ////
+//// Description: ////
+//// MD5 main simulation file ////
+//// ////
+//// To Do: ////
+//// - done ////
+//// ////
+//// Author(s): ////
+//// - Javier Castillo, jcastilo@opencores.org ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
+//// ////
+//// This source file may be used and distributed without ////
+//// restriction provided that this copyright statement is not ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer. ////
+//// ////
+//// This source file is free software; you can redistribute it ////
+//// and/or modify it under the terms of the GNU Lesser General ////
+//// Public License as published by the Free Software Foundation; ////
+//// either version 2.1 of the License, or (at your option) any ////
+//// later version. ////
+//// ////
+//// This source is distributed in the hope that it will be ////
+//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
+//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
+//// PURPOSE. See the GNU Lesser General Public License for more ////
+//// details. ////
+//// ////
+//// You should have received a copy of the GNU Lesser General ////
+//// Public License along with this source; if not, download it ////
+//// from http://www.opencores.org/lgpl.shtml ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//
+// CVS Revision History
+//
+// $Log: not supported by cvs2svn $
+
+
+#include "systemc.h"
+#include "iostream.h"
+#include "md5.h"
+#include "stimulus.h"
+
+int
+sc_main (int argc, char *argv[])
+{
+
+ sc_clock clk ("clk", 20);
+
+ test *t;
+ md5_transactor *tr;
+ md5 *md51;
+
+ t = new test ("testbench");
+ tr = new md5_transactor ("md5_transactor");
+ md51 = new md5 ("md5");
+
+ t->transactor (*tr);
+
+ sc_signal < bool > reset;
+ sc_signal < bool > load_i;
+ sc_signal < bool > newtext_i;
+ sc_signal < sc_biguint < 128 > >data_i;
+ sc_signal < sc_biguint < 128 > >data_o;
+ sc_signal < bool > ready_o;
+
+ md51->clk (clk);
+ md51->reset (reset);
+ md51->load_i (load_i);
+ md51->newtext_i (newtext_i);
+ md51->data_i (data_i);
+ md51->data_o (data_o);
+ md51->ready_o (ready_o);
+
+ tr->clk (clk);
+ tr->reset (reset);
+ tr->load_i (load_i);
+ tr->newtext_i (newtext_i);
+ tr->data_i (data_i);
+ tr->data_o (data_o);
+ tr->ready_o (ready_o);
+
+
+ sc_trace_file *tf = sc_create_vcd_trace_file ("md5");
+
+ sc_trace (tf, clk, "clk");
+ sc_trace (tf, reset, "reset");
+
+ sc_trace (tf, load_i, "load_i");
+ sc_trace (tf, data_i, "data_i");
+
+ sc_trace (tf, data_o, "data_o");
+ sc_trace (tf, ready_o, "ready_o");
+
+ sc_trace (tf, md51->hash_generated, "hash_generated");
+ sc_trace (tf, md51->generate_hash, "generate_hash");
+
+ sc_trace (tf, md51->round64, "round64");
+ sc_trace (tf, md51->round, "round");
+ sc_trace (tf, md51->message, "message");
+ sc_trace (tf, md51->getdata_state, "getdata_state");
+
+ sc_trace (tf, md51->ar, "ar");
+ sc_trace (tf, md51->br, "br");
+ sc_trace (tf, md51->cr, "cr");
+ sc_trace (tf, md51->dr, "dr");
+ sc_trace (tf, md51->t, "t");
+
+ sc_trace (tf, md51->func_out, "func_out");
+
+ sc_start (20, SC_US);
+
+ sc_close_vcd_trace_file (tf);
+
+ return 0;
+
+}
Index: systemcmd5/tags/arelease/rtl/systemc/md5.cpp
===================================================================
--- systemcmd5/tags/arelease/rtl/systemc/md5.cpp (nonexistent)
+++ systemcmd5/tags/arelease/rtl/systemc/md5.cpp (revision 6)
@@ -0,0 +1,533 @@
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// MD5 main implementation file ////
+//// ////
+//// This file is part of the SystemC MD5 ////
+//// ////
+//// Description: ////
+//// MD5 main implementation file ////
+//// ////
+//// To Do: ////
+//// - done ////
+//// ////
+//// Author(s): ////
+//// - Javier Castillo, jcastilo@opencores.org ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
+//// ////
+//// This source file may be used and distributed without ////
+//// restriction provided that this copyright statement is not ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer. ////
+//// ////
+//// This source file is free software; you can redistribute it ////
+//// and/or modify it under the terms of the GNU Lesser General ////
+//// Public License as published by the Free Software Foundation; ////
+//// either version 2.1 of the License, or (at your option) any ////
+//// later version. ////
+//// ////
+//// This source is distributed in the hope that it will be ////
+//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
+//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
+//// PURPOSE. See the GNU Lesser General Public License for more ////
+//// details. ////
+//// ////
+//// You should have received a copy of the GNU Lesser General ////
+//// Public License along with this source; if not, download it ////
+//// from http://www.opencores.org/lgpl.shtml ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//
+// CVS Revision History
+//
+// $Log: not supported by cvs2svn $
+
+#define assign_uint_to_array() \
+{ \
+ message_var[0]=message.read().range(511,480); \
+ message_var[1]=message.read().range(479,448); \
+ message_var[2]=message.read().range(447,416); \
+ message_var[3]=message.read().range(415,384); \
+ message_var[4]=message.read().range(383,352); \
+ message_var[5]=message.read().range(351,320); \
+ message_var[6]=message.read().range(319,288); \
+ message_var[7]=message.read().range(287,256); \
+ message_var[8]=message.read().range(255,224); \
+ message_var[9]=message.read().range(223,192); \
+ message_var[10]=message.read().range(191,160); \
+ message_var[11]=message.read().range(159,128); \
+ message_var[12]=message.read().range(127,96); \
+ message_var[13]=message.read().range(95,64); \
+ message_var[14]=message.read().range(63,32); \
+ message_var[15]=message.read().range(31,0); \
+}
+
+
+#include "md5.h"
+
+
+void
+md5::md5_rom ()
+{
+ switch (round64.read ())
+ {
+ case 0:
+ t.write (0xD76AA478070);
+ break;
+ case 1:
+ t.write (0xE8C7B7560C1);
+ break;
+ case 2:
+ t.write (0x242070DB112);
+ break;
+ case 3:
+ t.write (0xC1BDCEEE163);
+ break;
+ case 4:
+ t.write (0xF57C0FAF074);
+ break;
+ case 5:
+ t.write (0x4787C62A0C5);
+ break;
+ case 6:
+ t.write (0xA8304613116);
+ break;
+ case 7:
+ t.write (0xFD469501167);
+ break;
+ case 8:
+ t.write (0x698098D8078);
+ break;
+ case 9:
+ t.write (0x8B44F7AF0C9);
+ break;
+ case 10:
+ t.write (0xFFFF5BB111A);
+ break;
+ case 11:
+ t.write (0x895CD7BE16B);
+ break;
+ case 12:
+ t.write (0x6B90112207C);
+ break;
+ case 13:
+ t.write (0xFD9871930CD);
+ break;
+ case 14:
+ t.write (0xA679438E11E);
+ break;
+ case 15:
+ t.write (0x49B4082116F);
+ break;
+
+ case 16:
+ t.write (0xf61e2562051);
+ break;
+ case 17:
+ t.write (0xc040b340096);
+ break;
+ case 18:
+ t.write (0x265e5a510EB);
+ break;
+ case 19:
+ t.write (0xe9b6c7aa140);
+ break;
+ case 20:
+ t.write (0xd62f105d055);
+ break;
+ case 21:
+ t.write (0x0244145309A);
+ break;
+ case 22:
+ t.write (0xd8a1e6810EF);
+ break;
+ case 23:
+ t.write (0xe7d3fbc8144);
+ break;
+ case 24:
+ t.write (0x21e1cde6059);
+ break;
+ case 25:
+ t.write (0xc33707d609E);
+ break;
+ case 26:
+ t.write (0xf4d50d870E3);
+ break;
+ case 27:
+ t.write (0x455a14ed148);
+ break;
+ case 28:
+ t.write (0xa9e3e90505D);
+ break;
+ case 29:
+ t.write (0xfcefa3f8092);
+ break;
+ case 30:
+ t.write (0x676f02d90E7);
+ break;
+ case 31:
+ t.write (0x8d2a4c8a14C);
+ break;
+
+ case 32:
+ t.write (0xfffa3942045);
+ break;
+ case 33:
+ t.write (0x8771f6810B8);
+ break;
+ case 34:
+ t.write (0x6d9d612210B);
+ break;
+ case 35:
+ t.write (0xfde5380c17E);
+ break;
+ case 36:
+ t.write (0xa4beea44041);
+ break;
+ case 37:
+ t.write (0x4bdecfa90B4);
+ break;
+ case 38:
+ t.write (0xf6bb4b60107);
+ break;
+ case 39:
+ t.write (0xbebfbc7017A);
+ break;
+ case 40:
+ t.write (0x289b7ec604D);
+ break;
+ case 41:
+ t.write (0xeaa127fa0B0);
+ break;
+ case 42:
+ t.write (0xd4ef3085103);
+ break;
+ case 43:
+ t.write (0x04881d05176);
+ break;
+ case 44:
+ t.write (0xd9d4d039049);
+ break;
+ case 45:
+ t.write (0xe6db99e50BC);
+ break;
+ case 46:
+ t.write (0x1fa27cf810F);
+ break;
+ case 47:
+ t.write (0xc4ac5665172);
+ break;
+
+ case 48:
+ t.write (0xf4292244060);
+ break;
+ case 49:
+ t.write (0x432aff970A7);
+ break;
+ case 50:
+ t.write (0xab9423a70FE);
+ break;
+ case 51:
+ t.write (0xfc93a039155);
+ break;
+ case 52:
+ t.write (0x655b59c306C);
+ break;
+ case 53:
+ t.write (0x8f0ccc920A3);
+ break;
+ case 54:
+ t.write (0xffeff47d0FA);
+ break;
+ case 55:
+ t.write (0x85845dd1151);
+ break;
+ case 56:
+ t.write (0x6fa87e4f068);
+ break;
+ case 57:
+ t.write (0xfe2ce6e00AF);
+ break;
+ case 58:
+ t.write (0xa30143140F6);
+ break;
+ case 59:
+ t.write (0x4e0811a115D);
+ break;
+ case 60:
+ t.write (0xf7537e82064);
+ break;
+ case 61:
+ t.write (0xbd3af2350AB);
+ break;
+ case 62:
+ t.write (0x2ad7d2bb0F2);
+ break;
+ case 63:
+ t.write (0xeb86d391159);
+ break;
+
+ }
+}
+
+
+void
+md5::funcs ()
+{
+ sc_uint < 32 > aux, fr_var, tr_var, rotate1, rotate2;
+ sc_uint < 8 > s_var;
+ sc_uint < 4 > nblock;
+ sc_uint < 32 > message_var[16];
+
+ assign_uint_to_array ();
+
+ fr_var = 0;
+
+ switch (round.read ())
+ {
+ case 0:
+ fr_var = ((br.read () & cr.read ()) | (~br.read () & dr.read ()));
+ break;
+ case 1:
+ fr_var = ((br.read () & dr.read ()) | (cr.read () & (~dr.read ())));
+ break;
+ case 2:
+ fr_var = (br.read () ^ cr.read () ^ dr.read ());
+ break;
+ case 3:
+ fr_var = (cr.read () ^ (br.read () | ~dr.read ()));
+ break;
+ default:
+ break;
+ }
+
+ tr_var = t.read ().range (43, 12);
+ s_var = t.read ().range (11, 4);
+ nblock = t.read ().range (3, 0);
+
+ 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;
+
+ rotate1 = aux << (int) s_var;
+ rotate2 = aux >> (int) (32 - s_var);
+ func_out.write (br.read () + (rotate1 | rotate2));
+
+}
+
+void
+md5::round64FSM ()
+{
+
+ next_ar.write (ar.read ());
+ next_br.write (br.read ());
+ next_cr.write (cr.read ());
+ next_dr.write (dr.read ());
+ next_round64.write (round64.read ());
+ next_round.write (round.read ());
+ hash_generated.write (0);
+
+ if (generate_hash.read () != 0)
+ {
+ next_ar.write (dr.read ());
+ next_br.write (func_out.read ());
+ next_cr.write (br.read ());
+ next_dr.write (cr.read ());
+ }
+
+ switch (round64.read ())
+ {
+
+ case 0:
+ next_round.write (0);
+ if (generate_hash.read ())
+ {
+ next_round64.write (1);
+ }
+ break;
+ case 15:
+ case 31:
+ case 47:
+ next_round.write (round.read () + 1);
+ next_round64.write (round64.read () + 1);
+ break;
+ case 63:
+ next_round.write (0);
+ next_round64.write (0);
+ hash_generated.write (1);
+ break;
+ default:
+ next_round64.write (round64.read () + 1);
+ break;
+ }
+
+ if (newtext_i.read ())
+ {
+ next_ar.write (0x67452301);
+ next_br.write (0xEFCDAB89);
+ next_cr.write (0x98BADCFE);
+ next_dr.write (0x10325476);
+ next_round.write (0);
+ next_round64.write (0);
+ }
+
+ if (getdata_state.read () == 0)
+ {
+ next_ar.write (A.read ());
+ next_br.write (B.read ());
+ next_cr.write (C.read ());
+ next_dr.write (D.read ());
+ }
+}
+
+void
+md5::reg_signal ()
+{
+ if (!reset)
+ {
+ ready_o.write (0);
+ data_o.write (0);
+ message.write (0);
+
+ ar.write (0x67452301);
+ br.write (0xEFCDAB89);
+ cr.write (0x98BADCFE);
+ dr.write (0x10325476);
+
+ getdata_state.write (0);
+ generate_hash.write (0);
+
+ round.write (0);
+ round64.write (0);
+
+ A.write (0x67452301);
+ B.write (0xEFCDAB89);
+ C.write (0x98BADCFE);
+ D.write (0x10325476);
+
+ }
+ else
+ {
+ ready_o.write (next_ready_o.read ());
+ data_o.write (next_data_o.read ());
+ message.write (next_message.read ());
+
+ ar.write (next_ar.read ());
+ br.write (next_br.read ());
+ cr.write (next_cr.read ());
+ dr.write (next_dr.read ());
+
+ A.write (next_A.read ());
+ B.write (next_B.read ());
+ C.write (next_C.read ());
+ D.write (next_D.read ());
+
+ generate_hash.write (next_generate_hash.read ());
+ getdata_state.write (next_getdata_state.read ());
+
+ round.write (next_round.read ());
+ round64.write (next_round64.read ());
+
+ }
+
+}
+
+
+void
+md5::md5_getdata ()
+{
+
+ sc_biguint < 128 > data_o_var;
+ sc_biguint < 512 > aux;
+
+ sc_uint < 32 > A_t, B_t, C_t, D_t;
+
+ next_A.write (A.read ());
+ next_B.write (B.read ());
+ next_C.write (C.read ());
+ next_D.write (D.read ());
+
+ next_generate_hash.write (0);
+ next_ready_o.write (0);
+ next_data_o.write (0);
+
+ aux = message.read ();
+ next_message.write (message.read ());
+ next_getdata_state.write (getdata_state.read ());
+
+ if (newtext_i.read ())
+ {
+ next_A.write (0x67452301);
+ next_B.write (0xEFCDAB89);
+ next_C.write (0x98BADCFE);
+ next_D.write (0x10325476);
+ next_getdata_state.write (0);
+ }
+
+ switch (getdata_state.read ())
+ {
+
+ case 0:
+ if (load_i.read ())
+ {
+ aux.range (511, 384) = data_i.read ();
+ next_message.write (aux);
+ next_getdata_state.write (1);
+ }
+ break;
+ case 1:
+ if (load_i.read ())
+ {
+ aux.range (383, 256) = data_i.read ();
+ next_message.write (aux);
+ next_getdata_state.write (2);
+ }
+ break;
+ case 2:
+ if (load_i.read ())
+ {
+ aux.range (255, 128) = data_i.read ();
+ next_message.write (aux);
+ next_getdata_state.write (3);
+ }
+ break;
+ case 3:
+ if (load_i.read ())
+ {
+ aux.range (127, 0) = data_i.read ();
+ next_message.write (aux);
+ next_getdata_state.write (4);
+ next_generate_hash.write (1);
+ }
+ break;
+ case 4:
+ next_generate_hash.write (1);
+
+ A_t = dr.read () + A.read ();
+ B_t = func_out.read () + B.read ();
+ C_t = br.read () + C.read ();
+ D_t = cr.read () + D.read ();
+
+ data_o_var.range (127, 96) = A_t;
+ data_o_var.range (95, 64) = B_t;
+ data_o_var.range (63, 32) = C_t;
+ data_o_var.range (31, 0) = D_t;
+ next_data_o.write (data_o_var);
+
+
+ if (hash_generated.read ())
+ {
+ next_A.write (A_t);
+ next_B.write (B_t);
+ next_C.write (C_t);
+ next_D.write (D_t);
+ next_getdata_state.write (0);
+ next_ready_o.write (1);
+ next_generate_hash.write (0);
+ }
+ break;
+ }
+
+}
Index: systemcmd5/tags/arelease/rtl/systemc/stimulus.cpp
===================================================================
--- systemcmd5/tags/arelease/rtl/systemc/stimulus.cpp (nonexistent)
+++ systemcmd5/tags/arelease/rtl/systemc/stimulus.cpp (revision 6)
@@ -0,0 +1,90 @@
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// MD5 stimulus ////
+//// ////
+//// This file is part of the SystemC MD5 ////
+//// ////
+//// Description: ////
+//// MD5 stimulus file ////
+//// ////
+//// To Do: ////
+//// - done ////
+//// ////
+//// Author(s): ////
+//// - Javier Castillo, jcastilo@opencores.org ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
+//// ////
+//// This source file may be used and distributed without ////
+//// restriction provided that this copyright statement is not ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer. ////
+//// ////
+//// This source file is free software; you can redistribute it ////
+//// and/or modify it under the terms of the GNU Lesser General ////
+//// Public License as published by the Free Software Foundation; ////
+//// either version 2.1 of the License, or (at your option) any ////
+//// later version. ////
+//// ////
+//// This source is distributed in the hope that it will be ////
+//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
+//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
+//// PURPOSE. See the GNU Lesser General Public License for more ////
+//// details. ////
+//// ////
+//// You should have received a copy of the GNU Lesser General ////
+//// Public License along with this source; if not, download it ////
+//// from http://www.opencores.org/lgpl.shtml ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//
+// CVS Revision History
+//
+// $Log: not supported by cvs2svn $
+
+#include "stimulus.h"
+
+void
+test::tb ()
+{
+
+ transactor->resetea ();
+
+ transactor->wait_cycles (5);
+
+ //hash of "a"
+ transactor->hash (0x00008061, 0x0, 0x0, 0x0);
+ transactor->hash (0x0, 0x0, 0x0, 0x0);
+ transactor->hash (0x0, 0x0, 0x0, 0x0);
+ transactor->hash (0x0, 0x0, 0x8, 0x0);
+
+ transactor->print_result ();
+
+ transactor->new_text ();
+
+ //hash of lots of "a"
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+
+ transactor->print_result ();
+
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x80, 0x0, 0x0, 0x0);
+ transactor->hash (0x0, 0x0, 0x300, 0x0);
+
+ transactor->print_result ();
+
+ transactor->new_text ();
+
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+ transactor->hash (0x61616161, 0x61616161, 0x61616161, 0x61616161);
+
+ transactor->print_result ();
+}
Index: systemcmd5/tags/arelease/rtl/systemc/transactor.h
===================================================================
--- systemcmd5/tags/arelease/rtl/systemc/transactor.h (nonexistent)
+++ systemcmd5/tags/arelease/rtl/systemc/transactor.h (revision 6)
@@ -0,0 +1,158 @@
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// MD5 transactor ////
+//// ////
+//// This file is part of the SystemC MD5 ////
+//// ////
+//// Description: ////
+//// MD5 transactor ////
+//// ////
+//// To Do: ////
+//// - done ////
+//// ////
+//// Author(s): ////
+//// - Javier Castillo, jcastilo@opencores.org ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
+//// ////
+//// This source file may be used and distributed without ////
+//// restriction provided that this copyright statement is not ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer. ////
+//// ////
+//// This source file is free software; you can redistribute it ////
+//// and/or modify it under the terms of the GNU Lesser General ////
+//// Public License as published by the Free Software Foundation; ////
+//// either version 2.1 of the License, or (at your option) any ////
+//// later version. ////
+//// ////
+//// This source is distributed in the hope that it will be ////
+//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
+//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
+//// PURPOSE. See the GNU Lesser General Public License for more ////
+//// details. ////
+//// ////
+//// You should have received a copy of the GNU Lesser General ////
+//// Public License along with this source; if not, download it ////
+//// from http://www.opencores.org/lgpl.shtml ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//
+// CVS Revision History
+//
+// $Log: not supported by cvs2svn $
+
+#include "systemc.h"
+
+class transactor_ports:public sc_module
+{
+public:
+
+ // Ports
+ sc_in < bool > clk;
+ sc_out < bool > reset;
+
+ sc_out < bool > load_i;
+ sc_in < bool > ready_o;
+ sc_out < bool > newtext_i;
+
+ //Input must be padded and in little endian mode
+ sc_out < sc_biguint < 128 > >data_i;
+ sc_in < sc_biguint < 128 > >data_o;
+};
+
+
+class rw_task_if:virtual public sc_interface
+{
+
+public:
+ //Funciones para el transactor
+ virtual void resetea (void) = 0;
+ virtual void new_text (void) = 0;
+ virtual void print_result (void) = 0;
+ virtual void hash (sc_uint < 32 > data_4, sc_uint < 32 > data_3,
+ sc_uint < 32 > data_2, sc_uint < 32 > data_1) = 0;
+ virtual void wait_cycles (int cycles) = 0;
+
+};
+
+
+//Transactor
+class md5_transactor:public rw_task_if, public transactor_ports
+{
+
+public:
+
+ SC_CTOR (md5_transactor)
+ {
+
+ cout.unsetf (ios::dec);
+ cout.setf (ios::hex);
+ cout.setf (ios::showbase);
+
+ }
+
+
+
+ void resetea (void)
+ {
+ reset.write (0);
+ wait (clk->posedge_event ());
+ reset.write (1);
+ cout << "Reseteado" << endl;
+ }
+
+ void new_text ()
+ {
+ newtext_i.write (1);
+ wait (clk->posedge_event ());
+ newtext_i.write (0);
+ }
+
+ void print_result ()
+ {
+ sc_biguint < 128 > data_o_var;
+
+ wait (ready_o->posedge_event ());
+ data_o_var = data_o.read ();
+ cout << "HASH: " << (int) (sc_uint < 32 >) data_o_var.range (127,
+ 96) << " " <<
+ (int) (sc_uint < 32 >) data_o_var.range (95,
+ 64) << " " << (int) (sc_uint <
+ 32 >)
+ data_o_var.range (63,
+ 32) << " " << (int) (sc_uint <
+ 32 >) data_o_var.range (31,
+ 0) <<
+ endl;
+ }
+
+ void hash (sc_uint < 32 > data_4, sc_uint < 32 > data_3,
+ sc_uint < 32 > data_2, sc_uint < 32 > data_1)
+ {
+ sc_biguint < 128 > data_t;
+
+ wait (clk->posedge_event ());
+ load_i.write (1);
+ data_t.range (127, 96) = data_4;
+ data_t.range (95, 64) = data_3;
+ data_t.range (63, 32) = data_2;
+ data_t.range (31, 0) = data_1;
+ data_i.write (data_t);
+ wait (clk->posedge_event ());
+ load_i.write (0);
+
+ }
+
+
+ void wait_cycles (int cycles)
+ {
+ for (int i = 0; i < cycles; i++)
+ {
+ wait (clk->posedge_event ());
+ }
+ }
+
+};
Index: systemcmd5/tags/arelease/rtl/systemc/md5.h
===================================================================
--- systemcmd5/tags/arelease/rtl/systemc/md5.h (nonexistent)
+++ systemcmd5/tags/arelease/rtl/systemc/md5.h (revision 6)
@@ -0,0 +1,118 @@
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// MD5 header ////
+//// ////
+//// This file is part of the SystemC MD5 ////
+//// ////
+//// Description: ////
+//// MD5 top file header ////
+//// ////
+//// To Do: ////
+//// - done ////
+//// ////
+//// Author(s): ////
+//// - Javier Castillo, jcastilo@opencores.org ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
+//// ////
+//// This source file may be used and distributed without ////
+//// restriction provided that this copyright statement is not ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer. ////
+//// ////
+//// This source file is free software; you can redistribute it ////
+//// and/or modify it under the terms of the GNU Lesser General ////
+//// Public License as published by the Free Software Foundation; ////
+//// either version 2.1 of the License, or (at your option) any ////
+//// later version. ////
+//// ////
+//// This source is distributed in the hope that it will be ////
+//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
+//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
+//// PURPOSE. See the GNU Lesser General Public License for more ////
+//// details. ////
+//// ////
+//// You should have received a copy of the GNU Lesser General ////
+//// Public License along with this source; if not, download it ////
+//// from http://www.opencores.org/lgpl.shtml ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//
+// CVS Revision History
+//
+// $Log: not supported by cvs2svn $
+
+#include "systemc.h"
+
+SC_MODULE (md5)
+{
+
+ sc_in < bool > clk;
+ sc_in < bool > reset;
+
+ sc_in < bool > load_i;
+ sc_out < bool > ready_o;
+ sc_in < bool > newtext_i;
+
+
+ //Input must be padded and in little endian mode
+ sc_in < sc_biguint < 128 > >data_i;
+ sc_out < sc_biguint < 128 > >data_o;
+
+
+ //Signals
+ sc_signal < sc_uint < 32 > >ar, br, cr, dr;
+ sc_signal < sc_uint < 32 > >next_ar, next_br, next_cr, next_dr;
+ sc_signal < sc_uint < 32 > >A, B, C, D;
+ sc_signal < sc_uint < 32 > >next_A, next_B, next_C, next_D;
+
+ sc_signal < bool > next_ready_o;
+ sc_signal < sc_biguint < 128 > >next_data_o;
+
+ sc_signal < sc_biguint < 512 > >message, next_message;
+ sc_signal < bool > generate_hash, hash_generated, next_generate_hash;
+
+ sc_signal < sc_uint < 3 > >getdata_state, next_getdata_state;
+
+ sc_signal < sc_uint < 2 > >round, next_round;
+ sc_signal < sc_uint < 6 > >round64, next_round64;
+
+ sc_signal < sc_uint < 44 > >t;
+
+ sc_signal < sc_uint < 32 > >func_out;
+
+ void md5_getdata ();
+ void reg_signal ();
+ void round64FSM ();
+ void md5_rom ();
+ void funcs ();
+
+ SC_CTOR (md5)
+ {
+
+ SC_METHOD (reg_signal);
+ sensitive_pos << clk;
+ sensitive_neg << reset;
+
+ SC_METHOD (md5_getdata);
+ sensitive << newtext_i << data_i << load_i << getdata_state <<
+ hash_generated << message;
+ sensitive << func_out << A << B << C << D << ar << br << cr << dr <<
+ generate_hash;
+
+ SC_METHOD (round64FSM);
+ sensitive << newtext_i << round << round64 << ar << br << cr << dr <<
+ generate_hash << func_out;
+ sensitive << getdata_state << A << B << C << D;
+
+
+ SC_METHOD (md5_rom);
+ sensitive << round64;
+
+ SC_METHOD (funcs);
+ sensitive << t << ar << br << cr << dr << round << message << func_out;
+
+ }
+};
Index: systemcmd5/tags/arelease/rtl/systemc/stimulus.h
===================================================================
--- systemcmd5/tags/arelease/rtl/systemc/stimulus.h (nonexistent)
+++ systemcmd5/tags/arelease/rtl/systemc/stimulus.h (revision 6)
@@ -0,0 +1,61 @@
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// MD5 stimulus header ////
+//// ////
+//// This file is part of the SystemC MD5 ////
+//// ////
+//// Description: ////
+//// MD5 stimulus file header ////
+//// ////
+//// To Do: ////
+//// - done ////
+//// ////
+//// Author(s): ////
+//// - Javier Castillo, jcastilo@opencores.org ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
+//// ////
+//// This source file may be used and distributed without ////
+//// restriction provided that this copyright statement is not ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer. ////
+//// ////
+//// This source file is free software; you can redistribute it ////
+//// and/or modify it under the terms of the GNU Lesser General ////
+//// Public License as published by the Free Software Foundation; ////
+//// either version 2.1 of the License, or (at your option) any ////
+//// later version. ////
+//// ////
+//// This source is distributed in the hope that it will be ////
+//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
+//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
+//// PURPOSE. See the GNU Lesser General Public License for more ////
+//// details. ////
+//// ////
+//// You should have received a copy of the GNU Lesser General ////
+//// Public License along with this source; if not, download it ////
+//// from http://www.opencores.org/lgpl.shtml ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//
+// CVS Revision History
+//
+// $Log: not supported by cvs2svn $
+
+#include "systemc.h"
+#include "transactor.h"
+
+class test:public sc_module
+{
+public:
+ void tb ();
+
+ sc_port < rw_task_if > transactor;
+
+ SC_CTOR (test)
+ {
+ SC_THREAD (tb);
+ }
+};
Index: systemcmd5/tags/arelease/rtl/systemc/Makefile
===================================================================
--- systemcmd5/tags/arelease/rtl/systemc/Makefile (nonexistent)
+++ systemcmd5/tags/arelease/rtl/systemc/Makefile (revision 6)
@@ -0,0 +1,14 @@
+TARGET_ARCH = linux
+
+CC = g++
+OPT = -O3
+DEBUG = -g
+OTHER = -Wall -Wno-deprecated
+EXTRA_CFLAGS = $(OPT) $(OTHER)
+# EXTRA_CFLAGS = $(DEBUG) $(OTHER)
+
+MODULE = md5
+SRCS = md5.cpp stimulus.cpp main.cpp
+OBJS = $(SRCS:.cpp=.o)
+
+include Makefile.defs
Index: systemcmd5/tags/arelease/rtl/systemc/Makefile.defs
===================================================================
--- systemcmd5/tags/arelease/rtl/systemc/Makefile.defs (nonexistent)
+++ systemcmd5/tags/arelease/rtl/systemc/Makefile.defs (revision 6)
@@ -0,0 +1,34 @@
+## Variable that points to SystemC installation path
+SYSTEMC = $(SYSTEMC_HOME)
+
+INCDIR = -I. -I.. -I../../bench -I$(SYSTEMC)/include
+LIBDIR = -L. -L.. -L$(SYSTEMC)/lib-$(TARGET_ARCH)
+
+# Build with maximum gcc warning level
+CFLAGS = $(PLATFORM_SPECIFIC_FLAGS) $(EXTRA_CFLAGS)
+
+LIBS = -lm -lsystemc $(EXTRA_LIBS)
+
+EXE = $(MODULE).x
+
+.SUFFIXES: .cpp .cc .o .x
+
+$(EXE): $(OBJS) $(SYSTEMC)/lib-$(TARGET_ARCH)/libsystemc.a
+ $(CC) $(CFLAGS) $(INCDIR) $(LIBDIR) -o $@ $(OBJS) $(LIBS) $(SYSTEMC)/lib-$(TARGET_ARCH)/libsystemc.a 2>&1 | c++filt
+
+.cpp.o:
+ $(CC) $(CFLAGS) $(INCDIR) -c $< $(USB_FLAGS)
+
+.cc.o:
+ $(CC) $(CFLAGS) $(INCDIR) -c $< $(USB_FLAGS)
+
+clean::
+ rm -f $(OBJS) *~ $(EXE)
+
+ultraclean: clean
+ rm -f Makefile.deps
+
+Makefile.deps:
+ $(CC) $(CFLAGS) $(INCDIR) -M $(SRCS) >> Makefile.deps
+
+#include Makefile.deps
Index: systemcmd5/tags/arelease/rtl/verilog/md5.v
===================================================================
--- systemcmd5/tags/arelease/rtl/verilog/md5.v (nonexistent)
+++ systemcmd5/tags/arelease/rtl/verilog/md5.v (revision 6)
@@ -0,0 +1,435 @@
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// MD5 implementation ////
+//// ////
+//// This file is part of the SystemC MD5 ////
+//// ////
+//// Description: ////
+//// MD5 implementation ////
+//// ////
+//// To Do: ////
+//// - done ////
+//// ////
+//// Author(s): ////
+//// - Javier Castillo, jcastilo@opencores.org ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//// ////
+//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
+//// ////
+//// This source file may be used and distributed without ////
+//// restriction provided that this copyright statement is not ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer. ////
+//// ////
+//// This source file is free software; you can redistribute it ////
+//// and/or modify it under the terms of the GNU Lesser General ////
+//// Public License as published by the Free Software Foundation; ////
+//// either version 2.1 of the License, or (at your option) any ////
+//// later version. ////
+//// ////
+//// This source is distributed in the hope that it will be ////
+//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
+//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
+//// PURPOSE. See the GNU Lesser General Public License for more ////
+//// details. ////
+//// ////
+//// You should have received a copy of the GNU Lesser General ////
+//// Public License along with this source; if not, download it ////
+//// from http://www.opencores.org/lgpl.shtml ////
+//// ////
+//////////////////////////////////////////////////////////////////////
+//
+// CVS Revision History
+//
+// $Log: not supported by cvs2svn $
+
+`timescale 10ns/1ns
+
+
+
+module md5(clk,reset,load_i,ready_o,newtext_i,data_i,data_o);
+
+input clk;
+input reset;
+input load_i;
+output ready_o;
+input newtext_i;
+
+
+//Input must be padded and in little endian mode
+input [127:0] data_i;
+output [127:0] data_o;
+
+reg ready_o, next_ready_o;
+reg [127:0] data_o, next_data_o;
+
+reg [5:0] round64, next_round64;
+reg [43:0] t;
+
+
+reg [31:0] ar,br,cr,dr,func_out, next_ar,next_br, next_cr, next_dr;
+reg [31:0] A,B,C,D,next_A,next_B, next_C, next_D;
+reg [511:0] message, next_message;
+reg [2:0] round,next_round;
+reg next_generate_hash,generate_hash;
+reg hash_generated;
+
+reg [2:0] next_getdata_state, getdata_state;
+
+//rom process
+always @(round64)
+begin
+
+ case(round64)
+ 0: t = 44'hD76AA478070;
+ 1: t = 44'hE8C7B7560C1;
+ 2: t = 44'h242070DB112;
+ 3: t = 44'hC1BDCEEE163;
+ 4: t = 44'hF57C0FAF074;
+ 5: t = 44'h4787C62A0C5;
+ 6: t = 44'hA8304613116;
+ 7: t = 44'hFD469501167;
+ 8: t = 44'h698098D8078;
+ 9: t = 44'h8B44F7AF0C9;
+ 10: t = 44'hFFFF5BB111A;
+ 11: t = 44'h895CD7BE16B;
+ 12: t = 44'h6B90112207C;
+ 13: t = 44'hFD9871930CD;
+ 14: t = 44'hA679438E11E;
+ 15: t = 44'h49B4082116F;
+
+ 16: t = 44'hf61e2562051;
+ 17: t = 44'hc040b340096;
+ 18: t = 44'h265e5a510EB;
+ 19: t = 44'he9b6c7aa140;
+ 20: t = 44'hd62f105d055;
+ 21: t = 44'h0244145309A;
+ 22: t = 44'hd8a1e6810EF;
+ 23: t = 44'he7d3fbc8144;
+ 24: t = 44'h21e1cde6059;
+ 25: t = 44'hc33707d609E;
+ 26: t = 44'hf4d50d870E3;
+ 27: t = 44'h455a14ed148;
+ 28: t = 44'ha9e3e90505D;
+ 29: t = 44'hfcefa3f8092;
+ 30: t = 44'h676f02d90E7;
+ 31: t = 44'h8d2a4c8a14C;
+
+ 32: t = 44'hfffa3942045;
+ 33: t = 44'h8771f6810B8;
+ 34: t = 44'h6d9d612210B;
+ 35: t = 44'hfde5380c17E;
+ 36: t = 44'ha4beea44041;
+ 37: t = 44'h4bdecfa90B4;
+ 38: t = 44'hf6bb4b60107;
+ 39: t = 44'hbebfbc7017A;
+ 40: t = 44'h289b7ec604D;
+ 41: t = 44'heaa127fa0B0;
+ 42: t = 44'hd4ef3085103;
+ 43: t = 44'h04881d05176;
+ 44: t = 44'hd9d4d039049;
+ 45: t = 44'he6db99e50BC;
+ 46: t = 44'h1fa27cf810F;
+ 47: t = 44'hc4ac5665172;
+
+ 48: t = 44'hf4292244060;
+ 49: t = 44'h432aff970A7;
+ 50: t = 44'hab9423a70FE;
+ 51: t = 44'hfc93a039155;
+ 52: t = 44'h655b59c306C;
+ 53: t = 44'h8f0ccc920A3;
+ 54: t = 44'hffeff47d0FA;
+ 55: t = 44'h85845dd1151;
+ 56: t = 44'h6fa87e4f068;
+ 57: t = 44'hfe2ce6e00AF;
+ 58: t = 44'ha30143140F6;
+ 59: t = 44'h4e0811a115D;
+ 60: t = 44'hf7537e82064;
+ 61: t = 44'hbd3af2350AB;
+ 62: t = 44'h2ad7d2bb0F2;
+ 63: t = 44'heb86d391159;
+ endcase
+end
+//end process rom
+
+
+//funcs process
+
+
+reg [31:0] aux31,fr_var,tr_var,rotate1,rotate2;
+reg [7:0] s_var;
+reg [3:0] nblock;
+reg [31:0] message_var[15:0];
+
+always @(t or ar or br or cr or dr or round or message or func_out or message_var[0] or message_var[1] or message_var[2] or message_var[3]
+ or message_var[4] or message_var[5] or message_var[6] or message_var[7] or message_var[8] or message_var[9] or message_var[10]
+ or message_var[11] or message_var[12] or message_var[13] or message_var[14] or message_var[15])
+begin
+
+ message_var[0]=message[511:480];
+ message_var[1]=message[479:448];
+ message_var[2]=message[447:416];
+ message_var[3]=message[415:384];
+ message_var[4]=message[383:352];
+ message_var[5]=message[351:320];
+ message_var[6]=message[319:288];
+ message_var[7]=message[287:256];
+ message_var[8]=message[255:224];
+ message_var[9]=message[223:192];
+ message_var[10]=message[191:160];
+ message_var[11]=message[159:128];
+ message_var[12]=message[127:96];
+ message_var[13]=message[95:64];
+ message_var[14]=message[63:32];
+ message_var[15]=message[31:0];
+
+ fr_var=0;
+
+ case(round)
+ 0: fr_var=((br&cr)|(~br&dr));
+ 1: fr_var=((br&dr)|(cr& (~dr)));
+ 2: fr_var=(br^cr^dr);
+ 3: fr_var=(cr^(br|~dr));
+ endcase
+
+
+ tr_var=t[43:12];
+ s_var=t[11:4];
+ nblock=t[3:0];
+
+ aux31=(ar+fr_var+message_var[nblock]+tr_var);
+
+ rotate1=aux31 << s_var;
+ rotate2=aux31 >> (32-s_var);
+ func_out=br+(rotate1 | rotate2);
+
+end
+//end process funcs
+
+
+//process round64FSM
+always @(newtext_i or round or round64 or ar or br or cr or dr or generate_hash or func_out or getdata_state or A or B or C or D)
+begin
+
+ next_ar=ar;
+ next_br=br;
+ next_cr=cr;
+ next_dr=dr;
+ next_round64=round64;
+ next_round=round;
+ hash_generated=0;
+
+ if(generate_hash!=0)
+ begin
+ next_ar=dr;
+ next_br=func_out;
+ next_cr=br;
+ next_dr=cr;
+ end
+
+ case(round64)
+ 0:
+ begin
+ next_round=0;
+ if(generate_hash) next_round64=1;
+ end
+
+ 15,31,47:
+ begin
+ next_round=round+1;
+ next_round64=round64+1;
+ end
+
+ 63:
+ begin
+ next_round=0;
+ next_round64=0;
+ hash_generated=1;
+ end
+
+ default: next_round64=round64+1;
+
+ endcase
+
+
+ if(newtext_i)
+ begin
+ next_ar=32'h67452301;
+ next_br=32'hEFCDAB89;
+ next_cr=32'h98BADCFE;
+ next_dr=32'h10325476;
+ next_round=0;
+ next_round64=0;
+ end
+
+ if(!getdata_state)
+ begin
+ next_ar=A;
+ next_br=B;
+ next_cr=C;
+ next_dr=D;
+ end
+
+end
+//end round64FSM process
+
+//regsignal process
+always @(posedge clk or negedge reset)
+begin
+
+ if(!reset)
+ begin
+ ready_o=0;
+ data_o=0;
+ message=0;
+
+ ar=32'h67452301;
+ br=32'hEFCDAB89;
+ cr=32'h98BADCFE;
+ dr=32'h10325476;
+
+ getdata_state=0;
+ generate_hash=0;
+
+ round=0;
+ round64=0;
+ A=32'h67452301;
+ B=32'hEFCDAB89;
+ C=32'h98BADCFE;
+ D=32'h10325476;
+
+ end
+ else
+ begin
+ ready_o=next_ready_o;
+ data_o=next_data_o;
+ message=next_message;
+
+ ar=next_ar;
+ br=next_br;
+ cr=next_cr;
+ dr=next_dr;
+
+ A=next_A;
+ B=next_B;
+ C=next_C;
+ D=next_D;
+
+ generate_hash=next_generate_hash;
+ getdata_state=next_getdata_state;
+
+ round=next_round;
+ round64=next_round64;
+ end
+end
+//end regsignals process
+
+
+//getdata process
+
+reg [127:0] data_o_var;
+reg [511:0] aux;
+wire [31:0] A_t,B_t,C_t,D_t;
+
+assign A_t=dr+A;
+assign B_t=func_out+B;
+assign C_t=br+C;
+assign D_t=cr+D;
+
+always @(newtext_i or A_t or B_t or C_t or D_t or data_i or load_i or getdata_state or generate_hash or hash_generated or message or func_out or A or B or C or D or ar or br or cr or dr)
+begin
+
+ next_A=A;
+ next_B=B;
+ next_C=C;
+ next_D=D;
+
+ next_generate_hash=generate_hash;
+ next_ready_o=0;
+ next_getdata_state=getdata_state;
+
+ next_data_o=0;
+ aux=message;
+ next_message=message;
+
+ if(newtext_i)
+ begin
+ next_A=32'h67452301;
+ next_B=32'hEFCDAB89;
+ next_C=32'h98BADCFE;
+ next_D=32'h10325476;
+ next_getdata_state=0;
+ end
+
+ case(getdata_state)
+
+ 0 :
+ begin
+ if(load_i)
+ begin
+ aux[511:384]=data_i;
+ next_message=aux;
+ next_getdata_state=1;
+ end
+ end
+
+ 1 :
+ begin
+ if(load_i)
+ begin
+ aux[383:256]=data_i;
+ next_message=aux;
+ next_getdata_state=2;
+ end
+ end
+
+ 2 :
+ begin
+ if(load_i)
+ begin
+ aux[255:128]=data_i;
+ next_message=aux;
+ next_getdata_state=3;
+ end
+ end
+
+ 3 :
+ begin
+ if(load_i)
+ begin
+ aux[127:0]=data_i;
+ next_message=aux;
+ next_getdata_state=4;
+ next_generate_hash=1;
+ end
+ end
+
+ 4 :
+ begin
+
+ next_generate_hash=1;
+
+ data_o_var[127:96]=A_t;
+ data_o_var[95:64]=B_t;
+ data_o_var[63:32]=C_t;
+ data_o_var[31:0]=D_t;
+ next_data_o=data_o_var;
+
+ if(hash_generated)
+ begin
+ next_A=A_t;
+ next_B=B_t;
+ next_C=C_t;
+ next_D=D_t;
+ next_getdata_state=0;
+ next_ready_o=1;
+ next_generate_hash=0;
+ end
+ end
+ endcase
+end
+//end getdata process
+
+
+endmodule
Index: systemcmd5/tags
===================================================================
--- systemcmd5/tags (nonexistent)
+++ systemcmd5/tags (revision 6)
systemcmd5/tags
Property changes :
Added: svn:mergeinfo
## -0,0 +0,0 ##