-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
2,598 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,40 @@ | ||
# a small wrapper to map SLS, OSCI SystemC (from environment) and conan package to the same variables | ||
if(NOT SystemC_FOUND) | ||
if(USE_CWR_SYSTEMC) | ||
find_package(SLSSystemC REQUIRED) | ||
elseif(USE_NCSC_SYSTEMC) | ||
find_package(XMSystemC REQUIRED) | ||
else() | ||
find_package(SystemCLanguage QUIET) | ||
if(TARGET SystemC::systemc) # conan find_package_generator or the cmake of an SystemC installation | ||
set(SystemC_FOUND true) | ||
set(SystemC_LIBRARIES SystemC::systemc) | ||
find_package(systemc-scv QUIET) | ||
if(systemc-scv_FOUND) | ||
set(SCV_FOUND TRUE) | ||
set(SCV_LIBRARIES systemc-scv::systemc-scv) | ||
endif() | ||
find_package(systemc-cci QUIET) | ||
if(systemc-cci_FOUND) | ||
set(CCI_FOUND TRUE) | ||
set(CCI_LIBRARIES systemc-cci::systemc-cci) | ||
endif() | ||
elseif(TARGET CONAN_PKG::systemc) # conan cmake targets | ||
set(SystemC_FOUND true) | ||
set(SystemC_LIBRARIES CONAN_PKG::systemc) | ||
if(TARGET CONAN_PKG::systemc-scv) | ||
set(SCV_FOUND TRUE) | ||
set(SCV_LIBRARIES CONAN_PKG::systemc-scv) | ||
endif() | ||
if(TARGET CONAN_PKG::systemc-cci) | ||
set(CCI_FOUND TRUE) | ||
set(CCI_LIBRARIES CONAN_PKG::systemc-cci) | ||
endif() | ||
else() | ||
find_package(OSCISystemC) | ||
if(USE_CWR_SYSTEMC) | ||
find_package(SLSSystemC REQUIRED) | ||
set(SystemC_LIBRARIES SystemC::systemc) | ||
elseif(USE_NCSC_SYSTEMC) | ||
find_package(XMSystemC REQUIRED) | ||
set(SystemC_LIBRARIES SystemC::systemc) | ||
else() | ||
find_package(SystemCLanguage QUIET) | ||
if(TARGET SystemC::systemc) # conan find_package_generator or the cmake of an SystemC installation | ||
set(SystemC_FOUND true) | ||
set(SystemC_LIBRARIES SystemC::systemc) | ||
endif() | ||
endif() | ||
find_package(systemc-scv QUIET) | ||
if(systemc-scv_FOUND) | ||
set(SCV_FOUND TRUE) | ||
set(SCV_LIBRARIES systemc-scv::systemc-scv) | ||
endif() | ||
find_package(systemc-cci QUIET) | ||
if(systemc-cci_FOUND) | ||
set(CCI_FOUND TRUE) | ||
set(CCI_LIBRARIES systemc-cci::systemc-cci) | ||
endif() | ||
elseif(TARGET CONAN_PKG::systemc) # conan cmake targets | ||
set(SystemC_FOUND true) | ||
set(SystemC_LIBRARIES CONAN_PKG::systemc) | ||
if(TARGET CONAN_PKG::systemc-scv) | ||
set(SCV_FOUND TRUE) | ||
set(SCV_LIBRARIES CONAN_PKG::systemc-scv) | ||
endif() | ||
if(TARGET CONAN_PKG::systemc-cci) | ||
set(CCI_FOUND TRUE) | ||
set(CCI_LIBRARIES CONAN_PKG::systemc-cci) | ||
endif() | ||
else() | ||
find_package(OSCISystemC) | ||
set(SystemC_LIBRARIES SystemC::systemc) | ||
endif() | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
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 LINK_PUBLIC scc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
#include <ahb/pin/initiator.h> | ||
#include <ahb/pin/target.h> | ||
#include <tlm/scc/initiator_mixin.h> | ||
#include <tlm/scc/target_mixin.h> | ||
#include <scc/configurable_tracer.h> | ||
#include <scc/configurer.h> | ||
#include <scc/report.h> | ||
#include <scc/tracer.h> | ||
#include <scc/traceable.h> | ||
#include <cci_utils/broker.h> | ||
#include <fstream> | ||
|
||
using namespace sc_core; | ||
using namespace scc; | ||
|
||
class testbench: public sc_module, public scc::traceable { | ||
public: | ||
enum { WIDTH=64}; | ||
tlm::scc::initiator_mixin<tlm::tlm_initiator_socket<WIDTH>> isck{"isck"}; | ||
ahb::pin::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"}; | ||
|
||
ahb::pin::target<WIDTH> target{"target"}; | ||
tlm::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; | ||
std::array<uint8_t, 8> data; | ||
data[0]=2; | ||
data[1]=4; | ||
gp.set_address(0x1000); | ||
gp.set_data_length(8); | ||
gp.set_data_ptr(data.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.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); | ||
/////////////////////////////////////////////////////////////////////////// | ||
// configure logging | ||
/////////////////////////////////////////////////////////////////////////// | ||
scc::init_logging(scc::log::DEBUG); | ||
/////////////////////////////////////////////////////////////////////////// | ||
// set up configuration and tracing | ||
/////////////////////////////////////////////////////////////////////////// | ||
scc::configurer cfg("ahb_bfm.json"); | ||
scc::configurable_tracer trace("ahb_bfm", 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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
find_package(Boost COMPONENTS program_options REQUIRED) | ||
add_executable (simple_system | ||
plic.cpp | ||
uart.cpp | ||
spi.cpp | ||
gpio.cpp | ||
test_initiator.cpp | ||
simple_system.cpp | ||
sc_main.cpp | ||
) | ||
target_link_libraries (simple_system LINK_PUBLIC scc) | ||
if(TARGET Boost::program_options) | ||
target_link_libraries(simple_system PUBLIC Boost::program_options) | ||
else() | ||
target_link_libraries(simple_system PUBLIC ${BOOST_program_options_LIBRARY}) | ||
endif() | ||
add_test(NAME simple_system_test COMMAND simple_system) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/******************************************************************************* | ||
* Copyright 2017 [email protected] | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
******************************************************************************/ | ||
#ifndef _E300_PLAT_MAP_H_ | ||
#define _E300_PLAT_MAP_H_ | ||
// need double braces, see | ||
// https://stackoverflow.com/questions/6893700/how-to-construct-stdarray-object-with-initializer-list#6894191 | ||
const std::array<scc::target_name_map_entry<32>, 4> e300_plat_map = {{ | ||
{"plic", 0x0c000000, 0x200008}, | ||
{"gpio", 0x10012000, 0x1000}, | ||
{"uart", 0x10013000, 0x1000}, | ||
{"spi", 0x10014000, 0x1000}, | ||
}}; | ||
|
||
#endif /* _E300_PLAT_MAP_H_ */ |
Oops, something went wrong.