Logo SoCRocket

Transaction-Level Modeling Framework for Space Applications

Files | Classes | Functions
GPTimer

Files

file  gpcounter.cpp
 
file  gpcounter.h
 
file  gptimer.cpp
 

Classes

class  GPCounter
 This class implements an internal counter of a gptimer. More...
 
class  GPTimer
 This class is a TLM 2.0 Model of the Aeroflex Gaisler GRLIB GPTimer. Further informations to the original VHDL Modle are available in the GRLIB IP Core User's Manual Section 37. More...
 

Functions

 SR_HAS_MODULE (GPTimer)
 
 GPCounter::GPCounter (GPTimer *_parent, unsigned int nr, ModuleName name)
 Creates a new Counter instance. Only usfull if its called from inside of a GPTimer instance. More...
 
 GPCounter::~GPCounter ()
 Destroies a Counter instance. More...
 
void GPCounter::end_of_elaboration ()
 Execute the callback registering when systemc reaches the end of elaboration. More...
 
void GPCounter::end_of_simulation ()
 Execute the callback registering when systemc reaches the end of simulation. More...
 
void GPCounter::ctrl_read ()
 
void GPCounter::ctrl_write ()
 
void GPCounter::value_read ()
 
void GPCounter::value_write ()
 
void GPCounter::chaining ()
 This function prepares the Counter for chaining. More...
 
void GPCounter::ticking ()
 
void GPCounter::do_reset ()
 Performs the reset code for the Counter. This function is executed by the Timer::do_reset() function. More...
 
sc_core::sc_time GPCounter::nextzero ()
 
sc_core::sc_time GPCounter::cycletime ()
 
void GPCounter::calculate ()
 Function calculating the waiting time for the next timer event. More...
 
void GPCounter::start ()
 Start a Counter from dhalt or to enable it etc. More...
 
void GPCounter::stop ()
 Stop a Counter from dhalt or to enable it etc. More...
 
 GPTimer::GPTimer (ModuleName name, unsigned int ncounters=1, int pindex=0, int paddr=0, int pmask=4095, int pirq=0, int sepirq=0, int sbits=16, int nbits=32, int wdog=0, bool powmon=false)
 
 GPTimer::~GPTimer ()
 Free all counter and unregister all callbacks. More...
 
void GPTimer::init_generics ()
 
void GPTimer::init_registers ()
 
void GPTimer::start_of_simulation ()
 SystemC start of simulation callback. More...
 
void GPTimer::power_model ()
 Calculate power/energy values from normalized input data. More...
 
gs::cnf::callback_return_type GPTimer::sta_power_cb (gs::gs_param_base &changed_param, gs::cnf::callback_type reason)
 Static power callback. More...
 
gs::cnf::callback_return_type GPTimer::int_power_cb (gs::gs_param_base &changed_param, gs::cnf::callback_type reason)
 Dynamic/Internal power callback. More...
 
void GPTimer::end_of_elaboration ()
 Execute the callback registering when systemc reaches the end of elaboration. More...
 
void GPTimer::scaler_read ()
 Register callback executed before the prescaler value register gets read, to calculate the current value. More...
 
void GPTimer::screload_write ()
 Register callback executed after the presacler reset is written, to recalculate the counter and ticking functions. More...
 
void GPTimer::scaler_write ()
 Register callback executed after the presacler value is written, to recalculate the counter and ticking functions. More...
 
void GPTimer::conf_read ()
 Register callback executed before the prescaler config register gets read, to calculate the current value. More...
 
virtual void GPTimer::dorst ()
 
int64_t GPTimer::valueof (sc_core::sc_time t, int64_t offset, sc_core::sc_time cycletime) const
 
int64_t GPTimer::numberofticksbetween (sc_core::sc_time start, sc_core::sc_time end, int counter, sc_core::sc_time cycletime)
 

Detailed Description

Function Documentation

void GPCounter::calculate ( )

Function calculating the waiting time for the next timer event.

References CLKDevice::clock_cycle, GPTimer::CTRL(), GPTimer::CTRL_EN, GPCounter::cycletime(), GPCounter::e_wait, GPCounter::nextzero(), GPCounter::nr, GPCounter::p, APBSlave::r, usi.systemc::time(), GPTimer::VALUE(), and GPCounter::value_read().

Referenced by GPCounter::start(), GPCounter::ticking(), and GPCounter::value_write().

Here is the call graph for this function:

void GPCounter::chaining ( )

This function prepares the Counter for chaining.

References GPCounter::chain_run, v::debug, setup::name, GPCounter::nr, and GPCounter::start().

Here is the call graph for this function:

void GPTimer::conf_read ( )

Register callback executed before the prescaler config register gets read, to calculate the current value.

