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

Subversion Repositories crcahb

[/] [crcahb/] [trunk/] [rtl/] [bit_reversal.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 redbear
//////////////////////////////////////////////////////////////////
2
////
3
////
4
////    CRCAHB CORE BLOCK
5
////
6
////
7
////
8
//// This file is part of the APB to I2C project
9
////
10
//// http://www.opencores.org/cores/apbi2c/
11
////
12
////
13
////
14
//// Description
15
////
16
//// Implementation of APB IP core according to
17
////
18
//// crcahb 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): -  Julio Cesar 
29
////
30
///////////////////////////////////////////////////////////////// 
31
////
32
////
33
//// Copyright (C) 2009 Authors and OPENCORES.ORG
34
////
35
////
36
////
37
//// This source file may be used and distributed without
38
////
39
//// restriction provided that this copyright statement is not
40
////
41
//// removed from the file and that any derivative work contains
42
//// the original copyright notice and the associated disclaimer.
43
////
44
////
45
//// This source file is free software; you can redistribute it
46
////
47
//// and/or modify it under the terms of the GNU Lesser General
48
////
49
//// Public License as published by the Free Software Foundation;
50
//// either version 2.1 of the License, or (at your option) any
51
////
52
//// later version.
53
////
54
////
55
////
56
//// This source is distributed in the hope that it will be
57
////
58
//// useful, but WITHOUT ANY WARRANTY; without even the implied
59
////
60
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
61
////
62
//// PURPOSE. See the GNU Lesser General Public License for more
63
//// details.
64
////
65
////
66
////
67
//// You should have received a copy of the GNU Lesser General
68
////
69
//// Public License along with this source; if not, download it
70
////
71
//// from http://www.opencores.org/lgpl.shtml
72
////
73
////
74
///////////////////////////////////////////////////////////////////
75
 
76 2 julioameri
`define size ((DATA_SIZE/4) * (2 ** (type - 1)))
77
 
78
module bit_reversal
79
#(
80
        parameter DATA_SIZE = 32
81
)
82
(
83
        //OUTPUTS
84
        output [DATA_SIZE - 1 : 0] data_out,
85
        //INPUTS
86
        input  [DATA_SIZE - 1 : 0] data_in,
87
        input  [1 : 0] rev_type
88
);
89
 
90
 
91
//Bit reversing types
92
localparam NO_REVERSE = 2'b00;
93
localparam BYTE       = 2'b01;
94
localparam HALF_WORD  = 2'b10;
95
localparam WORD       = 2'b11;
96
 
97
localparam TYPES = 4;
98
 
99
wire [DATA_SIZE - 1 : 0] data_reversed[0 : 3];
100
 
101
 
102
assign data_reversed[NO_REVERSE] = data_in; //bit order not affected
103
 
104
generate
105
        genvar i, type;
106
        for(type = 1 ; type < TYPES; type = type + 1)
107
                for(i = 0; i < DATA_SIZE; i = i + 1)
108
                        begin
109
                                if(i < `size)
110
                                        assign data_reversed[type][i] = data_in[`size*((i/`size) + 1) - 1 - i];
111
                                else
112
                                        assign data_reversed[type][i] = data_in[`size*((i/`size) + 1) - 1 - (i%(`size*(i/`size)))];
113
                        end
114
endgenerate
115
 
116
//Output Mux
117
assign data_out = data_reversed[rev_type];
118
 
119
endmodule

powered by: WebSVN 2.1.0

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