2 Copyright (c) 2013, IIT Madras
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
9 * Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14 * Neither the name of IIT Madras nor the names of its contributors
15 may be used to endorse or promote products derived from this software
16 without specific prior written permission.
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 -------------------------------------------------------------------
32 /*====== Package imports === */
35 import SpecialFIFOs::*;
37 import ClientServer::*;
39 import Connectable::*;
42 /*=== Project imports === */
46 import AXI4_Fabric::*;
47 import defined_types::*;
48 import MemoryMap :: *;
49 import slow_peripherals::*;
50 import fast_memory_map::*;
51 import slow_memory_map::*;
53 `include "defines.bsv"
55 `include "instance_defines.bsv"
56 `include "core_parameters.bsv"
66 import Memory_AXI4 ::*;
72 import DebugModule::*;
85 /*========================= */
87 interface SP_dedicated_ios slow_ios;
88 interface IOCellSide iocell_side;
89 (*always_ready,always_enabled*)
90 method Action boot_sequence(Bit#(1) bootseq);
93 (*prefix="M_AXI"*) interface
94 AXI4_Master_IFC#(`PADDR, `DATA, `USERSPACE) master;
97 (*always_ready,always_enabled*)
98 interface Ifc_flash ifc_flash;
100 /*=============================================== */
102 interface Vme_out proc_ifc;
103 interface Data_bus_inf proc_dbus;
108 //============ mkSoc module =================
111 module mkSoc #(Bit#(`VADDR) reset_vector,
112 Clock slow_clock, Reset slow_reset, Clock uart_clock,
113 Reset uart_reset, Clock clk0, Clock tck, Reset trst
114 `ifdef PWM_AXI4Lite ,Clock ext_pwm_clock `endif )(Ifc_Soc);
115 Clock core_clock <-exposeCurrentClock; // slow peripheral clock
116 Reset core_reset <-exposeCurrentReset; // slow peripheral reset
119 Ifc_DebugModule core<-mkDebugModule(reset_vector);
121 Ifc_core_AXI4 core <-mkcore_AXI4(reset_vector);
124 BootRom_IFC bootrom <-mkBootRom;
127 Memory_IFC#(`SDRAMMemBase,`Addr_space)main_memory <-
128 mkMemory("code.mem.MSB","code.mem.LSB","MainMEM");
131 Ifc_TCM tcm <- mkTCM;
134 DmaC#(7,`NUM_DMACHANNELS) dma <- mkDMA();
137 Ifc_vme_top vme <-mkvme_top();
139 Ifc_slow_peripherals slow_peripherals <-mkslow_peripherals(
140 core_clock, core_reset,
141 uart_clock, uart_reset,
142 clocked_by slow_clock, reset_by slow_reset
143 `ifdef PWM_AXI4Lite , ext_pwm_clock `endif );
145 // clock sync mkConnections
149 AXI4_Fabric_IFC #(Num_Masters, Num_Fast_Slaves,
150 `PADDR, `DATA,`USERSPACE)
151 fabric <- mkAXI4_Fabric(fn_addr_to_slave_num);
153 // Connect traffic generators to fabric
154 mkConnection (core.dmem_master,fabric.v_from_masters
155 [fromInteger(valueOf(Dmem_master_num))]);
156 mkConnection (core.imem_master, fabric.v_from_masters
157 [fromInteger(valueOf(Imem_master_num))]);
159 mkConnection (core.debug_master, fabric.v_from_masters
160 [fromInteger(valueOf(Debug_master_num))]);
163 mkConnection (dma.mmu, fabric.v_from_masters
164 [fromInteger(valueOf(DMA_master_num))]);
169 // Connect fabric to memory slaves
171 mkConnection (fabric.v_to_slaves
172 [fromInteger(valueOf(Debug_slave_num))],
176 mkConnection(fabric.v_to_slaves
177 [fromInteger(valueOf(Sdram_slave_num))],
178 main_memory.axi_slave);
181 mkConnection (fabric.v_to_slaves
182 [fromInteger(valueOf(BootRom_slave_num))],
186 mkConnection (fabric.v_to_slaves
187 [fromInteger(valueOf(Dma_slave_num))],
188 dma.cfg); //DMA slave
191 mkConnection (fabric.v_to_slaves
192 [fromInteger(valueOf(TCM_slave_num))],
195 mkConnection(fabric.v_to_slaves
196 [fromInteger(valueOf(SlowPeripheral_slave_num))],
197 slow_peripherals.axi_slave);
199 mkConnection (fabric.v_to_slaves
200 [fromInteger(valueOf(VME_slave_num))],
207 // fabric connections
211 // rule to connect all interrupt lines to the DMA
212 // All the interrupt lines to DMA are active
213 // HIGH. For peripherals that are not connected,
214 // or those which do not
215 // generate an interrupt (like TCM), drive a constant 1
216 // on the corresponding interrupt line.
221 /*==== Synchornization between the JTAG and the Debug Module ===== */
223 SyncFIFOIfc#(Bit#(40)) sync_request_to_dm <-
224 mkSyncFIFOToCC(1,tck,trst);
225 SyncFIFOIfc#(Bit#(34)) sync_response_from_dm <-
226 mkSyncFIFOFromCC(1,tck);
227 rule connect_tap_request_to_syncfifo;
228 let x<-tap.request_to_dm;
229 sync_request_to_dm.enq(x);
231 rule read_synced_request_to_dm;
232 sync_request_to_dm.deq;
233 core.request_from_dtm(sync_request_to_dm.first);
236 rule connect_debug_response_to_syncfifo;
237 let x<-core.response_to_dtm;
238 sync_response_from_dm.enq(x);
240 rule read_synced_response_from_dm;
241 sync_response_from_dm.deq;
242 tap.response_from_dm(sync_response_from_dm.first);
245 /*============================================================ */
248 //rule drive_flexbus_inputs;
249 //flexbus.flexbus_side.m_TAn(1'b1);
250 //flexbus.flexbus_side.m_din(32'haaaaaaaa);
255 SyncBitIfc#(Bit#(1)) clint_mtip_int <-
256 mkSyncBitToCC(slow_clock,slow_reset);
257 SyncBitIfc#(Bit#(1)) clint_msip_int <-
258 mkSyncBitToCC(slow_clock,slow_reset);
259 Reg#(Bit#(`DATA)) clint_mtime_value <-
260 mkSyncRegToCC(0,slow_clock,slow_reset);
261 rule synchronize_clint_data;
262 clint_mtip_int.send(slow_peripherals.mtip_int);
263 clint_msip_int.send(slow_peripherals.msip_int);
264 clint_mtime_value<=slow_peripherals.mtime;
266 rule connect_msip_mtip_from_clint;
267 core.clint_msip(clint_msip_int.read);
268 core.clint_mtip(clint_mtip_int.read);
269 core.clint_mtime(clint_mtime_value);
273 Reg#(Tuple2#(Bool,Bool)) plic_interrupt_note <-
274 mkSyncRegToCC(tuple2(False,False),
275 slow_clock,slow_reset);
276 rule synchronize_interrupts;
277 let note <- slow_peripherals.intrpt_note;
278 plic_interrupt_note<=note;
280 rule rl_send_external_interrupt_to_csr;
281 core.set_external_interrupt(plic_interrupt_note);
286 interface proc_ifc = vme.proc_ifc;
287 interface proc_dbus = vme.proc_dbus;
289 method Action boot_sequence(Bit#(1) bootseq) =
290 core.boot_sequence(bootseq);
292 interface master=fabric.v_to_slaves
293 [fromInteger(valueOf(Sdram_slave_num))];
295 interface slow_ios = slow_peripherals.slow_ios;
296 interface iocell_side = slow_peripherals.iocell_side;