References GPTimer::CONF, GPTimer::conf_defaults, and APBSlave::r.

Referenced by GPTimer::init_registers().

void GPCounter::ctrl_read ( )

This is a callback which gets executed before the control register is read. It updates the control register with the current values.

References GPTimer::CTRL(), GPTimer::CTRL_DH, GPTimer::CTRL_IP, GPCounter::m_pirq, GPCounter::nr, GPCounter::p, and APBSlave::r.

Referenced by GPTimer::init_registers().

Here is the call graph for this function:

void GPCounter::ctrl_write ( )

This is a callback which gets executed after the control register is written. It applies the changes to the current state of the Counter. If recalculation of the waiting time is needed it calle calculate().

References GPCounter::chain_run, GPTimer::CTRL(), GPTimer::CTRL_CH, GPTimer::CTRL_DH, GPTimer::CTRL_EN, GPTimer::CTRL_IP, GPTimer::CTRL_LD, v::debug, GPCounter::m_pirq, setup::name, GPCounter::nr, GPCounter::p, APBSlave::r, GPTimer::RELOAD(), GPCounter::start(), GPCounter::stop(), GPCounter::stopped, GPTimer::VALUE(), and GPCounter::value_write().

Referenced by GPTimer::init_registers().

Here is the call graph for this function:

sc_core::sc_time GPCounter::cycletime ( )

References CLKDevice::clock_cycle, GPTimer::counter, GPTimer::CTRL(), GPTimer::CTRL_CH, GPCounter::nr, GPCounter::p, APBSlave::r, GPTimer::RELOAD(), and GPTimer::SCRELOAD.

Referenced by GPCounter::calculate().

Here is the call graph for this function:

void GPCounter::do_reset ( )

Performs the reset code for the Counter. This function is executed by the Timer::do_reset() function.

References GPCounter::chain_run, GPTimer::CTRL(), GPCounter::lasttime, GPCounter::lastvalue, GPCounter::nr, GPCounter::p, APBSlave::r, GPTimer::RELOAD(), GPCounter::stopped, and GPTimer::VALUE().

Here is the call graph for this function:

void GPTimer::dorst ( )
virtual

Signal callback executed a reset on the timer when the rst signal arrives.

Parameters
valueThe new Value of the Signal.
timeA possible delay. Which means the reset might be performed in the future (Not used for resets!).

Reimplemented from CLKDevice.

References GPTimer::CONF, GPTimer::conf_defaults, count, GPTimer::counter, GPTimer::CTRL(), GPTimer::g_sbits, GPTimer::g_wdog_length, GPTimer::lasttime, GPTimer::lastvalue, APBSlave::r, GPTimer::RELOAD(), GPTimer::SCALER, GPTimer::scaler_read(), GPTimer::scaler_write(), GPTimer::SCRELOAD, and GPTimer::wdog.

Here is the call graph for this function:

void GPCounter::end_of_elaboration ( )

Execute the callback registering when systemc reaches the end of elaboration.

void GPTimer::end_of_elaboration ( )

Execute the callback registering when systemc reaches the end of elaboration.

void GPCounter::end_of_simulation ( )

Execute the callback registering when systemc reaches the end of simulation.

References setup::name, and v::report.

GPCounter::GPCounter ( GPTimer _parent,
unsigned int  nr,
ModuleName  name 
)

Creates a new Counter instance. Only usfull if its called from inside of a GPTimer instance.

References GPCounter::ticking().

Here is the call graph for this function:

GPTimer::GPTimer ( ModuleName  name,
unsigned int  ncounters = 1,
int  pindex = 0,
int  paddr = 0,
int  pmask = 4095,
int  pirq = 0,
int  sepirq = 0,
int  sbits = 16,
int  nbits = 32,
int  wdog = 0,
bool  powmon = false 
)

Creates an instance of an GPTimer.

Parameters
nameThe name of the instance. It's needed for debunging.
ncountersDefines the number of counters in the unit. Default is 1. Max is 7.
pindexAPB bus slave index
paddrAPB bus slave address
pmaskAPB bus slave mask
pirqDefines which APB interupt the timers will generate. Default is 0.
sepirqIf set to 1, each timer will drive an individual interrupt line, starting with interrupt irq. If set to 0, all timers will drive the same interrupt line (irq).
nbitsDefines the number of bits in the timers. Default is 32.
sbitsDefines the number of bits in the scaler. Default is 16.
wdogWatchdog reset value. When set to a non-zero value, the last timer will be enabled and pre-loaded with this value at reset. When the timer value reaches 0, the WDOG output is driven active.

