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

Subversion Repositories systemcaes

[/] [systemcaes/] [trunk/] [bench/] [systemc/] [aes128lowarea/] [transactor.h] - Blame information for rev 21

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 jcastillo
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Transactor for AES ramdom verification                      ////
4
////                                                              ////
5
////  This file is part of the SystemC AES                        ////
6
////                                                              ////
7
////  Description:                                                ////
8
////  Transactor acording to TLM for SystemC AES project          ////
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
// Revision 1.3  2004/08/30 14:47:38  jcastillo
47
// Code formated
48
//
49
// Revision 1.1.1.1  2004/07/05 09:46:22  jcastillo
50
// First import
51
//
52
 
53
 
54
#include "systemc.h"
55
 
56
class transactor_ports: public sc_module
57
{
58
public:
59
 
60
        // Ports
61
        sc_in<bool> clk;
62
        sc_out<bool> reset;
63
 
64
        //Ports to RT model
65
        sc_out<bool> rt_load_o;
66
        sc_out<bool> rt_decrypt_o;
67
        sc_out<sc_biguint<128> > rt_aes_data_o;
68
        sc_out<sc_biguint<128> > rt_aes_key_o;
69
        sc_in<bool> rt_aes_ready_i;
70
 
71
        //Ports to C model
72
        sc_fifo_out<bool> c_decrypt_o;
73
        sc_fifo_out<sc_biguint <128> > c_aes_key_o;
74
        sc_fifo_out<sc_biguint <128> > c_aes_data_o;
75
 
76
};
77
 
78
 
79
class rw_task_if: virtual public sc_interface
80
{
81
 
82
public:
83
        //Funciones para el transactor
84
        virtual void resetea(void) = 0;
85
        virtual void encrypt(sc_biguint<128> data, sc_biguint<128> key) = 0;
86
        virtual void decrypt(sc_biguint<128> data, sc_biguint<128> key) = 0;
87
        virtual void wait_cycles(int cycles) = 0;
88
 
89
};
90
 
91
 
92
//Transactor
93
class aes_transactor: public rw_task_if, public transactor_ports
94
{
95
 
96
public:
97
 
98
        SC_CTOR(aes_transactor)
99
        {
100
 
101
                cout.unsetf(ios::dec);
102
                cout.setf(ios::hex);
103
 
104
        }
105
 
106
 
107
        void resetea(void)
108
        {
109
                reset.write(0);
110
                wait(clk->posedge_event());
111
                reset.write(1);
112
                cout << "Reseted" << endl;
113
        }
114
 
115
        void encrypt(sc_biguint <128 >data, sc_biguint <128 >key)
116
        {
117
 
118
                wait(clk->posedge_event());
119
 
120
                //To RT model
121
                rt_load_o.write(1);
122
                rt_aes_data_o.write(data);
123
                rt_aes_key_o.write(key);
124
                rt_decrypt_o.write(0);
125
 
126
                //To C model through fifos
127
                c_aes_data_o.write(data);
128
                c_aes_key_o.write(key);
129
                c_decrypt_o.write(0);
130
 
131
                wait(clk->posedge_event());
132
                rt_load_o.write(0);
133
                wait(rt_aes_ready_i->posedge_event());
134
        }
135
 
136
        void decrypt(sc_biguint <128 >data, sc_biguint <128 >key)
137
        {
138
 
139
                wait(clk->posedge_event());
140
 
141
                //To RT model
142
                rt_load_o.write(1);
143
                rt_aes_data_o.write(data);
144
                rt_aes_key_o.write(key);
145
                rt_decrypt_o.write(1);
146
 
147
                //To C model through fifos
148
                c_aes_data_o.write(data);
149
                c_aes_key_o.write(key);
150
                c_decrypt_o.write(1);
151
 
152
                wait(clk->posedge_event());
153
                rt_load_o.write(0);
154
                wait(rt_aes_ready_i->posedge_event());
155
 
156
        }
157
 
158
        void wait_cycles(int cycles)
159
        {
160
                for (int i = 0; i < cycles; i++)
161
                {
162
                        wait(clk->posedge_event());
163
                }
164
        }
165
 
166
};

powered by: WebSVN 2.1.0

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