mem8.v
2.38 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// 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 : mem.vhd
// Author : Vincenzo Liguori
// Date : 01-03-02
// Version 1.0
// Abstract :
// This implements the AES key registers
//
// Modification history :
// Date by Version Change description
// -------------------------------------------------
// 01-03-02 VL 1.0 Original
module mem8(
clk,
rstn,
en,
we,
ar,
aw,
din,
dout
);
input clk, rstn;
input en, we;
input[2:0] ar, aw;
input[31:0] din;
output[31:0] dout;
wire clk;
wire rstn;
wire en;
wire we;
wire [2:0] ar;
wire [2:0] aw;
wire [31:0] din;
reg [31:0] dout;
reg [31:0] d0;
reg [31:0] d1;
reg [31:0] d2;
reg [31:0] d3;
reg [31:0] d4;
reg [31:0] d5;
reg [31:0] d6;
reg [31:0] d7;
always @(ar or d0 or d1 or d2 or d3 or d4 or d5 or d6 or d7) begin
case(ar)
3'b 000 : dout <= d0;
3'b 001 : dout <= d1;
3'b 010 : dout <= d2;
3'b 011 : dout <= d3;
3'b 100 : dout <= d4;
3'b 101 : dout <= d5;
3'b 110 : dout <= d6;
default : dout <= d7;
endcase
end
always @(posedge clk or negedge rstn) begin
if(rstn == 1'b 0) begin
d0 <= {32{1'b0}};
d1 <= {32{1'b0}};
d2 <= {32{1'b0}};
d3 <= {32{1'b0}};
d4 <= {32{1'b0}};
d5 <= {32{1'b0}};
d6 <= {32{1'b0}};
d7 <= {32{1'b0}};
end else begin
if(en == 1'b 1) begin
if(we == 1'b 1) begin
case(aw)
3'b 000 : begin
d0 <= din;
end
3'b 001 : begin
d1 <= din;
end
3'b 010 : begin
d2 <= din;
end
3'b 011 : begin
d3 <= din;
end
3'b 100 : begin
d4 <= din;
end
3'b 101 : begin
d5 <= din;
end
3'b 110 : begin
d6 <= din;
end
default : begin
d7 <= din;
end
endcase
end
end
end
end
endmodule