Commit c3e90009 authored by Tristan Gingold's avatar Tristan Gingold

wrtd: add loopbacks.

parent 73dcea14
/*
* Shared Memory-based Loopback queue for internal trigger distribution
*
* Copyright (C) 2013-2014 CERN (www.cern.ch)
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* 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 3 of the License, or
* 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/>.
*/
#include "mockturtle-rt.h"
#include "wrtd-common.h"
#define LOOP_QUEUE_SIZE 16
static SMEM int head, tail, count;
static SMEM struct wrtd_trigger_entry buf[16];
void loop_queue_init()
{
head = 0;
tail = 0;
count = 0;
}
void loop_queue_push(struct wrtd_trig_id *id, uint32_t seq,
struct wr_timestamp *ts)
{
if (count >= LOOP_QUEUE_SIZE)
return;
buf[head].id = *id;
buf[head].seq = seq;
buf[head].ts = *ts;
smem_atomic_add(&head, 1);
if (head >= LOOP_QUEUE_SIZE)
head = 0;
smem_atomic_add(&count, 1);
}
volatile struct wrtd_trigger_entry *loop_queue_pop(void)
{
volatile struct wrtd_trigger_entry *rv;
if (count == 0)
return NULL; /* No entry */
rv = &buf[tail];
smem_atomic_add(&tail, 1);
if(tail >= LOOP_QUEUE_SIZE)
tail = 0;
smem_atomic_sub(&count, 1);
return rv;
}
/*
* Shared Memory-based Loopback queue for internal trigger distribution
*
* Copyright (C) 2013-2014 CERN (www.cern.ch)
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* 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 3 of the License, or
* 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/>.
*/
#ifndef __LOOP_QUEUE_H
#define __LOOP_QUEUE_H
#include "mockturtle-rt.h"
#include "wrtd-common.h"
#define LOOP_QUEUE_SIZE 16
void loop_queue_init();
void loop_queue_push(struct wrtd_trig_id *id, uint32_t seq,
struct wr_timestamp *ts);
volatile struct wrtd_trigger_entry *loop_queue_pop(void);
#endif
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