-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathone_iteration.v
More file actions
executable file
·93 lines (78 loc) · 1.93 KB
/
one_iteration.v
File metadata and controls
executable file
·93 lines (78 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 11:09:49 05/12/2015
// Design Name:
// Module Name: one_iteration
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module one_iteration(
clk,
rst,
left,
right,
subk,
left_new,
right_new
);
input clk;
input rst;
input [32:1] left;
input [32:1] right;
input [48:1] subk;
output reg [32:1] left_new;
output reg [32:1] right_new;
wire [48:1] rightexp;
Expansion e1 ( right, rightexp);
wire [48:1] Bout;
xor_exp x1(rightexp, subk, Bout);
wire [6:1] b1,b2,b3,b4,b5,b6,b7,b8;
assign b8 = Bout[6:1];
assign b7 = Bout[12:7];
assign b6 = Bout[18:13];
assign b5 = Bout[24:19];
assign b4 = Bout[30:25];
assign b3 = Bout[36:31];
assign b2 = Bout[42:37];
assign b1 = Bout[48:43];
wire [4:1] s1out, s2out, s3out,s4out,s5out,s6out, s7out, s8out;
sbox1 s1 (b1, s1out);
sbox2 s2 (b2, s2out);
sbox3 s3 (b3, s3out);
sbox4 s4 (b4, s4out);
sbox5 s5 (b5, s5out);
sbox6 s6 (b6, s6out);
sbox7 s7 (b7, s7out);
sbox8 s8 (b8, s8out);
wire [32:1] sboxOut;
assign sboxOut = {s1out, s2out,s3out, s4out,s5out,s6out, s7out,s8out};
wire [32:1]PermS;
sbox_perm sb1(sboxOut, PermS);
wire [32:1] xorOut;
xor2 x2(left,PermS, xorOut);
always@(posedge clk or posedge rst)
begin
if(rst)
begin
left_new <= 32'b00000000000000000000000000000000;
right_new <= 32'b00000000000000000000000000000000;
end
else
begin
left_new <= right;
right_new <= xorOut;
end
end
endmodule