import soc fasttuple2 and peripherals slowtuple2
[shakti-core.git] / src / lib / MemoryMap.bsv
1 /*
2 Copyright (c) 2013, IIT Madras
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 * Neither the name of IIT Madras nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
11 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
13 */
14 package MemoryMap;
15 /*=== Project imports ==== */
16 import defined_types::*;
17 import SoC::*;
18 import slow_peripherals::*;
19 `include "instance_defines.bsv"
20 `include "core_defines.bsv"
21 /*========================= */
22
23
24 function Tuple2 #(Bool, Bit#(TLog#(Num_Slaves))) fn_addr_to_slave_num (Bit#(`PADDR) addr);
25
26 Bool isfast;
27 Bit#(TLog#(Num_Slaves) y;
28 FastTuple2(isfast, y);
29 if (isfast)
30 return tuple2(isfast, y);
31
32 Bool isslow;
33 Bit#(TLog#(Num_Slow_Slaves) y;
34 SlowTuple2(isslow, y);
35 if (isslow)
36 return tuple2(True,fromInteger(valueOf(SlowPeripheral_slave_num)));
37
38 return tuple2(False,?);
39
40 endfunction
41
42 function Bool is_IO_Addr(Bit#(`PADDR) addr); // TODO Shuold be PADDR
43 if(addr>=`DebugBase && addr<=`DebugEnd)
44 return (True);
45 else if(addr>=`SDRAMMemBase && addr<=`SDRAMMemEnd)
46 `ifdef FlexBus
47 return (True);
48 `else
49 return (False);
50 `endif
51 `ifdef BOOTROM
52 else if(addr>=`BootRomBase && addr<=`BootRomEnd)
53 return (False);
54 `endif
55 `ifdef TCMemory
56 else if(addr>=`TCMBase && addr<=`TCMEnd)
57 return (False);
58 `endif
59 else
60 return True;
61 endfunction
62
63
64 endpackage