Commit f71de082 authored by Dimitris Lampridis's avatar Dimitris Lampridis

sw: add simulation option for both tdc and fd firmware

parent a2b76479
......@@ -25,6 +25,12 @@
#define OUT_TIMEOUT 10
#ifdef SIMULATION
static const int is_simulation = 1;
#else
static const int is_simulation = 0;
#endif
struct wrtd_out_trigger triggers[FD_HASH_ENTRIES]; /**< list of triggers */
struct wrtd_out_trigger *ht[FD_HASH_ENTRIES]; /* hash table */
static unsigned int tlist_count = 0; /**< number of valid trigger entry
......@@ -78,6 +84,11 @@ static void wr_update_link(void)
{
int i;
if (is_simulation) {
wr_state = WR_LINK_SYNCED;
return;
}
switch(wr_state) {
case WR_LINK_OFFLINE:
for(i = 0; i < FD_NUM_CHANNELS; i++)
......@@ -884,6 +895,31 @@ static trtl_fw_action_t *wrtd_out_actions[] = {
};
static int wrtd_o_sim_init(void)
{
int i;
for (i = 0; i < FD_NUM_CHANNELS; i++) {
int hidx;
wrtd_out_channels[i].config.log_level = WRTD_LOG_ALL;
wrtd_out_channels[i].config.state = OUT_ST_ARMED;
wrtd_out_channels[i].config.flags =
WRTD_ENABLED | WRTD_ARMED | WRTD_TRIGGER_ASSIGNED;
triggers[i].id.system = 0;
triggers[i].id.source_port = i;
triggers[i].id.trigger = i;
triggers[i].flags = ENTRY_FLAG_VALID;
triggers[i].ocfg[i].delay_cycles = 0;
triggers[i].ocfg[i].delay_frac = 0;
triggers[i].ocfg[i].state = HASH_ENT_DIRECT;
hidx = wrtd_out_hash_table_free(&triggers[i].id);
tlist_count++;
ht[hidx] = &triggers[i];
}
return 0;
}
/**
* Initialize data structures, RT application and variables
*/
......@@ -949,7 +985,12 @@ static int wrtd_o_init(void)
rmq_bind_in(WRTD_OUT_RMQ, TRTL_EP_ETH, &addr);
fd_init();
/* Skip WR sync and automatically generate some events when simulating */
if (is_simulation)
wrtd_o_sim_init();
if (!is_simulation)
fd_init();
pr_debug("rt-output firmware initialized.\n\r");
......
......@@ -25,6 +25,12 @@
#define BASE_DP_TDC_REGS 0x2000
#define BASE_DP_TDC_DIRECT 0x8000
#ifdef SIMULATION
static const int is_simulation = 1;
#else
static const int is_simulation = 0;
#endif
enum wrtd_in_wr_link {
WR_LINK_OFFLINE = 1,
WR_LINK_ONLINE,
......@@ -308,6 +314,11 @@ void wr_update_link(void)
{
int i;
if (is_simulation) {
wr_state = WR_LINK_SYNCED;
return;
}
switch (wr_state) {
case WR_LINK_OFFLINE:
for(i = 0; i < TDC_NUM_CHANNELS; i++)
......@@ -415,6 +426,24 @@ static trtl_fw_action_t *wrtd_in_actions[] = {
[WRTD_IN_ACTION_SW_TRIG] = wrtd_in_trigger_sw,
};
static int wrtd_i_sim_init(void)
{
int i;
for(i = 0; i < TDC_NUM_CHANNELS; i++) {
wrtd_in_channels[i].config.log_level = WRTD_LOG_ALL;
wrtd_in_channels[i].config.id.system = 0;
wrtd_in_channels[i].config.id.source_port = i;
wrtd_in_channels[i].config.id.trigger = i;
wrtd_in_channels[i].config.flags =
WRTD_ENABLED | WRTD_ARMED | WRTD_TRIGGER_ASSIGNED;
}
dp_writel(0x1f, BASE_DP_TDC_DIRECT + DR_REG_CHAN_ENABLE);
dp_writel(0x40, BASE_DP_TDC_DIRECT + DR_REG_DEAD_TIME);
return 0;
}
static int wrtd_i_init(void)
{
......@@ -455,6 +484,12 @@ static int wrtd_i_init(void)
rmq_bind_out(WRTD_IN_RMQ, TRTL_EP_ETH, &addr);
/* Skip WR sync and automatically generate some events when simulating */
if (is_simulation)
wrtd_i_sim_init();
pr_debug("rt-input firmware initialized.\n\r");
return 0;
}
......
......@@ -86,7 +86,12 @@
#define TDC_NUM_CHANNELS 5
#ifdef SIMULATION
#define TDC_TRIGGER_COALESCE_LIMIT 1
#else
#define TDC_TRIGGER_COALESCE_LIMIT 5
#endif // SIMULATION
#define FD_NUM_CHANNELS 4
#define FD_HASH_ENTRIES 32
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment