URL
https://opencores.org/ocsvn/xtea/xtea/trunk
Subversion Repositories xtea
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 4 to Rev 3
- ↔ Reverse comparison
Rev 4 → Rev 3
/trunk/LICENSE
File deleted
\ No newline at end of file
/trunk/xtea.v
File deleted
\ No newline at end of file
/trunk/testbench.v
1,47 → 1,3
////////////////////////////////////////////////////////////////////// |
//// //// |
//// XTEA IP Core //// |
//// //// |
//// This file is part of the xtea project //// |
//// http://www.opencores.org/projects.cgi/web/xtea/overview //// |
//// //// |
//// Test-bench for the XTEA encryption algorithm. //// |
//// //// |
//// TODO: //// |
//// * Update for new combined encipher/decipher module //// |
//// * Tidy //// |
//// * Add interconnections //// |
//// //// |
//// Author: David Johnson, dj@david-web.co.uk //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2006 David Johnson //// |
//// //// |
//// 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, write to the //// |
//// Free Software Foundation, Inc., 51 Franklin Street, Fifth //// |
//// Floor, Boston, MA 02110-1301 USA //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
// |
// CVS Revision History |
// |
// $Log: not supported by cvs2svn $ |
// |
|
module cipher_testbench (clock, reset, all_done_encipher, all_done_decipher, data_out_encipher1, data_out_encipher2, data_out_decipher1, data_out_decipher2, data_in_encipher1, data_in_encipher2, data_in_decipher1, data_in_decipher2, key_out, result, reset_out); |
|
input clock, reset, all_done_encipher, all_done_decipher; |
/trunk/encipher.v
0,0 → 1,106
module encipher(clock, reset, data_in1, data_in2, key_in, data_out1, data_out2, all_done); |
|
parameter s0 = 4'd0, s1 = 4'd1, s2 = 4'd2, s3 = 4'd3, s4 = 4'd4, s5 = 4'd5, s6 = 4'd6, s7 = 4'd7, s8 = 4'd8, s9 = 4'd9, s14 = 4'd14, s15 = 4'd15; |
|
input clock, reset; |
input[31:0] data_in, data_in2; |
input[127:0] key_in; |
output[31:0] data_out1, data_out2; |
output all_done; |
|
wire clock, reset; |
wire[31:0] data_in1, data_in2; |
wire[127:0] key_in; |
|
reg all_done, while_flag; |
reg[1:0] selectslice; |
reg[3:0] state; |
reg[7:0] x; |
reg[31:0] data_out1, data_out2, sum, workunit1, workunit2, delta; |
|
always @(posedge clock or posedge reset) |
begin |
if (reset) |
state = s0; |
else begin |
case (state) |
s0: state = s1; |
s1: state = s2; |
s2: state = s15; |
s15: state = while_flag ? s3 : s14; |
s3: state = s4; |
s4: state = s5; |
s5: state = s6; |
s6: state = s7; |
s7: state = s2; |
s14: state = s8; |
s8: state = s9; |
s9: state = s9; |
default: state = 4'bxxxx; |
endcase |
end |
end |
|
always @(posedge clock or posedge reset) |
begin |
if (reset) begin |
data_out1 = 32'h00000000; |
data_out2 = 32'h00000000; |
x = 8'b00000000; |
sum = 32'h00000000; |
while_flag = 1'b0; |
workunit1 = 32'h00000000; |
workunit2 = 32'h00000000; |
selectslice = 1'b0; |
all_done = 1'b0; |
delta = 32'h00000000; |
end |
else begin |
case (state) |
s1: begin |
workunit1 = data_in1; |
workunit2 = data_in2; |
sum = 32'h00000000; |
delta = 32'h9E3779B9; |
end |
s2: if (x < 8'd32) while_flag = 1'b1; else while_flag = 1'b0; |
s15: begin |
//do nothing |
end |
s3: selectslice = (sum & 32'd3); |
s4: case (selectslice) |
2'b00: workunit1 = workunit1 + (((workunit2 << 4 ^ workunit2 >> 5) + workunit2) ^ (sum + key_in[127:96])); |
2'b01: workunit1 = workunit1 + (((workunit2 << 4 ^ workunit2 >> 5) + workunit2) ^ (sum + key_in[95:64])); |
2'b10: workunit1 = workunit1 + (((workunit2 << 4 ^ workunit2 >> 5) + workunit2) ^ (sum + key_in[63:32])); |
2'b11: workunit1 = workunit1 + (((workunit2 << 4 ^ workunit2 >> 5) + workunit2) ^ (sum + key_in[31:0])); |
default: workunit1 = 32'bzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz; |
endcase |
s5: sum = sum + delta; |
s6: selectslice = (sum >> 32'd11 & 32'd3); |
s7: begin |
case (selectslice) |
2'b00: workunit2 = workunit2 + (((workunit1 << 4 ^ workunit1 >> 5) + workunit1) ^ (sum + key_in[127:96])); |
2'b01: workunit2 = workunit2 + (((workunit1 << 4 ^ workunit1 >> 5) + workunit1) ^ (sum + key_in[95:64])); |
2'b10: workunit2 = workunit2 + (((workunit1 << 4 ^ workunit1 >> 5) + workunit1) ^ (sum + key_in[63:32])); |
2'b11: workunit2 = workunit2 + (((workunit1 << 4 ^ workunit1 >> 5) + workunit1) ^ (sum + key_in[31:0])); |
default: workunit2 = 32'bzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz; |
endcase |
x = x + 1'b1; |
end |
s14: begin |
//do nothing |
end |
s8: begin |
data_out1 = workunit1; |
data_out2 = workunit2; |
end |
s9: all_done = 1'b1; |
default: begin |
data_out1 = 32'bzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz; |
data_out2 = 32'bzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz; |
end |
endcase |
end |
end |
|
endmodule |
trunk/encipher.v
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/decipher.v
===================================================================
--- trunk/decipher.v (nonexistent)
+++ trunk/decipher.v (revision 3)
@@ -0,0 +1,105 @@
+module decipher(clock, reset, data_in1, data_in2, key_in, data_out1, data_out2, all_done);
+
+parameter s0 = 4'd0, s1 = 4'd1, s2 = 4'd2, s3 = 4'd3, s4 = 4'd4, s5 = 4'd5, s6 = 4'd6, s7 = 4'd7, s8 = 4'd8, s9 = 4'd9, s14 = 4'd14, s15 = 4'd15;
+
+input clock, reset;
+input[31:0] data_in1, data_in2;
+input[127:0] key_in;
+output[31:0] data_out1, data_out2;
+output all_done;
+
+wire clock, reset;
+wire[31:0] data_in1, data_in2;
+wire[127:0] key_in;
+reg all_done, while_flag;
+reg[1:0] selectslice;
+reg[3:0] state;
+reg[7:0] x;
+reg[31:0] data_out1, data_out2, sum, workunit1, workunit2, delta;
+
+always @(posedge clock or posedge reset)
+begin
+ if (reset)
+ state = s0;
+ else begin
+ case (state)
+ s0: state = s1;
+ s1: state = s2;
+ s2: state = s15;
+ s15: state = while_flag ? s3 : s14;
+ s3: state = s4;
+ s4: state = s5;
+ s5: state = s6;
+ s6: state = s7;
+ s7: state = s2;
+ s14: state = s8;
+ s8: state = s9;
+ s9: state = s9;
+ default: state = 4'bxxxx;
+ endcase
+ end
+end
+
+always @(posedge clock or posedge reset)
+begin
+ if (reset) begin
+ data_out1 = 32'h00000000;
+ data_out2 = 32'h00000000;
+ x = 8'b00000000;
+ sum = 32'h00000000;
+ while_flag = 1'b0;
+ workunit1 = 32'h00000000;
+ workunit2 = 32'h00000000;
+ selectslice = 1'b0;
+ all_done = 1'b0;
+ delta = 32'h00000000;
+ end
+ else begin
+ case (state)
+ s1: begin
+ workunit1 = data_in1;
+ workunit2 = data_in2;
+ delta = 32'h9E3779B9;
+ sum = 32'hc6ef3720;
+ end
+ s2: if (x < 8'd32) while_flag = 1'b1; else while_flag = 1'b0;
+ s15: begin
+ //do nothing
+ end
+ s3: selectslice = (sum >> 32'd11 & 32'd3);
+ s4: case (selectslice)
+ 2'b00: workunit2 = workunit2 - (((workunit1 << 4 ^ workunit1 >> 5) + workunit1) ^ (sum + key_in[127:96]));
+ 2'b01: workunit2 = workunit2 - (((workunit1 << 4 ^ workunit1 >> 5) + workunit1) ^ (sum + key_in[95:64]));
+ 2'b10: workunit2 = workunit2 - (((workunit1 << 4 ^ workunit1 >> 5) + workunit1) ^ (sum + key_in[63:32]));
+ 2'b11: workunit2 = workunit2 - (((workunit1 << 4 ^ workunit1 >> 5) + workunit1) ^ (sum + key_in[31:0]));
+ default: workunit2 = 32'bzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz;
+ endcase
+ s5: sum = sum - delta;
+ s6: selectslice = (sum & 32'd3);
+ s7: begin
+ case (selectslice)
+ 2'b00: workunit1 = workunit1 - (((workunit2 << 4 ^ workunit2 >> 5) + workunit2) ^ (sum + key_in[127:96]));
+ 2'b01: workunit1 = workunit1 - (((workunit2 << 4 ^ workunit2 >> 5) + workunit2) ^ (sum + key_in[95:64]));
+ 2'b10: workunit1 = workunit1 - (((workunit2 << 4 ^ workunit2 >> 5) + workunit2) ^ (sum + key_in[63:32]));
+ 2'b11: workunit1 = workunit1 - (((workunit2 << 4 ^ workunit2 >> 5) + workunit2) ^ (sum + key_in[31:0]));
+ default: workunit1 = 32'bzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz;
+ endcase
+ x = x + 1'b1;
+ end
+ s14: begin
+ //do nothing
+ end
+ s8: begin
+ data_out1 = workunit1;
+ data_out2 = workunit2;
+ end
+ s9: all_done = 1'b1;
+ default: begin
+ data_out1 = 32'bzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz;
+ data_out2 = 32'bzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz;
+ end
+ endcase
+ end
+end
+
+endmodule
\ No newline at end of file
trunk/decipher.v
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property