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

Subversion Repositories pci

[/] [pci/] [tags/] [rel_3/] [rtl/] [verilog/] [decoder.v] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mihad
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name: decoder.v                                        ////
4
////                                                              ////
5
////  This file is part of the "PCI bridge" project               ////
6
////  http://www.opencores.org/cores/pci/                         ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Tadej Markovic, tadej@opencores.org                   ////
10
////      - Tilen Novak, tilen@opencores.org                      ////
11
////                                                              ////
12
////  All additional information is avaliable in the README.txt   ////
13
////  file.                                                       ////
14
////                                                              ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2000 Tadej Markovic, tadej@opencores.org       ////
19
////                    Tilen Novak, tilen@opencores.org          ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47 6 mihad
// Revision 1.1.1.1  2001/10/02 15:33:46  mihad
48
// New project directory structure
49 2 mihad
//
50 6 mihad
//
51 2 mihad
 
52
`include "constants.v"
53 6 mihad
`include "timescale.v"
54 2 mihad
 
55
module DECODER (hit, addr_out, addr_in, base_addr, mask_addr, tran_addr, at_en) ;
56
 
57
// Decoding address size parameter - for FPGAs 1MegByte is recommended
58
//   MAXIMUM is 20 (4KBytes), length 12 is 1 MByte !!!
59
parameter               decode_len     = 12 ;
60
 
61
//###########################################################################################################
62
// ALL COMMENTS are written as there were decode_len 20. This number and 12 (32 - 20) are assigning the 
63
// numbers of decoded and compared bits, etc.
64
//###########################################################################################################
65
 
66
/*-----------------------------------------------------------------------------------------------------------
67
DECODER interface decodes input address (ADDR_IN); what means that it validates (HIT), if input address
68
falls within the defined image space boundaries. Image space boundarie is defined with image base address
69
register (BASE_ADDR) and address mask register (MASK_ADDR).
70
Beside that, it also translates (maps) the input address to the output address (ADDR_OUT), regarding the
71
translation address register (TRAN_ADDR) and the address mask register.
72
-----------------------------------------------------------------------------------------------------------*/
73
 
74
// output control  
75
output  hit ;
76
// output address 
77
output  [31:0]   addr_out ;
78
// input address
79
input   [31:0]   addr_in ;
80
 
81
// input registers - 12 LSbits are not valid since the smallest possible size is 4KB !
82
input   [31:(32-decode_len)]    base_addr ;
83
input   [31:(32-decode_len)]    mask_addr ;
84
input   [31:(32-decode_len)]    tran_addr ;
85
 
86
// input bit[2] of the Image Control register used to enable the address translation !
87
input   at_en ;
88
/*-----------------------------------------------------------------------------------------------------------
89
Internal signals !
90
-----------------------------------------------------------------------------------------------------------*/
91
 
92
// bit[31] if address mask register is IMAGE ENABLE bit (img_en)
93
wire    img_en ;
94
 
95
// addr_in_compare are masked input address bits that are compared with masked base_addr
96
wire    [31:(32-decode_len)]    addr_in_compare ;
97
// base_addr_compare are masked base address bits that are compared with masked addr_in
98
wire    [31:(32-decode_len)]    base_addr_compare ;
99
 
100
/*-----------------------------------------------------------------------------------------------------------
101
Decoding the input address!
102
This logic produces the loghest path in this module!
103
 
104
20 MSbits of input addres are as well as base address (20 bits) masked with corrected address mask. Only
105
masked bits of each vector are actually logically compared.
106
Bit[31] of address mask register is used to enable the image space !
107
-----------------------------------------------------------------------------------------------------------*/
108
 
109
assign addr_in_compare = (addr_in[31:(32-decode_len)] & mask_addr) ;
110
 
111
assign base_addr_compare = (base_addr & mask_addr) ;
112
 
113
assign img_en = mask_addr[31] ;
114
 
115
assign hit = { 1'b1, addr_in_compare } == { img_en, base_addr_compare } ;
116
 
117
/*-----------------------------------------------------------------------------------------------------------
118
Translating the input address!
119
 
120
Translation of input address is not implemented if ADDR_TRAN_IMPL is not defined
121
 
122
20 MSbits of input address are masked with negated value of the corrected address mask in order to get
123
address bits of the input address which won't be replaced with translation address bits.
124
Translation address bits (20 bits) are masked with corrected address mask. Only masked bits of vector are
125
actually valid, all others are zero.
126
Boath vectors are bit-wise ORed in order to get the valid translation address with an offset of an input
127
address.
128
12 LSbits of an input address are assigned to 12 LSbits of an output addres.
129
-----------------------------------------------------------------------------------------------------------*/
130
 
131
`ifdef ADDR_TRAN_IMPL
132
    // if Address Translation Enable bit is set, then translation address is used othervise input address is used!
133
    // addr_in_combine input address bits are not replaced with translation address!
134
    wire        [31:(32-decode_len)] addr_in_combine ;
135
    // tran_addr_combine are masked and combined with addr_in_combine!
136
    reg         [31:(32-decode_len)] tran_addr_combine ;
137
 
138
    assign addr_in_combine = (addr_in[31:(32-decode_len)] & ~mask_addr) ;
139
    always@(at_en or tran_addr or mask_addr or addr_in)
140
        begin
141
            if (at_en)
142
                        begin
143
                                tran_addr_combine <= (tran_addr & mask_addr) ;
144
                end
145
        else
146
                        begin
147
                                tran_addr_combine <= (addr_in[31:(32-decode_len)] & mask_addr) ;
148
                        end
149
        end
150
 
151
    assign addr_out[31:(32-decode_len)] = addr_in_combine | tran_addr_combine ;
152
    assign addr_out[(31-decode_len):0] = addr_in [(31-decode_len):0] ;
153
`else
154
    assign addr_out = addr_in ;
155
`endif
156
 
157
endmodule
158
 

powered by: WebSVN 2.1.0

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