References APBSlave::apb, APBSlaveSocket< BUSWIDTH, ADDR_TYPE, DATA_TYPE >::get_base_addr(), APBSlaveSocket< BUSWIDTH, ADDR_TYPE, DATA_TYPE >::get_size(), GPTimer::init_generics(), GPTimer::init_registers(), GPTimer::int_power, GPTimer::int_power_cb(), GPTimer::powermon, usi.cci.callback::pre_read, srInfo, GPTimer::sta_power, GPTimer::sta_power_cb(), and GPTimer::wdog.

Here is the call graph for this function:

void GPTimer::init_generics ( )
virtual

Initialize the generics with meta data.

Will ne called from the constructor.

Reimplemented from BaseModule< DefaultBase >.

References sr_param_base::add_properties(), GPTimer::g_nbits, GPTimer::g_ntimers, GPTimer::g_sbits, GPTimer::g_sepirq, and GPTimer::g_wdog_length.

Referenced by GPTimer::GPTimer().

Here is the call graph for this function:

void GPTimer::init_registers ( )
virtual

Initialize the register file.

Will be called from the constructor. Also creates the GPCounter objects to minimize the number of loops in the constructor.

Reimplemented from BaseModule< DefaultBase >.

References sr_register< DATA_TYPE >::callback(), GPTimer::conf_defaults, GPTimer::conf_read(), GPTimer::counter, sr_register_bank< ADDR_TYPE, DATA_TYPE >::create_register(), GPTimer::CTRL(), GPCounter::ctrl_read(), GPCounter::ctrl_write(), GPTimer::g_nbits, GPTimer::g_ntimers, GPTimer::g_sbits, GPTimer::GPCounter, i, APBSlave::r, GPTimer::RELOAD(), GPTimer::scaler_read(), GPTimer::scaler_write(), GPTimer::screload_write(), SR_POST_WRITE, SR_PRE_READ, GPTimer::VALUE(), GPCounter::value_read(), and GPCounter::value_write().

Referenced by GPTimer::GPTimer().

Here is the call graph for this function:

gs::cnf::callback_return_type GPTimer::int_power_cb ( gs::gs_param_base &  changed_param,
gs::cnf::callback_type  reason 
)

Dynamic/Internal power callback.

References GC_RETURN_OK.

Referenced by GPTimer::GPTimer().

sc_core::sc_time GPCounter::nextzero ( )

References CLKDevice::clock_cycle, GPTimer::counter, GPTimer::CTRL(), GPTimer::CTRL_CH, GPCounter::nr, GPCounter::p, APBSlave::r, GPTimer::SCALER, GPTimer::scaler_read(), GPTimer::VALUE(), and x.

Referenced by GPCounter::calculate().

Here is the call graph for this function:

int64_t GPTimer::numberofticksbetween ( sc_core::sc_time  start,
sc_core::sc_time  end,
int  counter,
sc_core::sc_time  cycletime 
)

Calculates the number of ticks (prescaler underflows) in between two certain time points.

The cycletime can be set to enable the simple calculation of chained counters. Usualy it is clock_cycle but in case of a chained counter it is the cycletime of counter[n-1].

Parameters
startStart time as sc_core::sc_time
endEnd time as sc_core::sc_time
counterNumber of a gpcounter to respect the counter delay (round robin decrement).
cycletimeThe length of an cycle in which the decremention of the prescalet takes place.

References APBSlave::r, GPTimer::SCRELOAD, and GPTimer::valueof().

Referenced by GPCounter::value_read().

Here is the call graph for this function:

void GPTimer::power_model ( )

Calculate power/energy values from normalized input data.

References CLKDevice::clock_cycle, GPTimer::g_ntimers, GPTimer::int_power, GPTimer::int_power_norm, GPTimer::sta_power, and GPTimer::sta_power_norm.

Referenced by GPTimer::start_of_simulation().

void GPTimer::scaler_read ( )

Register callback executed before the prescaler value register gets read, to calculate the current value.

References CLKDevice::clock_cycle, APBSlave::r, GPTimer::SCALER, GPTimer::SCRELOAD, and GPTimer::valueof().

Referenced by GPTimer::dorst(), GPTimer::init_registers(), and GPCounter::nextzero().

Here is the call graph for this function:

void GPTimer::scaler_write ( )

Register callback executed after the presacler value is written, to recalculate the counter and ticking functions.

References GPTimer::counter, GPTimer::lasttime, GPTimer::lastvalue, APBSlave::r, and GPTimer::SCALER.

Referenced by GPTimer::dorst(), GPTimer::init_registers(), and GPTimer::screload_write().

void GPTimer::screload_write ( )

Register callback executed after the presacler reset is written, to recalculate the counter and ticking functions.

References APBSlave::r, GPTimer::SCALER, GPTimer::scaler_write(), and GPTimer::SCRELOAD.

Referenced by GPTimer::init_registers().

