Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
饶先宏
hdl4se
提交
81805f29
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 搜索 >>
提交
81805f29
编写于
5月 21, 2021
作者:
饶先宏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
202105211801
上级
383aabde
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
392 addition
and
91 deletion
+392
-91
bignumber/include/bignumber.h
bignumber/include/bignumber.h
+2
-2
bignumber/src/bignumber.c
bignumber/src/bignumber.c
+111
-75
examples/testbignumber/testbignumber.c
examples/testbignumber/testbignumber.c
+14
-2
hdl4secell/CMakeLists.txt
hdl4secell/CMakeLists.txt
+3
-1
hdl4secell/include/hdl4secell.h
hdl4secell/include/hdl4secell.h
+3
-4
hdl4secell/src/hdl4se_mudule.c
hdl4secell/src/hdl4se_mudule.c
+231
-0
hdl4secell/src/hdl4se_mux16.c
hdl4secell/src/hdl4se_mux16.c
+5
-0
hdl4secell/src/hdl4se_mux2.c
hdl4secell/src/hdl4se_mux2.c
+10
-4
hdl4secell/src/hdl4se_mux4.c
hdl4secell/src/hdl4se_mux4.c
+7
-2
hdl4secell/src/hdl4se_mux8.c
hdl4secell/src/hdl4se_mux8.c
+6
-1
未找到文件。
bignumber/include/bignumber.h
浏览文件 @
81805f29
...
@@ -61,7 +61,7 @@ typedef struct sIBigNumber {
...
@@ -61,7 +61,7 @@ typedef struct sIBigNumber {
int
(
*
Assign
)(
HOBJECT
object
,
HOBJECT
src
);
int
(
*
Assign
)(
HOBJECT
object
,
HOBJECT
src
);
int
(
*
AssignSub
)(
HOBJECT
object
,
HOBJECT
src
,
int
from
,
int
width
);
int
(
*
AssignSub
)(
HOBJECT
object
,
HOBJECT
src
,
int
from
,
int
width
);
int
(
*
Bind
)(
HOBJECT
object
,
HOBJECT
src
,
int
width
);
int
(
*
Bind
)(
HOBJECT
object
,
HOBJECT
src
);
int
(
*
Neg
)(
HOBJECT
object
);
int
(
*
Neg
)(
HOBJECT
object
);
int
(
*
AddInt
)(
HOBJECT
object
,
int
value
);
int
(
*
AddInt
)(
HOBJECT
object
,
int
value
);
...
@@ -106,7 +106,7 @@ typedef struct sIBigNumber {
...
@@ -106,7 +106,7 @@ typedef struct sIBigNumber {
static int _obj##_bn_AssignInt64(HOBJECT object, long long value); \
static int _obj##_bn_AssignInt64(HOBJECT object, long long value); \
static int _obj##_bn_Assign(HOBJECT object, HOBJECT src); \
static int _obj##_bn_Assign(HOBJECT object, HOBJECT src); \
static int _obj##_bn_AssignSub(HOBJECT object, HOBJECT src, int from, int width); \
static int _obj##_bn_AssignSub(HOBJECT object, HOBJECT src, int from, int width); \
static int _obj##_bn_Bind(HOBJECT object, HOBJECT src
, int width
); \
static int _obj##_bn_Bind(HOBJECT object, HOBJECT src); \
static int _obj##_bn_Neg(HOBJECT object); \
static int _obj##_bn_Neg(HOBJECT object); \
static int _obj##_bn_AddInt(HOBJECT object, int value); \
static int _obj##_bn_AddInt(HOBJECT object, int value); \
static int _obj##_bn_Add(HOBJECT object, HOBJECT src); \
static int _obj##_bn_Add(HOBJECT object, HOBJECT src); \
...
...
bignumber/src/bignumber.c
浏览文件 @
81805f29
/*
/*
** HDL
(CELL_WIDTH/8)
SE: 软件Verilog综合仿真平台
** HDL
4
SE: 软件Verilog综合仿真平台
** Copyright (C) 2021-2021, raoxianhong<raoxianhong@163.net>
** Copyright (C) 2021-2021, raoxianhong<raoxianhong@163.net>
** LCOM: 轻量级组件对象模型
** LCOM: 轻量级组件对象模型
** Copyright (C) 2021-2021, raoxianhong<raoxianhong@163.net>
** Copyright (C) 2021-2021, raoxianhong<raoxianhong@163.net>
...
@@ -139,13 +139,6 @@ static int bigint_bn_GetBitsCount(HOBJECT object)
...
@@ -139,13 +139,6 @@ static int bigint_bn_GetBitsCount(HOBJECT object)
int
i
;
int
i
;
sBigInteger
*
pobj
;
sBigInteger
*
pobj
;
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
/*
for (i = pobj->buflen - 1; i >= 0; i--) {
if (pobj->buf[i] != 0) {
return i * CELL_WIDTH + actualwidth(pobj->buf[i]);
}
}*/
return
pobj
->
width
;
return
pobj
->
width
;
}
}
...
@@ -154,17 +147,29 @@ static int bigint_bn_SetBitsCount(HOBJECT object, int count)
...
@@ -154,17 +147,29 @@ static int bigint_bn_SetBitsCount(HOBJECT object, int count)
int
i
,
bc
;
int
i
,
bc
;
sBigInteger
*
pobj
;
sBigInteger
*
pobj
;
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
if
(
count
<=
0
)
{
if
(
count
<=
0
)
{
memset
(
pobj
->
buf
,
0
,
pobj
->
buflen
*
(
CELL_WIDTH
/
8
));
memset
(
pobj
->
buf
,
0
,
pobj
->
buflen
*
(
CELL_WIDTH
/
8
));
pobj
->
width
=
0
;
return
0
;
return
0
;
}
}
bc
=
bigint_bn_GetBitsCount
(
pobj
);
if
(
pobj
->
buflen
<
(
count
+
CELL_WIDTH
-
1
)
/
CELL_WIDTH
)
{
if
(
count
>=
bc
)
char
*
buf
;
return
0
;
int
blen
=
(
count
+
CELL_WIDTH
-
1
)
/
CELL_WIDTH
;
buf
=
malloc
(
blen
*
(
CELL_WIDTH
/
8
));
if
(
buf
==
NULL
)
return
-
1
;
for
(
i
=
0
;
i
<
pobj
->
buflen
;
i
++
)
buf
[
i
]
=
pobj
->
buf
[
i
];
pobj
->
buflen
=
blen
;
free
(
pobj
->
buf
);
pobj
->
buf
=
buf
;
}
for
(
i
=
(
count
+
(
CELL_WIDTH
-
1
))
/
CELL_WIDTH
;
i
<
pobj
->
buflen
;
i
++
)
{
for
(
i
=
(
count
+
(
CELL_WIDTH
-
1
))
/
CELL_WIDTH
;
i
<
pobj
->
buflen
;
i
++
)
{
pobj
->
buf
[
i
]
=
0
;
pobj
->
buf
[
i
]
=
0
;
}
}
pobj
->
buf
[
count
/
CELL_WIDTH
]
&=
0xffffffff
>>
(
CELL_WIDTH
-
(
count
&
(
CELL_WIDTH
-
1
)));
pobj
->
buf
[
count
/
CELL_WIDTH
]
&=
0xffffffff
>>
(
CELL_WIDTH
-
(
count
&
(
CELL_WIDTH
-
1
)));
pobj
->
width
=
count
;
return
0
;
return
0
;
}
}
...
@@ -358,6 +363,7 @@ lastnum:
...
@@ -358,6 +363,7 @@ lastnum:
static
int
bigint_bn_AssignInt
(
HOBJECT
object
,
int
value
)
static
int
bigint_bn_AssignInt
(
HOBJECT
object
,
int
value
)
{
{
sBigInteger
*
pobj
;
sBigInteger
*
pobj
;
int
i
;
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
if
(
value
<
0
)
{
if
(
value
<
0
)
{
pobj
->
sign
=
1
;
pobj
->
sign
=
1
;
...
@@ -365,14 +371,16 @@ static int bigint_bn_AssignInt(HOBJECT object, int value)
...
@@ -365,14 +371,16 @@ static int bigint_bn_AssignInt(HOBJECT object, int value)
}
else
{
}
else
{
pobj
->
sign
=
0
;
pobj
->
sign
=
0
;
}
}
memset
(
pobj
->
buf
,
0
,
pobj
->
buflen
*
(
CELL_WIDTH
/
8
));
pobj
->
buf
[
0
]
=
value
;
pobj
->
buf
[
0
]
=
value
;
for
(
i
=
1
;
i
<
pobj
->
buflen
;
i
++
)
pobj
->
buf
[
i
]
=
0
;
return
0
;
return
0
;
}
}
static
int
bigint_bn_AssignInt64
(
HOBJECT
object
,
long
long
value
)
static
int
bigint_bn_AssignInt64
(
HOBJECT
object
,
long
long
value
)
{
{
sBigInteger
*
pobj
;
sBigInteger
*
pobj
;
int
i
;
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
if
(
value
<
0
)
{
if
(
value
<
0
)
{
pobj
->
sign
=
1
;
pobj
->
sign
=
1
;
...
@@ -381,9 +389,10 @@ static int bigint_bn_AssignInt64(HOBJECT object, long long value)
...
@@ -381,9 +389,10 @@ static int bigint_bn_AssignInt64(HOBJECT object, long long value)
else
{
else
{
pobj
->
sign
=
0
;
pobj
->
sign
=
0
;
}
}
memset
(
pobj
->
buf
,
0
,
pobj
->
buflen
*
(
CELL_WIDTH
/
8
));
pobj
->
buf
[
0
]
=
value
&
0xFFFFFFFF
;
pobj
->
buf
[
0
]
=
value
&
0xFFFFFFFF
;
pobj
->
buf
[
1
]
=
value
>>
CELL_WIDTH
;
pobj
->
buf
[
1
]
=
value
>>
CELL_WIDTH
;
for
(
i
=
2
;
i
<
pobj
->
buflen
;
i
++
)
pobj
->
buf
[
i
]
=
0
;
return
0
;
return
0
;
}
}
...
@@ -391,21 +400,25 @@ static int bigint_bn_Assign(HOBJECT object, HOBJECT src)
...
@@ -391,21 +400,25 @@ static int bigint_bn_Assign(HOBJECT object, HOBJECT src)
{
{
sBigInteger
*
pobj
;
sBigInteger
*
pobj
;
sBigInteger
*
psrc
;
sBigInteger
*
psrc
;
unsigned
int
*
buf
;
int
i
;
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
if
(
!
objectIsClass
(
src
,
CLSID_BIGINTEGER
))
{
if
(
!
objectIsClass
(
src
,
CLSID_BIGINTEGER
))
{
return
-
1
;
return
-
1
;
}
}
psrc
=
(
sBigInteger
*
)
objectThis
(
src
);
psrc
=
(
sBigInteger
*
)
objectThis
(
src
);
buf
=
(
unsigned
int
*
)
malloc
(
psrc
->
buflen
*
(
CELL_WIDTH
/
8
));
if
(
pobj
->
buflen
<
psrc
->
buflen
)
{
if
(
buf
==
NULL
)
unsigned
int
*
buf
;
return
-
2
;
buf
=
(
unsigned
int
*
)
malloc
(
psrc
->
buflen
*
(
CELL_WIDTH
/
8
));
free
(
pobj
->
buf
);
if
(
buf
==
NULL
)
pobj
->
buf
=
buf
;
return
-
2
;
memcpy
(
pobj
->
buf
,
psrc
->
buf
,
psrc
->
buflen
*
(
CELL_WIDTH
/
8
));
free
(
pobj
->
buf
);
pobj
->
buf
=
buf
;
}
pobj
->
buflen
=
psrc
->
buflen
;
pobj
->
buflen
=
psrc
->
buflen
;
pobj
->
sign
=
psrc
->
sign
;
pobj
->
sign
=
psrc
->
sign
;
pobj
->
width
=
psrc
->
width
;
pobj
->
width
=
psrc
->
width
;
for
(
i
=
0
;
i
<
pobj
->
buflen
;
i
++
)
pobj
->
buf
[
i
]
=
psrc
->
buf
[
i
];
return
0
;
return
0
;
}
}
...
@@ -417,14 +430,12 @@ static int bigint_bn_AssignSub(HOBJECT object, HOBJECT src, int from, int width)
...
@@ -417,14 +430,12 @@ static int bigint_bn_AssignSub(HOBJECT object, HOBJECT src, int from, int width)
return
0
;
return
0
;
}
}
static
int
bigint_bn_Bind
(
HOBJECT
object
,
HOBJECT
src
,
int
width
)
static
int
bigint_bn_Bind
(
HOBJECT
object
,
HOBJECT
src
)
{
{
IBigNumber
**
temp
=
bigintegerCreate
();
int
width
=
bigint_bn_GetBitsCount
(
src
);
bigint_bn_Assign
(
temp
,
src
);
bigint_bn_SetBitsCount
(
object
,
bigint_bn_GetBitsCount
(
object
)
+
width
);
bigint_bn_SetBitsCount
(
temp
,
width
);
bigint_bn_SHL
(
object
,
width
);
bigint_bn_SHL
(
object
,
width
);
bigint_bn_Or
(
object
,
temp
);
bigint_bn_Or
(
object
,
src
);
objectRelease
(
temp
);
return
0
;
return
0
;
}
}
...
@@ -436,20 +447,6 @@ static int bigint_bn_Neg(HOBJECT object)
...
@@ -436,20 +447,6 @@ static int bigint_bn_Neg(HOBJECT object)
return
0
;
return
0
;
}
}
static
int
bigint_expandbuf
(
sBigInteger
*
pobj
)
{
unsigned
int
*
buf
;
buf
=
(
unsigned
int
*
)
malloc
(
pobj
->
buflen
*
2
*
(
CELL_WIDTH
/
8
));
if
(
buf
==
NULL
)
return
-
1
;
memcpy
(
buf
,
pobj
->
buf
,
pobj
->
buflen
*
(
CELL_WIDTH
/
8
));
memset
(
&
buf
[
pobj
->
buflen
],
0
,
pobj
->
buflen
*
(
CELL_WIDTH
/
8
));
free
(
pobj
->
buf
);
pobj
->
buf
=
buf
;
pobj
->
buflen
*=
2
;
return
0
;
}
static
int
bigint_bn_AddInt
(
HOBJECT
object
,
int
value
)
static
int
bigint_bn_AddInt
(
HOBJECT
object
,
int
value
)
{
{
int
vsign
;
int
vsign
;
...
@@ -472,8 +469,7 @@ static int bigint_bn_AddInt(HOBJECT object, int value)
...
@@ -472,8 +469,7 @@ static int bigint_bn_AddInt(HOBJECT object, int value)
/* 处理进位 */
/* 处理进位 */
while
(
temp
!=
0
)
{
while
(
temp
!=
0
)
{
if
(
i
>=
pobj
->
buflen
)
{
if
(
i
>=
pobj
->
buflen
)
{
if
(
0
!=
bigint_expandbuf
(
pobj
))
break
;
return
-
1
;
}
}
temp
+=
pobj
->
buf
[
i
];
temp
+=
pobj
->
buf
[
i
];
pobj
->
buf
[
i
]
=
temp
&
0xffffffff
;
pobj
->
buf
[
i
]
=
temp
&
0xffffffff
;
...
@@ -556,18 +552,44 @@ static int bigint_bn_MulInt(HOBJECT object, int value)
...
@@ -556,18 +552,44 @@ static int bigint_bn_MulInt(HOBJECT object, int value)
pobj
->
buf
[
i
]
=
mulr
&
0xffffffff
;
pobj
->
buf
[
i
]
=
mulr
&
0xffffffff
;
addin
=
mulr
>>
CELL_WIDTH
;
addin
=
mulr
>>
CELL_WIDTH
;
}
}
if
(
addin
!=
0
)
{
if
(
0
!=
bigint_expandbuf
(
pobj
))
return
-
1
;
pobj
->
buf
[
i
]
=
addin
&
0xffffffff
;
}
return
0
;
return
0
;
}
}
static
int
bigint_bn_Mul
(
HOBJECT
object
,
HOBJECT
src
)
static
int
bigint_bn_Mul
(
HOBJECT
object
,
HOBJECT
src
)
{
{
sBigInteger
*
pobj
;
sBigInteger
*
pobj
;
sBigInteger
*
psrc
;
unsigned
int
*
buf
;
int
i
,
j
;
unsigned
long
long
temp
;
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
if
(
!
objectIsClass
(
src
,
CLSID_BIGINTEGER
))
{
return
-
1
;
}
psrc
=
(
sBigInteger
*
)
objectThis
(
src
);
buf
=
(
unsigned
int
*
)
malloc
(
pobj
->
buflen
*
CELL_WIDTH
/
8
);
if
(
buf
==
NULL
)
return
-
2
;
for
(
i
=
0
;
i
<
pobj
->
buflen
;
i
++
)
buf
[
i
]
=
0
;
for
(
i
=
0
;
i
<
pobj
->
buflen
;
i
++
)
{
unsigned
long
long
addin
;
addin
=
0
;
for
(
j
=
0
;
j
<
psrc
->
buflen
;
j
++
)
{
unsigned
long
long
m0
,
m1
;
if
(
i
+
j
>=
pobj
->
buflen
)
break
;
m0
=
pobj
->
buf
[
i
];
m1
=
psrc
->
buf
[
j
];
m0
=
m0
*
m1
+
addin
+
buf
[
i
+
j
];
buf
[
i
+
j
]
=
m0
&
0xffffffff
;
addin
=
m0
>>
CELL_WIDTH
;
}
}
free
(
pobj
->
buf
);
pobj
->
buf
=
buf
;
pobj
->
sign
^=
psrc
->
sign
;
bigint_bn_SetBitsCount
(
pobj
,
pobj
->
width
);
return
0
;
return
0
;
}
}
...
@@ -588,39 +610,29 @@ static int bigint_bn_Div(HOBJECT object, HOBJECT src)
...
@@ -588,39 +610,29 @@ static int bigint_bn_Div(HOBJECT object, HOBJECT src)
static
int
bigint_bn_SHL
(
HOBJECT
object
,
int
bits
)
static
int
bigint_bn_SHL
(
HOBJECT
object
,
int
bits
)
{
{
sBigInteger
*
pobj
;
sBigInteger
*
pobj
;
int
bc
,
blen
;
int
ifrom
,
ito
,
i
;
int
ifrom
,
ito
,
i
;
unsigned
long
long
current
,
next
;
unsigned
long
long
current
,
next
;
unsigned
int
*
buf
;
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
if
(
bits
==
0
)
if
(
bits
==
0
)
return
0
;
return
0
;
if
(
bits
<
0
)
if
(
bits
<
0
)
return
bigint_bn_SHR
(
object
,
-
bits
);
return
bigint_bn_SHR
(
object
,
-
bits
);
bc
=
bigint_bn_GetBitsCount
(
object
);
blen
=
(
bc
+
bits
+
(
CELL_WIDTH
-
1
))
/
CELL_WIDTH
;
buf
=
(
unsigned
int
*
)
malloc
(
blen
*
(
CELL_WIDTH
/
8
));
if
(
buf
==
NULL
)
return
-
1
;
ito
=
bits
/
CELL_WIDTH
;
ito
=
bits
/
CELL_WIDTH
;
if
(
ito
>
0
)
{
memset
(
buf
,
0
,
ito
*
(
CELL_WIDTH
/
8
));
}
bits
-=
ito
*
CELL_WIDTH
;
bits
-=
ito
*
CELL_WIDTH
;
ifrom
=
0
;
ifrom
=
0
;
current
=
pobj
->
buf
[
0
];
for
(
i
=
pobj
->
buflen
-
1
;
i
>=
0
;
i
--
)
{
current
<<=
bits
;
current
=
0
;
for
(
i
=
1
;
i
<
(
bc
+
(
CELL_WIDTH
-
1
))
/
CELL_WIDTH
;
i
++
)
{
if
(
i
>=
ito
)
{
buf
[
ito
++
]
=
(
unsigned
int
)(
current
&
0xffffffff
);
current
=
pobj
->
buf
[
i
-
ito
];
current
>>=
CELL_WIDTH
;
current
<<=
CELL_WIDTH
;
next
=
pobj
->
buf
[
i
];
}
next
<<=
bits
;
if
(
i
>=
ito
+
1
)
{
current
|=
next
;
next
=
pobj
->
buf
[
i
-
ito
-
1
];
current
|=
next
;
}
current
>>=
CELL_WIDTH
-
bits
;
pobj
->
buf
[
i
]
=
(
unsigned
int
)(
current
&
0xffffffff
);
}
}
buf
[
ito
]
=
(
unsigned
int
)(
current
&
0xffffffff
);
free
(
pobj
->
buf
);
pobj
->
buf
=
buf
;
pobj
->
buflen
=
blen
;
return
0
;
return
0
;
}
}
...
@@ -666,8 +678,12 @@ static int bigint_bn_SHR(HOBJECT object, int bits)
...
@@ -666,8 +678,12 @@ static int bigint_bn_SHR(HOBJECT object, int bits)
static
int
bigint_bn_Not
(
HOBJECT
object
)
static
int
bigint_bn_Not
(
HOBJECT
object
)
{
{
int
i
;
sBigInteger
*
pobj
;
sBigInteger
*
pobj
;
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
for
(
i
=
0
;
i
<
pobj
->
buflen
;
i
++
)
pobj
->
buf
[
i
]
=
~
pobj
->
buf
[
i
];
bigint_bn_SetBitsCount
(
object
,
pobj
->
width
);
return
0
;
return
0
;
}
}
...
@@ -695,7 +711,19 @@ static int bigint_bn_uXor(HOBJECT object)
...
@@ -695,7 +711,19 @@ static int bigint_bn_uXor(HOBJECT object)
static
int
bigint_bn_And
(
HOBJECT
object
,
HOBJECT
src
)
static
int
bigint_bn_And
(
HOBJECT
object
,
HOBJECT
src
)
{
{
sBigInteger
*
pobj
;
sBigInteger
*
pobj
;
sBigInteger
*
psrc
;
int
i
;
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
if
(
!
objectIsClass
(
src
,
CLSID_BIGINTEGER
))
{
return
-
1
;
}
psrc
=
(
sBigInteger
*
)
objectThis
(
src
);
for
(
i
=
0
;
i
<
pobj
->
buflen
&&
i
<
psrc
->
buflen
;
i
++
)
{
pobj
->
buf
[
i
]
&=
psrc
->
buf
[
i
];
}
for
(;
i
<
pobj
->
buflen
;
i
++
)
{
pobj
->
buf
[
i
]
=
0
;
}
return
0
;
return
0
;
}
}
...
@@ -703,17 +731,13 @@ static int bigint_bn_Or(HOBJECT object, HOBJECT src)
...
@@ -703,17 +731,13 @@ static int bigint_bn_Or(HOBJECT object, HOBJECT src)
{
{
sBigInteger
*
pobj
;
sBigInteger
*
pobj
;
sBigInteger
*
psrc
;
sBigInteger
*
psrc
;
int
bc
,
bcsrc
,
i
;
int
i
;
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
if
(
!
objectIsClass
(
src
,
CLSID_BIGINTEGER
))
{
if
(
!
objectIsClass
(
src
,
CLSID_BIGINTEGER
))
{
return
-
1
;
return
-
1
;
}
}
psrc
=
(
sBigInteger
*
)
objectThis
(
src
);
psrc
=
(
sBigInteger
*
)
objectThis
(
src
);
bc
=
bigint_bn_GetBitsCount
(
object
);
for
(
i
=
0
;
i
<
pobj
->
buflen
&&
i
<
psrc
->
buflen
;
i
++
)
{
bcsrc
=
bigint_bn_GetBitsCount
(
src
);
for
(
i
=
0
;
i
<
(
bcsrc
+
(
CELL_WIDTH
-
1
))
/
CELL_WIDTH
;
i
++
)
{
while
(
pobj
->
buflen
<=
i
)
bigint_expandbuf
(
pobj
);
pobj
->
buf
[
i
]
|=
psrc
->
buf
[
i
];
pobj
->
buf
[
i
]
|=
psrc
->
buf
[
i
];
}
}
return
0
;
return
0
;
...
@@ -722,7 +746,19 @@ static int bigint_bn_Or(HOBJECT object, HOBJECT src)
...
@@ -722,7 +746,19 @@ static int bigint_bn_Or(HOBJECT object, HOBJECT src)
static
int
bigint_bn_Xor
(
HOBJECT
object
,
HOBJECT
src
)
static
int
bigint_bn_Xor
(
HOBJECT
object
,
HOBJECT
src
)
{
{
sBigInteger
*
pobj
;
sBigInteger
*
pobj
;
sBigInteger
*
psrc
;
int
i
;
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
pobj
=
(
sBigInteger
*
)
objectThis
(
object
);
if
(
!
objectIsClass
(
src
,
CLSID_BIGINTEGER
))
{
return
-
1
;
}
psrc
=
(
sBigInteger
*
)
objectThis
(
src
);
for
(
i
=
0
;
i
<
pobj
->
buflen
&&
i
<
psrc
->
buflen
;
i
++
)
{
pobj
->
buf
[
i
]
^=
psrc
->
buf
[
i
];
}
for
(;
i
<
pobj
->
buflen
;
i
++
)
{
pobj
->
buf
[
i
]
^=
0
;
}
return
0
;
return
0
;
}
}
...
...
examples/testbignumber/testbignumber.c
浏览文件 @
81805f29
...
@@ -39,7 +39,8 @@ const char* testnumber = "77'h41374891374198374081390481379087918758419832749871
...
@@ -39,7 +39,8 @@ const char* testnumber = "77'h41374891374198374081390481379087918758419832749871
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
char
buf
[
128
];
char
buf
[
128
];
IBigNumber
**
bignumber
=
bigintegerCreate
();
IBigNumber
**
bignumber
=
bigintegerCreate
(
300
);
IBigNumber
**
bignumber2
=
bigintegerCreate
(
300
);
const
char
*
nstr
=
testnumber
;
const
char
*
nstr
=
testnumber
;
const
char
*
lstr
=
testnumber
;
const
char
*
lstr
=
testnumber
;
while
(
0
==
objectCall2
(
bignumber
,
AssignStr
,
lstr
,
&
nstr
))
{
while
(
0
==
objectCall2
(
bignumber
,
AssignStr
,
lstr
,
&
nstr
))
{
...
@@ -50,8 +51,19 @@ int main(int argc, char* argv[])
...
@@ -50,8 +51,19 @@ int main(int argc, char* argv[])
objectCall2
(
bignumber
,
AssignStr
,
testnumber
,
&
nstr
);
objectCall2
(
bignumber
,
AssignStr
,
testnumber
,
&
nstr
);
objectCall3
(
bignumber
,
GetStr
,
16
,
buf
,
256
);
objectCall3
(
bignumber
,
GetStr
,
16
,
buf
,
256
);
printf
(
"n=%s
\n
"
,
buf
);
printf
(
"n=%s
\n
"
,
buf
);
objectCall1
(
bignumber
,
SetBitsCount
,
9
);
objectCall1
(
bignumber
,
SHL
,
200
);
objectCall3
(
bignumber
,
GetStr
,
16
,
buf
,
256
);
printf
(
"n<<200=%s
\n
"
,
buf
);
objectCall1
(
bignumber
,
SHR
,
212
);
objectCall3
(
bignumber
,
GetStr
,
16
,
buf
,
256
);
printf
(
"n>>212=%s
\n
"
,
buf
);
objectCall1
(
bignumber
,
SetBitsCount
,
128
);
objectCall3
(
bignumber
,
GetStr
,
16
,
buf
,
256
);
objectCall3
(
bignumber
,
GetStr
,
16
,
buf
,
256
);
printf
(
"n<<68=%s
\n
"
,
buf
);
printf
(
"n<<68=%s
\n
"
,
buf
);
objectCall2
(
bignumber
,
AssignStr
,
"1262562534"
,
&
nstr
);
objectCall2
(
bignumber2
,
AssignStr
,
"45652656526567"
,
&
nstr
);
objectCall1
(
bignumber
,
Mul
,
bignumber2
);
objectCall3
(
bignumber
,
GetStr
,
16
,
buf
,
256
);
printf
(
"mul=%s
\n
"
,
buf
);
return
0
;
return
0
;
}
}
\ No newline at end of file
hdl4secell/CMakeLists.txt
浏览文件 @
81805f29
...
@@ -9,7 +9,9 @@ add_library (hdl4secell STATIC
...
@@ -9,7 +9,9 @@ add_library (hdl4secell STATIC
"src/hdl4se_mux2.c"
"src/hdl4se_mux2.c"
"src/hdl4se_mux4.c"
"src/hdl4se_mux4.c"
"src/hdl4se_mux8.c"
"src/hdl4se_mux8.c"
"src/hdl4se_mux16.c"
)
"src/hdl4se_mux16.c"
"src/hdl4se_mudule.c"
)
include_directories
(
"../../lcom/include"
)
include_directories
(
"../../lcom/include"
)
include_directories
(
"../hdl4secell/include"
)
include_directories
(
"../hdl4secell/include"
)
...
...
hdl4secell/include/hdl4secell.h
浏览文件 @
81805f29
...
@@ -99,9 +99,6 @@ static int _obj##_hdl4se_unit_SetFuncSet(HOBJECT object, int funcset) \
...
@@ -99,9 +99,6 @@ static int _obj##_hdl4se_unit_SetFuncSet(HOBJECT object, int funcset) \
}
}
DEFINE_GUID
(
IID_HDL4SEMODULE
,
0x88cf84f9
,
0x17ac
,
0x4edf
,
0xbf
,
0x0
,
0xc7
,
0x32
,
0xd5
,
0x26
,
0x99
,
0x2a
);
DEFINE_GUID
(
IID_HDL4SEMODULE
,
0x88cf84f9
,
0x17ac
,
0x4edf
,
0xbf
,
0x0
,
0xc7
,
0x32
,
0xd5
,
0x26
,
0x99
,
0x2a
);
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 PORTTYPE_INPUT 0
#define PORTTYPE_INPUT 0
#define PORTTYPE_OUTPUT 1
#define PORTTYPE_OUTPUT 1
...
@@ -125,7 +122,9 @@ typedef struct sIHDL4SEModule {
...
@@ -125,7 +122,9 @@ typedef struct sIHDL4SEModule {
_obj##_hdl4se_module_AddUnit, \
_obj##_hdl4se_module_AddUnit, \
};
};
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
);
/*
/*
以下定义请与hdl4cell.v中的定义保持一致
以下定义请与hdl4cell.v中的定义保持一致
*/
*/
...
...
hdl4secell/src/hdl4se_mudule.c
0 → 100644
浏览文件 @
81805f29
/*
** 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_module.c
修改记录:
202105180851: rxh, initial version
*/
#include "stdlib.h"
#include "stdio.h"
#include "object.h"
#include "dlist.h"
#include "bignumber.h"
#include "hdl4secell.h"
/*
HDL4SE_MODULE
instance parameter: "8", width=8
*/
typedef
struct
_sHDL4SEModule
{
OBJECT_HEADER
INTERFACE_DECLARE
(
IHDL4SEModule
)
HDL4SEMODULE_VARDECLARE
INTERFACE_DECLARE
(
IHDL4SEUnit
)
HDL4SEUNIT_VARDECLARE
DLIST_VARDECLARE
IHDL4SEModule
**
parent
;
char
*
name
;
}
sHDL4SEModule
;
OBJECT_FUNCDECLARE
(
hdl4se_module
,
CLSID_HDL4SE_MODULE
);
HDL4SEUNIT_FUNCDECLARE
(
hdl4se_module
,
CLSID_HDL4SE_MODULE
,
sHDL4SEModule
);
HDL4SEMODULE_FUNCDECLARE
(
hdl4se_module
,
CLSID_HDL4SE_MODULE
,
sHDL4SEModule
);
HDL4SEUNIT_FUNCIMPL
(
hdl4se_module
,
CLSID_HDL4SE_MODULE
,
sHDL4SEModule
);
DLIST_FUNCIMPL
(
hdl4se_module
,
CLSID_HDL4SE_MODULE
,
sHDL4SEModule
);
OBJECT_FUNCIMPL
(
hdl4se_module
,
sHDL4SEModule
,
CLSID_HDL4SE_MODULE
);
QUERYINTERFACE_BEGIN
(
hdl4se_module
,
CLSID_HDL4SE_MODULE
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sHDL4SEModule
)
QUERYINTERFACE_ITEM
(
IID_DLIST
,
IDList
,
sHDL4SEModule
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEMODULE
,
IHDL4SEModule
,
sHDL4SEModule
)
QUERYINTERFACE_END
static
const
char
*
hdl4se_moduleModuleInfo
()
{
return
"1.0.0-20210521.1754 HDL4SE Module cell"
;
}
static
int
hdl4se_moduleCreate
(
const
PARAMITEM
*
pParams
,
int
paramcount
,
HOBJECT
*
pObject
)
{
sHDL4SEModule
*
pobj
;
int
i
;
pobj
=
(
sHDL4SEModule
*
)
malloc
(
sizeof
(
sHDL4SEModule
));
if
(
pobj
==
NULL
)
return
-
1
;
*
pObject
=
0
;
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_HDL4SE_MODULE
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
hdl4se_module
,
hdl4se_unit
);
DLIST_VARINIT
(
pobj
,
hdl4se_module
);
pobj
->
name
=
NULL
;
pobj
->
parent
=
NULL
;
for
(
i
=
0
;
i
<
paramcount
;
i
++
)
{
if
(
pParams
[
i
].
name
==
PARAMID_HDL4SE_UNIT_NAME
)
{
if
(
pobj
->
name
!=
NULL
)
free
(
pobj
->
name
);
pobj
->
name
=
strdup
(
pParams
[
i
].
pvalue
);
}
else
if
(
pParams
[
i
].
name
==
PARAMID_HDL4SE_UNIT_PARENT
)
{
pobj
->
parent
=
(
IHDL4SEModule
**
)
pParams
[
i
].
pvalue
;
}
else
if
(
pParams
[
i
].
name
==
PARAMID_HDL4SE_UNIT_INSTANCE_PARAMETERS
)
{
}
}
/* 返回生成的对象 */
OBJECT_RETURN_GEN
(
hdl4se_module
,
pobj
,
pObject
,
CLSID_HDL4SE_MODULE
);
return
EIID_OK
;
}
static
void
hdl4se_moduleDestroy
(
HOBJECT
object
)
{
sHDL4SEModule
*
pobj
;
pobj
=
(
sHDL4SEModule
*
)
objectThis
(
object
);
if
(
pobj
->
name
!=
NULL
)
free
(
pobj
->
name
);
memset
(
pobj
,
0
,
sizeof
(
sHDL4SEModule
));
free
(
pobj
);
}
static
int
hdl4se_moduleValid
(
HOBJECT
object
)
{
sHDL4SEModule
*
pobj
;
pobj
=
(
sHDL4SEModule
*
)
objectThis
(
object
);
return
1
;
}
static
int
hdl4se_module_hdl4se_unit_Connect
(
HOBJECT
object
,
int
index
,
HOBJECT
from
,
int
fromindex
)
{
sHDL4SEModule
*
pobj
;
IHDL4SEUnit
**
unit
=
NULL
;
pobj
=
(
sHDL4SEModule
*
)
objectThis
(
object
);
/*
if (index == 0) {
if (0 == objectQueryInterface(from, IID_HDL4SEUNIT, (void**)&unit)) {
objectRelease(pobj->sel);
pobj->sel = unit;
pobj->sel_index = fromindex;
}
else {
return -2;
}
}
else if (index >= 1 && index <= 2) {
if (0 == objectQueryInterface(from, IID_HDL4SEUNIT, (void**)&unit)) {
objectRelease(pobj->in[index-1]);
pobj->in[index-1] = unit;
pobj->in_index[index-1] = fromindex;
}
else {
return -2;
}
}
else {
return -1;
}
*/
return
0
;
}
static
int
hdl4se_module_hdl4se_unit_GetValue
(
HOBJECT
object
,
int
index
,
int
width
,
IBigNumber
**
value
)
{
int
i
;
int
sel
;
sHDL4SEModule
*
pobj
;
pobj
=
(
sHDL4SEModule
*
)
objectThis
(
object
);
/*
if (index != 3)
return -1;
objectCall3(pobj->sel, GetValue, pobj->sel_index, 1, pobj->in_sel);
objectCall1(pobj->in_sel, GetInt, &sel);
if (sel >= 0 && sel <= 1) {
objectCall3(pobj->in[sel], GetValue, pobj->in_index[sel], pobj->width, pobj->out_data);
}
else {
return -2;
}
//objectCall(pobj->out_data, SetBitscount, width);
objectCall1(value, Assign, pobj->out_data);
hdl4se_module_hdl4se_unit_SetFuncSet(object, 1);
*/
return
0
;
}
static
int
hdl4se_module_hdl4se_unit_GetValueStored
(
HOBJECT
object
,
int
index
,
int
width
,
IBigNumber
**
value
)
{
sHDL4SEModule
*
pobj
;
pobj
=
(
sHDL4SEModule
*
)
objectThis
(
object
);
/*
if (index != 3)
return -1;
objectCall1(value, Assign, pobj->out_data);
//objectCall(value, SetBitscount, width);
*/
return
0
;
}
static
int
hdl4se_module_hdl4se_unit_ClkTick
(
HOBJECT
object
)
{
sHDL4SEModule
*
pobj
;
pobj
=
(
sHDL4SEModule
*
)
objectThis
(
object
);
return
0
;
}
static
int
hdl4se_module_hdl4se_unit_Setup
(
HOBJECT
object
)
{
sHDL4SEModule
*
pobj
;
pobj
=
(
sHDL4SEModule
*
)
objectThis
(
object
);
hdl4se_module_hdl4se_unit_SetFuncSet
(
object
,
0
);
return
0
;
}
static
int
hdl4se_module_hdl4se_module_AddPort
(
HOBJECT
object
,
int
width
,
int
type
,
const
char
*
name
)
{
sHDL4SEModule
*
pobj
;
pobj
=
(
sHDL4SEModule
*
)
objectThis
(
object
);
return
0
;
}
static
int
hdl4se_module_hdl4se_module_AddUnit
(
HOBJECT
object
,
IHDL4SEUnit
**
unit
,
const
char
*
name
)
{
sHDL4SEModule
*
pobj
;
pobj
=
(
sHDL4SEModule
*
)
objectThis
(
object
);
return
0
;
}
hdl4secell/src/hdl4se_mux16.c
浏览文件 @
81805f29
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include "stdlib.h"
#include "stdlib.h"
#include "stdio.h"
#include "stdio.h"
#include "object.h"
#include "object.h"
#include "dlist.h"
#include "bignumber.h"
#include "bignumber.h"
#include "hdl4secell.h"
#include "hdl4secell.h"
...
@@ -49,6 +50,7 @@ typedef struct _sHDL4SEMux16 {
...
@@ -49,6 +50,7 @@ typedef struct _sHDL4SEMux16 {
OBJECT_HEADER
OBJECT_HEADER
INTERFACE_DECLARE
(
IHDL4SEUnit
)
INTERFACE_DECLARE
(
IHDL4SEUnit
)
HDL4SEUNIT_VARDECLARE
HDL4SEUNIT_VARDECLARE
DLIST_VARDECLARE
IHDL4SEModule
**
parent
;
IHDL4SEModule
**
parent
;
char
*
name
;
char
*
name
;
...
@@ -67,11 +69,13 @@ typedef struct _sHDL4SEMux16 {
...
@@ -67,11 +69,13 @@ typedef struct _sHDL4SEMux16 {
OBJECT_FUNCDECLARE
(
hdl4se_mux16
,
CLSID_HDL4SE_MUX16
);
OBJECT_FUNCDECLARE
(
hdl4se_mux16
,
CLSID_HDL4SE_MUX16
);
HDL4SEUNIT_FUNCDECLARE
(
hdl4se_mux16
,
CLSID_HDL4SE_MUX16
,
sHDL4SEMux16
);
HDL4SEUNIT_FUNCDECLARE
(
hdl4se_mux16
,
CLSID_HDL4SE_MUX16
,
sHDL4SEMux16
);
HDL4SEUNIT_FUNCIMPL
(
hdl4se_mux16
,
CLSID_HDL4SE_MUX16
,
sHDL4SEMux16
);
HDL4SEUNIT_FUNCIMPL
(
hdl4se_mux16
,
CLSID_HDL4SE_MUX16
,
sHDL4SEMux16
);
DLIST_FUNCIMPL
(
hdl4se_mux16
,
CLSID_HDL4SE_MUX16
,
sHDL4SEMux16
);
OBJECT_FUNCIMPL
(
hdl4se_mux16
,
sHDL4SEMux16
,
CLSID_HDL4SE_MUX16
);
OBJECT_FUNCIMPL
(
hdl4se_mux16
,
sHDL4SEMux16
,
CLSID_HDL4SE_MUX16
);
QUERYINTERFACE_BEGIN
(
hdl4se_mux16
,
CLSID_HDL4SE_MUX16
)
QUERYINTERFACE_BEGIN
(
hdl4se_mux16
,
CLSID_HDL4SE_MUX16
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sHDL4SEMux16
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sHDL4SEMux16
)
QUERYINTERFACE_ITEM
(
IID_DLIST
,
IDList
,
sHDL4SEMux16
)
QUERYINTERFACE_END
QUERYINTERFACE_END
static
const
char
*
hdl4se_mux16ModuleInfo
()
static
const
char
*
hdl4se_mux16ModuleInfo
()
...
@@ -89,6 +93,7 @@ static int hdl4se_mux16Create(const PARAMITEM* pParams, int paramcount, HOBJECT*
...
@@ -89,6 +93,7 @@ static int hdl4se_mux16Create(const PARAMITEM* pParams, int paramcount, HOBJECT*
*
pObject
=
0
;
*
pObject
=
0
;
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_HDL4SE_MUX16
);
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_HDL4SE_MUX16
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
hdl4se_mux16
,
hdl4se_unit
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
hdl4se_mux16
,
hdl4se_unit
);
DLIST_VARINIT
(
pobj
,
hdl4se_mux16
);
pobj
->
sel
=
NULL
;
pobj
->
sel
=
NULL
;
pobj
->
sel_index
=
0
;
pobj
->
sel_index
=
0
;
...
...
hdl4secell/src/hdl4se_mux2.c
浏览文件 @
81805f29
...
@@ -30,26 +30,28 @@
...
@@ -30,26 +30,28 @@
*/
*/
/*
/*
* hdl4se_m
ux2
.c
* hdl4se_m
odule
.c
修改记录:
修改记录:
202105180851: rxh, initial version
202105180851: rxh, initial version
*/
*/
#include "stdlib.h"
#include "stdlib.h"
#include "stdio.h"
#include "stdio.h"
#include "object.h"
#include "object.h"
#include "dlist.h"
#include "bignumber.h"
#include "bignumber.h"
#include "hdl4secell.h"
#include "hdl4secell.h"
/*
/*
HDL4SE_MUX2
HDL4SE_MUX2
instance parameter: "8", width=8
instance parameter: "8", width=8
*/
*/
typedef
struct
_sHDL4SEMux2
{
typedef
struct
_sHDL4SEMux2
{
OBJECT_HEADER
OBJECT_HEADER
INTERFACE_DECLARE
(
IHDL4SEUnit
)
INTERFACE_DECLARE
(
IHDL4SEUnit
)
HDL4SEUNIT_VARDECLARE
HDL4SEUNIT_VARDECLARE
DLIST_VARDECLARE
IHDL4SEModule
**
parent
;
IHDL4SEModule
**
parent
;
char
*
name
;
char
*
name
;
...
@@ -67,11 +69,14 @@ typedef struct _sHDL4SEMux2 {
...
@@ -67,11 +69,14 @@ typedef struct _sHDL4SEMux2 {
OBJECT_FUNCDECLARE
(
hdl4se_mux2
,
CLSID_HDL4SE_MUX2
);
OBJECT_FUNCDECLARE
(
hdl4se_mux2
,
CLSID_HDL4SE_MUX2
);
HDL4SEUNIT_FUNCDECLARE
(
hdl4se_mux2
,
CLSID_HDL4SE_MUX2
,
sHDL4SEMux2
);
HDL4SEUNIT_FUNCDECLARE
(
hdl4se_mux2
,
CLSID_HDL4SE_MUX2
,
sHDL4SEMux2
);
HDL4SEUNIT_FUNCIMPL
(
hdl4se_mux2
,
CLSID_HDL4SE_MUX2
,
sHDL4SEMux2
);
HDL4SEUNIT_FUNCIMPL
(
hdl4se_mux2
,
CLSID_HDL4SE_MUX2
,
sHDL4SEMux2
);
DLIST_FUNCIMPL
(
hdl4se_mux2
,
CLSID_HDL4SE_MUX2
,
sHDL4SEMux2
);
OBJECT_FUNCIMPL
(
hdl4se_mux2
,
sHDL4SEMux2
,
CLSID_HDL4SE_MUX2
);
OBJECT_FUNCIMPL
(
hdl4se_mux2
,
sHDL4SEMux2
,
CLSID_HDL4SE_MUX2
);
QUERYINTERFACE_BEGIN
(
hdl4se_mux2
,
CLSID_HDL4SE_MUX2
)
QUERYINTERFACE_BEGIN
(
hdl4se_mux2
,
CLSID_HDL4SE_MUX2
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sHDL4SEMux2
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sHDL4SEMux2
)
QUERYINTERFACE_ITEM
(
IID_DLIST
,
IDList
,
sHDL4SEMux2
)
QUERYINTERFACE_END
QUERYINTERFACE_END
static
const
char
*
hdl4se_mux2ModuleInfo
()
static
const
char
*
hdl4se_mux2ModuleInfo
()
...
@@ -89,7 +94,8 @@ static int hdl4se_mux2Create(const PARAMITEM* pParams, int paramcount, HOBJECT*
...
@@ -89,7 +94,8 @@ static int hdl4se_mux2Create(const PARAMITEM* pParams, int paramcount, HOBJECT*
*
pObject
=
0
;
*
pObject
=
0
;
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_HDL4SE_MUX2
);
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_HDL4SE_MUX2
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
hdl4se_mux2
,
hdl4se_unit
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
hdl4se_mux2
,
hdl4se_unit
);
DLIST_VARINIT
(
pobj
,
hdl4se_mux2
);
pobj
->
sel
=
NULL
;
pobj
->
sel
=
NULL
;
pobj
->
sel_index
=
0
;
pobj
->
sel_index
=
0
;
for
(
i
=
0
;
i
<
2
;
i
++
)
{
for
(
i
=
0
;
i
<
2
;
i
++
)
{
...
...
hdl4secell/src/hdl4se_mux4.c
浏览文件 @
81805f29
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include "stdlib.h"
#include "stdlib.h"
#include "stdio.h"
#include "stdio.h"
#include "object.h"
#include "object.h"
#include "dlist.h"
#include "bignumber.h"
#include "bignumber.h"
#include "hdl4secell.h"
#include "hdl4secell.h"
...
@@ -49,7 +50,8 @@ typedef struct _sHDL4SEMux4 {
...
@@ -49,7 +50,8 @@ typedef struct _sHDL4SEMux4 {
OBJECT_HEADER
OBJECT_HEADER
INTERFACE_DECLARE
(
IHDL4SEUnit
)
INTERFACE_DECLARE
(
IHDL4SEUnit
)
HDL4SEUNIT_VARDECLARE
HDL4SEUNIT_VARDECLARE
DLIST_VARDECLARE
IHDL4SEModule
**
parent
;
IHDL4SEModule
**
parent
;
char
*
name
;
char
*
name
;
...
@@ -67,11 +69,13 @@ typedef struct _sHDL4SEMux4 {
...
@@ -67,11 +69,13 @@ typedef struct _sHDL4SEMux4 {
OBJECT_FUNCDECLARE
(
hdl4se_mux4
,
CLSID_HDL4SE_MUX4
);
OBJECT_FUNCDECLARE
(
hdl4se_mux4
,
CLSID_HDL4SE_MUX4
);
HDL4SEUNIT_FUNCDECLARE
(
hdl4se_mux4
,
CLSID_HDL4SE_MUX4
,
sHDL4SEMux4
);
HDL4SEUNIT_FUNCDECLARE
(
hdl4se_mux4
,
CLSID_HDL4SE_MUX4
,
sHDL4SEMux4
);
HDL4SEUNIT_FUNCIMPL
(
hdl4se_mux4
,
CLSID_HDL4SE_MUX4
,
sHDL4SEMux4
);
HDL4SEUNIT_FUNCIMPL
(
hdl4se_mux4
,
CLSID_HDL4SE_MUX4
,
sHDL4SEMux4
);
DLIST_FUNCIMPL
(
hdl4se_mux4
,
CLSID_HDL4SE_MUX4
,
sHDL4SEMux4
);
OBJECT_FUNCIMPL
(
hdl4se_mux4
,
sHDL4SEMux4
,
CLSID_HDL4SE_MUX4
);
OBJECT_FUNCIMPL
(
hdl4se_mux4
,
sHDL4SEMux4
,
CLSID_HDL4SE_MUX4
);
QUERYINTERFACE_BEGIN
(
hdl4se_mux4
,
CLSID_HDL4SE_MUX4
)
QUERYINTERFACE_BEGIN
(
hdl4se_mux4
,
CLSID_HDL4SE_MUX4
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sHDL4SEMux4
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sHDL4SEMux4
)
QUERYINTERFACE_ITEM
(
IID_DLIST
,
IDList
,
sHDL4SEMux4
)
QUERYINTERFACE_END
QUERYINTERFACE_END
static
const
char
*
hdl4se_mux4ModuleInfo
()
static
const
char
*
hdl4se_mux4ModuleInfo
()
...
@@ -89,7 +93,8 @@ static int hdl4se_mux4Create(const PARAMITEM* pParams, int paramcount, HOBJECT*
...
@@ -89,7 +93,8 @@ static int hdl4se_mux4Create(const PARAMITEM* pParams, int paramcount, HOBJECT*
*
pObject
=
0
;
*
pObject
=
0
;
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_HDL4SE_MUX4
);
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_HDL4SE_MUX4
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
hdl4se_mux4
,
hdl4se_unit
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
hdl4se_mux4
,
hdl4se_unit
);
DLIST_VARINIT
(
pobj
,
hdl4se_mux4
);
pobj
->
sel
=
NULL
;
pobj
->
sel
=
NULL
;
pobj
->
sel_index
=
0
;
pobj
->
sel_index
=
0
;
for
(
i
=
0
;
i
<
4
;
i
++
)
{
for
(
i
=
0
;
i
<
4
;
i
++
)
{
...
...
hdl4secell/src/hdl4se_mux8.c
浏览文件 @
81805f29
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include "stdlib.h"
#include "stdlib.h"
#include "stdio.h"
#include "stdio.h"
#include "object.h"
#include "object.h"
#include "dlist.h"
#include "bignumber.h"
#include "bignumber.h"
#include "hdl4secell.h"
#include "hdl4secell.h"
...
@@ -49,7 +50,8 @@ typedef struct _sHDL4SEMux8 {
...
@@ -49,7 +50,8 @@ typedef struct _sHDL4SEMux8 {
OBJECT_HEADER
OBJECT_HEADER
INTERFACE_DECLARE
(
IHDL4SEUnit
)
INTERFACE_DECLARE
(
IHDL4SEUnit
)
HDL4SEUNIT_VARDECLARE
HDL4SEUNIT_VARDECLARE
DLIST_VARDECLARE
IHDL4SEModule
**
parent
;
IHDL4SEModule
**
parent
;
char
*
name
;
char
*
name
;
...
@@ -67,11 +69,13 @@ typedef struct _sHDL4SEMux8 {
...
@@ -67,11 +69,13 @@ typedef struct _sHDL4SEMux8 {
OBJECT_FUNCDECLARE
(
hdl4se_mux8
,
CLSID_HDL4SE_MUX8
);
OBJECT_FUNCDECLARE
(
hdl4se_mux8
,
CLSID_HDL4SE_MUX8
);
HDL4SEUNIT_FUNCDECLARE
(
hdl4se_mux8
,
CLSID_HDL4SE_MUX8
,
sHDL4SEMux8
);
HDL4SEUNIT_FUNCDECLARE
(
hdl4se_mux8
,
CLSID_HDL4SE_MUX8
,
sHDL4SEMux8
);
HDL4SEUNIT_FUNCIMPL
(
hdl4se_mux8
,
CLSID_HDL4SE_MUX8
,
sHDL4SEMux8
);
HDL4SEUNIT_FUNCIMPL
(
hdl4se_mux8
,
CLSID_HDL4SE_MUX8
,
sHDL4SEMux8
);
DLIST_FUNCIMPL
(
hdl4se_mux8
,
CLSID_HDL4SE_MUX8
,
sHDL4SEMux8
);
OBJECT_FUNCIMPL
(
hdl4se_mux8
,
sHDL4SEMux8
,
CLSID_HDL4SE_MUX8
);
OBJECT_FUNCIMPL
(
hdl4se_mux8
,
sHDL4SEMux8
,
CLSID_HDL4SE_MUX8
);
QUERYINTERFACE_BEGIN
(
hdl4se_mux8
,
CLSID_HDL4SE_MUX8
)
QUERYINTERFACE_BEGIN
(
hdl4se_mux8
,
CLSID_HDL4SE_MUX8
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sHDL4SEMux8
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sHDL4SEMux8
)
QUERYINTERFACE_ITEM
(
IID_DLIST
,
IDList
,
sHDL4SEMux8
)
QUERYINTERFACE_END
QUERYINTERFACE_END
static
const
char
*
hdl4se_mux8ModuleInfo
()
static
const
char
*
hdl4se_mux8ModuleInfo
()
...
@@ -89,6 +93,7 @@ static int hdl4se_mux8Create(const PARAMITEM* pParams, int paramcount, HOBJECT*
...
@@ -89,6 +93,7 @@ static int hdl4se_mux8Create(const PARAMITEM* pParams, int paramcount, HOBJECT*
*
pObject
=
0
;
*
pObject
=
0
;
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_HDL4SE_MUX8
);
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_HDL4SE_MUX8
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
hdl4se_mux8
,
hdl4se_unit
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
hdl4se_mux8
,
hdl4se_unit
);
DLIST_VARINIT
(
pobj
,
hdl4se_mux8
);
pobj
->
sel
=
NULL
;
pobj
->
sel
=
NULL
;
pobj
->
sel_index
=
0
;
pobj
->
sel_index
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录