Adapted simple_system to demonstrate use of tlm_target by reference and

by ingeritance
This commit is contained in:
2017-09-19 17:02:23 +02:00
parent 7c32c6aab2
commit 792a40d3f1
13 changed files with 104 additions and 46 deletions

View File

@ -19,18 +19,16 @@
#include <util/bit_field.h>
#include <sysc/register.h>
#include <sysc/tlmtarget.h>
#include <sysc/utilities.h>
#include <sysc/tlm_target.h>
namespace sysc {
template<unsigned BUSWIDTH=32>
class gpio_regs :
public sc_core::sc_module,
public sysc::tlm_target<BUSWIDTH>,
public sysc::resetable
{
protected:
{
public:
// storage declarations
uint32_t r_value;
@ -86,17 +84,19 @@ protected:
sysc::sc_register<uint32_t> out_xor;
gpio_regs(sc_core::sc_module_name nm);
protected:
sc_core::sc_time clk;
template<unsigned BUSWIDTH=32>
void registerResources(sysc::tlm_target<BUSWIDTH>& target);
};
}
//////////////////////////////////////////////////////////////////////////////
// member functions
//////////////////////////////////////////////////////////////////////////////
template<unsigned BUSWIDTH>
gpio_regs<BUSWIDTH>::gpio_regs(sc_core::sc_module_name nm)
inline sysc::gpio_regs::gpio_regs(sc_core::sc_module_name nm)
: sc_core::sc_module(nm)
, sysc::tlm_target<BUSWIDTH>(clk)
, NAMED(value, r_value, 0, *this)
, NAMED(input_en, r_input_en, 0, *this)
, NAMED(output_en, r_output_en, 0, *this)
@ -115,24 +115,27 @@ gpio_regs<BUSWIDTH>::gpio_regs(sc_core::sc_module_name nm)
, NAMED(iof_sel, r_iof_sel, 0, *this)
, NAMED(out_xor, r_out_xor, 0, *this)
{
this->socket_map.addEntry(&value, 0x0UL, 0x4UL);
this->socket_map.addEntry(&input_en, 0x4UL, 0x4UL);
this->socket_map.addEntry(&output_en, 0x8UL, 0x4UL);
this->socket_map.addEntry(&port, 0xcUL, 0x4UL);
this->socket_map.addEntry(&pue, 0x10UL, 0x4UL);
this->socket_map.addEntry(&ds, 0x14UL, 0x4UL);
this->socket_map.addEntry(&rise_ie, 0x18UL, 0x4UL);
this->socket_map.addEntry(&rise_ip, 0x1cUL, 0x4UL);
this->socket_map.addEntry(&fall_ie, 0x20UL, 0x4UL);
this->socket_map.addEntry(&fall_ip, 0x24UL, 0x4UL);
this->socket_map.addEntry(&high_ie, 0x28UL, 0x4UL);
this->socket_map.addEntry(&high_ip, 0x2cUL, 0x4UL);
this->socket_map.addEntry(&low_ie, 0x30UL, 0x4UL);
this->socket_map.addEntry(&low_ip, 0x34UL, 0x4UL);
this->socket_map.addEntry(&iof_en, 0x38UL, 0x4UL);
this->socket_map.addEntry(&iof_sel, 0x3cUL, 0x4UL);
this->socket_map.addEntry(&out_xor, 0x40UL, 0x4UL);
}
template<unsigned BUSWIDTH>
inline void sysc::gpio_regs::registerResources(sysc::tlm_target<BUSWIDTH>& target) {
target.addResource(value, 0x0UL, 0x4UL);
target.addResource(input_en, 0x4UL, 0x4UL);
target.addResource(output_en, 0x8UL, 0x4UL);
target.addResource(port, 0xcUL, 0x4UL);
target.addResource(pue, 0x10UL, 0x4UL);
target.addResource(ds, 0x14UL, 0x4UL);
target.addResource(rise_ie, 0x18UL, 0x4UL);
target.addResource(rise_ip, 0x1cUL, 0x4UL);
target.addResource(fall_ie, 0x20UL, 0x4UL);
target.addResource(fall_ip, 0x24UL, 0x4UL);
target.addResource(high_ie, 0x28UL, 0x4UL);
target.addResource(high_ip, 0x2cUL, 0x4UL);
target.addResource(low_ie, 0x30UL, 0x4UL);
target.addResource(low_ip, 0x34UL, 0x4UL);
target.addResource(iof_en, 0x38UL, 0x4UL);
target.addResource(iof_sel, 0x3cUL, 0x4UL);
target.addResource(out_xor, 0x40UL, 0x4UL);
}
#endif // _GPIO_REGS_H_

View File

@ -19,8 +19,8 @@
#include <util/bit_field.h>
#include <sysc/register.h>
#include <sysc/tlmtarget.h>
#include <sysc/utilities.h>
#include <sysc/tlm_target.h>
namespace sysc {

View File

@ -19,8 +19,8 @@
#include <util/bit_field.h>
#include <sysc/register.h>
#include <sysc/tlmtarget.h>
#include <sysc/utilities.h>
#include <sysc/tlm_target.h>
namespace sysc {