Here is the call graph for this function:

SR_HAS_MODULE ( GPTimer  )
gs::cnf::callback_return_type GPTimer::sta_power_cb ( gs::gs_param_base &  changed_param,
gs::cnf::callback_type  reason 
)

Static power callback.

References GC_RETURN_OK.

Referenced by GPTimer::GPTimer().

void GPCounter::start ( )

Start a Counter from dhalt or to enable it etc.

References GPCounter::calculate(), GPCounter::chain_run, GPTimer::CTRL(), GPTimer::CTRL_CH, GPTimer::CTRL_EN, v::debug, GPCounter::lasttime, setup::name, GPCounter::nr, GPCounter::p, APBSlave::r, and GPCounter::stopped.

Referenced by GPCounter::chaining(), and GPCounter::ctrl_write().

Here is the call graph for this function:

void GPTimer::start_of_simulation ( )

SystemC start of simulation callback.

References GPTimer::power_model(), and GPTimer::powermon.

Here is the call graph for this function:

void GPCounter::stop ( )

Stop a Counter from dhalt or to enable it etc.

References v::debug, GPCounter::e_wait, GPCounter::lasttime, GPCounter::lastvalue, setup::name, GPCounter::nr, GPCounter::p, APBSlave::r, GPCounter::stopped, GPTimer::VALUE(), and GPCounter::value_read().

Referenced by GPCounter::ctrl_write(), and GPCounter::ticking().

Here is the call graph for this function:

void GPCounter::ticking ( )

This function contains the core functionality of the Counter. It is a SC_THREAD which triggers the interupt and waits for the e_tick event.

References GPCounter::calculate(), CLKDevice::clock_cycle, GPTimer::CONF, GPTimer::CONF_SI, GPTimer::counter, GPTimer::CTRL(), GPTimer::CTRL_CH, GPTimer::CTRL_EN, GPTimer::CTRL_IE, GPTimer::CTRL_RS, GPCounter::e_wait, GPTimer::g_wdog_length, GPTimer::irq, GPCounter::m_pirq, GPCounter::nr, GPCounter::p, APBSlave::r, GPCounter::stop(), GPCounter::value_read(), pysc::api::systemc::wait(), and GPTimer::wdog.

Referenced by GPCounter::GPCounter().

Here is the call graph for this function:

void GPCounter::value_read ( )

This is a callback wich gets executed before the value register is read. It calculates the current value of the register. lasttime and lastvalue are used as base. Other functions are using this function to trigger an update of the value register.

See Also
lastvalue
lasttime

References CLKDevice::clock_cycle, GPTimer::counter, GPTimer::CTRL(), GPTimer::CTRL_CH, GPTimer::CTRL_RS, GPTimer::g_sbits, GPCounter::lasttime, GPCounter::lastvalue, GPCounter::nr, GPTimer::numberofticksbetween(), GPCounter::p, APBSlave::r, GPTimer::RELOAD(), GPCounter::stopped, and GPTimer::VALUE().

Referenced by GPCounter::calculate(), GPTimer::init_registers(), GPCounter::stop(), and GPCounter::ticking().

Here is the call graph for this function:

void GPCounter::value_write ( )

This function is a callback wich gets executed after the value register is written. It stores the current time and value into the lasttime and lastvalue attributes and Triggers a recalculation of the waiting time.

See Also
lastvalue
lasttime
calculate()

References GPCounter::calculate(), GPCounter::lasttime, GPCounter::lastvalue, GPCounter::nr, GPCounter::p, APBSlave::r, GPCounter::stopped, and GPTimer::VALUE().

Referenced by GPCounter::ctrl_write(), and GPTimer::init_registers().

Here is the call graph for this function:

int64_t GPTimer::valueof ( sc_core::sc_time  t,
int64_t  offset,
sc_core::sc_time  cycletime 
) const

The time to value function of the prescaler or the counters.

This is the fundamental function which defines the connection between a given time and the value. All calculations in the Timer and Counter class are based on this function. The function itself is defined through the two attributes lastvalue and lasttime.

Parameters
tThe Time for which is needed the prescaler value.
offsetAn offset, defined to calculate a value which is influenced by the counter number. This is needed due to the fact that the rtl model decrements the counters one after one, Each in a clockcycle if the prescaler undeflows.
cycletimeThe cycle length which decrements the value.
Returns
The value to time t.
See Also
lastvalue
lasttime
numberofticksbetween()

References GPTimer::lasttime, and GPTimer::lastvalue.

Referenced by GPTimer::numberofticksbetween(), and GPTimer::scaler_read().

GPCounter::~GPCounter ( )

Destroies a Counter instance.

GPTimer::~GPTimer ( )

Free all counter and unregister all callbacks.

References GPTimer::counter.