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

Subversion Repositories systemcmd5

[/] [systemcmd5/] [trunk/] [bench/] [systemc/] [transactor.h] - Blame information for rev 2

Go to most recent revision | 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
 
47
#include "systemc.h"
48
 
49
class transactor_ports:public sc_module
50
{
51
public:
52
 
53
  // Ports
54
  sc_in < bool > clk;
55
  sc_out < bool > reset;
56
 
57
  sc_out < bool > load_i;
58
  sc_in < bool > ready_o;
59
  sc_out < bool > newtext_i;
60
 
61
  //Input must be padded and in little endian mode
62
  sc_out < sc_biguint < 128 > >data_i;
63
  sc_in < sc_biguint < 128 > >data_o;
64
};
65
 
66
 
67
class rw_task_if:virtual public sc_interface
68
{
69
 
70
public:
71
  //Funciones para el transactor 
72
  virtual void resetea (void) = 0;
73
  virtual void new_text (void) = 0;
74
  virtual void print_result (void) = 0;
75
  virtual void hash (sc_uint < 32 > data_4, sc_uint < 32 > data_3,
76
                     sc_uint < 32 > data_2, sc_uint < 32 > data_1) = 0;
77
  virtual void wait_cycles (int cycles) = 0;
78
 
79
};
80
 
81
 
82
//Transactor
83
class md5_transactor:public rw_task_if, public transactor_ports
84
{
85
 
86
public:
87
 
88
  SC_CTOR (md5_transactor)
89
  {
90
 
91
    cout.unsetf (ios::dec);
92
    cout.setf (ios::hex);
93
    cout.setf (ios::showbase);
94
 
95
  }
96
 
97
 
98
 
99
  void resetea (void)
100
  {
101
    reset.write (0);
102
    wait (clk->posedge_event ());
103
    reset.write (1);
104
    cout << "Reseteado" << endl;
105
  }
106
 
107
  void new_text ()
108
  {
109
    newtext_i.write (1);
110
    wait (clk->posedge_event ());
111
    newtext_i.write (0);
112
  }
113
 
114
  void print_result ()
115
  {
116
    sc_biguint < 128 > data_o_var;
117
 
118
    wait (ready_o->posedge_event ());
119
    data_o_var = data_o.read ();
120
    cout << "HASH: " << (int) (sc_uint < 32 >) data_o_var.range (127,
121
                                                                 96) << " " <<
122
      (int) (sc_uint < 32 >) data_o_var.range (95,
123
                                               64) << " " << (int) (sc_uint <
124
                                                                    32 >)
125
      data_o_var.range (63,
126
                        32) << " " << (int) (sc_uint <
127
                                             32 >) data_o_var.range (31,
128
                                                                     0) <<
129
      endl;
130
  }
131
 
132
  void hash (sc_uint < 32 > data_4, sc_uint < 32 > data_3,
133
             sc_uint < 32 > data_2, sc_uint < 32 > data_1)
134
  {
135
    sc_biguint < 128 > data_t;
136
 
137
    wait (clk->posedge_event ());
138
    load_i.write (1);
139
    data_t.range (127, 96) = data_4;
140
    data_t.range (95, 64) = data_3;
141
    data_t.range (63, 32) = data_2;
142
    data_t.range (31, 0) = data_1;
143
    data_i.write (data_t);
144
    wait (clk->posedge_event ());
145
    load_i.write (0);
146
 
147
  }
148
 
149
 
150
  void wait_cycles (int cycles)
151
  {
152
    for (int i = 0; i < cycles; i++)
153
      {
154
        wait (clk->posedge_event ());
155
      }
156
  }
157
 
158
};

powered by: WebSVN 2.1.0

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