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

Subversion Repositories systemcaes

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 23 to Rev 24
    Reverse comparison

Rev 23 → Rev 24

/trunk/rtl/systemc/aes192lowarea/subbytes.cpp
1,202 → 1,218
//////////////////////////////////////////////////////////////////////
//// ////
//// AES subbytes module implementation ////
//// ////
//// This file is part of the SystemC AES ////
//// ////
//// Description: ////
//// Subbytes stage implementation for AES algorithm ////
//// ////
//// 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//// ////
//// AES subbytes module implementation ////
//// ////
//// This file is part of the SystemC AES ////
//// ////
//// Description: ////
//// Subbytes stage implementation for AES algorithm ////
//// ////
//// 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 2005/02/14 11:18:31 jcastillo
// Moved
//
// CVS Revision History
//
// $Log: not supported by cvs2svn $
 
#include "subbytes.h"
 
#define assign_array_to_128() \
{ \
data_reg_128.range(127,120)=data_reg_var[0]; \
data_reg_128.range(119,112)=data_reg_var[1]; \
data_reg_128.range(111,104)=data_reg_var[2]; \
data_reg_128.range(103,96)=data_reg_var[3]; \
data_reg_128.range(95,88)=data_reg_var[4]; \
data_reg_128.range(87,80)=data_reg_var[5]; \
data_reg_128.range(79,72)=data_reg_var[6]; \
data_reg_128.range(71,64)=data_reg_var[7]; \
data_reg_128.range(63,56)=data_reg_var[8]; \
data_reg_128.range(55,48)=data_reg_var[9]; \
data_reg_128.range(47,40)=data_reg_var[10]; \
data_reg_128.range(39,32)=data_reg_var[11]; \
data_reg_128.range(31,24)=data_reg_var[12]; \
data_reg_128.range(23,16)=data_reg_var[13]; \
data_reg_128.range(15,8)=data_reg_var[14]; \
data_reg_128.range(7,0)=data_reg_var[15]; \
}
 
#define shift_array_to_128() \
{ \
data_reg_128.range(127,120)=data_reg_var[0]; \
data_reg_128.range(119,112)=data_reg_var[5]; \
data_reg_128.range(111,104)=data_reg_var[10]; \
data_reg_128.range(103,96)=data_reg_var[15]; \
data_reg_128.range(95,88)=data_reg_var[4]; \
data_reg_128.range(87,80)=data_reg_var[9]; \
data_reg_128.range(79,72)=data_reg_var[14]; \
data_reg_128.range(71,64)=data_reg_var[3]; \
data_reg_128.range(63,56)=data_reg_var[8]; \
data_reg_128.range(55,48)=data_reg_var[13]; \
data_reg_128.range(47,40)=data_reg_var[2]; \
data_reg_128.range(39,32)=data_reg_var[7]; \
data_reg_128.range(31,24)=data_reg_var[12]; \
data_reg_128.range(23,16)=data_reg_var[1]; \
data_reg_128.range(15,8)=data_reg_var[6]; \
data_reg_128.range(7,0)=data_reg_var[11]; \
}
 
#define invert_shift_array_to_128() \
{ \
data_reg_128.range(127,120)=data_reg_var[0]; \
data_reg_128.range(119,112)=data_reg_var[13]; \
data_reg_128.range(111,104)=data_reg_var[10]; \
data_reg_128.range(103,96)=data_reg_var[7]; \
data_reg_128.range(95,88)=data_reg_var[4]; \
data_reg_128.range(87,80)=data_reg_var[1]; \
data_reg_128.range(79,72)=data_reg_var[14]; \
data_reg_128.range(71,64)=data_reg_var[11]; \
data_reg_128.range(63,56)=data_reg_var[8]; \
data_reg_128.range(55,48)=data_reg_var[5]; \
data_reg_128.range(47,40)=data_reg_var[2]; \
data_reg_128.range(39,32)=data_reg_var[15]; \
data_reg_128.range(31,24)=data_reg_var[12]; \
data_reg_128.range(23,16)=data_reg_var[9]; \
data_reg_128.range(15,8)=data_reg_var[6]; \
data_reg_128.range(7,0)=data_reg_var[3]; \
}
 
