URL
https://opencores.org/ocsvn/systemcmd5/systemcmd5/trunk
Subversion Repositories systemcmd5
Compare Revisions
- This comparison shows the changes necessary to convert path
/systemcmd5/trunk/bench/systemc
- from Rev 4 to Rev 6
- ↔ Reverse comparison
Rev 4 → Rev 6
/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 (); |
|
|
|
} |
/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 ()); |
} |
} |
|
}; |
/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; |
|
} |
/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); |
} |
}; |