/* ** 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. */ /* * verilog_parsetree.h 修改记录: 202105280612: rxh, initial version */ #ifndef __VERILOG_PARSETREE_H #define __VERILOG_PARSETREE_H #ifdef __cplusplus extern "C" { #endif #ifndef _ASMLANGUAGE #include "guid.h" DEFINE_GUID(IID_VERILOG_ROOT, 0xa1fbe4b5, 0xbfb6, 0x41e2, 0xb2, 0xf, 0x5c, 0x14, 0xd1, 0xdf, 0x7c, 0x20); DEFINE_GUID(IID_VERILOG_NODE, 0x88ec245f, 0xff4c, 0x4d5a, 0xb3, 0xe, 0x59, 0x70, 0x85, 0x42, 0x14, 0x20); typedef struct sIVerilogNode { OBJECT_INTERFACE int (*dump)(HOBJECT object, FILE * pFile, int opt); int (*procheck)(HOBJECT object, HOBJECT module, void * param); int (*gencode)(HOBJECT object, FILE* pFile, HOBJECT module, void* param); }IVerilogNode; #define VERILOGNODE_VARDECLARE #define VERILOGNODE_VARINIT(_objptr, _clsid) #define VERILOGNODE_FUNCDECLARE(_obj, _clsid, _localstruct) \ static int _obj##_verilognode_dump(HOBJECT object, FILE * pFile, int opt); \ static int _obj##_verilognode_procheck(HOBJECT object, HOBJECT module, void * param); \ static int _obj##_verilognode_gencode(HOBJECT object, FILE * pFile, HOBJECT module, void * param); \ static const IVerilogNode _obj##_verilognode_interface = { \ INTERFACE_HEADER(_obj, IVerilogNode, _localstruct) \ _obj##_verilognode_dump, \ _obj##_verilognode_procheck, \ _obj##_verilognode_gencode, \ }; int verilog_dump_node_list(IDListVarPtr list, FILE* pFile, int opt, const char * gap, int itemperline); int verilog_dump_mapstr2ptr_list(IDListVarPtr list, FILE* pFile, int opt, const char * gap, int itemperline); int verilog_procheck_node_list(IDListVarPtr list, HOBJECT module, void * param); int verilog_gencode_node_list(IDListVarPtr list, FILE* pFile, HOBJECT module, void* param); typedef struct sIVerilogRoot { OBJECT_INTERFACE int (*add_module)(HOBJECT object, IConstStringVar* name, HOBJECT module); int (*find_module)(HOBJECT object, const char *name, HOBJECT *module); int (*gencode)(HOBJECT object, FILE * pFile, const char * topmodulename, void * param); }IVerilogRoot; #define VERILOGROOT_VARDECLARE #define VERILOGROOT_VARINIT(_objptr, _clsid) #define VERILOGROOT_FUNCDECLARE(_obj, _clsid, _localstruct) \ static int _obj##_verilogroot_add_module(HOBJECT object, IConstStringVar *name, HOBJECT module); \ static int _obj##_verilogroot_find_module(HOBJECT object, const char *name, HOBJECT *module); \ static int _obj##_verilogroot_gencode(HOBJECT object, FILE* pFile, const char* topmodulename, void* param); \ static const IVerilogRoot _obj##_verilogroot_interface = { \ INTERFACE_HEADER(_obj, IVerilogRoot, _localstruct) \ _obj##_verilogroot_add_module, \ _obj##_verilogroot_find_module, \ _obj##_verilogroot_gencode, \ }; int hdl4se_parser_SetPreProcess(HOBJECT object); int hdl4se_parser_AddLog(const char * log); int hdl4se_parser_GetCurrentFile(IConstStringVar** pfilename, int* lineno, int* linepos, int* filepos); char* hdl4se_parse_logbuf(); enum VAR_TYPE { VAR_TYPE_NONE, VAR_TYPE_SUPPLY0, VAR_TYPE_SUPPLY1, VAR_TYPE_TRI, VAR_TYPE_TRIAND, VAR_TYPE_TRIOR, VAR_TYPE_TRI0, VAR_TYPE_TRI1, VAR_TYPE_UWIRE, VAR_TYPE_WIRE, VAR_TYPE_WAND, VAR_TYPE_WOR, VAR_TYPE_INTEGER, VAR_TYPE_TIME, VAR_TYPE_REG, }; enum VECT_OR_SCALAR { VS_NONE, VS_VECTORED, VS_SCALARED, }; enum exprtype { EXPRTYPE_NUMBER, EXPRTYPE_BIGNUMBER, EXPRTYPE_PARAM, EXPRTYPE_LOCALPARAM, EXPRTYPE_STRING, EXPRTYPE_UNOP, EXPRTYPE_BINOP, EXPRTYPE_IFOP, EXPRTYPE_IDENT, EXPRTYPE_HIERARCHICAL_IDENT, EXPRTYPE_EMIT, }; enum RANGE_TYPE { RANGE_TYPE_NONE, RANGE_TYPE_BITSELECT, RANGE_TYPE_PARTSELECT, RANGE_TYPE_STARTPLUSWIDTH, RANGE_TYPE_STARTMINUSWIDTH, }; enum PORT_DIRECT { PORT_DIRECT_INPUT, PORT_DIRECT_INOUT, PORT_DIRECT_OUTPUT, PORT_DIRECT_UNKNOW, PORT_DIRECT_ASPRE, }; enum PARAM_TYPE { PARAM_TYPE_PARAM, PARAM_TYPE_LOCAL, PARAM_TYPE_SPEC, PARAM_TYPE_ASPRE, }; enum PARAM_DATA_TYPE { PARAM_DATA_TYPE_INTEGER, PARAM_DATA_TYPE_TIME, PARAM_DATA_TYPE_REAL, PARAM_DATA_TYPE_REALTIME, }; enum OPERATOR { OP_L_NOT, OP_B_NOT, OP_B_AND, OP_B_NAND, OP_B_OR, OP_B_NOR, OP_B_XOR, OP_B_EQU, OP_PLUS, OP_MINUS, OP_MUL, OP_DIV, OP_MOD, OP_POW, OP_L_EQ, OP_L_NEQ, OP_C_EQ, OP_C_NEQ, OP_L_AND, OP_L_OR, OP_LT, OP_LTE, OP_GT, OP_GTE, OP_LSR, OP_LSL, OP_ASR, OP_ASL, }; typedef struct _expr_code { int exprtype; union { int op; int index; const char* value; const char* name; }; }expr_code; int const_expr_eval(int expr_infosize, expr_code *expr_info, int paramcount, IBigNumber***parameters); const char * const_expr_list_eval(int expr_infosize, expr_code* expr_info, int paramcount, IBigNumber*** parameters); const char* const_expr_eval_const_param(int expr_infosize, expr_code* expr_info, int paramcount, IBigNumber*** parameters); #endif #ifdef __cplusplus } #endif #endif