OpenCores
URL https://opencores.org/ocsvn/apbtoaes128/apbtoaes128/trunk

Subversion Repositories apbtoaes128

[/] [apbtoaes128/] [trunk/] [rtl/] [data_swap.v] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 redbear
//////////////////////////////////////////////////////////////////
2
////
3
////
4
////    AES CORE BLOCK
5
////
6
////
7
////
8 7 redbear
//// This file is part of the APB to I2C project
9 2 redbear
////
10 7 redbear
//// http://www.opencores.org/cores/apbi2c/
11 2 redbear
////
12
////
13
////
14
//// Description
15
////
16
//// Implementation of APB IP core according to
17
////
18
//// aes128_spec IP core specification document.
19
////
20
////
21
////
22
//// To Do: Things are right here but always all block can suffer changes
23
////
24
////
25
////
26
////
27
////
28
//// Author(s): - Felipe Fernandes Da Costa, fefe2560@gmail.com
29
////              Julio Cesar 
30
////
31
///////////////////////////////////////////////////////////////// 
32
////
33
////
34
//// Copyright (C) 2009 Authors and OPENCORES.ORG
35
////
36
////
37
////
38
//// This source file may be used and distributed without
39
////
40
//// restriction provided that this copyright statement is not
41
////
42
//// removed from the file and that any derivative work contains
43
//// the original copyright notice and the associated disclaimer.
44
////
45
////
46
//// This source file is free software; you can redistribute it
47
////
48
//// and/or modify it under the terms of the GNU Lesser General
49
////
50
//// Public License as published by the Free Software Foundation;
51
//// either version 2.1 of the License, or (at your option) any
52
////
53
//// later version.
54
////
55
////
56
////
57
//// This source is distributed in the hope that it will be
58
////
59
//// useful, but WITHOUT ANY WARRANTY; without even the implied
60
////
61
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
62
////
63
//// PURPOSE. See the GNU Lesser General Public License for more
64
//// details.
65
////
66
////
67
////
68
//// You should have received a copy of the GNU Lesser General
69
////
70
//// Public License along with this source; if not, download it
71
////
72
//// from http://www.opencores.org/lgpl.shtml
73
////
74
////
75
///////////////////////////////////////////////////////////////////
76
module data_swap
77
#(
78
        parameter WIDTH = 32
79
)(
80
        //OUTPUTS
81
        output [WIDTH - 1:0] data_swap,
82
        //INPUTS
83
        input  [WIDTH - 1:0] data_in,
84
        input  [ 1:0] swap_type
85
);
86
 
87
//=====================================================================================
88
// Swap Types
89
//=====================================================================================
90
localparam NO_SWAP        = 2'b00;
91
localparam HALF_WORD_SWAP = 2'b01;
92
localparam BYTE_SWAP      = 2'b10;
93
localparam BIT_SWAP       = 2'b11;
94
 
95
localparam TYPES = 4;
96
 
97
wire [WIDTH - 1 : 0] words[0 : TYPES - 1];
98
 
99
generate
100
        genvar i, j;
101
        for(i = 0; i < TYPES; i = i + 1)
102 7 redbear
        begin:BLOCK
103 2 redbear
                for(j = 0; j < WIDTH; j = j + 1)
104 7 redbear
                        begin: SUB_BLOCK
105 2 redbear
                                if(i != 3)
106
                                        assign words[i][j] = data_in[(WIDTH - (WIDTH/2**i)) - 2*(WIDTH/2**i)*(j/(WIDTH/2**i)) + j];
107
                                else
108
                                        assign words[i][j] = data_in[WIDTH - 1 - j];
109
                        end
110 7 redbear
        end
111 2 redbear
endgenerate
112
 
113
assign data_swap = words[swap_type];
114
 
115
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.