Updated to latest scc version
This commit is contained in:
		| @@ -37,3 +37,5 @@ if(SCV_FOUND) | ||||
| endif(SCV_FOUND) | ||||
|  | ||||
| add_subdirectory(simple_system) | ||||
| add_subdirectory(transaction_recording) | ||||
| add_subdirectory(ahb_bfm_test) | ||||
|   | ||||
							
								
								
									
										10
									
								
								examples/ahb_bfm_test/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								examples/ahb_bfm_test/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| cmake_minimum_required(VERSION 3.3) | ||||
| # Add executable called "transaction_recording" that is built from the source files | ||||
| # "scv_tr_recording_example.cpp". The extensions are automatically found. | ||||
| add_executable (ahb_bfm_test | ||||
| 	sc_main.cpp | ||||
| ) | ||||
| # Link the executable to the sc_components library. Since the sc_components library has | ||||
| # public include directories we will use those link directories when building | ||||
| # transaction_recording | ||||
| target_link_libraries (ahb_bfm_test LINK_PUBLIC scc ${CONAN_LIBS}) | ||||
							
								
								
									
										151
									
								
								examples/ahb_bfm_test/sc_main.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										151
									
								
								examples/ahb_bfm_test/sc_main.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,151 @@ | ||||
| #include <tlm/ahb/bfm/initiator.h> | ||||
| #include <tlm/ahb/bfm/target.h> | ||||
| #include <scc/initiator_mixin.h> | ||||
| #include <scc/target_mixin.h> | ||||
| #include <scc/configurable_tracer.h> | ||||
| #include <scc/configurer.h> | ||||
| #include <scc/report.h> | ||||
| #include <scc/scv_tr_db.h> | ||||
| #include <scc/tracer.h> | ||||
| #include <scc/traceable.h> | ||||
| #include <scv.h> | ||||
| #include <cci_utils/broker.h> | ||||
| #include <iostream> | ||||
|  | ||||
| using namespace sc_core; | ||||
| using namespace scc; | ||||
|  | ||||
| class testbench: public sc_module, public scc::traceable { | ||||
| public: | ||||
|     enum { WIDTH=64}; | ||||
|     scc::initiator_mixin<tlm::tlm_initiator_socket<WIDTH>> isck{"isck"}; | ||||
|     tlm::ahb::bfm::initiator<WIDTH> intor{"intor"}; | ||||
|     sc_core::sc_clock                         HCLK{"HCLK", 10_ns}; | ||||
|     sc_core::sc_signal<bool>                  HRESETn{"HRESETn"}; | ||||
|     sc_core::sc_signal<sc_dt::sc_uint<32>>    HADDR{"HADDR"}; | ||||
|     sc_core::sc_signal<sc_dt::sc_uint<3>>     HBURST{"HBURST"}; | ||||
|     sc_core::sc_signal<bool>                  HMASTLOCK{"HMASTLOCK"}; | ||||
|     sc_core::sc_signal<sc_dt::sc_uint<4>>     HPROT{"HPROT"}; | ||||
|     sc_core::sc_signal<sc_dt::sc_uint<3>>     HSIZE{"HSIZE"}; | ||||
|     sc_core::sc_signal<sc_dt::sc_uint<2>>     HTRANS{"HTRANS"}; | ||||
|     sc_core::sc_signal<sc_dt::sc_uint<WIDTH>> HWDATA{"HWDATA"}; | ||||
|     sc_core::sc_signal<bool>                  HWRITE{"HWRITE"}; | ||||
|     sc_core::sc_signal<sc_dt::sc_uint<WIDTH>>  HRDATA{"HRDATA"}; | ||||
|     sc_core::sc_signal<bool>                   HREADY{"HREADY"}; | ||||
|     sc_core::sc_signal<bool>                   HRESP{"HRESP"}; | ||||
|     sc_core::sc_signal<bool>                   HSEL{"HSEL"}; | ||||
|  | ||||
|     tlm::ahb::bfm::target<WIDTH> target{"target"}; | ||||
|     scc::target_mixin<tlm::tlm_target_socket<WIDTH>> tsck{"tsck"}; | ||||
|  | ||||
|     testbench(sc_module_name nm):sc_module(nm){ | ||||
|         SC_HAS_PROCESS(testbench); | ||||
|         isck(intor.tsckt); | ||||
|         intor.HCLK_i(HCLK); | ||||
|         intor.HRESETn_i(HRESETn); | ||||
|         intor.HADDR_o(HADDR); | ||||
|         intor.HBURST_o(HBURST); | ||||
|         intor.HMASTLOCK_o(HMASTLOCK); | ||||
|         intor.HPROT_o(HPROT); | ||||
|         intor.HSIZE_o(HSIZE); | ||||
|         intor.HTRANS_o(HTRANS); | ||||
|         intor.HWDATA_o(HWDATA); | ||||
|         intor.HWRITE_o(HWRITE); | ||||
|         intor.HRDATA_i(HRDATA); | ||||
|         intor.HREADY_i(HREADY); | ||||
|         intor.HRESP_i(HRESP); | ||||
|         target.HCLK_i(HCLK); | ||||
|         target.HRESETn_i(HRESETn); | ||||
|         target.HADDR_i(HADDR); | ||||
|         target.HBURST_i(HBURST); | ||||
|         target.HMASTLOCK_i(HMASTLOCK); | ||||
|         target.HPROT_i(HPROT); | ||||
|         target.HSIZE_i(HSIZE); | ||||
|         target.HTRANS_i(HTRANS); | ||||
|         target.HWDATA_i(HWDATA); | ||||
|         target.HWRITE_i(HWRITE); | ||||
|         target.HSEL_i(HSEL); | ||||
|         target.HRDATA_o(HRDATA); | ||||
|         target.HREADY_o(HREADY); | ||||
|         target.HRESP_o(HRESP); | ||||
|         target.isckt(tsck); | ||||
|         SC_THREAD(run); | ||||
|         tsck.register_b_transport([this](tlm::tlm_generic_payload& gp, sc_time& delay){ | ||||
|             gp.set_response_status(tlm::TLM_OK_RESPONSE); | ||||
|             if(gp.is_write()){ | ||||
|                 SCCINFO(SCMOD)<<"Received write access to addr 0x"<<std::hex<<gp.get_address(); | ||||
|             } else{ | ||||
|                 memset(gp.get_data_ptr(), 0x55, gp.get_data_length()); | ||||
|                 SCCINFO(SCMOD)<<"Received read access from addr 0x"<<std::hex<<gp.get_address(); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     void run(){ | ||||
|         HRESETn.write(false); | ||||
|         for(size_t i=0; i<10; ++i) wait(HCLK.posedge_event()); | ||||
|         HRESETn.write(true); | ||||
|         wait(HCLK.posedge_event()); | ||||
|         HSEL.write(true); | ||||
|         tlm::tlm_generic_payload gp; | ||||
|         uint8_t data[8]; | ||||
|         data[0]=2; | ||||
|         data[1]=4; | ||||
|         gp.set_address(0x1000); | ||||
|         gp.set_data_length(8); | ||||
|         gp.set_data_ptr(data); | ||||
|         gp.set_streaming_width(8); | ||||
|         gp.set_command(tlm::TLM_WRITE_COMMAND); | ||||
|         sc_time delay; | ||||
|         isck->b_transport(gp, delay); | ||||
|         gp.set_address(0x1020); | ||||
|         gp.set_data_length(8); | ||||
|         gp.set_data_ptr(data); | ||||
|         gp.set_streaming_width(8); | ||||
|         gp.set_command(tlm::TLM_READ_COMMAND); | ||||
|         delay=SC_ZERO_TIME; | ||||
|         isck->b_transport(gp, delay); | ||||
|         for(size_t i=0; i<10; ++i) wait(HCLK.posedge_event()); | ||||
|         sc_stop(); | ||||
|     } | ||||
|  | ||||
| }; | ||||
|  | ||||
| int sc_main (int argc , char *argv[]){ | ||||
|     sc_core::sc_report_handler::set_actions( "/IEEE_Std_1666/deprecated", sc_core::SC_DO_NOTHING ); | ||||
|     sc_report_handler::set_actions(SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, SC_DO_NOTHING); | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     // create global CCI broker | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     cci::cci_register_broker(new cci_utils::broker("Global Broker")); | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     // configure logging | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     scc::init_logging(logging::DEBUG); | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     // set up configuration | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     scc::configurer cfg("ahb_test.json"); | ||||
|     scc::configurable_tracer trace("ahb_test", tracer::TEXT, true, true); | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     // create modules/channels and trace | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     testbench tb("tb"); | ||||
|     trace.add_control(); | ||||
|     { | ||||
|         std::ofstream of{"ahb_test.default.json"}; | ||||
|         if (of.is_open()) cfg.dump_configuration(of); | ||||
|     } | ||||
|     cfg.configure(); | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     // run the simulation | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     try { | ||||
|         sc_core::sc_start(1_us); | ||||
|         if (!sc_core::sc_end_of_simulation_invoked()) sc_core::sc_stop(); | ||||
|     } catch (sc_core::sc_report &rep) { | ||||
|         sc_core::sc_report_handler::get_handler()(rep, sc_core::SC_DISPLAY | sc_core::SC_STOP); | ||||
|     } | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| @@ -13,10 +13,6 @@ add_executable (simple_system | ||||
| # Link the executable to the sc_components library. Since the sc_components library has | ||||
| # public include directories we will use those link directories when building | ||||
| # simple_system | ||||
| target_link_libraries (simple_system LINK_PUBLIC sc-components) | ||||
| target_link_libraries (simple_system LINK_PUBLIC ${SystemC_LIBRARIES}) | ||||
| target_link_libraries (simple_system LINK_PUBLIC ${SCV_LIBRARIES}) | ||||
| target_link_libraries (simple_system LINK_PUBLIC scc) | ||||
| target_link_libraries (simple_system LINK_PUBLIC ${Boost_LIBRARIES} ) | ||||
| target_link_libraries (simple_system LINK_PUBLIC ${CMAKE_THREAD_LIBS_INIT}) | ||||
| target_link_libraries (simple_system LINK_PUBLIC ${ZLIB_LIBRARY}) | ||||
| target_link_libraries (simple_system LINK_PUBLIC ${CMAKE_DL_LIBS}) | ||||
|   | ||||
| @@ -18,10 +18,10 @@ | ||||
| // need double braces, see | ||||
| // https://stackoverflow.com/questions/6893700/how-to-construct-stdarray-object-with-initializer-list#6894191 | ||||
| const std::array<scc::target_memory_map_entry<32>, 4> e300_plat_map = {{ | ||||
|     {&i_plic, 0x0c000000, 0x200008}, | ||||
|     {&i_gpio, 0x10012000, 0x1000}, | ||||
|     {&i_uart, 0x10013000, 0x1000}, | ||||
|     {&i_spi, 0x10014000, 0x1000}, | ||||
|     {i_plic.socket, 0x0c000000, 0x200008}, | ||||
|     {i_gpio.socket, 0x10012000, 0x1000}, | ||||
|     {i_uart.socket, 0x10013000, 0x1000}, | ||||
|     {i_spi.socket, 0x10014000, 0x1000}, | ||||
| }}; | ||||
|  | ||||
| #endif /* _E300_PLAT_MAP_H_ */ | ||||
|   | ||||
| @@ -25,7 +25,7 @@ gpio::gpio(sc_core::sc_module_name nm) | ||||
| , tlm_target<>(clk) | ||||
| , NAMED(clk_i) | ||||
| , NAMED(rst_i) | ||||
| , NAMEDD(gpio_regs, regs) { | ||||
| , NAMEDD(regs, gpio_regs) { | ||||
|     regs->registerResources(*this); | ||||
|     SC_METHOD(clock_cb); | ||||
|     sensitive << clk_i; | ||||
|   | ||||
| @@ -50,8 +50,7 @@ plic::plic(sc_core::sc_module_name nm) | ||||
| , NAMED(rst_i) | ||||
| , NAMED(global_interrupts_i, 256) | ||||
| , NAMED(core_interrupt_o) | ||||
| , NAMEDD(plic_regs, regs) | ||||
|  | ||||
| , NAMEDD(regs, plic_regs) | ||||
| { | ||||
|     regs->registerResources(*this); | ||||
|     // register callbacks | ||||
|   | ||||
| @@ -21,11 +21,12 @@ | ||||
|  */ | ||||
|  | ||||
| #include "simple_system.h" | ||||
| #include <boost/program_options.hpp> | ||||
| #include <sstream> | ||||
| #include <scc/report.h> | ||||
| #include <scc/scv_tr_db.h> | ||||
| #include <scc/tracer.h> | ||||
| #include <cci_utils/broker.h> | ||||
| #include <boost/program_options.hpp> | ||||
| #include <sstream> | ||||
|  | ||||
| using namespace sysc; | ||||
| using namespace scc; | ||||
| @@ -38,10 +39,12 @@ const size_t ERROR_UNHANDLED_EXCEPTION = 2; | ||||
| } // namespace | ||||
|  | ||||
| int sc_main(int argc, char *argv[]) { | ||||
|     sc_core::sc_report_handler::set_actions( "/IEEE_Std_1666/deprecated", sc_core::SC_DO_NOTHING ); | ||||
|     sc_core::sc_report_handler::set_actions(sc_core::SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, sc_core::SC_DO_NOTHING); | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     // setup initial logging | ||||
|     // create global CCI broker | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     scc::Logger<>::reporting_level() = logging::INFO; | ||||
|     cci::cci_register_broker(new cci_utils::broker("Global Broker")); | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     // CLI argument parsing | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
| @@ -67,12 +70,10 @@ int sc_main(int argc, char *argv[]) { | ||||
|         std::cerr << desc << std::endl; | ||||
|         return ERROR_IN_COMMAND_LINE; | ||||
|     } | ||||
|     if (vm.count("debug")) { | ||||
|     	LOGGER(DEFAULT)::reporting_level() = log::DEBUG; | ||||
|         LOGGER(SystemC)::reporting_level() = log::DEBUG; | ||||
|         scc::Logger<>::reporting_level() = log::DEBUG; | ||||
|     } | ||||
|  | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     // configure logging | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     scc::init_logging(vm.count("debug")?logging::DEBUG:logging::INFO); | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|     // set up tracing & transaction recording | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|   | ||||
| @@ -42,8 +42,8 @@ simple_system::simple_system(sc_core::sc_module_name nm) | ||||
|     i_master.intor(i_router.target[0]); | ||||
|     size_t i = 0; | ||||
|     for (const auto &e : e300_plat_map) { | ||||
|         i_router.initiator[i](e.target->socket); | ||||
|         i_router.add_target_range(i, e.start, e.size); | ||||
|         i_router.initiator[i](e.target); | ||||
|         i_router.set_target_range(i, e.start, e.size); | ||||
|         i++; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -25,7 +25,7 @@ spi::spi(sc_core::sc_module_name nm) | ||||
| , tlm_target<>(clk) | ||||
| , NAMED(clk_i) | ||||
| , NAMED(rst_i) | ||||
| , NAMEDD(spi_regs, regs) { | ||||
| , NAMEDD(regs, spi_regs) { | ||||
|     regs->registerResources(*this); | ||||
|     SC_METHOD(clock_cb); | ||||
|     sensitive << clk_i; | ||||
|   | ||||
| @@ -25,7 +25,7 @@ uart::uart(sc_core::sc_module_name nm) | ||||
| , tlm_target<>(clk) | ||||
| , NAMED(clk_i) | ||||
| , NAMED(rst_i) | ||||
| , NAMEDD(uart_regs, regs) { | ||||
| , NAMEDD(regs, uart_regs) { | ||||
|     regs->registerResources(*this); | ||||
|     SC_METHOD(clock_cb); | ||||
|     sensitive << clk_i; | ||||
|   | ||||
| @@ -7,8 +7,4 @@ add_executable (transaction_recording | ||||
| # Link the executable to the sc_components library. Since the sc_components library has | ||||
| # public include directories we will use those link directories when building | ||||
| # transaction_recording | ||||
| target_link_libraries (transaction_recording LINK_PUBLIC sc-components) | ||||
| target_link_libraries (transaction_recording LINK_PUBLIC ${SystemC_LIBRARIES}) | ||||
| target_link_libraries (transaction_recording LINK_PUBLIC ${SCV_LIBRARIES}) | ||||
| target_link_libraries (transaction_recording LINK_PUBLIC ${CMAKE_THREAD_LIBS_INIT}) | ||||
| target_link_libraries (transaction_recording LINK_PUBLIC ${CMAKE_DL_LIBS}) | ||||
| target_link_libraries (transaction_recording LINK_PUBLIC scc ${CONAN_LIBS}) | ||||
|   | ||||
| @@ -329,13 +329,8 @@ extern void scv_tr_sqlite_init(); | ||||
| int sc_main(int argc, char *argv[]) { | ||||
|     scv_startup(); | ||||
|  | ||||
| #if 0 | ||||
|     scv_tr_text_init(); | ||||
|     const char* fileName = "my_db.txlog"; | ||||
| #else | ||||
|     scv_tr_sqlite_init(); | ||||
|     const char *fileName = "my_db"; | ||||
| #endif | ||||
|     scv_tr_db db(fileName); | ||||
|     scv_tr_db::set_default_db(&db); | ||||
|     sc_trace_file *tf = sc_create_vcd_trace_file("my_db"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user