-
Notifications
You must be signed in to change notification settings - Fork 1
/
aes_main.v
164 lines (135 loc) · 3.93 KB
/
aes_main.v
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
`timescale 1ns/1ps
/*
`include "/bob/bob.v"
`include "/alice/alice.v"
`include "./encryptor/enKeyGeneration.v"
`include "./encryptor/enmixcolumn.v"
`include "./encryptor/enroundlast.v"
`include "./encryptor/enrounds.v"
`include "./encryptor/ensbox.v"
`include "./encryptor/enshiftrow.v"
`include "./decryptor/KeyGeneration.v"
`include "./decryptor/make_inv_key.v"
`include "./decryptor/MakeKey1.v"
`include "./decryptor/MakeKey2.v"
`include "./decryptor/MakeKey3.v"
`include "./decryptor/MakeKey4.v"
`include "./decryptor/MakeKey5.v"
`include "./decryptor/MakeKey6.v"
`include "./decryptor/MakeKey7.v"
`include "./decryptor/MakeKey8.v"
`include "./decryptor/MakeKey9.v"
`include "./decryptor/MakeKey10.v"
`include "./decryptor/InvMixCol.v"
`include "./decryptor/InvSbox.v"
`include "./decryptor/InvShiftRows.v"
`include "./decryptor/InvSubBytes.v"
`include "./decryptor/InvRound.v"
`include "./decryptor/InvLastRound.v"
`include "/decryptor/AES_decryptor.v"
`include "/encryptor/AES_encryptor.v"
`include "/diffi_helman/diffi_helman.v"
`include "/randomizer/container_b.v"
`include "/counter/counter_4gb.v"
`include "/container/container.v"
`include "/randomizer/container_a.v"
*/
module aes_main(
input wire clk_in,
input wire reset,
input wire reset_clk,
output wire clk_out,
//data_in
input wire data_in_stb,
input wire data_out_stb,
input wire [127:0] data_in,
input wire [7:0] password,
output wire usr_long_key_valid,
output wire usr_long_key_change_rq,
input wire usr_long_key_ch,
output wire ready,
output wire ready_for_transmit,
//data_out
output wire [127:0] data_out,
output wire data_valid
);
wire alice_dh_data_val;
wire [127:0] alice_dh_data;
wire bob_dh_data_val;
wire [127:0] bob_dh_data;
wire ready_for_transmit_A;
wire ready_for_transmit_B;
wire [127:0] data_out_A_to_B;
wire data_out_A_to_B_val;
wire o_stb_B_to_A;
wire ready_B;
wire clk;
reg transmit_req;
wire usr_long_key_valid_A;
wire usr_long_key_valid_B;
wire usr_long_key_change_rq_A;
wire usr_long_key_change_rq_B;
wire usr_long_key_ch_A;
wire usr_long_key_ch_B;
assign usr_long_key_ch_A = usr_long_key_ch;
assign usr_long_key_ch_B = usr_long_key_ch;
//assign clk_in = clk;
assign usr_long_key_valid = usr_long_key_valid_A && usr_long_key_valid_B;
assign usr_long_key_change_rq = usr_long_key_change_rq_A && usr_long_key_change_rq_B;
assign ready_for_transmit = ready_for_transmit_A && ready_for_transmit_B;
assign clk_out = clk;
always @(posedge clk)
begin
if (reset)
transmit_req <= 1'b1;
else if (ready_for_transmit_A && ready_for_transmit_B)
transmit_req <= 1'b1;
else
transmit_req <= 1'b0;
end
bob bob (
.clk(clk),
.reset(reset),
.transmit_req(transmit_req),
.password(password),
.alice_dh_data(alice_dh_data),
.alice_dh_data_valid(alice_dh_data_val),
.bob_dh_data(bob_dh_data),
.bob_dh_data_valid(bob_dh_data_val),
.alice_data(data_out_A_to_B),
.alice_data_valid(data_out_A_to_B_val),
.o_stb(o_stb_B_to_A),
.usr_o_stb(data_out_stb),
.data(data_out),
.data_valid(data_valid),
.usr_long_key_valid(usr_long_key_valid_B),
.usr_long_key_change_rq(usr_long_key_change_rq_B),
.usr_long_key_ch(usr_long_key_ch_B),
.ready_for_transmit(ready_for_transmit_B)
);
alice alice (
.clk(clk),
.reset(reset),
.transmit_req(transmit_req),
.password(password),
.alice_dh_data(alice_dh_data),
.alice_dh_data_valid(alice_dh_data_val),
.bob_dh_data(bob_dh_data),
.bob_dh_data_valid(bob_dh_data_val),
.alice_data(data_out_A_to_B),
.alice_data_valid(data_out_A_to_B_val),
.o_stb(o_stb_B_to_A),
.ready(ready),
.ready_for_transmit(ready_for_transmit_A),
.data_stb(data_in_stb),
.data_in(data_in),
.usr_long_key_valid(usr_long_key_valid_A),
.usr_long_key_change_rq(usr_long_key_change_rq_A),
.usr_long_key_ch(usr_long_key_ch_A)
);
clk16 clk162(
.clk50(clk_in),
.reset(reset_clk),
.clk16(clk)
);
endmodule