OpenCores
URL https://opencores.org/ocsvn/systemcmd5/systemcmd5/trunk

Subversion Repositories systemcmd5

[/] [systemcmd5/] [trunk/] [rtl/] [systemc/] [transactor.h] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jcastillo
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  MD5 transactor                                              ////
4
////                                                              ////
5
////  This file is part of the SystemC MD5                        ////
6
////                                                              ////
7
////  Description:                                                ////
8
////  MD5 transactor                                              ////
9
////                                                              ////
10
////  To Do:                                                      ////
11
////   - done                                                     ////
12
////                                                              ////
13
////  Author(s):                                                  ////
14
////      - Javier Castillo, jcastilo@opencores.org               ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
//
43
// CVS Revision History
44
//
45
// $Log: not supported by cvs2svn $
46 4 jcastillo
// Revision 1.1.1.1  2004/09/08 16:24:49  jcastillo
47
// Initial release
48
//
49 2 jcastillo
 
50
#include "systemc.h"
51
 
52
class transactor_ports:public sc_module
53
{
54
public:
55
 
56
  // Ports
57
  sc_in < bool > clk;
58
  sc_out < bool > reset;
59
 
60
  sc_out < bool > load_i;
61
  sc_in < bool > ready_o;
62
  sc_out < bool > newtext_i;
63
 
64
  //Input must be padded and in little endian mode
65
  sc_out < sc_biguint < 128 > >data_i;
66
  sc_in < sc_biguint < 128 > >data_o;
67
};
68
 
69
 
70
class rw_task_if:virtual public sc_interface
71
{
72
 
73
public:
74
  //Funciones para el transactor 
75
  virtual void resetea (void) = 0;
76
  virtual void new_text (void) = 0;
77
  virtual void print_result (void) = 0;
78 4 jcastillo
  virtual void wait_result (void) = 0;
79 2 jcastillo
  virtual void hash (sc_uint < 32 > data_4, sc_uint < 32 > data_3,
80
                     sc_uint < 32 > data_2, sc_uint < 32 > data_1) = 0;
81
  virtual void wait_cycles (int cycles) = 0;
82
 
83
};
84
 
85
 
86
//Transactor
87
class md5_transactor:public rw_task_if, public transactor_ports
88
{
89
 
90
public:
91
 
92
  SC_CTOR (md5_transactor)
93
  {
94
 
95
    cout.unsetf (ios::dec);
96
    cout.setf (ios::hex);
97
    cout.setf (ios::showbase);
98
 
99
  }
100
 
101
 
102
 
103
  void resetea (void)
104
  {
105
    reset.write (0);
106
    wait (clk->posedge_event ());
107
    reset.write (1);
108
    cout << "Reseteado" << endl;
109
  }
110
 
111
  void new_text ()
112
  {
113
    newtext_i.write (1);
114
    wait (clk->posedge_event ());
115
    newtext_i.write (0);
116
  }
117
 
118 4 jcastillo
  void wait_result ()
119
  {
120
    wait (ready_o->posedge_event ());
121
  }
122
 
123
 
124 2 jcastillo
  void print_result ()
125
  {
126
    sc_biguint < 128 > data_o_var;
127
 
128
    wait (ready_o->posedge_event ());
129
    data_o_var = data_o.read ();
130 4 jcastillo
 
131
    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 >)
132
                data_o_var.range (63,32) << " " << (int) (sc_uint <32 >) data_o_var.range (31,0) <<endl;
133
 
134 2 jcastillo
  }
135
 
136
  void hash (sc_uint < 32 > data_4, sc_uint < 32 > data_3,
137
             sc_uint < 32 > data_2, sc_uint < 32 > data_1)
138
  {
139
    sc_biguint < 128 > data_t;
140
 
141
    wait (clk->posedge_event ());
142
    load_i.write (1);
143
    data_t.range (127, 96) = data_4;
144
    data_t.range (95, 64) = data_3;
145
    data_t.range (63, 32) = data_2;
146
    data_t.range (31, 0) = data_1;
147
    data_i.write (data_t);
148
    wait (clk->posedge_event ());
149
    load_i.write (0);
150
 
151
  }
152
 
153
 
154
  void wait_cycles (int cycles)
155
  {
156
    for (int i = 0; i < cycles; i++)
157
      {
158
        wait (clk->posedge_event ());
159
      }
160
  }
161
 
162
};

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.