| 
									
										
										
										
											2018-09-21 17:23:31 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |    @file BusCtrl.h | 
					
						
							|  |  |  |    @brief Basic TLM-2 Bus controller | 
					
						
							|  |  |  |    @author Màrius Montón | 
					
						
							|  |  |  |    @date September 2018 | 
					
						
							| 
									
										
										
										
											2018-09-20 05:44:38 +08:00
										 |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __BUSCTRL_H__
 | 
					
						
							|  |  |  | #define __BUSCTRL_H__
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <iostream>
 | 
					
						
							|  |  |  | #include <fstream>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define SC_INCLUDE_DYNAMIC_PROCESSES
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "systemc"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "tlm.h"
 | 
					
						
							|  |  |  | #include "tlm_utils/simple_initiator_socket.h"
 | 
					
						
							|  |  |  | #include "tlm_utils/simple_target_socket.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Log.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using namespace sc_core; | 
					
						
							|  |  |  | using namespace sc_dt; | 
					
						
							|  |  |  | using namespace std; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-21 17:23:31 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Memory mapped Trace peripheral address | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-09-20 05:44:38 +08:00
										 |  |  | #define TRACE_MEMORY_ADDRESS 0x40000000
 | 
					
						
							| 
									
										
										
										
											2018-09-21 17:23:31 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @brief Simple bus controller | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This module manages instructon & data bus. It has 2 target ports, | 
					
						
							|  |  |  |  * cpu_instr_socket and cpu_data_socket that receives accesses from CPU and | 
					
						
							|  |  |  |  * has 2 initiator ports to access main Memory and Trace module. | 
					
						
							|  |  |  |  * It will be expanded with more ports when required (for DMA, | 
					
						
							|  |  |  |  * other peripherals, etc.) | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-09-20 05:44:38 +08:00
										 |  |  | class BusCtrl: sc_module { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2018-09-21 17:23:31 +08:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * @brief TLM target socket CPU instruction memory bus | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2018-09-20 05:44:38 +08:00
										 |  |  |     tlm_utils::simple_target_socket<BusCtrl> cpu_instr_socket; | 
					
						
							| 
									
										
										
										
											2018-09-21 17:23:31 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * @brief TLM target socket CPU data memory bus | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2018-09-20 05:44:38 +08:00
										 |  |  |     tlm_utils::simple_target_socket<BusCtrl> cpu_data_socket; | 
					
						
							| 
									
										
										
										
											2018-09-21 17:23:31 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * @brief TLM initiator socket Main memory bus | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     tlm_utils::simple_initiator_socket<BusCtrl> memory_socket; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * @brief TLM initiator socket Trace module | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2018-09-20 05:44:38 +08:00
										 |  |  |     tlm_utils::simple_initiator_socket<BusCtrl> trace_socket; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-21 17:23:31 +08:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * @brief constructor | 
					
						
							|  |  |  |      * @param name module's name | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-20 05:44:38 +08:00
										 |  |  |     BusCtrl(sc_module_name name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-21 17:23:31 +08:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * @brief TLM-2 blocking mechanism | 
					
						
							|  |  |  |      * @param trans transtractino to perform | 
					
						
							|  |  |  |      * @param delay delay associated to this transaction | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2018-09-20 05:44:38 +08:00
										 |  |  |     virtual void b_transport( tlm::tlm_generic_payload& trans, sc_time& delay ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |       Log *log; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 |