Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
饶先宏
hdl4se
提交
15e40781
H
hdl4se
项目概览
饶先宏
/
hdl4se
通知
12
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hdl4se
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
15e40781
编写于
8月 11, 2021
作者:
饶先宏
浏览文件
操作
浏览文件
下载
差异文件
202108111906
上级
859b16f1
3f1c2ff3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
138 addition
and
25 deletion
+138
-25
hdl4secell/include/hdl4secell.h
hdl4secell/include/hdl4secell.h
+17
-1
hdl4secell/src/hdl4se_function.c
hdl4secell/src/hdl4se_function.c
+3
-0
hdl4secell/src/hdl4se_module.c
hdl4secell/src/hdl4se_module.c
+22
-19
hdl4secell/src/hdl4se_variable.c
hdl4secell/src/hdl4se_variable.c
+1
-1
hdl4sesim/src/hdl4sesim.c
hdl4sesim/src/hdl4sesim.c
+83
-1
hdl4seutils/include/threadlock.h
hdl4seutils/include/threadlock.h
+12
-3
未找到文件。
hdl4secell/include/hdl4secell.h
浏览文件 @
15e40781
...
...
@@ -99,6 +99,12 @@ typedef struct _sGeneralModule {
#define USEBIGINT 0
enum
varupdatefunc
{
VUF_UPDATED
,
VUF_WAITUPDATE
,
VUF_UPDATING
,
};
typedef
struct
sModuleVariable
{
struct
sModuleVariable
*
pNext
,
*
pLast
;
int
index
;
...
...
@@ -145,6 +151,7 @@ typedef struct sModuleFunction {
void
*
pobj
;
MODULE_FUNC
func
;
MODULE_FUNC
cur_func
;
int
callit
;
PointerArray
variables
;
/* 影响的variables */
}
ModuleFunction
;
...
...
@@ -239,7 +246,16 @@ int hdl4seCheckVariableArray(PointerArray* array);
ModuleFunction
*
functionCreateFunc
(
MODULE_FUNC
func
,
void
*
pobj
);
ModuleFunction
*
functionCreateGetValue
(
ModuleVariable
*
var
);
int
functionDestroy
(
ModuleFunction
*
func
);
int
functionCallAndSetNone
(
ModuleFunction
*
func
);
//int functionCallAndSetNone(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
);
...
...
hdl4secell/src/hdl4se_function.c
浏览文件 @
15e40781
...
...
@@ -59,6 +59,7 @@ ModuleFunction* functionCreateFunc(MODULE_FUNC func, void* pobj)
function
->
func
=
function
->
cur_func
=
func
;
function
->
pobj
=
pobj
;
function
->
var
=
NULL
;
function
->
callit
=
1
;
pointerarrayInit
(
&
function
->
variables
);
return
function
;
}
...
...
@@ -77,12 +78,14 @@ static int gen_none(void* p, void* v)
return
0
;
}
/*
int functionCallAndSetNone(ModuleFunction* func)
{
MODULE_FUNC genfunc;
genfunc = LOCKED_SWAP_POINTER(func->cur_func, gen_none);
return genfunc(func->pobj, func->var);
}
*/
int
functionDestroy
(
ModuleFunction
*
func
)
{
...
...
hdl4secell/src/hdl4se_module.c
浏览文件 @
15e40781
...
...
@@ -71,18 +71,14 @@ inline static void hdl4seUpdateVariableNone(ModuleVariable* var)
inline
static
void
hdl4seUpdateVariableGenFunc
(
ModuleVariable
*
var
)
{
//var->func_UpdateVariable = hdl4seUpdateVariableNone;
var
->
updatefunc
=
0
;
functionCallAndSetNone
(
var
->
moduledata
->
funcs
.
array
[
var
->
genfuncindex
]);
var
->
updatefunc
=
0
;
}
inline
static
void
hdl4seUpdateVariableGetValue
(
ModuleVariable
*
var
)
{
int
updatefunc
=
var
->
updatefunc
;
// var->func_UpdateVariable = hdl4seUpdateVariableNone;
//functionCallAndSetNone(var->moduledata->funcs.array[var->genfuncindex]);
hdl4se_module_GetValue
(
&
var
->
module
->
data
,
var
->
moduleportindex
,
var
->
width
,
var
);
var
->
updatefunc
=
0
;
hdl4se_module_GetValue
(
&
var
->
module
->
data
,
var
->
moduleportindex
,
var
->
width
,
var
);
// (var->type == VTYPE_REG) ? var->data_reg : var->data);
}
...
...
@@ -110,16 +106,22 @@ do { \
#define UpdateVariable(v) \
do { \
if (v->type != VTYPE_REG) { \
threadlockLock(v->lock); \
if (v->updatefunc != 0) { \
if (v->updatefunc == 1) { \
hdl4seUpdateVariableGenFunc(v); \
} \
else { \
hdl4seUpdateVariableGetValue(v); \
int updatefunc; \
updatefunc = LOCKED_COMP_SWAP(v->updatefunc, VUF_UPDATING, VUF_WAITUPDATE); \
if (updatefunc != VUF_UPDATED) { \
threadlockLock(v->lock); \
if (updatefunc == VUF_WAITUPDATE) { \
if (v->genfuncindex >= 0) { \
functionCallAndSetNone(v->moduledata->funcs.array[v->genfuncindex]); \
LOCKED_SWAP(v->updatefunc, VUF_UPDATED); \
} \
else if (v->module != NULL) { \
hdl4se_module_GetValue(&v->module->data, v->moduleportindex, v->width, v); \
LOCKED_SWAP(v->updatefunc, VUF_UPDATED); \
} \
} \
threadlockUnlock(v->lock); \
} \
threadlockUnlock(v->lock); \
} \
} while (0)
#endif
...
...
@@ -662,26 +664,27 @@ int hdl4se_module_Setup(sGeneralModule* pobj)
var
->
data
=
var
->
data_reg
;
#endif
//var->func_UpdateVariable = hdl4seUpdateVariableNone;
var
->
updatefunc
=
0
;
var
->
updatefunc
=
VUF_UPDATED
;
}
else
if
(
var
->
genfuncindex
>=
0
)
{
//var->func_UpdateVariable = hdl4seUpdateVariableGenFunc;
var
->
updatefunc
=
1
;
var
->
updatefunc
=
VUF_WAITUPDATE
;
}
else
if
(
var
->
module
!=
NULL
)
{
//var->func_UpdateVariable = hdl4seUpdateVariableGetValue;
var
->
updatefunc
=
2
;
var
->
updatefunc
=
VUF_WAITUPDATE
;
}
else
{
//var->func_UpdateVariable = hdl4seUpdateVariableNone;
var
->
updatefunc
=
0
;
var
->
updatefunc
=
VUF_UPDATED
;
}
}
for
(
i
=
0
;
i
<
pobj
->
funcs
.
itemcount
;
i
++
)
{
ModuleFunction
*
function
=
(
ModuleFunction
*
)
pobj
->
funcs
.
array
[
i
];
function
->
cur_func
=
function
->
func
;
//function->cur_func = function->func;
function
->
callit
=
1
;
}
return
0
;
...
...
hdl4secell/src/hdl4se_variable.c
浏览文件 @
15e40781
...
...
@@ -79,7 +79,7 @@ ModuleVariable* variableCreate(int type, int width, int portdirect, int isunsign
var
->
data_reg
=
bigintegerCreate2
(
width
,
isunsigned
);
}
#endif
var
->
updatefunc
=
0
;
var
->
updatefunc
=
VUF_WAITUPDATE
;
var
->
lock
=
threadlockCreate
();
return
var
;
}
...
...
hdl4sesim/src/hdl4sesim.c
浏览文件 @
15e40781
...
...
@@ -231,7 +231,7 @@ static int hdl4sesim_hdl4se_simulator_SetReset(HOBJECT object, int reset)
return
0
;
}
#define THREADCOUNT
9
#define THREADCOUNT
3
static
int
hdl4sesim_hdl4se_simulator_ClkTick
(
HOBJECT
object
)
{
...
...
@@ -297,6 +297,24 @@ softmax_168 complete
0.0356 n04505470 typewriter keyboard
clocks: 1884160, TSPD=1359.422799cps, LSPD=1170.285714cps
clocks: 1802240, TSPD=4681.142857cps, LSPD=4096.000000cps
softmax_168 complete
0.4901 n03085013 computer keyboard, keypad
0.1591 n04264628 space bar
0.0543 n04074963 remote control, remote
0.0438 n03832673 notebook, notebook computer
0.0356 n04505470 typewriter keyboard
clocks: 1818624, TSPD=4687.175258cps, LSPD=5461.333333cps
clocks: 1802240, TSPD=3935.021834cps, LSPD=4096.000000cps
softmax_168 complete
0.4901 n03085013 computer keyboard, keypad
0.1591 n04264628 space bar
0.0543 n04074963 remote control, remote
0.0439 n03832673 notebook, notebook computer
0.0356 n04505470 typewriter keyboard
clocks: 1818624, TSPD=3944.954447cps, LSPD=5461.333333cps
threadcount=3
clocks : 1867776, TSPD = 1552.598504cps, LSPD = 2048.000000cps
softmax_168 complete
...
...
@@ -317,6 +335,23 @@ softmax_168 complete
0.0356 n04505470 typewriter keyboard
clocks: 1884160, TSPD=1312.089136cps, LSPD=1260.307692cps
clocks: 1802240, TSPD=4767.830688cps, LSPD=4096.000000cps
softmax_168 complete
0.4901 n03085013 computer keyboard, keypad
0.1591 n04264628 space bar
0.0543 n04074963 remote control, remote
0.0439 n03832673 notebook, notebook computer
0.0356 n04505470 typewriter keyboard
clocks: 1818624, TSPD=4760.795812cps, LSPD=4096.000000cps
clocks: 1802240, TSPD=4353.236715cps, LSPD=5461.333333cps
softmax_168 complete
0.4901 n03085013 computer keyboard, keypad
0.1591 n04264628 space bar
0.0543 n04074963 remote control, remote
0.0439 n03832673 notebook, notebook computer
0.0356 n04505470 typewriter keyboard
clocks: 1818624, TSPD=4350.775120cps, LSPD=4096.000000cps
threadcount=2
clocks: 1867776, TSPD=1562.992469cps, LSPD=1365.333333cps
...
...
@@ -338,6 +373,34 @@ softmax_168 complete
0.0356 n04505470 typewriter keyboard
clocks: 1818624, TSPD=1752.046243cps, LSPD=1820.444444cps
usebigint == 0
clocks: 1802240, TSPD=3746.860707cps, LSPD=4096.000000cps
softmax_168 complete
0.4901 n03085013 computer keyboard, keypad
0.1591 n04264628 space bar
0.0543 n04074963 remote control, remote
0.0439 n03832673 notebook, notebook computer
0.0356 n04505470 typewriter keyboard
clocks: 1818624, TSPD=3749.740206cps, LSPD=4096.000000cps
clocks: 1802240, TSPD=4114.703196cps, LSPD=4096.000000cps
softmax_168 complete
0.4901 n03085013 computer keyboard, keypad
0.1591 n04264628 space bar
0.0543 n04074963 remote control, remote
0.0439 n03832673 notebook, notebook computer
0.0356 n04505470 typewriter keyboard
clocks: 1818624, TSPD=4114.533937cps, LSPD=4096.000000cps
clocks: 1802240, TSPD=3859.186296cps, LSPD=4096.000000cps
softmax_168 complete
0.4901 n03085013 computer keyboard, keypad
0.1591 n04264628 space bar
0.0543 n04074963 remote control, remote
0.0439 n03832673 notebook, notebook computer
0.0356 n04505470 typewriter keyboard
clocks: 1818624, TSPD=3861.197452cps, LSPD=4096.000000cps
threadcount=1
clocks: 1867776, TSPD=993.497872cps, LSPD=963.764706cps
softmax_168 complete
...
...
@@ -348,6 +411,25 @@ softmax_168 complete
0.0356 n04505470 typewriter keyboard
clocks: 1884160, TSPD=993.755274cps, LSPD=1024.000000cps
usebitint == 0
clocks: 1802240, TSPD=2549.137199cps, LSPD=2730.666667cps
softmax_168 complete
0.4901 n03085013 computer keyboard, keypad
0.1591 n04264628 space bar
0.0543 n04074963 remote control, remote
0.0439 n03832673 notebook, notebook computer
0.0356 n04505470 typewriter keyboard
clocks: 1818624, TSPD=2547.092437cps, LSPD=2340.571429cps
clocks: 1802240, TSPD=2802.861586cps, LSPD=2730.666667cps
softmax_168 complete
0.4901 n03085013 computer keyboard, keypad
0.1591 n04264628 space bar
0.0543 n04074963 remote control, remote
0.0439 n03832673 notebook, notebook computer
0.0356 n04505470 typewriter keyboard
clocks: 1818624, TSPD=2802.194145cps, LSPD=2730.666667cps
i9 10900 32G
threadcount=32
clocks: 1867776, TSPD=8768.901408cps, LSPD=8192.000000cps
...
...
hdl4seutils/include/threadlock.h
浏览文件 @
15e40781
...
...
@@ -61,7 +61,8 @@ void mt_free(void*);
#define LOCKED_INCREMENT(p) InterlockedIncrement(&p)
#define LOCKED_DECREMENT(p) InterlockedDecrement(&p)
#define LOCKED_SWAP_POINTER(p, v) InterlockedExchangePointer(&p, v)
#define LOCKED_SWAP(p, v) InterlockedExchange(&p, v)
#define LOCKED_COMP_SWAP(p, v, c) InterlockedCompareExchange(&p, v, c)
#define STRDUP _strdup
#endif
...
...
@@ -69,7 +70,8 @@ void mt_free(void*);
#define LOCKED_INCREMENT(p) __sync_fetch_and_add(&p, 1);
#define LOCKED_DECREMENT(p) __sync_fetch_and_sub(&p, 1);
#define LOCKED_SWAP_POINTER(p, v) __sync_val_compare_and_swap(&p, p, v)
#define LOCKED_SWAP(p, v) __sync_val_compare_and_swap(&p, p, v)
#define LOCKED_COMP_SWAP(p, v, c) __sync_val_compare_and_swap(&p, c, v)
#define STRDUP strdup
#endif
...
...
@@ -78,7 +80,14 @@ void mt_free(void*);
#define LOCKED_DECREMENT(p) p--
static
void
*
locked_swap_pointer
(
void
**
p
,
void
*
v
)
{
void
*
ret
=
v
;
void
*
ret
=
*
p
;
*
p
=
v
;
return
ret
;
}
#define LOCKED_SWAP_POINTER(p, v) locked_swap_pointer(&p, v)
static
long
locked_swap
(
long
*
p
,
long
v
)
{
long
ret
=
*
p
;
*
p
=
v
;
return
ret
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录