/* ** HDL4SE: 软件Verilog综合仿真平台 ** Copyright (C) 2021-2021, raoxianhong ** LCOM: 轻量级组件对象模型 ** Copyright (C) 2021-2021, raoxianhong ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are met: ** ** * Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright notice, ** this list of conditions and the following disclaimer in the documentation ** and/or other materials provided with the distribution. ** * The name of the author may be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF ** THE POSSIBILITY OF SUCH DAMAGE. */ /* * hdl4secell.h 修改记录: 202105180851: rxh, initial version 202105241101: rxh, 增加探头接口,支持调试器 */ #ifndef __HDL4SECELL_H #define __HDL4SECELL_H #include "pointerarray.h" #ifdef __cplusplus extern "C" { #endif #ifndef _ASMLANGUAGE #include "guid.h" enum port_direct { PORT_INPUT, PORT_OUTPUT, PORT_INOUT }; enum variable_type { VTYPE_PORT, VTYPE_WIRE, VTYPE_REG, VTYPE_TEMP, }; DEFINE_GUID(IID_HDL4SEMODULE, 0x88cf84f9, 0x17ac, 0x4edf, 0xbf, 0x0, 0xc7, 0x32, 0xd5, 0x26, 0x99, 0x2a); struct sHDL4SEModule; struct sHDL4SEModuleVar; typedef struct sHDL4SEModule IHDL4SEModule; typedef struct sHDL4SEModuleVar IHDL4SEModuleVar, * IHDL4SEModuleVarPtr; struct sHDL4SEModule { OBJECT_INTERFACE }; #include "threadlock.h" typedef int (*MODULE_FUNC)(void* pobj, void * variable); typedef struct _sGeneralModule { IHDL4SEModuleVar * parent; char* name; PointerArray parameters; PointerArray variables; PointerArray modules; PointerArray funcs; MODULE_FUNC setup_func; MODULE_FUNC clktick_func; MODULE_FUNC init_func; MODULE_FUNC deinit_func; THREADLOCK lock; void* pobj; void* priv_data; void* func_param; int canruninthread; }sGeneralModule; #define USEBIGINT 0 enum varupdatefunc { VUF_UPDATED, VUF_WAITUPDATE, VUF_UPDATING, }; #ifndef VARBITS #define VARBITS 512 #endif typedef struct sModuleVariable { struct sModuleVariable * pNext, *pLast; int index; int type; int width; int portdirect; int isunsigned; char* name; sGeneralModule *moduledata; IHDL4SEModuleVar* module; int moduleportindex; char* depend_list; PointerArray functions; /* 依赖它的函数 */ PointerArray variables; /* 依赖它的变量 */ PointerArray dependvar; int updatedisset; int genfuncindex; #if USEBIGINT IBigNumber** data; IBigNumber** data_reg; #else union { short int16; unsigned short uint16; int int32; unsigned int uint32; long long int64; unsigned long long uint64; //unsigned long long data; unsigned int data[VARBITS / 32]; unsigned long long data64[VARBITS / 64]; }; union { short int16_reg; unsigned short uint16_reg; int int32_reg; unsigned int uint32_reg; long long int64_reg; unsigned long long uint64_reg; //unsigned long long data_reg; unsigned int data_reg[VARBITS / 32]; unsigned long long data64_reg[VARBITS / 64]; }; #endif THREADLOCK lock; long updatefunc; }ModuleVariable; #define VAR_COPYDATA(dst, src) memcpy(dst, src, VARBITS/8) #define VAR_NEQ(dst, src) memcmp(dst, src, VARBITS/8) typedef struct sModuleFunction { ModuleVariable* var; /* getvalue对应的变量 */ void* pobj; MODULE_FUNC func; MODULE_FUNC cur_func; int callit; PointerArray variables; /* 影响的variables */ }ModuleFunction; #define HDL4SEMODULE_VARDECLARE \ INTERFACE_DECLARE(IHDL4SEModule) \ sGeneralModule data; \ sGeneralModule *pmodule; \ struct sHDL4SEModuleVar { HDL4SEMODULE_VARDECLARE }; #define HDL4SEMODULE_VARINIT(_objptr, _obj) \ do { \ INTERFACE_INIT(IHDL4SEModule, _objptr, _obj, hdl4se_module); \ if (0 != hdl4se_module_Init(&pobj->data, pobj, pParams, paramcount)) \ return -2; \ pobj->pmodule = &pobj->data; \ } while (0) #define HDL4SEMODULE_FUNCIMPL(_obj, _clsid, _localstruct) \ static const IHDL4SEModule _obj##_hdl4se_module_interface = { \ INTERFACE_HEADER(_obj, IHDL4SEModule, _localstruct) \ }; typedef ModuleVariable* var; int vartempInit(); int vartempClean(); ModuleVariable * varTemp(int width, int isunsigned); ModuleVariable * varConstStr(const char *str); ModuleVariable * varConst(int width, unsigned long long v); ModuleVariable * varConstSigned(int width, long long v); ModuleVariable * varConcat(int multicount, ...); ModuleVariable * varAdd(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varSub(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varMul(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varDiv(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varMod(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varPow(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varSHL(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varSHR(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varSAL(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varSAR(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varOr(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varXor(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varAnd(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varGT(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varGE(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varLT(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varLE(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varEQ(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varNE(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varAndL(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varOrL(ModuleVariable * a, ModuleVariable * b); ModuleVariable * varNeg(ModuleVariable * a); ModuleVariable * varNot(ModuleVariable * a); ModuleVariable * varNotL(ModuleVariable * a); ModuleVariable * varUAnd(ModuleVariable * a); ModuleVariable * varUNAnd(ModuleVariable * a); ModuleVariable * varUOr(ModuleVariable * a); ModuleVariable * varUNOr(ModuleVariable * a); ModuleVariable * varUXor(ModuleVariable * a); ModuleVariable * varUNXor(ModuleVariable * a); ModuleVariable * varBit(ModuleVariable * a, unsigned int bit); ModuleVariable * varBits(ModuleVariable * a, unsigned int lsb, unsigned int width); ModuleVariable * varSelect(ModuleVariable * a, ModuleVariable * b, ModuleVariable * c); int varAssign(ModuleVariable * a, ModuleVariable * b); int varCopy(ModuleVariable * a, ModuleVariable * b); int varIsZero(ModuleVariable * a); int varIsNotZero(ModuleVariable * a); int varSetBits32(ModuleVariable* a, unsigned int index, unsigned int v); unsigned int varGetBits32(ModuleVariable* a, unsigned int index); int varAssign_S32(ModuleVariable * a, int v); int varAssign_U32(ModuleVariable * a, unsigned int v); int varAssign_S64(ModuleVariable * a, long long v); int varAssign_U64(ModuleVariable * a, unsigned long long v); int varGet_S32(ModuleVariable * a); unsigned int varGet_U32(ModuleVariable * a); long long varGet_S64(ModuleVariable * a); unsigned long long varGet_U64(ModuleVariable * a); int varGetStr(ModuleVariable* a, int base, char* str, int buflen); ModuleVariable* variableCreate(int type, int width, int portdirect, int isunsigned, const char* name); int variableDestroy(ModuleVariable* var); int hdl4seCheckVariableArray(PointerArray* array); ModuleFunction* functionCreateFunc(MODULE_FUNC func, void * pobj); ModuleFunction* functionCreateGetValue(ModuleVariable * var); int functionDestroy(ModuleFunction* func); #define functionCallAndSetNone(obj) \ do { \ ModuleFunction * func = (ModuleFunction *)obj; \ int callit = LOCKED_SWAP(func->callit, 0); \ if (callit) { \ func->func(func->pobj, func->var); \ } \ } while (0) int hdl4se_split_string(const char* string, char** substr, int substrcount, int gap); unsigned int hdl4seGetParamUint32(const char* param); int hdl4se_set_gen_func(sGeneralModule* pobj, const char* signal_list, MODULE_FUNC func, const char * depend_list); int hdl4se_setgen_func_by_index(sGeneralModule* pobj, int index, MODULE_FUNC func); int hdl4se_set_depend_variables(ModuleVariable * v, const char * depend_list); sGeneralModule* hdl4seModuleGetData(HOBJECT object); int hdl4se_module_Connect(IHDL4SEModuleVar * parentmodule, IHDL4SEModuleVar * unitmodule, const char* connectlist); IHDL4SEModuleVar* hdl4se_module_Create(HOBJECT parent, const char* instanceparam, const char* name, const char* connectlist, int (*module_init)(sGeneralModule*)); /* return 0 to continue traversal, or stop traversal */ typedef int (*hdl4se_module_path_TraversalFunc)(IHDL4SEModuleVar* module, const char* pathname, void* param); int hdl4se_module_path_Traversal(HOBJECT object, hdl4se_module_path_TraversalFunc func, const char* pathname, void* param); IBigNumber** hdl4se_module_GetObj(sGeneralModule* pobj, int ind, int isdst); ModuleVariable * hdl4se_module_Var(sGeneralModule* pobj, int ind); int hdl4se_module_AssignObj(sGeneralModule* pobj, int dstind, IBigNumber** src); int hdl4se_module_AssignStr(sGeneralModule* pobj, int dstind, const char* src); unsigned int hdl4se_module_GetVarUint32(sGeneralModule* pobj, int varindex); int hdl4se_module_GetVarInt32(sGeneralModule* pobj, int varindex); unsigned long long hdl4se_module_GetVarUint64(sGeneralModule* pobj, int varindex); long long hdl4se_module_GetVarInt64(sGeneralModule* pobj, int varindex); void hdl4se_module_SetVarUint32(sGeneralModule* pobj, int varindex, unsigned int v); void hdl4se_module_SetVarInt32(sGeneralModule* pobj, int varindex, int v); void hdl4se_module_SetVarUint64(sGeneralModule* pobj, int varindex, unsigned long long v); int hdl4se_module_Assign(sGeneralModule* pobj, int dstind, int srcind); int hdl4se_module_AssignVar(sGeneralModule* pobj, int dstind, ModuleVariable * v); void hdl4se_module_SetVarInt64(sGeneralModule* pobj, int varindex, long long v); int hdl4se_module_AddVariable(sGeneralModule* pobj, int type, int width, int portdirect, int isunsigned, const char* name); int hdl4se_module_SetVariable(sGeneralModule* pobj, int index, int type, int width, int portdirect, int isunsigned, const char* name); int hdl4se_module_Init(sGeneralModule* pobj, void* obj, const PARAMITEM* pParams, int paramcount); void hdl4se_module_DeInit(sGeneralModule* pobj); int hdl4se_module_Valid(sGeneralModule* pobj); int hdl4se_module_GetName(sGeneralModule* pobj, const char** pname); int hdl4se_module_ConnectInput(sGeneralModule* pobj, int index, HOBJECT from, int fromindex); int hdl4se_module_GetValue(sGeneralModule* pobj, int index, int width, ModuleVariable* value); int hdl4se_module_InitDepend(sGeneralModule * pobj); int hdl4se_module_ClkTick(sGeneralModule* pobj); int hdl4se_module_Setup(sGeneralModule* pobj); int hdl4se_module_AddPort(sGeneralModule* pobj, const char* name, int width, int isunsigned, int portdirect); int hdl4se_module_AddModule(sGeneralModule* pobj, IHDL4SEModuleVar* module); int hdl4se_module_GetModuleCount(sGeneralModule* pobj); int hdl4se_module_GetModule(sGeneralModule* pobj, int index, IHDL4SEModuleVar** module); int hdl4se_module_GetVariableCount(sGeneralModule* pobj); int hdl4se_module_GetVariable(sGeneralModule* pobj, int index, ModuleVariable** portinfo); int hdl4se_module_GetParent(sGeneralModule* pobj, const IHDL4SEModuleVar ** parent); double hdl4seGetParamReal(PointerArray* list, int index); long long hdl4seGetParam(PointerArray* list, int index); const char* hdl4seGetParamStr(PointerArray* list, int index); /* 用CLSID和实例化参数生成一个电路单元,如果生成成功,电路单元而且parent是一个合法的Module, 则单元以name命名加入到parent中 */ IHDL4SEModuleVar* hdl4seCreateModule(HOBJECT parent, IIDTYPE clsid, const char* instanceparam, const char* name); IHDL4SEModuleVar* hdl4seCreateModule2(HOBJECT parent, const char* clsid, const char* instanceparam, const char* name); IHDL4SEModuleVar* hdl4seCreateModule3(HOBJECT parent, const char* clsid, const char* instanceparam, const char* name, const char* connectlist); #define VID(name) M_ID(name##_index) #define IDLIST enum M_ID(id_list) { #define END_IDLIST }; #define MODULE_DATA_TYPE M_ID(sHDL4SE_data) #define MODULE_DATA_STRUCT M_ID(_sHDL4SE_data) #define DEFINE_FUNC(funcname, dependlist) \ static const char * __##funcname##_depend_list = dependlist; \ static int funcname(MODULE_DATA_TYPE* pobj, ModuleVariable * variable) { #define CALL_FUNC(funcname) funcname(pobj, NULL) #define END_DEFINE_FUNC return 0; } #define MODULE_DECLARE(module_name) \ struct MODULE_DATA_STRUCT; \ typedef struct MODULE_DATA_STRUCT MODULE_DATA_TYPE; \ struct MODULE_DATA_STRUCT{ \ OBJECT_HEADER \ HDL4SEMODULE_VARDECLARE \ DLIST_VARDECLARE \ #define END_MODULE_DECLARE(module_name) }; \ \ OBJECT_FUNCDECLARE(module_name, M_ID(_MODULE_CLSID)); \ HDL4SEMODULE_FUNCIMPL(module_name, M_ID(_MODULE_CLSID), MODULE_DATA_TYPE); \ DLIST_FUNCIMPL(module_name, M_ID(_MODULE_CLSID), MODULE_DATA_TYPE); \ \ OBJECT_FUNCIMPL(module_name, MODULE_DATA_TYPE, M_ID(_MODULE_CLSID)); \ \ QUERYINTERFACE_BEGIN(module_name, M_ID(_MODULE_CLSID)) \ QUERYINTERFACE_ITEM(IID_HDL4SEMODULE, IHDL4SEModule, MODULE_DATA_TYPE) \ QUERYINTERFACE_ITEM(IID_DLIST, IDList, MODULE_DATA_TYPE) \ QUERYINTERFACE_END \ \ static const char* M_ID(ModuleInfo)() \ { \ return M_ID(_MODULE_VERSION_STRING); \ } \ \ IHDL4SEModuleVar * module_name##_module_create(HOBJECT parent, const char* instanceparam, const char* name, const char * connectlist) \ { \ IHDL4SEModuleVar * module; \ IHDL4SEModuleVar* parentmodule = NULL; \ A_u_t_o_registor_##module_name(); \ module = hdl4seCreateModule(parent, M_ID(_MODULE_CLSID), instanceparam, name); \ objectQueryInterface(parent, IID_HDL4SEMODULE, (const void**)&parentmodule); \ if (parentmodule == NULL) { \ return module; \ } \ hdl4se_module_Connect(parentmodule, module, connectlist); \ objectRelease(parentmodule); \ return module; \ } #define MODULE_INIT(module_name) \ \ static int M_ID(Create)(const PARAMITEM* pParams, int paramcount, HOBJECT* pObject) \ { \ MODULE_DATA_TYPE* pobj; \ pobj = (MODULE_DATA_TYPE*)mt_malloc(sizeof(MODULE_DATA_TYPE)); \ if (pobj == NULL) \ return -1; \ memset(pobj, 0, sizeof(MODULE_DATA_TYPE)); \ *pObject = 0; \ HDL4SEMODULE_VARINIT(pobj, module_name); \ DLIST_VARINIT(pobj, module_name); \ OBJECT_RETURN_GEN(module_name, pobj, pObject, M_ID(_MODULE_CLSID)); \ #define END_MODULE_INIT(module_name) \ hdl4se_module_InitDepend(pobj->pmodule); \ return EIID_OK; \ } \ \ static void M_ID(Destroy)(HOBJECT object) \ { \ MODULE_DATA_TYPE* pobj; \ pobj = (MODULE_DATA_TYPE*)objectThis(object); \ hdl4se_module_DeInit(pobj->pmodule); \ memset(pobj, 0, sizeof(MODULE_DATA_TYPE)); \ mt_free(pobj); \ } \ \ static int M_ID(Valid)(HOBJECT object) \ { \ return 1; \ } #define GEN_MODULE_DECLARE \ struct MODULE_DATA_STRUCT; \ typedef struct MODULE_DATA_STRUCT MODULE_DATA_TYPE; \ struct MODULE_DATA_STRUCT { \ sGeneralModule* pmodule; \ #define END_GEN_MODULE_DECLARE }; #define GEN_MODULE_INIT \ static int M_ID(_module_init)(sGeneralModule* pdata) {\ MODULE_DATA_TYPE * pobj; \ pobj = (MODULE_DATA_TYPE*)mt_malloc(sizeof(MODULE_DATA_TYPE)); \ if (pobj == NULL) \ return -1; \ pdata->priv_data = pobj; \ pdata->func_param = pobj; \ pobj->pmodule = pdata; \ #define END_GEN_MODULE_INIT \ hdl4se_module_InitDepend(pdata); \ return EIID_OK; \ } \ \ IHDL4SEModuleVar * M_ID(_module_create)(HOBJECT parent, const char* instanceparam, const char* name, const char * connectlist) \ { \ return hdl4se_module_Create(parent, instanceparam, name, connectlist, M_ID(_module_init)); \ } #define MODULE_CREATOR_DECLARE(module_name) IHDL4SEModuleVar * module_name##_module_create(HOBJECT parent, const char* instanceparam, const char* name, const char * connectlist) #define PORT_IN(name, width) hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_PORT, width, PORT_INPUT, 1, #name) #define PORT_OUT(name, width) hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_PORT, width, PORT_OUTPUT, 1, #name) #define GPORT_OUT(name, width, func) \ do { \ ModuleVariable * v; \ hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_PORT, width, PORT_OUTPUT, 1, #name); \ hdl4se_setgen_func_by_index(pobj->pmodule, VID(name), (void*)func); \ hdl4se_module_GetVariable(pobj->pmodule, VID(name), &v); \ hdl4se_set_depend_variables(v, __##func##_depend_list); \ } while (0) #define PORT_IN_SIGNED(name, width) hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_PORT, width, PORT_INPUT, 0, #name) #define PORT_OUT_SIGNED(name, width) hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_PORT, width, PORT_OUTPUT, 0, #name) #define GPORT_OUT_SIGNED(name, width, func) \ do { \ ModuleVariable * v; \ hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_PORT, width, PORT_OUTPUT, 0, #name); \ hdl4se_setgen_func_by_index(pobj->pmodule, VID(name), (void *)func); \ hdl4se_module_GetVariable(pobj->pmodule, VID(name), &v); \ hdl4se_set_depend_variables(v, __##func##_depend_list); \ } while (0) #define PORT_IN_idx(id, width, name) hdl4se_module_SetVariable(pobj->pmodule, id, VTYPE_PORT, width, PORT_INPUT, 1, name) #define PORT_OUT_idx(id, width, name) hdl4se_module_SetVariable(pobj->pmodule, id, VTYPE_PORT, width, PORT_OUTPUT, 1, name) #define GPORT_OUT_idx(id, width, name, func) \ do { \ ModuleVariable * v; \ hdl4se_module_SetVariable(pobj->pmodule, id, VTYPE_PORT, width, PORT_OUTPUT, 1, #name); \ hdl4se_setgen_func_by_index(pobj->pmodule, id, (void *)func); \ hdl4se_module_GetVariable(pobj->pmodule, id, &v); \ hdl4se_set_depend_variables(v, __##func##_depend_list); \ } while (0) #define PORT_IN_SIGNED_idx(id, width, name) hdl4se_module_SetVariable(pobj->pmodule, id, VTYPE_PORT, width, PORT_INPUT, 0, name) #define PORT_OUT_SIGNED_idx(id, width, name) hdl4se_module_SetVariable(pobj->pmodule, id, VTYPE_PORT, width, PORT_OUTPUT, 0, name) #define GPORT_OUT_SIGNED_idx(id, width, name, func) \ do { \ ModuleVariable * v; \ hdl4se_module_SetVariable(pobj->pmodule, id, VTYPE_PORT, width, PORT_OUTPUT, 0, #name); \ hdl4se_setgen_func_by_index(pobj->pmodule, id, (void *)func); \ hdl4se_module_GetVariable(pobj->pmodule, id, &v); \ hdl4se_set_depend_variables(v, __##func##_depend_list); \ } while (0) #define WIRE(name, width) hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_WIRE, width, 0, 1, #name) #define REG(name, width) hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_REG, width, 0, 1, #name) #define WIRE_S(name, width) hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_WIRE, width, 0, 0, #name) #define REG_S(name, width) hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_REG, width, 0, 0, #name) #define GWIRE(name, width, func) \ do { \ ModuleVariable * v; \ hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_WIRE, width, 0, 1, #name); \ hdl4se_setgen_func_by_index(pobj->pmodule, VID(name), (void *)func); \ hdl4se_module_GetVariable(pobj->pmodule, VID(name), &v); \ hdl4se_set_depend_variables(v, __##func##_depend_list); \ } while(0) #define GREG(name, width, func) \ do { \ ModuleVariable * v; \ hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_REG, width, 0, 1, #name); \ hdl4se_setgen_func_by_index(pobj->pmodule, VID(name), (void *)func); \ hdl4se_module_GetVariable(pobj->pmodule, VID(name), &v); \ hdl4se_set_depend_variables(v, __##func##_depend_list); \ } while(0) #define GWIRE_S(name, width, func) \ do { \ ModuleVariable * v; \ hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_WIRE, width, 0, 0, #name); \ hdl4se_setgen_func_by_index(pobj->pmodule, VID(name), (void *)func); \ hdl4se_module_GetVariable(pobj->pmodule, VID(name), &v); \ hdl4se_set_depend_variables(v, __##func##_depend_list); \ } while(0) #define GREG_S(name, width, func) \ do { \ ModuleVariable * v; \ hdl4se_module_SetVariable(pobj->pmodule, VID(name), VTYPE_REG, width, 0, 0, #name); \ hdl4se_setgen_func_by_index(pobj->pmodule, VID(name), (void *)func); \ hdl4se_module_GetVariable(pobj->pmodule, VID(name), &v); \ hdl4se_set_depend_variables(v, __##func##_depend_list); \ } while(0) #define GEN_FUNC(signal_list, func) \ do { \ hdl4se_set_gen_func(pobj->pmodule, signal_list, (void*)func, __##func##_depend_list); \ } while (0) #define SETUP_FUNC(func) pobj->pmodule->setup_func = func #define CLKTICK_FUNC(func) \ do { \ pobj->pmodule->clktick_func = func; \ }while (0) #define DEINIT_FUNC(func) pobj->pmodule->deinit_func = func #define INIT_FUNC(func) pobj->pmodule->init_func = func #define MODULE_INST(module_name, inst_name, instanceparam, connectlist) module_name##_module_create(pobj->pmodule->pobj, instanceparam, inst_name, connectlist) #define CELL_INST(clsid, inst_name, instanceparam, connectlist) hdl4seCreateModule3(pobj->pmodule->pobj, clsid, instanceparam, inst_name, connectlist) #define TOP_MODULE(module_name) module_name##_module_create(NULL, "", #module_name, "") #define VREAD_U32(v) hdl4se_module_GetVarUint32(pobj->pmodule, VID(v)) #define VWRITE_U32(v, value) hdl4se_module_SetVarUint32(pobj->pmodule, VID(v), value) #define VREAD_S32(v) hdl4se_module_GetVarInt32(pobj->pmodule, VID(v)) #define VWRITE_S32(v, value) hdl4se_module_SetVarInt32(pobj->pmodule, VID(v), value) #define VREAD_U64(v) hdl4se_module_GetVarUint64(pobj->pmodule, VID(v)) #define VWRITE_U64(v, value) hdl4se_module_SetVarUint64(pobj->pmodule, VID(v), value) #define VREAD_S64(v) hdl4se_module_GetVarInt64(pobj->pmodule, VID(v)) #define VWRITE_S64(v, value) hdl4se_module_SetVarInt64(pobj->pmodule, VID(v), value) #define vget(v) hdl4se_module_GetVarUint32(pobj->pmodule, VID(v)) #define vput(v, value) hdl4se_module_SetVarUint32(pobj->pmodule, VID(v), value) #define vget_idx(v) hdl4se_module_GetVarUint32(pobj->pmodule, v) #define vput_idx(v, value) hdl4se_module_SetVarUint32(pobj->pmodule, v, value) #define vgets(v) hdl4se_module_GetVarInt32(pobj->pmodule, VID(v)) #define vputs(v, value) hdl4se_module_SetVarInt32(pobj->pmodule, VID(v), value) #define vget64(v) hdl4se_module_GetVarUint64(pobj->pmodule, VID(v)) #define vput64(v, value) hdl4se_module_SetVarUint64(pobj->pmodule, VID(v), value) #define vget64s(v) hdl4se_module_GetVarInt64(pobj->pmodule, VID(v)) #define vput64s(v, value) hdl4se_module_SetVarInt64(pobj->pmodule, VID(v), value) /* #define VAssignNumberByName(vdst, obj) hdl4se_module_AssignObj(pobj->pmodule, VID(vdst), obj) #define VAssignNumberByIdx(id, obj) hdl4se_module_AssignObj(pobj->pmodule, id, obj) */ #define VAssignStr(vdst, str) hdl4se_module_AssignStr(pobj->pmodule, VID(vdst), str) #define VAssignStr_idx(id, srt) hdl4se_module_AssignStr(pobj->pmodule, id, str) #define VAssign(vdst, vsrc) hdl4se_module_Assign(pobj->pmodule, VID(vdst), VID(vsrc)) #define VAssign_idx(vdst, vsrc) hdl4se_module_Assign(pobj->pmodule, vdst, vsrc) #define VAssignVar(vdst, vsrc) hdl4se_module_AssignVar(pobj->pmodule, VID(vdst), vsrc) #define VAssignVar_idx(vdst, vsrc) hdl4se_module_AssignVar(pobj->pmodule, vdst, vsrc) #define Var(vname) hdl4se_module_Var(pobj->pmodule, VID(vname)) #define Var_idx(idx) hdl4se_module_Var(pobj->pmodule, idx) #define MODULE_PARAM(index) hdl4seGetParam(&pobj->pmodule->parameters, index) #define MODULE_PARAM_REAL(index) hdl4seGetParamReal(&pobj->pmodule->parameters, index) #define MODULE_PARAM_STR(index) hdl4seGetParamStr(&pobj->pmodule->parameters, index) DEFINE_GUID(PARAMID_HDL4SE_UNIT_INSTANCE_PARAMETERS, 0xad12c414, 0x631b, 0x42cb, 0xb9, 0xbb, 0xba, 0xbd, 0x78, 0x21, 0x3f, 0xef); DEFINE_GUID(PARAMID_HDL4SE_UNIT_NAME, 0x13c48518, 0x82e6, 0x4f71, 0xb7, 0x5b, 0x24, 0x47, 0xf9, 0xee, 0x4f, 0x6d); DEFINE_GUID(PARAMID_HDL4SE_UNIT_PARENT, 0x71dd0555, 0x1133, 0x4b69, 0xab, 0x6a, 0x33, 0x2b, 0xb5, 0x57, 0x75, 0x2b); DEFINE_GUID(CLSID_HDL4SE_RAM1P, 0xdffb1080, 0x8b92, 0x4b42, 0xa6, 0x7, 0xd1, 0xb3, 0x77, 0xc2, 0x7b, 0xb1); DEFINE_GUID(CLSID_HDL4SE_RAM2P, 0xd26dddb3, 0xfdf, 0x48c6, 0xb4, 0xf3, 0x40, 0x42, 0xef, 0xf8, 0xca, 0x79); DEFINE_GUID(CLSID_HDL4SE_MUX2, 0x9B0B3D25, 0x346D, 0x48B9, 0xAB, 0xB9, 0xED, 0x75, 0x59, 0x10, 0x42, 0x5D); DEFINE_GUID(CLSID_HDL4SE_MUX4, 0x041F3AA1, 0x97CD, 0x4412, 0x9E, 0x8E, 0xD0, 0x4A, 0xDF, 0x29, 0x1A, 0xE2); DEFINE_GUID(CLSID_HDL4SE_MUX8, 0xDD99B7F6, 0x9ED1, 0x45BB, 0x81, 0x50, 0xED, 0x78, 0xEE, 0xF9, 0x82, 0xCA); DEFINE_GUID(CLSID_HDL4SE_MUX16, 0x69B4A095, 0x0644, 0x4B9E, 0x9C, 0xF0, 0x29, 0x54, 0x74, 0xD7, 0xC2, 0x43); DEFINE_GUID(CLSID_HDL4SE_REG, 0x76FBFD4B, 0xFEAD, 0x45fd, 0xAA, 0x27, 0xAF, 0xC5, 0x8A, 0xC2, 0x41, 0xC2); DEFINE_GUID(CLSID_HDL4SE_FIFO, 0x230946ef, 0x3ec1, 0x43ec, 0xa8, 0x41, 0xcd, 0xe8, 0xa9, 0xe9, 0x73, 0x14); DEFINE_GUID(CLSID_HDL4SE_MODULE, 0x167d115e, 0x0c1e, 0x484e, 0x8b, 0xf3, 0xa7, 0x38, 0x5b, 0x3d, 0x3a, 0x57); #endif /* _ASMLANGUAGE */ #ifdef __cplusplus } #endif #endif /* __HDL4SECELL_H */