提交 4780766c 编写于 作者: 饶先宏's avatar 饶先宏

202107201750 引入C++?

上级 f4c1ad86
......@@ -271,6 +271,9 @@ DEFINE_FUNC(digitled_clktick) {
pobj->keypressed = keypressed;
if (reset == 0) {
pobj->keypressed = 0;
for (i = 0; i < LEDCOUNT; i++) {
pobj->ledvalue[i] = 0;
}
}
/* 读写命令,看是否写 */
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -26,7 +26,7 @@ add_library (hdl4secell STATIC
"src/hdl4se_split1.c"
"src/hdl4se_bindN.c"
"src/hdl4se_general.c"
)
"include/hdl4sevariable.h")
FIND_PACKAGE( OpenMP REQUIRED)
if(OPENMP_FOUND)
message("OPENMP FOUND")
......
/*
** HDL4SE: 软件Verilog综合仿真平台
** Copyright (C) 2021-2021, raoxianhong<raoxianhong@163.net>
** LCOM: 轻量级组件对象模型
** Copyright (C) 2021-2021, raoxianhong<raoxianhong@163.net>
** 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.
*/
/*
* hdl4se_vairble.h
修改记录:
202107201718: rxh, initial version
*/
#ifndef __HDL4SE_VARIABLE_H
#define __HDL4SE_VARIABLE_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ASMLANGUAGE
class ModuleVariable {
public:
int index;
int type;
int width;
int portdirect;
int isunsigned;
char* name;
IHDL4SEModuleVar* module;
int moduleportindex;
MODULE_FUNC genfunc;
IBigNumber** data;
IBigNumber** data_reg;
void (*func_UpdateVariable)(struct sModuleVariable* var, void* pobj);
ModuleVariable operator + (const ModuleVariable& v);
ModuleVariable operator += (const ModuleVariable& v);
ModuleVariable operator [](int sel);
ModuleVariable operator [](int msb, int lsb);
};
#endif /* _ASMLANGUAGE */
#ifdef __cplusplus
}
#endif
#endif /* __HDL4SE_VARIABLE_H */
\ No newline at end of file
......@@ -106,8 +106,6 @@ typedef struct sModuleVariable {
MODULE_FUNC genfunc;
IBigNumber** data;
IBigNumber** data_reg;
unsigned long long data64;
unsigned long long data64_reg;
void (*func_UpdateVariable)(struct sModuleVariable* var, void* pobj);
}ModuleVariable;
......
......@@ -113,7 +113,7 @@ int hdl4se_module_Assign(sGeneralModule* pobj, int dstind, int srcind)
objectCall1(vardst->data_reg, Assign, varsrc->data);
else
objectCall1(vardst->data, Assign, varsrc->data);
vardst->func_UpdateVariable = hdl4seUpdateVariableNone;
//vardst->func_UpdateVariable = hdl4seUpdateVariableNone;
return 0;
}
......@@ -146,7 +146,7 @@ int hdl4se_module_AssignObj(sGeneralModule* pobj, int dstind, IBigNumber ** src)
objectCall1(vardst->data_reg, Assign, src);
else
objectCall1(vardst->data, Assign, src);
vardst->func_UpdateVariable = hdl4seUpdateVariableNone;
//vardst->func_UpdateVariable = hdl4seUpdateVariableNone;
return 0;
}
......@@ -160,7 +160,7 @@ int hdl4se_module_AssignStr(sGeneralModule* pobj, int dstind, const char* src)
objectCall3(vardst->data_reg, AssignStr, src, NULL, 0);
else
objectCall3(vardst->data, AssignStr, src, NULL, 0);
vardst->func_UpdateVariable = hdl4seUpdateVariableNone;
//vardst->func_UpdateVariable = hdl4seUpdateVariableNone;
return 0;
}
......@@ -207,7 +207,7 @@ void hdl4se_module_SetVarUint32(sGeneralModule* pobj, int varindex, unsigned int
else
objectCall1(var->data, AssignUint32, v);
//var->datavalid = 1;
var->func_UpdateVariable = hdl4seUpdateVariableNone;
//var->func_UpdateVariable = hdl4seUpdateVariableNone;
#if HDL4SE_DEBUG
printf("%s(%s), %s, %d\n", __FUNCTION__, pobj->name, var->name, v);
#endif
......@@ -221,7 +221,7 @@ void hdl4se_module_SetVarInt32(sGeneralModule* pobj, int varindex, int v)
else
objectCall1(var->data, AssignInt32, v);
//var->datavalid = 1;
var->func_UpdateVariable = hdl4seUpdateVariableNone;
//var->func_UpdateVariable = hdl4seUpdateVariableNone;
}
void hdl4se_module_SetVarUint64(sGeneralModule* pobj, int varindex, unsigned long long v)
......@@ -232,7 +232,7 @@ void hdl4se_module_SetVarUint64(sGeneralModule* pobj, int varindex, unsigned lon
else
objectCall1(var->data, AssignUint64, v);
//var->datavalid = 1;
var->func_UpdateVariable = hdl4seUpdateVariableNone;
//var->func_UpdateVariable = hdl4seUpdateVariableNone;
}
void hdl4se_module_SetVarInt64(sGeneralModule* pobj, int varindex, long long v)
......@@ -243,7 +243,7 @@ void hdl4se_module_SetVarInt64(sGeneralModule* pobj, int varindex, long long v)
else
objectCall1(var->data, AssignInt64, v);
//var->datavalid = 1;
var->func_UpdateVariable = hdl4seUpdateVariableNone;
//var->func_UpdateVariable = hdl4seUpdateVariableNone;
}
int hdl4se_module_AddVariable(sGeneralModule* pobj, int type, int width, int portdirect, int isunsigned, const char* name)
......@@ -457,8 +457,6 @@ int hdl4se_module_Setup(sGeneralModule * pobj)
continue;
if (var->type == VTYPE_REG) {
objectCall1(var->data, Clone, var->data_reg);
}
if (var->type == VTYPE_REG) {
var->func_UpdateVariable = hdl4seUpdateVariableNone;
}
else if (var->genfunc != NULL) {
......
......@@ -136,6 +136,11 @@ static void exprDestroy(HOBJECT object)
objectRelease(pobj->data.range_msb);
objectRelease(pobj->data.range_lsb);
break;
case EXPRTYPE_CONCAT:
objectRelease(pobj->data.multicount);
dlistRemoveAll(pobj->data.expr_list);
objectRelease(pobj->data.expr_list);
break;
}
memset(pobj, 0, sizeof(sExpr));
free(pobj);
......@@ -1719,7 +1724,7 @@ const char * verilogparseGenExprStr(HOBJECT expr, HOBJECT module)
pobj = (sExpr*)objectThis(expr);
if (pobj == NULL)
return 0;
expr_verilognode_procheck(expr, module, NULL);
width = verilogparseGenExprWidth(expr, module);
switch (pobj->data.exprtype) {
case EXPRTYPE_NUMBER:
......@@ -1842,19 +1847,58 @@ const char * verilogparseGenExprStr(HOBJECT expr, HOBJECT module)
else if (select->range_type == RANGE_TYPE_BITSELECT) {
char * msb = strdup(verilogparseGenExprStr(select->range_msb, module));
if (index >= 0) {
sprintf(hdl4se_parse_logbuf(), "pobj->%s >> (%s)", select->name->string, msb);
sprintf(hdl4se_parse_logbuf(), "(pobj->%s >> (%s)) & 1", select->name->string, msb);
} else {
if (width <= 32)
sprintf(hdl4se_parse_logbuf(), "GEN_VREAD_S32(%s) >> (%s)", select->name->string, msb);
sprintf(hdl4se_parse_logbuf(), "(GEN_VREAD_U32(%s) >> (%s)) & 1", select->name->string, msb);
else
sprintf(hdl4se_parse_logbuf(), "GEN_VREAD_U64(%s) >> (%s)", select->name->string, msb);
sprintf(hdl4se_parse_logbuf(), "(GEN_VREAD_U64(%s) >> (%s)) & 1", select->name->string, msb);
}
free(msb);
return hdl4se_parse_logbuf();
}
else if (select->range_type == RANGE_TYPE_PARTSELECT) {
verilogExpr* msbinfo;
verilogExpr* lsbinfo;
int v_msb, v_lsb;
expr_verilognode_procheck(select->range_msb, module, NULL);
expr_verilognode_procheck(select->range_lsb, module, NULL);
msbinfo = verilogExprGetData(select->range_msb);
lsbinfo = verilogExprGetData(select->range_lsb);
if (msbinfo->exprtype == EXPRTYPE_BIGNUMBER && lsbinfo->exprtype == EXPRTYPE_BIGNUMBER) {
objectCall1(msbinfo->bignumber, GetInt32, &v_msb);
objectCall1(lsbinfo->bignumber, GetInt32, &v_lsb);
if (index >= 0) {
sprintf(hdl4se_parse_logbuf(), "(pobj->%s >> %d) & 0x%x", select->name->string, v_lsb, (0xffffffff >> (32 - (v_msb - v_lsb + 1))));
}
else {
if (width <= 32)
sprintf(hdl4se_parse_logbuf(), "(GEN_VREAD_U32(%s) >> %d) & 0x%x", select->name->string, v_lsb, (0xffffffff >> (32 - (v_msb - v_lsb + 1))));
else
sprintf(hdl4se_parse_logbuf(), "(GEN_VREAD_U64(%s) >> %d) & 0x%xllu", select->name->string, v_lsb, (0xffffffffffffffffllu >> (64 - (v_msb - v_lsb + 1))));
}
}
else {
char* msb = strdup(verilogparseGenExprStr(select->range_msb, module));
char* lsb = strdup(verilogparseGenExprStr(select->range_lsb, module));
if (index >= 0) {
sprintf(hdl4se_parse_logbuf(), "(pobj->%s >> (%s)) & (0xffffffff >> (32 - ((%s)-(%s) + 1))) ", select->name->string, lsb, msb, lsb);
}
else {
if (width <= 32)
sprintf(hdl4se_parse_logbuf(), "(GEN_VREAD_U32(%s) >> (%s)) & (0xffffffff >> (32 - ((%s)-(%s) + 1))) ", select->name->string, lsb, msb, lsb);
else
sprintf(hdl4se_parse_logbuf(), "(GEN_VREAD_U64(%s) >> (%s)) & (0xffffffffffffffffllu >> (64 - ((%s)-(%s) + 1))) ", select->name->string, lsb, msb, lsb);
}
free(msb);
free(lsb);
}
return hdl4se_parse_logbuf();
}
break;
}
case EXPRTYPE_CONCAT: {
}
default:
{
......@@ -1868,6 +1912,7 @@ const char * verilogparseGenExprStr(HOBJECT expr, HOBJECT module)
const char* verilogparseGenExprWidthStr(HOBJECT expr, HOBJECT module)
{
int width;
expr_verilognode_procheck(expr, module, NULL);
width = verilogparseGenExprWidth(expr, module);
if (width > 0) {
sprintf(hdl4se_parse_logbuf(), "%d", width);
......@@ -1960,6 +2005,10 @@ const char* verilogparseGenExprWidthStr(HOBJECT expr, HOBJECT module)
}
break;
}
case EXPRTYPE_CONCAT:
{
#error fixed me
}
default:
{
return "ERROR";
......@@ -2019,6 +2068,7 @@ int verilogparseGenExprWidth(HOBJECT expr, HOBJECT module)
pobj = (sExpr*)objectThis(expr);
if (pobj == NULL)
return -1;
expr_verilognode_procheck(expr, module, NULL);
switch (pobj->data.exprtype) {
case EXPRTYPE_NUMBER:
{
......@@ -2098,7 +2148,13 @@ int verilogparseGenExprWidth(HOBJECT expr, HOBJECT module)
return 32;
return verilogparseGetRangeWidth(varinfo->range_type, varinfo->range_msb, varinfo->range_lsb, module);
}
break;
}
case EXPRTYPE_CONCAT :
{
#error Fixed me
}
break;
default:
{
return -1;
......
......@@ -19,8 +19,8 @@ extern char* yytext;
static char logbuf[64 * 1024];
#define GOOGLENET 0
#define TERRIS 0
#define COUNTER 1
#define TERRIS 1
#define COUNTER 0
#ifdef WIN32
#define WORKDIR "d:/gitwork"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册