KONRAD Frederic

pl190: introduction.

This introduces PL190.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
*~
# CMakeFiles
CMakeCache.txt
CMakeFiles
CTestTestfile.cmake
Makefile
Testing
cmake_install.cmake
install_manifest.txt
# Objects
test/PL190_testbench
libpl190.so
... ...
# Copyright (C) 2014, GreenSocs ltd.
#
# CMakeLists.txt
#
# KONRAD Frederic <fred.konrad@greensocs.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking GreenSocs code, statically or dynamically with other modules
# is making a combined work based on GreenSocs code. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders, GreenSocs
# Ltd, give you permission to combine GreenSocs code with free software
# programs or libraries that are released under the GNU LGPL, under the
# OSCI license, under the OCP TLM Kit Research License Agreement or
# under the OVP evaluation license.You may copy and distribute such a
# system following the terms of the GNU GPL and the licenses of the
# other code concerned.
#
# Note that people who make modified versions of GreenSocs code are not
# obligated to grant this special exception for their modified versions;
# it is their choice whether to do so. The GNU General Public License
# gives permission to release a modified version without this exception;
# this exception also makes it possible to release a modified version
# which carries forward this exception.
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(PL190)
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
FIND_PACKAGE(SystemC)
if(SystemC_FOUND)
INCLUDE_DIRECTORIES(${SystemC_INCLUDE_DIRS})
LINK_DIRECTORIES(${SystemC_LIBRARY_DIRS})
else()
MESSAGE(FATAL_ERROR "SystemC library not found.")
endif()
FIND_PACKAGE(TLM)
if(TLM_FOUND)
INCLUDE_DIRECTORIES(${TLM_INCLUDE_DIRS})
else()
MESSAGE( FATAL_ERROR "TLM library not found." )
endif()
FIND_PACKAGE(GREENLIB)
if(GREENLIB_FOUND)
INCLUDE_DIRECTORIES(${GREENLIB_INCLUDE_DIRS})
LINK_DIRECTORIES(${GREENLIB_LIBRARY_DIRS})
else()
MESSAGE(FATAL_ERROR "GreenLib not found.")
endif()
set (INCLUDE_DIRS ${INCLUDE_DIRS} include)
INCLUDE_DIRECTORIES(${INCLUDE_DIRS})
set(CMAKE_CXX_FLAGS "-ggdb -Wall -Werror -DSC_INCLUDE_DYNAMIC_PROCESSES")
ADD_LIBRARY(pl190 SHARED
src/PL190.cpp
)
TARGET_LINK_LIBRARIES(pl190 ${GREENLIB_LIBRARIES})
# Installation paths
INSTALL(DIRECTORY include/PL190
DESTINATION include
)
# Not sure it's the right destination? Maybe we want lib64 in case of 64bits?
INSTALL(TARGETS pl190 DESTINATION lib)
# Make tests
ENABLE_TESTING()
ADD_SUBDIRECTORY(test)
... ...
2014-12-05 KONRAD Frederic <fred.konrad@greensocs.com>
* Create the repository.
... ...
# - Find GreenLib
# This module finds if GreenLib is installed and determines where the
# include files and libraries are.
#
#=============================================================================
# Copyright 2014 GreenSocs
#
# KONRAD Frederic <fred.konrad@greensocs.com>
#
#=============================================================================
MESSAGE(STATUS "Searching for GreenLib")
# The HINTS option should only be used for values computed from the system.
SET(_GREENLIB_HINTS
${GREENLIB_PREFIX}/include
${GREENLIB_PREFIX}/lib
${GREENLIB_PREFIX}/lib-linux
${GREENLIB_PREFIX}/lib-linux64
${GREENLIB_PREFIX}/lib-macos
$ENV{GREENLIB_PREFIX}/include
$ENV{GREENLIB_PREFIX}/lib
$ENV{GREENLIB_PREFIX}/lib-linux
$ENV{GREENLIB_PREFIX}/lib-linux64
$ENV{GREENLIB_PREFIX}/lib-macos
${CMAKE_INSTALL_PREFIX}/include
${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib-linux
${CMAKE_INSTALL_PREFIX}/lib-linux64
${CMAKE_INSTALL_PREFIX}/lib-macos
)
# Hard-coded guesses should still go in PATHS. This ensures that the user
# environment can always override hard guesses.
SET(_GREENLIB_PATHS
/usr/include
/usr/lib
/usr/lib-linux
/usr/lib-linux64
/usr/lib-macos
/usr/local/lib
/usr/local/lib-linux
/usr/local/lib-linux64
/usr/local/lib-macos
)
FIND_PATH(GREENLIB_INCLUDE_DIRS
NAMES greencontrol/config.h
HINTS ${_GREENLIB_HINTS}
PATHS ${_GREENLIB_PATHS}
)
FIND_PATH(GREENLIB_LIBRARY_DIRS
NAMES libgreenreg.a
HINTS ${_GREENLIB_HINTS}
PATHS ${_GREENLIB_PATHS}
)
if("${GREENLIB_INCLUDE_DIRS}" MATCHES "GREENLIB_INCLUDE_DIRS-NOTFOUND")
SET(GREENLIB_FOUND FALSE)
else("${GREENLIB_INCLUDE_DIRS}" MATCHES "GREENLIB_INCLUDE_DIRS-NOTFOUND")
SET(GREENLIB_FOUND TRUE)
MESSAGE(STATUS "GreenLib include directory = ${GREENLIB_INCLUDE_DIRS}")
MESSAGE(STATUS "GreenLib library directory = ${GREENLIB_LIBRARY_DIRS}")
SET(GREENLIB_LIBRARIES greenreg)
endif("${GREENLIB_INCLUDE_DIRS}" MATCHES "GREENLIB_INCLUDE_DIRS-NOTFOUND")
... ...
# - Find SystemC
# This module finds if SystemC is installed and determines where the
# include files and libraries are. This code sets the following
# variables: (from kernel/sc_ver.h)
#
# SystemC_VERSION_MAJOR = The major version of the package found.
# SystemC_VERSION_MINOR = The minor version of the package found.
# SystemC_VERSION_REV = The patch version of the package found.
# SystemC_VERSION = This is set to: $major.$minor.$rev
#
# The minimum required version of SystemC can be specified using the
# standard CMake syntax, e.g. FIND_PACKAGE(SystemC 2.2)
#
# For these components the following variables are set:
#
# SystemC_INCLUDE_DIRS - Full paths to all include dirs.
# SystemC_LIBRARIES - Full paths to all libraries.
#
# Example Usages:
# FIND_PACKAGE(SystemC)
# FIND_PACKAGE(SystemC 2.3)
#
#=============================================================================
# Copyright 2012 GreenSocs
#
#=============================================================================
message(STATUS "Searching for SystemC")
# The HINTS option should only be used for values computed from the system.
SET(_SYSTEMC_HINTS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\SystemC\\2.2;SystemcHome]/include"
${SYSTEMC_PREFIX}/include
${SYSTEMC_PREFIX}/lib
${SYSTEMC_PREFIX}/lib-linux
${SYSTEMC_PREFIX}/lib-linux64
${SYSTEMC_PREFIX}/lib-macos
$ENV{SYSTEMC_PREFIX}/include
$ENV{SYSTEMC_PREFIX}/lib
$ENV{SYSTEMC_PREFIX}/lib-linux
$ENV{SYSTEMC_PREFIX}/lib-linux64
$ENV{SYSTEMC_PREFIX}/lib-macos
${CMAKE_INSTALL_PREFIX}/include
${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib-linux
${CMAKE_INSTALL_PREFIX}/lib-linux64
${CMAKE_INSTALL_PREFIX}/lib-macos
)
# Hard-coded guesses should still go in PATHS. This ensures that the user
# environment can always override hard guesses.
SET(_SYSTEMC_PATHS
/usr/include/systemc
/usr/lib
/usr/lib-linux
/usr/lib-linux64
/usr/lib-macos
/usr/local/lib
/usr/local/lib-linux
/usr/local/lib-linux64
/usr/local/lib-macos
)
FIND_FILE(_SYSTEMC_VERSION_FILE
NAMES sc_ver.h
HINTS ${_SYSTEMC_HINTS}
PATHS ${_SYSTEMC_PATHS}
PATH_SUFFIXES sysc/kernel
)
EXEC_PROGRAM("cat ${_SYSTEMC_VERSION_FILE} |grep '#define SC_API_VERSION_STRING' | cut -d '_' -f 7 "
OUTPUT_VARIABLE SystemC_MAJOR)
EXEC_PROGRAM("cat ${_SYSTEMC_VERSION_FILE} |grep '#define SC_API_VERSION_STRING' | cut -d '_' -f 8 "
OUTPUT_VARIABLE SystemC_MINOR)
EXEC_PROGRAM("cat ${_SYSTEMC_VERSION_FILE} |grep '#define SC_API_VERSION_STRING' | cut -d '_' -f 9 "
OUTPUT_VARIABLE SystemC_REV)
set(SystemC_VERSION ${SystemC_MAJOR}.${SystemC_MINOR}.${SystemC_REV})
if("${SystemC_MAJOR}" MATCHES "2")
set(SystemC_FOUND TRUE)
endif("${SystemC_MAJOR}" MATCHES "2")
message(STATUS "SystemC version = ${SystemC_VERSION}")
FIND_PATH(SystemC_INCLUDE_DIRS
NAMES systemc.h
HINTS ${_SYSTEMC_HINTS}
PATHS ${_SYSTEMC_PATHS}
)
FIND_PATH(SystemC_LIBRARY_DIRS
NAMES libsystemc.a
HINTS ${_SYSTEMC_HINTS}
PATHS ${_SYSTEMC_PATHS}
)
set(SystemC_LIBRARIES ${SystemC_LIBRARY_DIRS}/libsystemc.a)
message(STATUS "SystemC library = ${SystemC_LIBRARIES}")
... ...
# - Find TLM
# This module finds if TLM is installed and determines where the
# include files and libraries are. This code sets the following
# variables: (from kernel/sc_ver.h)
#
# TLM_VERSION_STRING = Version of the package found, eg. "2.2.0"
# TLM_VERSION_MAJOR = The major version of the package found.
# TLM_VERSION_MINOR = The minor version of the package found.
# TLM_VERSION_PATCH = The patch version of the package found.
# TLM_VERSION_DATE = The date of release (from TLM_VERSION)
# TLM_VERSION = This is set to: $major.$minor.$patch
#
# The minimum required version of TLM can be specified using the
# standard CMake syntax, e.g. FIND_PACKAGE(TLM 2.2)
#
# For these components the following variables are set:
#
# TLM_FOUND - TRUE if all components are found.
# TLM_INCLUDE_DIRS - Full paths to all include dirs.
# TLM_LIBRARIES - Full paths to all libraries.
# TLM_<component>_FOUND - TRUE if <component> is found.
#
# Example Usages:
# FIND_PACKAGE(TLM)
# FIND_PACKAGE(TLM 2.3)
#
#=============================================================================
# Copyright 2012 GreenSocs
#
#=============================================================================
message(STATUS "Searching for TLM")
# The HINTS option should only be used for values computed from the system.
SET(_TLM_HINTS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\TLM\\2.2;TLMHome]/include"
$ENV{TLM_HOME}
${SYSTEMC_PREFIX}/include
${SYSTEMC_PREFIX}/lib
${SYSTEMC_PREFIX}/lib-linux
${SYSTEMC_PREFIX}/lib-linux64
${SYSTEMC_PREFIX}/lib-macos
$ENV{SYSTEMC_PREFIX}/include
$ENV{SYSTEMC_PREFIX}/lib
$ENV{SYSTEMC_PREFIX}/lib-linux
$ENV{SYSTEMC_PREFIX}/lib-linux64
$ENV{SYSTEMC_PREFIX}/lib-macos
${CMAKE_INSTALL_PREFIX}/include
${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib-linux
${CMAKE_INSTALL_PREFIX}/lib-linux64
${CMAKE_INSTALL_PREFIX}/lib-macos
)
# Hard-coded guesses should still go in PATHS. This ensures that the user
# environment can always override hard guesses.
SET(_TLM_PATHS
/usr/include/TLM
/usr/include/systemc
/usr/lib
/usr/lib-linux
/usr/lib-linux64
/usr/lib-macos
/usr/local/lib
/usr/local/lib-linux
/usr/local/lib-linux64
/usr/local/lib-macos
)
FIND_PATH(TLM_INCLUDE_DIRS
NAMES tlm.h
HINTS ${_TLM_HINTS}
PATHS ${_TLM_PATHS}
PATH_SUFFIXES include/tlm
)
EXEC_PROGRAM("ls ${TLM_INCLUDE_DIRS}/tlm.h"
RETURN_VALUE ret)
if("${ret}" MATCHES "0")
set(TLM_FOUND TRUE)
endif("${ret}" MATCHES "0")
message(STATUS "TLM library = ${TLM_INCLUDE_DIRS}/tlm.h")
... ...
Copyright (C) 2014, GreenSocs ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses>.
Linking GreenSocs code, statically or dynamically with other modules
is making a combined work based on GreenSocs code. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
In addition, as a special exception, the copyright holders, GreenSocs
Ltd, give you permission to combine GreenSocs code with free software
programs or libraries that are released under the GNU LGPL, under the
OSCI license, under the OCP TLM Kit Research License Agreement or
under the OVP evaluation license.You may copy and distribute such a
system following the terms of the GNU GPL and the licenses of the
other code concerned.
Note that people who make modified versions of GreenSocs code are not
obligated to grant this special exception for their modified versions;
it is their choice whether to do so. The GNU General Public License
gives permission to release a modified version without this exception;
this exception also makes it possible to release a modified version
which carries forward this exception.
... ...
This is a PL190 SystemC module using GreenReg.
How to include this model in a project:
* Copy the misc/FindPL190.cmake in your project repository.
* Add the following lines into your CMakeLists.txt:
FIND_PACKAGE(PL190)
if(PL190_FOUND)
INCLUDE_DIRECTORIES(${PL190_INCLUDE_DIRS})
LINK_DIRECTORIES(${PL190_LIBRARY_DIRS})
else()
MESSAGE(FATAL_ERROR "PL190 not found.")
endif()
You're now able to use PL190 headers and link the toplevel with PL190_LIBRARIES.
... ...
/*
* IRQ.h
*
* Copyright (C) 2014, GreenSocs Ltd.
*
* Developped by Konrad Frederic <fred.konrad@greensocs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses>.
*
* Linking GreenSocs code, statically or dynamically with other modules
* is making a combined work based on GreenSocs code. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders, GreenSocs
* Ltd, give you permission to combine GreenSocs code with free software
* programs or libraries that are released under the GNU LGPL, under the
* OSCI license, under the OCP TLM Kit Research License Agreement or
* under the OVP evaluation license.You may copy and distribute such a
* system following the terms of the GNU GPL and the licenses of the
* other code concerned.
*
* Note that people who make modified versions of GreenSocs code are not
* obligated to grant this special exception for their modified versions;
* it is their choice whether to do so. The GNU General Public License
* gives permission to release a modified version without this exception;
* this exception also makes it possible to release a modified version
* which carries forward this exception.
*
*/
#ifndef IRQ_H
#define IRQ_H
/*
* This just defines an IRQ extension for GreenSignal to pass the IRQ number and
* the value.
*/
GS_GUARD_ONLY_EXTENSION(IRQ_LINE_EXTENSION);
typedef struct IRQ_ext_data
{
uint32_t value;
uint32_t irq_line;
} IRQ_ext_data;
#define GS_CPU_IRQ 0
#define GS_CPU_FIQ 1
#endif /* !IRQ_H */
... ...
/*
* PL190.h
*
* Copyright (C) 2014, GreenSocs Ltd.
*
* Developped by Konrad Frederic <fred.konrad@greensocs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses>.
*
* Linking GreenSocs code, statically or dynamically with other modules
* is making a combined work based on GreenSocs code. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders, GreenSocs
* Ltd, give you permission to combine GreenSocs code with free software
* programs or libraries that are released under the GNU LGPL, under the
* OSCI license, under the OCP TLM Kit Research License Agreement or
* under the OVP evaluation license.You may copy and distribute such a
* system following the terms of the GNU GPL and the licenses of the
* other code concerned.
*
* Note that people who make modified versions of GreenSocs code are not
* obligated to grant this special exception for their modified versions;
* it is their choice whether to do so. The GNU General Public License
* gives permission to release a modified version without this exception;
* this exception also makes it possible to release a modified version
* which carries forward this exception.
*
*/
#ifndef PL190_H
#define PL190_H
#include <systemc.h>
#include <greenreg/greenreg.h>
#include <greenreg/greenreg_socket.h>
#include "greensignalsocket/green_signal.h"
class PL190:
public gs::reg::gr_device
{
public:
GC_HAS_CALLBACKS();
PL190(sc_core::sc_module_name name);
~PL190();
typedef gs_generic_signal::gs_generic_signal_payload irqPayload;
gs::reg::greenreg_socket<gs::gp::generic_slave> target_port;
gs_generic_signal::initiator_signal_multi_socket irq_socket;
gs_generic_signal::target_signal_multi_socket<PL190> irq_slave_socket;
private:
void end_of_elaboration();
void Unimplemented(gs::reg::transaction_type *&tr,
const sc_core::sc_time &delay);
void UpdateIRQ();
void ClearIntEnable(gs::reg::transaction_type *&tr,
const sc_core::sc_time &delay);
void WriteSoftwareInt(gs::reg::transaction_type *&tr,
const sc_core::sc_time &delay);
void ClearSoftwareInt(gs::reg::transaction_type *&tr,
const sc_core::sc_time &delay);
void WriteVectAddr(gs::reg::transaction_type *&tr,
const sc_core::sc_time &delay);
void irq_b_transport(unsigned int, irqPayload& payload,
sc_core::sc_time& time);
gs::gs_param<uint32_t> ext_irq; /*<! External IRQs, this is not accesible
directly by the registers.*/
gs::gs_param<uint8_t> cur_irq; /*<! Current active interrupt (for vector). */
gs::gs_param<bool> vect_int; /*<! True if there is a vectored IRQ. */
gs::gs_param<bool> cur_irq_lvl; /*<! Current IRQ level. */
gs::gs_param<bool> cur_fiq_lvl; /*<! Current FIQ level. */
};
#endif /* !PL190_H */
... ...
# This module looks for PL190 module and determines where the header files and
# libraries are.
#=============================================================================
# Copyright 2014 GreenSocs
#
# KONRAD Frederic <fred.konrad@greensocs.com>
#
#=============================================================================
MESSAGE(STATUS "Searching for PL190 model.")
# The HINTS option should only be used for values computed from the system.
SET(_PL190_HINTS
${PL190_PREFIX}/include
${PL190_PREFIX}/lib
${PL190_PREFIX}/lib64
$ENV{PL190_PREFIX}/include
$ENV{PL190_PREFIX}/lib
$ENV{PL190_PREFIX}/lib64
${CMAKE_INSTALL_PREFIX}/include
${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib64
)
# Hard-coded guesses should still go in PATHS. This ensures that the user
# environment can always override hard guesses.
SET(_PL190_PATHS
/usr/include
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
)
FIND_PATH(PL190_INCLUDE_DIRS
NAMES PL190/PL190.h
HINTS ${_PL190_HINTS}
PATHS ${_PL190_PATHS}
)
FIND_PATH(PL190_LIBRARY_DIRS
NAMES libpl190.so
HINTS ${_PL190_HINTS}
PATHS ${_PL190_PATHS}
)
if("${PL190_INCLUDE_DIRS}" MATCHES "PL190_INCLUDE_DIRS-NOTFOUND")
SET(PL190_FOUND FALSE)
else("${PL190_INCLUDE_DIRS}" MATCHES "PL190_INCLUDE_DIRS-NOTFOUND")
SET(PL190_FOUND TRUE)
MESSAGE(STATUS "PL190 include directory = ${PL190_INCLUDE_DIRS}")
MESSAGE(STATUS "PL190 library directory = ${PL190_LIBRARY_DIRS}")
SET(PL190_LIBRARIES pl190)
endif("${PL190_INCLUDE_DIRS}" MATCHES "PL190_INCLUDE_DIRS-NOTFOUND")
... ...
This diff is collapsed. Click to expand it.
#
# CMakeLists.txt
#
# Copyright (C) 2014, GreenSocs ltd.
#
# Developped by Konrad Frederic <fred.konrad@greensocs.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking GreenSocs code, statically or dynamically with other modules
# is making a combined work based on GreenSocs code. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders, GreenSocs
# Ltd, give you permission to combine GreenSocs code with free software
# programs or libraries that are released under the GNU LGPL, under the
# OSCI license, under the OCP TLM Kit Research License Agreement or
# under the OVP evaluation license.You may copy and distribute such a
# system following the terms of the GNU GPL and the licenses of the
# other code concerned.
#
# Note that people who make modified versions of GreenSocs code are not
# obligated to grant this special exception for their modified versions;
# it is their choice whether to do so. The GNU General Public License
# gives permission to release a modified version without this exception;
# this exception also makes it possible to release a modified version
# which carries forward this exception.
ADD_EXECUTABLE(PL190_testbench
PL190_testbench.cpp
)
TARGET_LINK_LIBRARIES(PL190_testbench pl190 systemc greenreg pthread)
ADD_TEST(NAME PL190 COMMAND ./PL190_testbench)
... ...
#include <systemc>
#include <greencontrol/config.h>
#include <greensignalsocket/green_signal.h>
#include "PL190/PL190.h"
#include "PL190/IRQ.h"
#define TEST(str) std::cout << "testing: " << str << std::endl;
#define ERROR(str) std::cout << "failed: " << str << std::endl;
#define SUCCESS(str) std::cout << "success " << str << std::endl;
class TestMaster:
public sc_module,
public gs::payload_event_queue_output_if<gs::gp::master_atom>
{
public:
SC_HAS_PROCESS(TestMaster);
TestMaster(sc_module_name name):
sc_module(name),
master_socket("master_port"),
irq_slave_socket("irq_port")
{
master_socket.out_port(*this);
fail = false;
gs::socket::config<gs_generic_signal::gs_generic_signal_protocol_types> cnf;
cnf.use_mandatory_extension<IRQ_LINE_EXTENSION>();
irq_slave_socket.set_config(cnf);
irq_slave_socket.register_b_transport(this, &TestMaster::irq_b_transport);
SC_THREAD(testing);
};
~TestMaster() {};
void notify(gs::gp::master_atom& tc) {};
void end_of_elaboration()
{
tHandle = master_socket.create_transaction();
}
typedef gs::gp::GenericMasterBlockingPort<32>::accessHandle transactionHandle;
gs::gp::GenericMasterBlockingPort<32> master_socket;
typedef gs_generic_signal::gs_generic_signal_payload irqPayload;
gs_generic_signal::target_signal_multi_socket<TestMaster> irq_slave_socket;
bool fail;
uint32_t expected_irq_lines;
private:
transactionHandle tHandle;
bool testResponse()
{
if (tHandle->getSResp() != gs::Generic_SRESP_DVA)
{
return false;
}
return true;
}
void irq_b_transport(unsigned int, irqPayload& payload,
sc_core::sc_time& time)
{
/* We got an IRQ from the tested device. */
}
void write(uint64_t address, uint32_t value)
{
gs::GSDataType::dtype data = gs::GSDataType::dtype((unsigned char *)&value,
sizeof(value));
tHandle->setMBurstLength(4);
tHandle->setMAddr(address);
tHandle->setMData(data);
tHandle->setMCmd(gs::Generic_MCMD_WR);
master_socket.Transact(tHandle);
if (!testResponse())
{
this->fail = true;
}
}
uint32_t read(uint64_t address)
{
uint32_t value = 0;
gs::GSDataType::dtype data = gs::GSDataType::dtype((unsigned char *)&value,
sizeof(value));
tHandle->setMBurstLength(4);
tHandle->setMAddr(address);
tHandle->setMData(data);
tHandle->setMCmd(gs::Generic_MCMD_RD);
master_socket.Transact(tHandle);
value = *((uint32_t *)data.getData());