adds cci test setup, needs to becomne self-checking
This commit is contained in:
parent
aee2211d10
commit
ea6d56f413
2
scc
2
scc
@ -1 +1 @@
|
|||||||
Subproject commit fc75958b72caa7bb93919515c92a5b0779fe06bd
|
Subproject commit b1b9ad050802cf38523a40b5845822f22d7af70e
|
@ -1,6 +1,7 @@
|
|||||||
add_subdirectory(io-redirector)
|
add_subdirectory(io-redirector)
|
||||||
add_subdirectory(ordered_semaphore)
|
add_subdirectory(ordered_semaphore)
|
||||||
add_subdirectory(axi4_pin_level)
|
add_subdirectory(axi4_pin_level)
|
||||||
|
add_subdirectory(configuration)
|
||||||
if(FULL_TEST_SUITE)
|
if(FULL_TEST_SUITE)
|
||||||
add_subdirectory(sim_performance)
|
add_subdirectory(sim_performance)
|
||||||
endif()
|
endif()
|
5
tests/configuration/CMakeLists.txt
Normal file
5
tests/configuration/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
add_executable (cci-example
|
||||||
|
sc_main.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries (cci-example LINK_PUBLIC scc-sysc)
|
||||||
|
add_test(NAME cci-example_test COMMAND cci-example)
|
140
tests/configuration/initiator.h
Normal file
140
tests/configuration/initiator.h
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
|
||||||
|
Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
|
||||||
|
more contributor license agreements. See the NOTICE file distributed
|
||||||
|
with this work for additional information regarding copyright ownership.
|
||||||
|
Accellera licenses this file to you 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.
|
||||||
|
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file initiator.h
|
||||||
|
* @brief initiator module implementation.
|
||||||
|
* This file declares and implements the functionality of the initiator.
|
||||||
|
* Few of the parameters of the initiator sc_module are configured by the
|
||||||
|
* router sc_module
|
||||||
|
* @author P V S Phaneendra, CircuitSutra Technologies <pvs@circuitsutra.com>
|
||||||
|
* Parvinder Pal Singh, CircuitSutra Technologies <parvinder@circuitsutra.com>
|
||||||
|
* @date 29th April, 2011 (Friday)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EXAMPLES_EX09_HIERARCHICAL_OVERRIDE_OF_PARAMETER_VALUES_INITIATOR_H_
|
||||||
|
#define EXAMPLES_EX09_HIERARCHICAL_OVERRIDE_OF_PARAMETER_VALUES_INITIATOR_H_
|
||||||
|
|
||||||
|
#include <cci_configuration>
|
||||||
|
#include <tlm>
|
||||||
|
#include <string>
|
||||||
|
#include <tlm_utils/simple_initiator_socket.h>
|
||||||
|
#include <scc/report.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class initiator
|
||||||
|
* @brief The implementation of the initiator module with tlm2 socket for communication
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
SC_MODULE(initiator) {
|
||||||
|
public:
|
||||||
|
int data;
|
||||||
|
|
||||||
|
tlm_utils::simple_initiator_socket<initiator, 32> initiator_socket; ///< Instance of TLM2 simple initiator socket
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn initiator
|
||||||
|
* @brief The class constructor
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
SC_CTOR(initiator)
|
||||||
|
:
|
||||||
|
data(0), initiator_socket("initiator_socket"), initiator_ID("initiator_ID", "initiator_default") {
|
||||||
|
SCCINFO(SCMOD) << "[" << initiator_ID.get_value() << " C_TOR] ------- [INITIATOR CONSTRUCTOR BEGINS HERE] --------";
|
||||||
|
|
||||||
|
// initiator's SC_THREAD declaration
|
||||||
|
SC_THREAD(run_initiator);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn void run_initiator(void)
|
||||||
|
* @brief Main function to send transactions
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void run_initiator(void) {
|
||||||
|
tlm::tlm_generic_payload *trans = new tlm::tlm_generic_payload;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
static tlm::tlm_command cmds[8] =
|
||||||
|
{ tlm::TLM_WRITE_COMMAND, tlm::TLM_READ_COMMAND, tlm::TLM_WRITE_COMMAND, tlm::TLM_READ_COMMAND, tlm::TLM_READ_COMMAND,
|
||||||
|
tlm::TLM_READ_COMMAND, tlm::TLM_WRITE_COMMAND, tlm::TLM_WRITE_COMMAND };
|
||||||
|
while (1) {
|
||||||
|
tlm::tlm_command cmd = cmds[(i >> 2) % 8];
|
||||||
|
//static_cast<tlm::tlm_command>(cmd_dist(rng));
|
||||||
|
|
||||||
|
if (cmd == tlm::TLM_WRITE_COMMAND) data = 0xFF000000 | i;
|
||||||
|
|
||||||
|
trans->set_command(cmd);
|
||||||
|
trans->set_address(i);
|
||||||
|
trans->set_data_ptr(reinterpret_cast<unsigned char*>(&data));
|
||||||
|
trans->set_data_length(4);
|
||||||
|
trans->set_streaming_width(4);
|
||||||
|
trans->set_byte_enable_ptr(0);
|
||||||
|
trans->set_dmi_allowed(false);
|
||||||
|
trans->set_response_status(tlm::TLM_INCOMPLETE_RESPONSE);
|
||||||
|
sc_core::sc_time delay = sc_core::sc_time(0, sc_core::SC_NS);
|
||||||
|
|
||||||
|
if (cmd == tlm::TLM_WRITE_COMMAND) {
|
||||||
|
SCCINFO(SCMOD) << "[Initiators Message]=>At address " << std::hex << i << " sending transaction with command = Write"
|
||||||
|
<< ", data=" << std::hex << data << " at time " << sc_core::sc_time_stamp();
|
||||||
|
} else {
|
||||||
|
SCCINFO(SCMOD) << "[Initiators Message]=>At address " << std::hex << i << " sending transaction with command= Read "
|
||||||
|
<< " at time " << sc_core::sc_time_stamp();
|
||||||
|
}
|
||||||
|
|
||||||
|
initiator_socket->b_transport(*trans, delay);
|
||||||
|
|
||||||
|
if (trans->is_response_error())
|
||||||
|
SCCERR(SCMOD) << "TLM_2" << trans->get_response_string().c_str();
|
||||||
|
|
||||||
|
if (delay.to_double() != 0) wait(delay);
|
||||||
|
|
||||||
|
if (cmd == tlm::TLM_WRITE_COMMAND) {
|
||||||
|
SCCINFO(SCMOD) << "[Initiators Message]=>At address " << std::hex << i << " received response of Write transaction "
|
||||||
|
<< " at time " << sc_core::sc_time_stamp();
|
||||||
|
} else {
|
||||||
|
SCCINFO(SCMOD) << "[Initiators Message]=>At address " << std::hex << i << " received response of Read transaction "
|
||||||
|
<< " data " << data << " at time " << sc_core::sc_time_stamp();
|
||||||
|
}
|
||||||
|
|
||||||
|
SCCINFO(SCMOD) << "--------------------------------------------------------";
|
||||||
|
|
||||||
|
wait(5.0, sc_core::SC_NS);
|
||||||
|
|
||||||
|
i = i + 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
cci::cci_param<std::string, cci::CCI_MUTABLE_PARAM> initiator_ID; ///< Elab Time Param for assigning initiator ID (initialized by top_module)
|
||||||
|
/**
|
||||||
|
* @fn void end_of_elaboration()
|
||||||
|
* @brief end of elaboration function to lock structural param
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void end_of_elaboration() {
|
||||||
|
initiator_ID.lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
// initiator
|
||||||
|
|
||||||
|
#endif // EXAMPLES_EX09_HIERARCHICAL_OVERRIDE_OF_PARAMETER_VALUES_INITIATOR_H_
|
175
tests/configuration/router.h
Normal file
175
tests/configuration/router.h
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
|
||||||
|
Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
|
||||||
|
more contributor license agreements. See the NOTICE file distributed
|
||||||
|
with this work for additional information regarding copyright ownership.
|
||||||
|
Accellera licenses this file to you 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.
|
||||||
|
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file router.h
|
||||||
|
* @brief Definition of the router module.
|
||||||
|
* This file declares and implements the functionality of the router.
|
||||||
|
* Few of the parameters of the target and initiator sc_module(s) are
|
||||||
|
* configured by the router sc_module
|
||||||
|
* @authors P V S Phaneendra, CircuitSutra Technologies <pvs@circuitsutra.com>
|
||||||
|
* @date 29th April, 2011 (Friday)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EXAMPLES_EX09_HIERARCHICAL_OVERRIDE_OF_PARAMETER_VALUES_ROUTER_H_
|
||||||
|
#define EXAMPLES_EX09_HIERARCHICAL_OVERRIDE_OF_PARAMETER_VALUES_ROUTER_H_
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define snprintf _snprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cci_configuration>
|
||||||
|
#include <tlm>
|
||||||
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
|
#include <tlm_utils/multi_passthrough_target_socket.h>
|
||||||
|
#include <tlm_utils/multi_passthrough_initiator_socket.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class router
|
||||||
|
* @brief Thes module implements a router functionality
|
||||||
|
*/
|
||||||
|
SC_MODULE(router) {
|
||||||
|
public:
|
||||||
|
// Declare tlm multi-passthrough sockets for target and initiator modules
|
||||||
|
tlm_utils::multi_passthrough_target_socket<router, 32> Router_target;
|
||||||
|
tlm_utils::multi_passthrough_initiator_socket<router, 32> Router_initiator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn router
|
||||||
|
* @brief The class constructor
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
SC_CTOR(router)
|
||||||
|
:
|
||||||
|
Router_target("Router_target"), Router_initiator("Router_initiator"), r_initiators("r_initiators", 0), r_targets("r_targets",
|
||||||
|
0), addr_limit("addr_max", 64), m_broker(cci::cci_get_broker()), addrSize(0) {
|
||||||
|
SCCINFO(SCMOD) << "[ROUTER C_TOR] ----- [ROUTER CONSTRUCTOR BEGINS HERE] ------";
|
||||||
|
|
||||||
|
// Register b_transport
|
||||||
|
Router_target.register_b_transport(this, &router::b_transport);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn void before_end_of_elaboration(void)
|
||||||
|
* @brief The router table information is filled in during this function
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void before_end_of_elaboration(void) {
|
||||||
|
SCCINFO(SCMOD) << "[ROUTER in beoe] : Number of initiator(s) : " << r_initiators.get_cci_value().to_json();
|
||||||
|
SCCINFO(SCMOD) << "[ROUTER in beoe] : Number of target(s) : " << r_targets.get_value();
|
||||||
|
SCCINFO(SCMOD) << "[ROUTER in beoe] : Maximum Addressable Limit of the router : " << addr_limit.get_value();
|
||||||
|
|
||||||
|
char targetName[10]; ///< Holds router table's fields' names
|
||||||
|
addrSize = (unsigned int) (addr_limit.get_value() / r_targets);
|
||||||
|
|
||||||
|
// Printing the Router Table contents
|
||||||
|
SCCINFO(SCMOD) << "============= ROUTER TABLE INFORMATION ==============";
|
||||||
|
SCCINFO(SCMOD) << "-----------------------------------------------------";
|
||||||
|
SCCINFO(SCMOD) << "| Target ID | Start Addr | End Addr | Base Addr |";
|
||||||
|
SCCINFO(SCMOD) << "-----------------------------------------------------";
|
||||||
|
|
||||||
|
// Sets the contents of the routing table with (default) values
|
||||||
|
// calculated within 'beoe' phase
|
||||||
|
for (int i = 0; i < r_targets; i++) {
|
||||||
|
snprintf(targetName, sizeof(targetName), "r_index_%d", i);
|
||||||
|
r_target_index.push_back(new cci::cci_param<unsigned int, cci::CCI_IMMUTABLE_PARAM>(targetName, i));
|
||||||
|
|
||||||
|
snprintf(targetName, sizeof(targetName), "r_sa_%d", i);
|
||||||
|
r_addr_start.push_back(new cci::cci_param<unsigned int, cci::CCI_IMMUTABLE_PARAM>(targetName, (i * addrSize)));
|
||||||
|
|
||||||
|
snprintf(targetName, sizeof(targetName), "r_ea_%d", i);
|
||||||
|
r_addr_end.push_back(new cci::cci_param<unsigned int, cci::CCI_IMMUTABLE_PARAM>(targetName, ((i + 1) * addrSize - 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < r_targets; i++) {
|
||||||
|
snprintf(stringName, sizeof(stringName), "top_module_inst.target_%d.s_base_addr", i);
|
||||||
|
|
||||||
|
base_handle = m_broker.get_param_handle(stringName);
|
||||||
|
if (!base_handle.is_valid()) {
|
||||||
|
sc_assert(!"target Base Address Handle returned is NULL");
|
||||||
|
}
|
||||||
|
std::stringstream row_ss;
|
||||||
|
row_ss << "| " << std::setw(10) << r_target_index[i]->get_value() << " | " << std::setw(10) << std::hex << std::showbase
|
||||||
|
<< r_addr_start[i]->get_value() << " | " << std::setw(10) << r_addr_end[i]->get_value() << " | " << std::setw(10)
|
||||||
|
<< base_handle.get_cci_value().to_json() << " |";
|
||||||
|
SCCINFO(SCMOD) << row_ss.str().c_str();
|
||||||
|
SCCINFO(SCMOD) << "-----------------------------------------------------";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Blocking transport implementation of the router
|
||||||
|
void b_transport(int i_, tlm::tlm_generic_payload &trans, sc_core::sc_time &delay) {
|
||||||
|
wait(delay);
|
||||||
|
|
||||||
|
delay = sc_core::SC_ZERO_TIME;
|
||||||
|
|
||||||
|
sc_dt::uint64 addr = trans.get_address();
|
||||||
|
|
||||||
|
if (addr >= static_cast<sc_dt::uint64>(addr_limit.get_value())) {
|
||||||
|
trans.set_response_status(tlm::TLM_ADDRESS_ERROR_RESPONSE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < r_target_index.size(); i++) {
|
||||||
|
if ((addr >= (r_addr_start[i]->get_value())) && (addr <= (r_addr_end[i]->get_value()))) {
|
||||||
|
SCCINFO(SCMOD) << "[Router in 'b_transport' layer]";
|
||||||
|
SCCINFO(SCMOD) << "Address = " << std::hex << addr;
|
||||||
|
SCCINFO(SCMOD) << "Index = " << (r_target_index[i])->get_value();
|
||||||
|
SCCINFO(SCMOD) << "Start addres = " << std::hex << (r_addr_start[i]->get_value());
|
||||||
|
SCCINFO(SCMOD) << "End Address = " << std::hex << (r_addr_end[i]->get_value());
|
||||||
|
Router_initiator[(r_target_index[i])->get_value()]->b_transport(trans, delay);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Demonstrates Model-to-Model Configuration (UC12)
|
||||||
|
/// Elaboration Time Parameters for setting up the model hierarcy;
|
||||||
|
cci::cci_param<int, cci::CCI_MUTABLE_PARAM> r_initiators; ///< initiator ID assigned by the top_module upon instantiation
|
||||||
|
cci::cci_param<int, cci::CCI_MUTABLE_PARAM> r_targets; ///< target ID assigned by the top_module upon instantiation
|
||||||
|
cci::cci_param<unsigned int, cci::CCI_MUTABLE_PARAM> addr_limit; ///< Router Addressing Range
|
||||||
|
cci::cci_broker_handle m_broker; ///< CCI configuration broker handle
|
||||||
|
|
||||||
|
/// Router Table contents holding targets related information
|
||||||
|
std::vector<cci::cci_param<unsigned int, cci::CCI_IMMUTABLE_PARAM>*> r_target_index; ///< Router table target index
|
||||||
|
std::vector<cci::cci_param<unsigned int, cci::CCI_IMMUTABLE_PARAM>*> r_addr_start; ///< Router table start address
|
||||||
|
std::vector<cci::cci_param<unsigned int, cci::CCI_IMMUTABLE_PARAM>*> r_addr_end; ///< Router table end address
|
||||||
|
|
||||||
|
cci::cci_param_handle base_handle; ///< CCI base parameter handle for target base address
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn void end_of_elaboration()
|
||||||
|
* @brief end of elaboration function to lock structural param
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void end_of_elaboration() {
|
||||||
|
r_initiators.lock();
|
||||||
|
r_targets.lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
int addrSize;
|
||||||
|
char stringName[50];
|
||||||
|
};
|
||||||
|
// router
|
||||||
|
|
||||||
|
#endif // EXAMPLES_EX09_HIERARCHICAL_OVERRIDE_OF_PARAMETER_VALUES_ROUTER_H_
|
86
tests/configuration/sc_main.cpp
Normal file
86
tests/configuration/sc_main.cpp
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
|
||||||
|
Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
|
||||||
|
more contributor license agreements. See the NOTICE file distributed
|
||||||
|
with this work for additional information regarding copyright ownership.
|
||||||
|
Accellera licenses this file to you 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 SC_INCLUDE_DYNAMIC_PROCESSES
|
||||||
|
#define SC_INCLUDE_DYNAMIC_PROCESSES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file main.cpp
|
||||||
|
* @brief Testbench file
|
||||||
|
* This file declares and implements the functionality of the target.
|
||||||
|
* Few of the parameters of the target sc_module are configured by the
|
||||||
|
* router sc_module.
|
||||||
|
* @author P V S Phaneendra, CircuitSutra Technologies <pvs@circuitsutra.com>
|
||||||
|
* @date 29th April, 2011 (Friday)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <cci_configuration>
|
||||||
|
#include <cci_utils/broker.h>
|
||||||
|
#include <string>
|
||||||
|
#include "top_module.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn int sc_main(int argc, char* argv[])
|
||||||
|
* @brief The testbench for the hierarchical override of parameter values example
|
||||||
|
* @param argc The number of input arguments
|
||||||
|
* @param argv The list of input arguments
|
||||||
|
* @return An integer for the execution status
|
||||||
|
*/
|
||||||
|
int sc_main(int sc_argc, char *sc_argv[]) {
|
||||||
|
scc::init_logging(scc::log::INFO);
|
||||||
|
cci::cci_originator me = cci::cci_originator("sc_main");
|
||||||
|
// Get handle to the default broker
|
||||||
|
cci::cci_broker_handle myGlobalBroker = cci::cci_get_global_broker(me);
|
||||||
|
myGlobalBroker.set_preset_cci_value("top_module_inst.**.log_level", cci::cci_value(3));
|
||||||
|
SCCINFO("sc_main") << "[MAIN] : Setting preset value of the number of initiators to 2";
|
||||||
|
// Set preset value to the number of initiator(s) (within top_module)
|
||||||
|
std::string initiatorHierarchicalName = "top_module_inst.number_of_initiators";
|
||||||
|
myGlobalBroker.set_preset_cci_value(initiatorHierarchicalName, cci::cci_value(2));
|
||||||
|
SCCINFO("sc_main") << "[MAIN] : Setting preset value of the number of initiators to 1";
|
||||||
|
// The program considers only the last set preset value
|
||||||
|
myGlobalBroker.set_preset_cci_value(initiatorHierarchicalName, cci::cci_value(1));
|
||||||
|
SCCINFO("sc_main") << "[MAIN] : Setting preset value of the number of targets to 4";
|
||||||
|
// Set preset value to the number of target(s) (within top_module)
|
||||||
|
std::string targetHierarchicalName = "top_module_inst.number_of_targets";
|
||||||
|
myGlobalBroker.set_preset_cci_value(targetHierarchicalName, cci::cci_value(4));
|
||||||
|
// Set the maximum addressing limit for the router
|
||||||
|
myGlobalBroker.set_preset_cci_value("top_module_inst.RouterInstance.addr_max", cci::cci_value(1024));
|
||||||
|
// Set and lock the Router Table presets values for target_1
|
||||||
|
// These values have again been tried to set within the Top_MODULE
|
||||||
|
// @see top_module.h
|
||||||
|
SCCINFO("sc_main") << "[MAIN] : Set and lock Router Table target_1 contents";
|
||||||
|
myGlobalBroker.set_preset_cci_value("top_module_inst.RouterInstance.r_index_1", cci::cci_value(1));
|
||||||
|
myGlobalBroker.lock_preset_value("top_module_inst.RouterInstance.r_index_1");
|
||||||
|
SCCINFO("sc_main") << "[MAIN] : Set and lock Router Table Start Address for target_1 to 128";
|
||||||
|
myGlobalBroker.set_preset_cci_value("top_module_inst.RouterInstance.r_sa_1", cci::cci_value(128));
|
||||||
|
myGlobalBroker.lock_preset_value("top_module_inst.RouterInstance.r_sa_1");
|
||||||
|
SCCINFO("sc_main") << "[MAIN] : Set and lock Router Table End Address for target_1 to 255";
|
||||||
|
myGlobalBroker.set_preset_cci_value("top_module_inst.RouterInstance.r_ea_1", cci::cci_value(255));
|
||||||
|
myGlobalBroker.lock_preset_value("top_module_inst.RouterInstance.r_ea_1");
|
||||||
|
SCCINFO("sc_main") << "[MAIN] : Instantiate top module after setting preset values to top_module, router and target parameters";
|
||||||
|
// Instantiate TOP_MODULE responsible for creating the model hierarchy
|
||||||
|
top_module top_mod("top_module_inst");
|
||||||
|
// Start the simulation
|
||||||
|
SCCINFO("sc_main") << "Begin Simulation.";
|
||||||
|
sc_core::sc_start(1140, sc_core::SC_NS);
|
||||||
|
SCCINFO("sc_main") << "End Simulation.";
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
} // End of 'sc_main'
|
147
tests/configuration/target.h
Normal file
147
tests/configuration/target.h
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
|
||||||
|
Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
|
||||||
|
more contributor license agreements. See the NOTICE file distributed
|
||||||
|
with this work for additional information regarding copyright ownership.
|
||||||
|
Accellera licenses this file to you 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.
|
||||||
|
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file target.h
|
||||||
|
* @brief target module implementation.
|
||||||
|
* This file declares and implements the functionality of the target.
|
||||||
|
* Few of the parameters of the target sc_module are configured by the
|
||||||
|
* router sc_module
|
||||||
|
* @author P V S Phaneendra, CircuitSutra Technologies <pvs@circuitsutra.com>
|
||||||
|
* Parvinder Pal Singh, CircuitSutra Technologies <parvinder@circuitsutra.com>
|
||||||
|
* @date 5th May, 2011 (Thursday)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EXAMPLES_EX09_HIERARCHICAL_OVERRIDE_OF_PARAMETER_VALUES_TARGET_H_
|
||||||
|
#define EXAMPLES_EX09_HIERARCHICAL_OVERRIDE_OF_PARAMETER_VALUES_TARGET_H_
|
||||||
|
|
||||||
|
#include <cci_configuration>
|
||||||
|
#include <tlm>
|
||||||
|
#include <string>
|
||||||
|
#include <tlm_utils/simple_target_socket.h>
|
||||||
|
#include <scc/report.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class target
|
||||||
|
* @brief This module implementas the functionality of a target IP
|
||||||
|
*/
|
||||||
|
SC_MODULE(target) {
|
||||||
|
public:
|
||||||
|
tlm_utils::simple_target_socket<target, 32> target_socket;
|
||||||
|
sc_core::sc_time read_latency, write_latency;
|
||||||
|
|
||||||
|
SC_CTOR(target)
|
||||||
|
:
|
||||||
|
target_socket("target_socket"), target_ID("target_ID", "target_default"), s_base_addr("s_base_addr", 0), s_size("s_size", 256) {
|
||||||
|
SCCINFO(SCMOD) << "[" << target_ID.get_value() << " C_TOR] ------- [TARGET CONSTRUCTOR BEGINS HERE] --------";
|
||||||
|
SCCINFO(SCMOD) << "[" << target_ID.get_value() << " C_TOR] : Base Address : " << s_base_addr.get_value();
|
||||||
|
|
||||||
|
// Register b_transport
|
||||||
|
target_socket.register_b_transport(this, &target::b_transport);
|
||||||
|
|
||||||
|
write_latency = sc_core::sc_time(3, sc_core::SC_NS);
|
||||||
|
read_latency = sc_core::sc_time(5, sc_core::SC_NS);
|
||||||
|
|
||||||
|
mem = new int[s_size.get_value()];
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < s_size.get_value(); i++)
|
||||||
|
mem[i] = 0xAABBCCDD | i;
|
||||||
|
|
||||||
|
// target's SC_THREAD declaration
|
||||||
|
SC_THREAD(run_target);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn void run_target(void)
|
||||||
|
* @brief The run thread of the modeul (does nothing)
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void run_target(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn void b_transport(tlm::tlm_generic_payload& trans, sc_core::sc_time& delay)
|
||||||
|
* @brief Implementation of the blocking transport in the target
|
||||||
|
* @param trans The transaction being sent
|
||||||
|
* @param delay The annotated delay associated with the transaction
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void b_transport(tlm::tlm_generic_payload &trans, sc_core::sc_time &delay) {
|
||||||
|
tlm::tlm_command cmd = trans.get_command();
|
||||||
|
sc_dt::uint64 adr = trans.get_address() - s_base_addr.get_value();
|
||||||
|
unsigned char *ptr = trans.get_data_ptr();
|
||||||
|
unsigned int len = trans.get_data_length();
|
||||||
|
unsigned char *byt = trans.get_byte_enable_ptr();
|
||||||
|
unsigned int wid = trans.get_streaming_width();
|
||||||
|
|
||||||
|
SCCINFO(SCMOD) << "[TARGET] : adr ---- " << std::hex << adr;
|
||||||
|
SCCINFO(SCMOD) << "[TARGET] : base addr ---- " << std::hex << s_base_addr.get_value();
|
||||||
|
|
||||||
|
// Check for storage address overflow
|
||||||
|
if (adr > s_size.get_value()) {
|
||||||
|
trans.set_response_status(tlm::TLM_ADDRESS_ERROR_RESPONSE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Target unable to support byte enable attribute
|
||||||
|
if (byt) {
|
||||||
|
trans.set_response_status(tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Target unable to support streaming width attribute
|
||||||
|
if (wid < len) {
|
||||||
|
trans.set_response_status(tlm::TLM_BURST_ERROR_RESPONSE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd == tlm::TLM_READ_COMMAND) {
|
||||||
|
memcpy(ptr, &mem[adr], len);
|
||||||
|
delay = delay + read_latency;
|
||||||
|
} else
|
||||||
|
if (cmd == tlm::TLM_WRITE_COMMAND) {
|
||||||
|
memcpy(&mem[adr], ptr, len);
|
||||||
|
delay = delay + write_latency;
|
||||||
|
}
|
||||||
|
|
||||||
|
trans.set_response_status(tlm::TLM_OK_RESPONSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
cci::cci_param<std::string, cci::CCI_MUTABLE_PARAM> target_ID; ///< Elaboration Time Param for assigning target ID (initialized by top_module)
|
||||||
|
|
||||||
|
cci::cci_param<int, cci::CCI_MUTABLE_PARAM> s_base_addr; ///< Mutable time param for setting target's base addr (initialized by router)
|
||||||
|
|
||||||
|
cci::cci_param<unsigned int> s_size; ///< Mutable time parameter for setting target's size (initialized by router);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn void end_of_elaboration()
|
||||||
|
* @brief end of elaboration function to lock structural param
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void end_of_elaboration() {
|
||||||
|
target_ID.lock();
|
||||||
|
s_base_addr.lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
int *mem;
|
||||||
|
};
|
||||||
|
// target
|
||||||
|
|
||||||
|
#endif // EXAMPLES_EX09_HIERARCHICAL_OVERRIDE_OF_PARAMETER_VALUES_TARGET_H_
|
224
tests/configuration/top_module.h
Normal file
224
tests/configuration/top_module.h
Normal file
@ -0,0 +1,224 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
|
||||||
|
Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
|
||||||
|
more contributor license agreements. See the NOTICE file distributed
|
||||||
|
with this work for additional information regarding copyright ownership.
|
||||||
|
Accellera licenses this file to you 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.
|
||||||
|
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file top_module.h
|
||||||
|
* @brief Implementation the TOP_MODULE.
|
||||||
|
* This header contains code related to the top module which decides
|
||||||
|
* the model hierarchy for example#9.
|
||||||
|
* @author P V S Phaneendra, CircuitSutra Technologies <pvs@circuitsutra.com>
|
||||||
|
* Girish Verma, CircuitSutra Technologies <girish@circuitsutra.com>
|
||||||
|
* Parvinder Pal Singh, CircuitSutra Technologies <parvinder@circuitsutra.com>
|
||||||
|
* @date 29th April, 2011 (Friday)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EXAMPLES_EX09_HIERARCHICAL_OVERRIDE_OF_PARAMETER_VALUES_TOP_MODULE_H_
|
||||||
|
#define EXAMPLES_EX09_HIERARCHICAL_OVERRIDE_OF_PARAMETER_VALUES_TOP_MODULE_H_
|
||||||
|
|
||||||
|
#include <cci_configuration>
|
||||||
|
#include <tlm>
|
||||||
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
#include <scc/report.h>
|
||||||
|
|
||||||
|
#include "router.h"
|
||||||
|
#include "initiator.h"
|
||||||
|
#include "target.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class top_module
|
||||||
|
* @brief This module instantiated a initiator, target, and router and binds them correctly for communication.
|
||||||
|
*/
|
||||||
|
SC_MODULE(top_module) {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @fn top_module
|
||||||
|
* @brief The class constructor
|
||||||
|
*/
|
||||||
|
SC_CTOR(top_module)
|
||||||
|
:
|
||||||
|
n_initiators("number_of_initiators", 0), n_targets("number_of_targets", 0), m_broker(cci::cci_get_broker()) {
|
||||||
|
std::stringstream ss;
|
||||||
|
|
||||||
|
SCCINFO(SCMOD) << "[TOP_MODULE C_TOR] -- [TOP MODULE CONSTRUCTOR BEGINS HERE]";
|
||||||
|
|
||||||
|
SCCINFO(SCMOD) << "[TOP_MODULE C_TOR] : Number of initiators : " << n_initiators.get_value();
|
||||||
|
SCCINFO(SCMOD) << "[TOP_MODULE C_TOR] : Number of targets : " << n_targets.get_value();
|
||||||
|
|
||||||
|
// Set and lock the number of initiators in Router Table
|
||||||
|
// to value passed from 'sc_main'
|
||||||
|
m_broker.set_preset_cci_value("top_module_inst.RouterInstance.r_initiators", n_initiators.get_cci_value());
|
||||||
|
m_broker.lock_preset_value("top_module_inst.RouterInstance.r_initiators");
|
||||||
|
|
||||||
|
// Set and lock the number of targets in Router Table
|
||||||
|
// to value passed from 'sc_main'
|
||||||
|
m_broker.set_preset_cci_value("top_module_inst.RouterInstance.r_targets", n_targets.get_cci_value());
|
||||||
|
m_broker.lock_preset_value("top_module_inst.RouterInstance.r_targets");
|
||||||
|
|
||||||
|
// Declaring and defining router module
|
||||||
|
char routerName[15] = "RouterInstance";
|
||||||
|
SCCINFO(SCMOD) << "[TOP_MODULE C_TOR] : Creating Router : " << routerName;
|
||||||
|
routerInstance = new router(routerName);
|
||||||
|
|
||||||
|
// Top_Module begins construction of the model hierarchy from here
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
|
cci::cci_param_handle r_addr_limit_handle = m_broker.get_param_handle("top_module_inst.RouterInstance.addr_limit");
|
||||||
|
if (r_addr_limit_handle.is_valid()) {
|
||||||
|
r_addr_max = atoi((r_addr_limit_handle.get_cci_value().to_json()).c_str());
|
||||||
|
|
||||||
|
SCCINFO(SCMOD) << "[TOP_MODULE C_TOR] : Router's maximum addressable limit : " << r_addr_max;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creating instances of initiator(s)
|
||||||
|
for (int i = 0; i < n_initiators; i++) {
|
||||||
|
snprintf(initiatorName, sizeof(initiatorName), "initiator_%d", i);
|
||||||
|
SCCINFO(SCMOD) << "[TOP_MODULE C_TOR] : Creating initiator : " << initiatorName;
|
||||||
|
|
||||||
|
snprintf(stringMisc, sizeof(stringMisc), "%s.%s.initiator_ID", name(), initiatorName);
|
||||||
|
|
||||||
|
snprintf(initiatorName, sizeof(initiatorName), "\"initiator_%d\"", i);
|
||||||
|
m_broker.set_preset_cci_value(stringMisc, cci::cci_value::from_json(initiatorName));
|
||||||
|
snprintf(initiatorName, sizeof(initiatorName), "initiator_%d", i);
|
||||||
|
initiatorList.push_back(new initiator(initiatorName));
|
||||||
|
|
||||||
|
// Binding of initiator to Router
|
||||||
|
SCCINFO(SCMOD) << "[TOP MODULE C_TOR] : Binding Router_Initiator to " << initiatorName;
|
||||||
|
initiatorList[i]->initiator_socket.bind(routerInstance->Router_target);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Defining target size
|
||||||
|
targetSize = 128;
|
||||||
|
|
||||||
|
// Creating instances of target(s)
|
||||||
|
for (int i = 0; i < n_targets; i++) {
|
||||||
|
snprintf(targetName, sizeof(targetName), "target_%d", i);
|
||||||
|
SCCINFO(SCMOD) << "[TOP_MODULE C_TOR] : Creating target : " << targetName;
|
||||||
|
|
||||||
|
snprintf(stringMisc, sizeof(stringMisc), "%s.%s.target_ID", name(), targetName);
|
||||||
|
snprintf(targetName, sizeof(targetName), "\"target_%d\"", i);
|
||||||
|
m_broker.set_preset_cci_value(stringMisc, cci::cci_value::from_json(targetName));
|
||||||
|
snprintf(targetName, sizeof(targetName), "target_%d", i);
|
||||||
|
|
||||||
|
// Set preset value for maximum target size(memory)
|
||||||
|
snprintf(stringMisc, sizeof(stringMisc), "%s.%s.s_size", name(), targetName);
|
||||||
|
ss.clear();
|
||||||
|
ss.str("");
|
||||||
|
ss << targetSize;
|
||||||
|
|
||||||
|
m_broker.set_preset_cci_value(stringMisc, cci::cci_value::from_json(ss.str()));
|
||||||
|
targetList.push_back(new target(targetName));
|
||||||
|
|
||||||
|
// Binding Router to target
|
||||||
|
SCCINFO(SCMOD) << "[TOP MODULE C_TOR] : Binding Router_Initiator to " << targetName;
|
||||||
|
routerInstance->Router_initiator.bind(targetList[i]->target_socket);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try re-setting locked values for Router Table contents
|
||||||
|
for (int i = 0; i < n_targets; i++) {
|
||||||
|
snprintf(targetName, sizeof(targetName), "%s.RouterInstance.r_index_%d", name(), i);
|
||||||
|
ss.clear();
|
||||||
|
ss.str("");
|
||||||
|
ss << i;
|
||||||
|
|
||||||
|
try {
|
||||||
|
SCCINFO(SCMOD) << "[TOP_MODULE C_TOR] : Re-setting fields of target_" << i;
|
||||||
|
m_broker.set_preset_cci_value(targetName, cci::cci_value::from_json(ss.str()));
|
||||||
|
} catch (sc_core::sc_report const &exception) {
|
||||||
|
SCCINFO(SCMOD) << "[ROUTER : Caught] : " << exception.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(targetName, sizeof(targetName), "%s.RouterInstance.r_sa_%d", name(), i);
|
||||||
|
ss.clear();
|
||||||
|
ss.str("");
|
||||||
|
ss << (i * targetSize);
|
||||||
|
|
||||||
|
snprintf(targetBaseAddr, sizeof(targetBaseAddr), "%s.target_%d.s_base_addr", name(), i);
|
||||||
|
|
||||||
|
cci::cci_param_untyped_handle h = m_broker.get_param_handle(targetBaseAddr);
|
||||||
|
h.set_cci_value(cci::cci_value::from_json(ss.str()));
|
||||||
|
|
||||||
|
try {
|
||||||
|
SCCINFO(SCMOD) << "[TOP_MODULE C_TOR] : Re-setting start addr of target_" << i;
|
||||||
|
m_broker.set_preset_cci_value(targetName, cci::cci_value::from_json(ss.str()));
|
||||||
|
} catch (sc_core::sc_report const &exception) {
|
||||||
|
SCCINFO(SCMOD) << "[ROUTER : Caught] : " << exception.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(targetName, sizeof(targetName), "%s.RouterInstance.r_ea_%d", name(), i);
|
||||||
|
ss.clear();
|
||||||
|
ss.str("");
|
||||||
|
ss << ((i + 1) * targetSize - 1);
|
||||||
|
|
||||||
|
try {
|
||||||
|
SCCINFO(SCMOD) << "[TOP_MODULE C_TOR] : Re-setting end addr of target_" << i;
|
||||||
|
m_broker.set_preset_cci_value(targetName, cci::cci_value::from_json(ss.str()));
|
||||||
|
} catch (sc_core::sc_report const &exception) {
|
||||||
|
SCCINFO(SCMOD) << "[ROUTER : Caught] : " << exception.what();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn ~top_module()
|
||||||
|
* @brief The class destructor
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
~top_module() {
|
||||||
|
if (!initiatorList.empty()) {
|
||||||
|
for (std::vector<initiator*>::iterator it = initiatorList.begin(); it != initiatorList.end(); ++it) {
|
||||||
|
delete (*it);
|
||||||
|
}
|
||||||
|
initiatorList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!targetList.empty()) {
|
||||||
|
for (std::vector<target*>::iterator it = targetList.begin(); it != targetList.end(); ++it) {
|
||||||
|
delete (*it);
|
||||||
|
}
|
||||||
|
targetList.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Immutable type cci-parameters
|
||||||
|
cci::cci_param<int, cci::CCI_IMMUTABLE_PARAM> n_initiators; ///< Number of initiators to be instantiated
|
||||||
|
cci::cci_param<int, cci::CCI_IMMUTABLE_PARAM> n_targets; ///< Number of targets to be instantiated
|
||||||
|
|
||||||
|
cci::cci_broker_handle m_broker; ///< Configuration broker handle
|
||||||
|
|
||||||
|
router *routerInstance; ///< Declaration of a router pointer
|
||||||
|
|
||||||
|
// STD::VECTORs for creating instances of initiator and target
|
||||||
|
std::vector<initiator*> initiatorList; ///< STD::VECTOR for initiators
|
||||||
|
std::vector<target*> targetList; ///< STD::VECTOR for targets
|
||||||
|
|
||||||
|
char initiatorName[50]; ///< initiator_ID
|
||||||
|
char targetName[50]; ///< target_ID
|
||||||
|
char stringMisc[50]; ///< String to be used for misc things
|
||||||
|
char targetBaseAddr[50]; ///< The base address of the target
|
||||||
|
|
||||||
|
int addrValue
|
||||||
|
{ 0 }; ///< Address Value
|
||||||
|
int targetSize; ///< Maximum target Size (preset value)
|
||||||
|
int r_addr_max; ///< Maximum Router Table's memory range
|
||||||
|
};
|
||||||
|
// top_module
|
||||||
|
|
||||||
|
#endif // EXAMPLES_EX09_HIERARCHICAL_OVERRIDE_OF_PARAMETER_VALUES_TOP_MODULE_H_
|
Loading…
Reference in New Issue
Block a user