void subbytes::sub(){
sc_biguint<128> data_i_var,data_reg_128;
sc_uint<8> data_array[16],data_reg_var[16];
data_i_var=data_i.read();
data_array[0]=data_i_var.range(127,120);
data_array[1]=data_i_var.range(119,112);
data_array[2]=data_i_var.range(111,104);
data_array[3]=data_i_var.range(103,96);
data_array[4]=data_i_var.range(95,88);
data_array[5]=data_i_var.range(87,80);
data_array[6]=data_i_var.range(79,72);
data_array[7]=data_i_var.range(71,64);
data_array[8]=data_i_var.range(63,56);
data_array[9]=data_i_var.range(55,48);
data_array[10]=data_i_var.range(47,40);
data_array[11]=data_i_var.range(39,32);
data_array[12]=data_i_var.range(31,24);
data_array[13]=data_i_var.range(23,16);
data_array[14]=data_i_var.range(15,8);
data_array[15]=data_i_var.range(7,0);
data_reg_var[0]=data_reg.read().range(127,120);
data_reg_var[1]=data_reg.read().range(119,112);
data_reg_var[2]=data_reg.read().range(111,104);
data_reg_var[3]=data_reg.read().range(103,96);
data_reg_var[4]=data_reg.read().range(95,88);
data_reg_var[5]=data_reg.read().range(87,80);
data_reg_var[6]=data_reg.read().range(79,72);
data_reg_var[7]=data_reg.read().range(71,64);
data_reg_var[8]=data_reg.read().range(63,56);
data_reg_var[9]=data_reg.read().range(55,48);
data_reg_var[10]=data_reg.read().range(47,40);
data_reg_var[11]=data_reg.read().range(39,32);
data_reg_var[12]=data_reg.read().range(31,24);
data_reg_var[13]=data_reg.read().range(23,16);
data_reg_var[14]=data_reg.read().range(15,8);
data_reg_var[15]=data_reg.read().range(7,0);
sbox_decrypt_o.write(decrypt_i.read());
sbox_data_o.write(0);
next_state.write(state.read());
next_data_reg.write(data_reg.read());
next_ready_o.write(0);
data_o.write(data_reg.read());
switch(state.read()){
case 0:
if(start_i.read()){
sbox_data_o.write(data_array[0]);
next_state.write(1);
}
break;
case 16:
data_reg_var[15]=sbox_data_i.read();
//Make shift rows stage
switch(decrypt_i.read()){
case 0:
shift_array_to_128();
break;
case 1:
invert_shift_array_to_128();
break;
}
next_data_reg.write(data_reg_128);
next_ready_o.write(1);
next_state.write(0);
break;
default:
sbox_data_o.write(data_array[(int)state.read()]);
data_reg_var[(int)state.read()-1]=sbox_data_i.read();
assign_array_to_128();
next_data_reg.write(data_reg_128);
next_state.write(state.read()+1);
break;
}
}
 
