1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-16 00:00:02 +01:00
VILLASnode/include/villas/fpga/ips/model.h

127 lines
2.9 KiB
C
Raw Permalink Normal View History

2016-06-14 01:19:17 +02:00
/** Interface to Xilinx System Generator Models via PCIe
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2017, Steffen Vogel
2016-06-14 01:19:17 +02:00
*********************************************************************************/
2017-02-18 10:43:58 -05:00
/** @addtogroup fpga VILLASfpga
* @{
*/
2017-02-18 10:43:58 -05:00
#pragma once
2016-06-14 01:19:17 +02:00
#include <stdlib.h>
2016-06-19 19:23:19 +02:00
#include <stdint.h>
2016-06-14 01:19:17 +02:00
#include "list.h"
2016-06-14 01:19:17 +02:00
2016-06-19 19:23:19 +02:00
#define XSG_MAPLEN 0x1000
#define XSG_MAGIC 0xDEADBABE
2016-06-14 01:19:17 +02:00
2016-06-19 19:23:19 +02:00
/* Forward declaration */
struct ip;
2016-06-14 01:19:17 +02:00
enum model_type {
MODEL_TYPE_HLS,
MODEL_TYPE_XSG
};
enum model_xsg_block_type {
XSG_BLOCK_GATEWAY_IN = 0x1000,
XSG_BLOCK_GATEWAY_OUT = 0x1001,
XSG_BLOCK_INFO = 0x2000
2016-06-14 01:19:17 +02:00
};
enum model_param_type {
MODEL_PARAM_TYPE_UFIX,
MODEL_PARAM_TYPE_FIX,
MODEL_PARAM_TYPE_FLOAT,
MODEL_PARAM_TYPE_BOOLEAN
};
enum model_param_direction {
MODEL_PARAM_IN,
MODEL_PARAM_OUT,
MODEL_PARAM_INOUT
};
union model_param_value {
uint32_t ufix;
int32_t fix;
float flt;
bool bol;
};
struct model {
2016-06-19 19:23:19 +02:00
enum model_type type; /**< Either HLS or XSG model */
struct list parameters; /**< List of model parameters. */
2016-06-19 19:23:19 +02:00
struct list infos; /**< A list of key / value pairs with model details */
union {
struct xsg_model {
2016-06-19 19:23:19 +02:00
uint32_t *map;
ssize_t maplen;
} xsg; /**< XSG specific model data */
struct hls_model {
} hls; /**< HLS specific model data */
};
};
struct model_info {
char *field;
char *value;
};
2016-06-14 01:19:17 +02:00
struct model_param {
char *name; /**< Name of the parameter */
enum model_param_direction direction; /**< Read / Write / Read-write? */
enum model_param_type type; /**< Data type. Integers are represented by MODEL_GW_TYPE_(U)FIX with model_gw::binpt == 0 */
int binpt; /**< Binary point for type == MODEL_GW_TYPE_(U)FIX */
uintptr_t offset; /**< Register offset to model::baseaddress */
2016-06-14 01:19:17 +02:00
union model_param_value default_value;
2017-02-18 10:43:58 -05:00
struct fpga_ip *ip; /**< A pointer to the model structure to which this parameters belongs to. */
2016-06-14 01:19:17 +02:00
};
2016-06-19 19:23:19 +02:00
/** Initialize a model */
2017-02-18 10:43:58 -05:00
int model_init(struct fpga_ip *c);
/** Parse model */
2017-02-18 10:43:58 -05:00
int model_parse(struct fpga_ip *c);
2016-06-19 19:23:19 +02:00
/** Destroy a model */
2017-02-18 10:43:58 -05:00
int model_destroy(struct fpga_ip *c);
2016-06-14 01:19:17 +02:00
2016-06-19 19:23:19 +02:00
/** Print detailed information about the model to the screen. */
2017-02-18 10:43:58 -05:00
void model_dump(struct fpga_ip *c);
2016-06-14 01:19:17 +02:00
2016-06-19 19:23:19 +02:00
/** Add a new parameter to the model */
2017-02-18 10:43:58 -05:00
void model_param_add(struct fpga_ip *c, const char *name, enum model_param_direction dir, enum model_param_type type);
2016-06-14 01:19:17 +02:00
2016-06-19 19:23:19 +02:00
/** Remove an existing parameter by its name */
2017-02-18 10:43:58 -05:00
int model_param_remove(struct fpga_ip *c, const char *name);
2016-06-14 01:19:17 +02:00
/** Read a model parameter.
*
* Note: the data type of the register is taken into account.
* All datatypes are converted to double.
*/
int model_param_read(struct model_param *p, double *v);
/** Update a model parameter.
*
* Note: the data type of the register is taken into account.
* The double argument will be converted to the respective data type of the
* GatewayIn/Out block.
*/
int model_param_write(struct model_param *p, double v);
int model_param_update(struct model_param *p, struct model_param *u);
2017-02-18 10:43:58 -05:00
/** @} */