1
+ `timescale 1ns / 1ps
2
+ // ////////////////////////////////////////////////////////////////////////////////
3
+ // This is the wrapper module for the AES encryption.
4
+ // This is designed as a black box to be dropped in as
5
+ // Co-Processor Two in the Main module.
6
+ // The AES as is only accepts a single 128bit block of data at a time.
7
+ // -This wrapper will accept data in length up to N bytes
8
+ // -Data will be broken into blocks, processed one block at a time
9
+ // then returned as a whole to the main processor.
10
+ // ////////////////////////////////////////////////////////////////////////////////
11
+
12
+
13
+
14
+
15
+ module CP2 (
16
+ input clk, rst,
17
+ input wrEn_cpu,
18
+ input [ 5 :0 ] addr_cpu,
19
+ input [31 :0 ] wrData_cpu,
20
+ output [31 :0 ] rdData_cpu,
21
+
22
+ input wrEn_dma
23
+ input [20 :0 ] addr_dma,
24
+ input [31 :0 ] wrData_dma,
25
+ output [31 :0 ] rdData_dma,
26
+
27
+ output INT
28
+ );
29
+
30
+ // CPU interface/status reg // 31 , 30, 29, 28, 27-25, ..., 15:0
31
+ // [0] status // INT, go, 128/256, encDec, clkMult, 0 , words of data
32
+ // [1] start address
33
+ // [2] KEY_0
34
+ // [3] KEY_1
35
+ // [4] KEY_2
36
+ // [5] KEY_3
37
+ // [6] KEY_4
38
+ // [7] KEY_5
39
+ // [8] KEY_6
40
+ // [9] KEY_7
41
+ reg [31 :0 ] reg_cpu [9 :0 ];
42
+
43
+ // internal registers; 64kB; each set forms a block
44
+ reg [31 :0 ] r00 [0 :3999 ];
45
+ reg [31 :0 ] r01 [0 :3999 ];
46
+ reg [31 :0 ] r02 [0 :3999 ];
47
+ reg [31 :0 ] r03 [0 :3999 ];
48
+
49
+ // no CPU output if AES is running : Write Only for Key
50
+ assign rdData_cpu = (! go && (addr_cpu< 2 )) ? reg_cpu[addr_cpu] : 0 ;
51
+ assign INT = reg_cpu[0 ][31 ]; // INT bit
52
+
53
+ always @ (posedge clk, posedge rst)begin
54
+ if (rst) begin
55
+ integer i;
56
+ for (i= 0 ; i< 10 ; i= i+ 1 )begin
57
+ reg_cpu[i] = 0 ;
58
+ end
59
+ for (i= 0 ; i< 4000 ; i= i+ 1 )begin
60
+ r00[i] = 0 ;
61
+ r01[i] = 0 ;
62
+ r02[i] = 0 ;
63
+ r03[i] = 0 ;
64
+ end
65
+ end // END rst
66
+ else begin
67
+ if (wrEn_cpu) reg_cpu[addr_cpu] = wrData_cpu;
68
+ end
69
+ end
70
+
71
+
72
+ always @ (posedge reg_cpu[0 ][30 ])begin
73
+
74
+
75
+ end // END GO
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+ endmodule
0 commit comments