void subbytes::registers(){
if(!reset.read()){
data_reg.write(0);
state.write(0);
ready_o.write(0);
}else{
data_reg.write(next_data_reg.read());
state.write(next_state.read());
ready_o.write(next_ready_o.read());
}
// Revision 1.2 2004/08/30 14:44:44 jcastillo
// Code Formater used to give better appearance to SystemC code
//
// Revision 1.1.1.1 2004/07/05 09:46:22 jcastillo
// First import
//
 
#include "subbytes.h"
 
void subbytes::sub()
{
sc_biguint<128> data_i_var, data_reg_128;
sc_uint<8> data_array[16], data_reg_var[16];
 
#define assign_array_to_128() \
{ \
data_reg_128.range(127,120)=data_reg_var[0]; \
data_reg_128.range(119,112)=data_reg_var[1]; \
data_reg_128.range(111,104)=data_reg_var[2]; \
data_reg_128.range(103,96)=data_reg_var[3]; \
data_reg_128.range(95,88)=data_reg_var[4]; \
data_reg_128.range(87,80)=data_reg_var[5]; \
data_reg_128.range(79,72)=data_reg_var[6]; \
data_reg_128.range(71,64)=data_reg_var[7]; \
data_reg_128.range(63,56)=data_reg_var[8]; \
data_reg_128.range(55,48)=data_reg_var[9]; \
data_reg_128.range(47,40)=data_reg_var[10]; \
data_reg_128.range(39,32)=data_reg_var[11]; \
data_reg_128.range(31,24)=data_reg_var[12]; \
data_reg_128.range(23,16)=data_reg_var[13]; \
data_reg_128.range(15,8)=data_reg_var[14]; \
data_reg_128.range(7,0)=data_reg_var[15]; \
}
 
#define shift_array_to_128() \
{ \
data_reg_128.range(127,120)=data_reg_var[0]; \
data_reg_128.range(119,112)=data_reg_var[5]; \
data_reg_128.range(111,104)=data_reg_var[10]; \
data_reg_128.range(103,96)=data_reg_var[15]; \
data_reg_128.range(95,88)=data_reg_var[4]; \
data_reg_128.range(87,80)=data_reg_var[9]; \
data_reg_128.range(79,72)=data_reg_var[14]; \
data_reg_128.range(71,64)=data_reg_var[3]; \
data_reg_128.range(63,56)=data_reg_var[8]; \
data_reg_128.range(55,48)=data_reg_var[13]; \
data_reg_128.range(47,40)=data_reg_var[2]; \
data_reg_128.range(39,32)=data_reg_var[7]; \
data_reg_128.range(31,24)=data_reg_var[12]; \
data_reg_128.range(23,16)=data_reg_var[1]; \
data_reg_128.range(15,8)=data_reg_var[6]; \
data_reg_128.range(7,0)=data_reg_var[11]; \
}
 
#define invert_shift_array_to_128() \
{ \
data_reg_128.range(127,120)=data_reg_var[0]; \
data_reg_128.range(119,112)=data_reg_var[13]; \
data_reg_128.range(111,104)=data_reg_var[10]; \
data_reg_128.range(103,96)=data_reg_var[7]; \
data_reg_128.range(95,88)=data_reg_var[4]; \
data_reg_128.range(87,80)=data_reg_var[1]; \
data_reg_128.range(79,72)=data_reg_var[14]; \
data_reg_128.range(71,64)=data_reg_var[11]; \
data_reg_128.range(63,56)=data_reg_var[8]; \
data_reg_128.range(55,48)=data_reg_var[5]; \
data_reg_128.range(47,40)=data_reg_var[2]; \
data_reg_128.range(39,32)=data_reg_var[15]; \
data_reg_128.range(31,24)=data_reg_var[12]; \
data_reg_128.range(23,16)=data_reg_var[9]; \
data_reg_128.range(15,8)=data_reg_var[6]; \
data_reg_128.range(7,0)=data_reg_var[3]; \
}
 
data_i_var = data_i.read();
 
data_array[0] = data_i_var.range(127, 120);
data_array[1] = data_i_var.range(119, 112);
data_array[2] = data_i_var.range(111, 104);
data_array[3] = data_i_var.range(103, 96);
data_array[4] = data_i_var.range(95, 88);
data_array[5] = data_i_var.range(87, 80);
data_array[6] = data_i_var.range(79, 72);
data_array[7] = data_i_var.range(71, 64);
data_array[8] = data_i_var.range(63, 56);
data_array[9] = data_i_var.range(55, 48);
data_array[10] = data_i_var.range(47, 40);
data_array[11] = data_i_var.range(39, 32);
data_array[12] = data_i_var.range(31, 24);
data_array[13] = data_i_var.range(23, 16);
data_array[14] = data_i_var.range(15, 8);
data_array[15] = data_i_var.range(7, 0);
 
data_reg_var[0] = data_reg.read().range(127, 120);
data_reg_var[1] = data_reg.read().range(119, 112);
data_reg_var[2] = data_reg.read().range(111, 104);
data_reg_var[3] = data_reg.read().range(103, 96);
data_reg_var[4] = data_reg.read().range(95, 88);
data_reg_var[5] = data_reg.read().range(87, 80);
data_reg_var[6] = data_reg.read().range(79, 72);
data_reg_var[7] = data_reg.read().range(71, 64);
data_reg_var[8] = data_reg.read().range(63, 56);
data_reg_var[9] = data_reg.read().range(55, 48);
data_reg_var[10] = data_reg.read().range(47, 40);
data_reg_var[11] = data_reg.read().range(39, 32);
data_reg_var[12] = data_reg.read().range(31, 24);
data_reg_var[13] = data_reg.read().range(23, 16);
data_reg_var[14] = data_reg.read().range(15, 8);
data_reg_var[15] = data_reg.read().range(7, 0);
 
 
sbox_decrypt_o.write(decrypt_i.read());
sbox_data_o.write(0);
next_state.write(state.read());
next_data_reg.write(data_reg.read());
 
next_ready_o.write(0);
data_o.write(data_reg.read());
 
switch (state.read())
{
 
case 0:
if (start_i.read())
{
sbox_data_o.write(data_array[0]);
next_state.write(1);
}
break;
case 16:
data_reg_var[15] = sbox_data_i.read();
//Make shift rows stage
switch (decrypt_i.read())
{
case 0:
shift_array_to_128();
break;
case 1:
invert_shift_array_to_128();
break;
}
next_data_reg.write(data_reg_128);
next_ready_o.write(1);
next_state.write(0);
break;
default:
sbox_data_o.write(data_array[(int)state.read()]);
data_reg_var[(int)state.read()-1] = sbox_data_i.read();
assign_array_to_128();
next_data_reg.write(data_reg_128);
next_state.write(state.read() + 1);
break;
}
}
 
void subbytes::registers()
{
if (!reset.read())
{
data_reg.write(0);
state.write(0);
ready_o.write(0);
}
else
{
data_reg.write(next_data_reg.read());
state.write(next_state.read());
ready_o.write(next_ready_o.read());
}
}
/trunk/rtl/systemc/aes192lowarea/subbytes.h
1,83 → 1,95
//////////////////////////////////////////////////////////////////////
//// ////
//// AES subbytes module header ////
//// ////
//// This file is part of the SystemC AES ////
//// ////
//// Description: ////
//// Subbytes stage header for AES algorithm ////
//// ////
//// 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//// ////
//// AES subbytes module header ////
//// ////
//// This file is part of the SystemC AES ////
//// ////
//// Description: ////
//// Subbytes stage header for AES algorithm ////
//// ////
//// 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 2005/02/14 11:18:31 jcastillo
// Moved
//
// CVS Revision History
//
// $Log: not supported by cvs2svn $
 
#include "systemc.h"
 
SC_MODULE(subbytes){
 
sc_in<bool> clk;
sc_in<bool> reset;
sc_in<bool> start_i;
sc_in<bool> decrypt_i;
sc_in<sc_biguint<128> > data_i;
sc_out<bool> ready_o;
sc_out<sc_biguint<128> > data_o;
//To sbox
sc_out<sc_uint<8> > sbox_data_o;
sc_in<sc_uint<8> > sbox_data_i;
sc_out<bool> sbox_decrypt_o;
void sub();
void registers();
sc_signal<sc_uint<5> > state,next_state;
sc_signal<sc_biguint<128> > data_reg,next_data_reg;
sc_signal<bool> next_ready_o;
SC_CTOR(subbytes){
SC_METHOD(registers);
sensitive_pos << clk;
sensitive_neg << reset;
SC_METHOD(sub);
sensitive << decrypt_i << start_i << state << data_i << sbox_data_i << data_reg;
}
// Revision 1.2 2004/08/30 14:44:44 jcastillo
// Code Formater used to give better appearance to SystemC code
//
// Revision 1.1.1.1 2004/07/05 09:46:22 jcastillo
// First import
//
 
 
#include "systemc.h"
 
SC_MODULE(subbytes)
{
 
sc_in<bool> clk;
sc_in<bool> reset;
 
sc_in<bool> start_i;
sc_in<bool> decrypt_i;
sc_in<sc_biguint <128> > data_i;
 
sc_out<bool> ready_o;
sc_out<sc_biguint<128> > data_o;
 
//To sbox
sc_out<sc_uint<8> > sbox_data_o;
sc_in<sc_uint<8> > sbox_data_i;
sc_out<bool>sbox_decrypt_o;
 
void sub();
void registers();
 
sc_signal<sc_uint<5> > state, next_state;
sc_signal<sc_biguint<128> > data_reg, next_data_reg;
sc_signal<bool> next_ready_o;
 
SC_CTOR(subbytes)
{
 
SC_METHOD(registers);
sensitive_pos << clk;
sensitive_neg << reset;
 
SC_METHOD(sub);
sensitive << decrypt_i << start_i << state << data_i << sbox_data_i << data_reg;
 
}
};
/trunk/rtl/systemc/aes192lowarea/byte_mixcolum.cpp
44,38 → 44,50
// CVS Revision History
//
// $Log: not supported by cvs2svn $
// Revision 1.1 2005/02/14 11:18:31 jcastillo
// Moved
//
// Revision 1.2 2004/08/30 14:44:44 jcastillo
// Code Formater used to give better appearance to SystemC code
//
// Revision 1.1.1.1 2004/07/05 09:46:22 jcastillo
// First import
//
 
#include "byte_mixcolum.h"
 
sc_uint<8> xtime(sc_uint<8> in){
sc_uint<4> xtime_t;
sc_uint<8> out;
out.range(7,5)=in.range(6,4);
xtime_t[3]=in[7];xtime_t[2]=in[7];xtime_t[1]=0;xtime_t[0]=in[7];
out.range(4,1)=xtime_t^in.range(3,0);
out[0]=in[7];
return out;
//Aux function
sc_uint <8> byte_mixcolum::xtime(sc_uint<8> in)
{
sc_uint<4> xtime_t;
sc_uint<8> out;
 
out.range(7, 5) = in.range(6, 4);
xtime_t[3] = in[7]; xtime_t[2] = in[7]; xtime_t[1] = 0; xtime_t[0] = in[7];
out.range(4, 1) = xtime_t ^ in.range(3, 0);
out[0] = in[7];
return out;
}
 
void byte_mixcolum::dataflow(){
void byte_mixcolum::dataflow()
{
 
sc_uint<8> w1,w2,w3,w4,w5,w6,w7,w8,outx_var;
w1=a.read()^b.read();
w2=a.read()^c.read();
w3=c.read()^d.read();
w4=xtime(w1);
w5=xtime(w3);
w6=w2^w4^w5;
w7=xtime(w6);
w8=xtime(w7);
outx_var=b.read()^w3^w4;
sc_uint<8> w1, w2, w3, w4, w5, w6, w7, w8, outx_var;
 
w1 = a.read() ^ b.read();
w2 = a.read() ^ c.read();
w3 = c.read() ^ d.read();
 
w4 = xtime(w1);
w5 = xtime(w3);
 
w6 = w2 ^ w4 ^ w5;
 
w7 = xtime(w6);
w8 = xtime(w7);
 
outx_var = b.read() ^ w3 ^ w4;
outx.write(outx_var);
outy.write(w8^outx_var);
outy.write(w8 ^ outx_var);
 
}
/trunk/rtl/systemc/aes192lowarea/byte_mixcolum.h
43,18 → 43,30
// CVS Revision History
//
// $Log: not supported by cvs2svn $
// Revision 1.1 2005/02/14 11:18:31 jcastillo
// Moved
//
// Revision 1.2 2004/08/30 14:44:44 jcastillo
// Code Formater used to give better appearance to SystemC code
//
// Revision 1.1.1.1 2004/07/05 09:46:22 jcastillo
// First import
//
 
#include "systemc.h"
 
SC_MODULE(byte_mixcolum){
SC_MODULE(byte_mixcolum)
{
 
sc_in<sc_uint<8> > a,b,c,d;
sc_out<sc_uint<8> > outx,outy;
sc_in<sc_uint<8> > a, b, c, d;
sc_out<sc_uint<8> > outx, outy;
 
void dataflow();
sc_uint <8> xtime(sc_uint<8> in);
SC_CTOR(byte_mixcolum){
SC_CTOR(byte_mixcolum)
{
 
SC_METHOD(dataflow);
sensitive << a << b << c << d;
}
/trunk/rtl/systemc/aes128lowarea/subbytes.cpp
43,6 → 43,9
// CVS Revision History
//
// $Log: not supported by cvs2svn $
// Revision 1.1 2005/02/14 11:18:31 jcastillo
// Moved
//
// Revision 1.2 2004/08/30 14:44:44 jcastillo
// Code Formater used to give better appearance to SystemC code
//
52,8 → 55,13
 
#include "subbytes.h"
 
#define assign_array_to_128() \
{ \
void subbytes::sub()
{
sc_biguint<128> data_i_var, data_reg_128;
sc_uint<8> data_array[16], data_reg_var[16];
 
#define assign_array_to_128() \
{ \
data_reg_128.range(127,120)=data_reg_var[0]; \
data_reg_128.range(119,112)=data_reg_var[1]; \
data_reg_128.range(111,104)=data_reg_var[2]; \
70,10 → 78,10
data_reg_128.range(23,16)=data_reg_var[13]; \
data_reg_128.range(15,8)=data_reg_var[14]; \
data_reg_128.range(7,0)=data_reg_var[15]; \
}
}
 
#define shift_array_to_128() \
{ \
#define shift_array_to_128() \
{ \
data_reg_128.range(127,120)=data_reg_var[0]; \
data_reg_128.range(119,112)=data_reg_var[5]; \
data_reg_128.range(111,104)=data_reg_var[10]; \
90,10 → 98,10
data_reg_128.range(23,16)=data_reg_var[1]; \
data_reg_128.range(15,8)=data_reg_var[6]; \
data_reg_128.range(7,0)=data_reg_var[11]; \
}
}
 
#define invert_shift_array_to_128() \
{ \
#define invert_shift_array_to_128() \
{ \
data_reg_128.range(127,120)=data_reg_var[0]; \
data_reg_128.range(119,112)=data_reg_var[13]; \
data_reg_128.range(111,104)=data_reg_var[10]; \
110,14 → 118,8
data_reg_128.range(23,16)=data_reg_var[9]; \
data_reg_128.range(15,8)=data_reg_var[6]; \
data_reg_128.range(7,0)=data_reg_var[3]; \
}
}
 
 
void subbytes::sub()
{
sc_biguint<128> data_i_var, data_reg_128;
sc_uint<8> data_array[16], data_reg_var[16];
 
data_i_var = data_i.read();
 
data_array[0] = data_i_var.range(127, 120);
/trunk/rtl/systemc/aes128lowarea/byte_mixcolum.cpp
1,89 → 1,93
//////////////////////////////////////////////////////////////////////
//// ////
//// AES mixcolums 8 bit module implementation ////
//// ////
//// This file is part of the SystemC AES ////
//// ////
//// Description: ////
//// Submodule of mixcolums stage implementation for ////
/// AES algorithm ////
//// ////
//// 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
//
//////////////////////////////////////////////////////////////////////
//// ////
//// AES mixcolums 8 bit module implementation ////
//// ////
//// This file is part of the SystemC AES ////
//// ////
//// Description: ////
//// Submodule of mixcolums stage implementation for ////
/// AES algorithm ////
//// ////
//// 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 2005/02/14 11:18:31 jcastillo
// Moved
//
// Revision 1.2 2004/08/30 14:44:44 jcastillo
// Code Formater used to give better appearance to SystemC code
//
// Revision 1.1.1.1 2004/07/05 09:46:22 jcastillo
// First import
//
 
#include "byte_mixcolum.h"
 
sc_uint <8> xtime(sc_uint<8> in)
{
sc_uint<4> xtime_t;
sc_uint<8> out;
 
out.range(7, 5) = in.range(6, 4);
xtime_t[3] = in[7]; xtime_t[2] = in[7]; xtime_t[1] = 0; xtime_t[0] = in[7];
out.range(4, 1) = xtime_t ^ in.range(3, 0);
out[0] = in[7];
return out;
}
 
void byte_mixcolum::dataflow()
{
 
sc_uint<8> w1, w2, w3, w4, w5, w6, w7, w8, outx_var;
 
w1 = a.read() ^ b.read();
w2 = a.read() ^ c.read();
w3 = c.read() ^ d.read();
 
w4 = xtime(w1);
w5 = xtime(w3);
 
w6 = w2 ^ w4 ^ w5;
 
w7 = xtime(w6);
w8 = xtime(w7);
 
outx_var = b.read() ^ w3 ^ w4;
outx.write(outx_var);
outy.write(w8 ^ outx_var);
 
//
// Revision 1.1.1.1 2004/07/05 09:46:22 jcastillo
// First import
//
 
#include "byte_mixcolum.h"
 
//Aux function
sc_uint <8> byte_mixcolum::xtime(sc_uint<8> in)
{
sc_uint<4> xtime_t;
sc_uint<8> out;
 
out.range(7, 5) = in.range(6, 4);
xtime_t[3] = in[7]; xtime_t[2] = in[7]; xtime_t[1] = 0; xtime_t[0] = in[7];
out.range(4, 1) = xtime_t ^ in.range(3, 0);
out[0] = in[7];
return out;
}
 
void byte_mixcolum::dataflow()
{
 
sc_uint<8> w1, w2, w3, w4, w5, w6, w7, w8, outx_var;
 
w1 = a.read() ^ b.read();
w2 = a.read() ^ c.read();
w3 = c.read() ^ d.read();
 
w4 = xtime(w1);
w5 = xtime(w3);
 
w6 = w2 ^ w4 ^ w5;
 
w7 = xtime(w6);
w8 = xtime(w7);
 
outx_var = b.read() ^ w3 ^ w4;
outx.write(outx_var);
outy.write(w8 ^ outx_var);
 
}
/trunk/rtl/systemc/aes128lowarea/byte_mixcolum.h
1,69 → 1,73
//////////////////////////////////////////////////////////////////////
//// ////
//// Byte mixcolum header ////
//// ////
//// This file is part of the SystemC AES ////
//// ////
//// Description: ////
//// Header file for 8-bit mixcolum submodule ////
//// ////
//// 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
//
//////////////////////////////////////////////////////////////////////
//// ////
//// Byte mixcolum header ////
//// ////
//// This file is part of the SystemC AES ////
//// ////
//// Description: ////
//// Header file for 8-bit mixcolum submodule ////
//// ////
//// 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 2005/02/14 11:18:31 jcastillo
// Moved
//
// Revision 1.2 2004/08/30 14:44:44 jcastillo
// Code Formater used to give better appearance to SystemC code
//
// Revision 1.1.1.1 2004/07/05 09:46:22 jcastillo
// First import
//
 
#include "systemc.h"
 
SC_MODULE(byte_mixcolum)
{
 
sc_in<sc_uint<8> > a, b, c, d;
sc_out<sc_uint<8> > outx, outy;
 
void dataflow();
 
SC_CTOR(byte_mixcolum)
{
 
SC_METHOD(dataflow);
sensitive << a << b << c << d;
}
//
// Revision 1.1.1.1 2004/07/05 09:46:22 jcastillo
// First import
//
 
#include "systemc.h"
 
SC_MODULE(byte_mixcolum)
{
 
sc_in<sc_uint<8> > a, b, c, d;
sc_out<sc_uint<8> > outx, outy;
 
void dataflow();
sc_uint <8> xtime(sc_uint<8> in);
SC_CTOR(byte_mixcolum)
{
 
SC_METHOD(dataflow);
sensitive << a << b << c << d;
}
};

powered by: WebSVN 2.1.0

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