aes_mem4.v
1.79 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
94
95
96
97
// This confidential and propriety software may be used
// only as authorized by a licensing agreement from
// Ocean Logic Pty Ltd http://www.ocean-logic.com
//
// In the event of publication, the following notice is
// applicable
//
// (C) COPYRIGHT 2001 Ocean Logic Pty Ltd
// ALL RIGHTS RESERVED
//
// the entire notice must be reproduced on all
// authorized copies
//
// File : mem4.vhd
// Author : Vincenzo Liguori
// Date : 01-03-02
// Version 1.0
// Abstract :
// This implements the AES status registers
//
// Modification history :
// Date by Version Change description
// -------------------------------------------------
// 01-03-02 VL 1.0 Original
// 08-07-02 frank name change to avoid vcs module name conflict
module aes_mem4(
clk,
rstn,
en,
we,
ar,
aw,
din,
dout
);
input clk, rstn;
input en, we;
input[1:0] ar, aw;
input[7:0] din;
output[7:0] dout;
wire clk;
wire rstn;
wire en;
wire we;
wire [1:0] ar;
wire [1:0] aw;
wire [7:0] din;
reg [7:0] dout;
reg [7:0] d0;
reg [7:0] d1;
reg [7:0] d2;
reg [7:0] d3;
always @(ar or d0 or d1 or d2 or d3) begin
case(ar)
2'b 00 : dout <= d0;
2'b 01 : dout <= d1;
2'b 10 : dout <= d2;
default : dout <= d3;
endcase
end
always @(posedge clk or negedge rstn) begin
if(rstn == 1'b 0) begin
d0 <= {8{1'b0}};
d1 <= {8{1'b0}};
d2 <= {8{1'b0}};
d3 <= {8{1'b0}};
end else begin
if(en == 1'b 1) begin
if(we == 1'b 1) begin
case(aw)
2'b 00 : begin
d0 <= din;
end
2'b 01 : begin
d1 <= din;
end
2'b 10 : begin
d2 <= din;
end
default : begin
d3 <= din;
end
endcase
end
end
end
end
endmodule