Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
饶先宏
hdl4se
提交
ae406627
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 搜索 >>
提交
ae406627
编写于
7月 06, 2021
作者:
饶先宏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
202107061636
上级
36d9e769
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
1771 addition
and
63 deletion
+1771
-63
examples/hdl4secnn/cnn/cnn/cnn.c
examples/hdl4secnn/cnn/cnn/cnn.c
+2
-4
examples/hdl4secnn/cnn/cnncell/CMakeLists.txt
examples/hdl4secnn/cnn/cnncell/CMakeLists.txt
+4
-2
examples/hdl4secnn/cnn/cnncell/cnncell.c
examples/hdl4secnn/cnn/cnncell/cnncell.c
+16
-4
examples/hdl4secnn/cnn/cnncell/cnncell.h
examples/hdl4secnn/cnn/cnncell/cnncell.h
+5
-5
examples/hdl4secnn/cnn/cnncell/cnncell_buf.c
examples/hdl4secnn/cnn/cnncell/cnncell_buf.c
+295
-0
examples/hdl4secnn/cnn/cnncell/cnncell_buf_r4.c
examples/hdl4secnn/cnn/cnncell/cnncell_buf_r4.c
+316
-0
examples/hdl4secnn/cnn/cnncell/cnncell_coeffbuf.c
examples/hdl4secnn/cnn/cnncell/cnncell_coeffbuf.c
+3
-1
examples/hdl4secnn/cnn/cnncell/cnncell_convolution.c
examples/hdl4secnn/cnn/cnncell/cnncell_convolution.c
+1
-1
examples/hdl4secnn/cnn/cnncell/cnncell_dataoutput.c
examples/hdl4secnn/cnn/cnncell/cnncell_dataoutput.c
+329
-0
examples/hdl4secnn/cnn/cnncell/cnncell_lrn.c
examples/hdl4secnn/cnn/cnncell/cnncell_lrn.c
+262
-0
examples/hdl4secnn/cnn/cnncell/cnncell_pooling.c
examples/hdl4secnn/cnn/cnncell/cnncell_pooling.c
+266
-0
examples/hdl4secnn/cnn/cnncell/cnncell_softmax.c
examples/hdl4secnn/cnn/cnncell/cnncell_softmax.c
+258
-0
examples/hdl4secnn/cnn/verilog/cnncell.v
examples/hdl4secnn/cnn/verilog/cnncell.v
+3
-36
examples/hdl4secnn/googlenet/verilog/googlenet.c
examples/hdl4secnn/googlenet/verilog/googlenet.c
+2
-2
examples/hdl4secnn/googlenet/verilog/googlenet.dump.v
examples/hdl4secnn/googlenet/verilog/googlenet.dump.v
+7
-5
examples/hdl4secnn/googlenet/verilog/googlenet.v
examples/hdl4secnn/googlenet/verilog/googlenet.v
+2
-3
未找到文件。
examples/hdl4secnn/cnn/cnn/cnn.c
浏览文件 @
ae406627
...
@@ -1020,11 +1020,9 @@ int node_setup(cnn_layer_node* node, FILE * pCodeFile)
...
@@ -1020,11 +1020,9 @@ int node_setup(cnn_layer_node* node, FILE * pCodeFile)
fprintf
(
pCodeFile
,
"
\t
/* 归一化分类层 %d:%s */
\n
"
,
pInfo
->
layer_base
.
layer_index
,
pInfo
->
layer_base
.
layer_name
);
fprintf
(
pCodeFile
,
"
\t
/* 归一化分类层 %d:%s */
\n
"
,
pInfo
->
layer_base
.
layer_index
,
pInfo
->
layer_base
.
layer_name
);
fprintf
(
pCodeFile
,
fprintf
(
pCodeFile
,
"
\t
hdl4se_cnn_softmax #(
\n
"
"
\t
hdl4se_cnn_softmax #(
\n
"
"
\t\t
%4d, %4d, %4d,
\t
/* 输入大小 */
\n
"
"
\t\t
%4d, %4d, %4d
\t
/* 输入输出大小 */
\n
"
"
\t\t
%4d, %4d, %4d
\t
/* 输出大小 */
\n
"
"
\t
)
\n
"
,
"
\t
)
\n
"
,
node
->
inputsize
[
0
][
1
],
node
->
inputsize
[
0
][
0
],
node
->
inputsize
[
0
][
2
],
node
->
inputsize
[
0
][
1
],
node
->
inputsize
[
0
][
0
],
node
->
inputsize
[
0
][
2
]
node
->
outputsize
[
0
][
1
],
node
->
outputsize
[
0
][
0
],
node
->
outputsize
[
0
][
2
]
);
);
fprintf
(
pCodeFile
,
"
\t
softmax_%d (
\n
"
,
node
->
layer_info
->
layer_index
);
fprintf
(
pCodeFile
,
"
\t
softmax_%d (
\n
"
,
node
->
layer_info
->
layer_index
);
fprintf
(
pCodeFile
,
"
\t\t
wClk, nwReset,
\n
"
);
fprintf
(
pCodeFile
,
"
\t\t
wClk, nwReset,
\n
"
);
...
...
examples/hdl4secnn/cnn/cnncell/CMakeLists.txt
浏览文件 @
ae406627
...
@@ -9,10 +9,12 @@ add_library(cnncell STATIC
...
@@ -9,10 +9,12 @@ add_library(cnncell STATIC
"cnncell_innerproduct.c"
"cnncell_innerproduct.c"
"cnncell_concat.c"
"cnncell_concat.c"
"cnncell_datasource.c"
"cnncell_datasource.c"
"cnncell_coeffbuf.c"
)
"cnncell_coeffbuf.c"
"cnncell_buf_r4.c"
"cnncell_buf.c"
"cnncell_dataoutput.c"
"cnncell_pooling.c"
"cnncell_lrn.c"
"cnncell_softmax.c"
)
include_directories
(
"../../../../../lcom/include"
)
include_directories
(
"../../../../../lcom/include"
)
include_directories
(
"../../../../hdl4secell/include"
)
include_directories
(
"../../../../hdl4secell/include"
)
include_directories
(
"../../../../bignumber/include"
)
include_directories
(
"../../../../bignumber/include"
)
examples/hdl4secnn/cnn/cnncell/cnncell.c
浏览文件 @
ae406627
...
@@ -45,21 +45,33 @@
...
@@ -45,21 +45,33 @@
static
int
cnncell_registed
=
0
;
static
int
cnncell_registed
=
0
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_
convolution
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_
buf
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_
innerproduct
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_
buf_r4
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_coeffbuf
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_coeffbuf
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_concat
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_concat
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_convolution
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_dataoutput
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_datasource
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_datasource
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_innerproduct
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_lrn
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_pooling
;
extern
OFUNCPTR
A_u_t_o_registor_cnncell_softmax
;
int
cnnInit
()
int
cnnInit
()
{
{
if
(
cnncell_registed
)
if
(
cnncell_registed
)
return
0
;
return
0
;
A_u_t_o_registor_cnncell_
convolution
();
A_u_t_o_registor_cnncell_
buf
();
A_u_t_o_registor_cnncell_
innerproduct
();
A_u_t_o_registor_cnncell_
buf_r4
();
A_u_t_o_registor_cnncell_coeffbuf
();
A_u_t_o_registor_cnncell_coeffbuf
();
A_u_t_o_registor_cnncell_concat
();
A_u_t_o_registor_cnncell_concat
();
A_u_t_o_registor_cnncell_convolution
();
A_u_t_o_registor_cnncell_dataoutput
();
A_u_t_o_registor_cnncell_datasource
();
A_u_t_o_registor_cnncell_datasource
();
A_u_t_o_registor_cnncell_innerproduct
();
A_u_t_o_registor_cnncell_lrn
();
A_u_t_o_registor_cnncell_pooling
();
A_u_t_o_registor_cnncell_softmax
();
cnncell_registed
=
1
;
cnncell_registed
=
1
;
return
0
;
return
0
;
}
}
\ No newline at end of file
examples/hdl4secnn/cnn/cnncell/cnncell.h
浏览文件 @
ae406627
...
@@ -46,18 +46,18 @@ extern "C" {
...
@@ -46,18 +46,18 @@ extern "C" {
#include "guid.h"
#include "guid.h"
DEFINE_GUID
(
CLSID_CNN_COEFFBUF
,
0xc72d0d42
,
0x2d4d
,
0x4dc3
,
0x9d
,
0xda
,
0x4f
,
0x58
,
0xce
,
0x75
,
0x69
,
0xbc
);
DEFINE_GUID
(
CLSID_CNN_BUF
,
0x66106096
,
0xd61b
,
0x4b27
,
0xb2
,
0x78
,
0x8b
,
0xed
,
0x3a
,
0x27
,
0xb5
,
0x63
);
DEFINE_GUID
(
CLSID_CNN_BUF
,
0x66106096
,
0xd61b
,
0x4b27
,
0xb2
,
0x78
,
0x8b
,
0xed
,
0x3a
,
0x27
,
0xb5
,
0x63
);
DEFINE_GUID
(
CLSID_CNN_BUF_R4
,
0x9aa0d743
,
0x5ffb
,
0x4649
,
0xac
,
0xec
,
0x4b
,
0x46
,
0x75
,
0xae
,
0x2a
,
0x57
);
DEFINE_GUID
(
CLSID_CNN_BUF_R4
,
0x9aa0d743
,
0x5ffb
,
0x4649
,
0xac
,
0xec
,
0x4b
,
0x46
,
0x75
,
0xae
,
0x2a
,
0x57
);
DEFINE_GUID
(
CLSID_CNN_BUF_W4
,
0x9d2c00a4
,
0x519f
,
0x4b07
,
0x82
,
0x1e
,
0x94
,
0x34
,
0xf7
,
0xd3
,
0xd5
,
0xee
);
DEFINE_GUID
(
CLSID_CNN_COEFFBUF
,
0xc72d0d42
,
0x2d4d
,
0x4dc3
,
0x9d
,
0xda
,
0x4f
,
0x58
,
0xce
,
0x75
,
0x69
,
0xbc
);
DEFINE_GUID
(
CLSID_CNN_CONCAT4
,
0x8ec66cdf
,
0xc750
,
0x46a1
,
0xaa
,
0x1f
,
0xc4
,
0x43
,
0x8
,
0xe1
,
0xf0
,
0x1
);
DEFINE_GUID
(
CLSID_CNN_CONVOLUTION
,
0xfb3d226e
,
0xd508
,
0x476b
,
0x81
,
0xe1
,
0xf3
,
0xb2
,
0x2c
,
0xcf
,
0x8f
,
0x11
);
DEFINE_GUID
(
CLSID_CNN_CONVOLUTION
,
0xfb3d226e
,
0xd508
,
0x476b
,
0x81
,
0xe1
,
0xf3
,
0xb2
,
0x2c
,
0xcf
,
0x8f
,
0x11
);
DEFINE_GUID
(
CLSID_CNN_DATAOUTPUT
,
0xcc51df54
,
0xf7af
,
0x407c
,
0xa4
,
0xb3
,
0x24
,
0xd6
,
0x71
,
0x39
,
0xe1
,
0x7e
);
DEFINE_GUID
(
CLSID_CNN_DATASOURCE
,
0x70b19638
,
0x3b9
,
0x466d
,
0x97
,
0x2a
,
0x5d
,
0x31
,
0xab
,
0xd4
,
0x48
,
0xd4
);
DEFINE_GUID
(
CLSID_CNN_INNERPRODUCT
,
0x78b9bec2
,
0x3df7
,
0x4421
,
0x92
,
0x74
,
0x64
,
0x5b
,
0xfb
,
0x60
,
0x32
,
0xb
);
DEFINE_GUID
(
CLSID_CNN_INNERPRODUCT
,
0x78b9bec2
,
0x3df7
,
0x4421
,
0x92
,
0x74
,
0x64
,
0x5b
,
0xfb
,
0x60
,
0x32
,
0xb
);
DEFINE_GUID
(
CLSID_CNN_CONCAT4
,
0x8ec66cdf
,
0xc750
,
0x46a1
,
0xaa
,
0x1f
,
0xc4
,
0x43
,
0x8
,
0xe1
,
0xf0
,
0x1
);
DEFINE_GUID
(
CLSID_CNN_LRN
,
0x59076b10
,
0x44f2
,
0x46e4
,
0xb9
,
0x50
,
0x17
,
0x9b
,
0x8d
,
0x29
,
0x59
,
0xb6
);
DEFINE_GUID
(
CLSID_CNN_LRN
,
0x59076b10
,
0x44f2
,
0x46e4
,
0xb9
,
0x50
,
0x17
,
0x9b
,
0x8d
,
0x29
,
0x59
,
0xb6
);
DEFINE_GUID
(
CLSID_CNN_POOLING
,
0x3b2e096b
,
0x5572
,
0x47e2
,
0xa4
,
0xbc
,
0x31
,
0x39
,
0x41
,
0x9d
,
0x33
,
0x21
);
DEFINE_GUID
(
CLSID_CNN_POOLING
,
0x3b2e096b
,
0x5572
,
0x47e2
,
0xa4
,
0xbc
,
0x31
,
0x39
,
0x41
,
0x9d
,
0x33
,
0x21
);
DEFINE_GUID
(
CLSID_CNN_SOFTMAX
,
0x5b646ef4
,
0xfe9e
,
0x44bf
,
0x92
,
0x5f
,
0xaf
,
0x98
,
0x56
,
0x6a
,
0xeb
,
0x23
);
DEFINE_GUID
(
CLSID_CNN_SOFTMAX
,
0x5b646ef4
,
0xfe9e
,
0x44bf
,
0x92
,
0x5f
,
0xaf
,
0x98
,
0x56
,
0x6a
,
0xeb
,
0x23
);
DEFINE_GUID
(
CLSID_CNN_DATASOURCE
,
0x70b19638
,
0x3b9
,
0x466d
,
0x97
,
0x2a
,
0x5d
,
0x31
,
0xab
,
0xd4
,
0x48
,
0xd4
);
DEFINE_GUID
(
CLSID_CNN_BUF_W4
,
0x9d2c00a4
,
0x519f
,
0x4b07
,
0x82
,
0x1e
,
0x94
,
0x34
,
0xf7
,
0xd3
,
0xd5
,
0xee
);
DEFINE_GUID
(
CLSID_CNN_DATAOUTPUT
,
0xcc51df54
,
0xf7af
,
0x407c
,
0xa4
,
0xb3
,
0x24
,
0xd6
,
0x71
,
0x39
,
0xe1
,
0x7e
);
int
cnnInit
();
int
cnnInit
();
...
...
examples/hdl4secnn/cnn/cnncell/cnncell_buf.c
0 → 100644
浏览文件 @
ae406627
/*
** 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.
*/
/*
* cnncell_buf.c
修改记录:
202107061537: rxh, initial version
*/
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "object.h"
#include "dlist.h"
#include "cnncell.h"
#include "bignumber.h"
#include "hdl4secell.h"
#define HDL4SEDEBUG 0
/*
(*
HDL4SE="LCOM",
CLSID="9AA0D743-5FFB-4649-ACEC-4B4675AE2A57",
softmodule="hdl4se"
*)
module hdl4se_cnn_buf
#(parameter wordsize=32, wordcount=1024)
(
0 input wClk,
1 input nwReset,
2 output wDataReadEnable,
3 input wDataRead,
4 output wDataReadValid,
5 input [31:0] bDataReadAddr,
6 output [31:0]bDataReadData,
7 input wDataReadComplete,
26 output wDataWriteEnable,
27 input wDataWrite,
28 input [31:0] bDataWriteAddr,
29 input [31:0] bDataWriteData,
30 input wDataWriteComplete
);
endmodule
*/
/* wClk不算 */
#define INPUTPORTCOUNT 8
#define PARAMCOUNT 2
#define READPORT 1
typedef
struct
_sCNNCellBuf
{
OBJECT_HEADER
INTERFACE_DECLARE
(
IHDL4SEUnit
)
HDL4SEUNIT_VARDECLARE
DLIST_VARDECLARE
IHDL4SEModule
**
parent
;
char
*
name
;
IBigNumber
**
inputdata
;
IHDL4SEUnit
**
input_unit
[
INPUTPORTCOUNT
];
int
input_index
[
INPUTPORTCOUNT
];
unsigned
char
*
buf
;
union
{
struct
{
int
wordsize
;
int
wordcount
;
};
int
__param
[
PARAMCOUNT
];
};
struct
sReadPortSingal
{
/* input */
int
readcmd
,
read_reg
;
int
readaddr
,
readaddr_reg
;
int
readcomplete
,
readcomplete_reg
;
/* output */
int
datareadenable
,
datareadenable_reg
;
}
readport
[
READPORT
];
int
writeenable
,
writeenable_reg
;
}
sCNNCellBuf
;
OBJECT_FUNCDECLARE
(
cnncell_buf
,
CLSID_CNN_BUF
);
HDL4SEUNIT_FUNCDECLARE
(
cnncell_buf
,
CLSID_CNN_BUF
,
sCNNCellBuf
);
DLIST_FUNCIMPL
(
cnncell_buf
,
CLSID_CNN_BUF
,
sCNNCellBuf
);
OBJECT_FUNCIMPL
(
cnncell_buf
,
sCNNCellBuf
,
CLSID_CNN_BUF
);
QUERYINTERFACE_BEGIN
(
cnncell_buf
,
CLSID_CNN_BUF
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sCNNCellBuf
)
QUERYINTERFACE_ITEM
(
IID_DLIST
,
IDList
,
sCNNCellBuf
)
QUERYINTERFACE_END
static
const
char
*
cnncell_bufModuleInfo
()
{
return
"0.3.0-20210706.1537 CNN Buf cell"
;
}
static
int
cnncell_bufCreate
(
const
PARAMITEM
*
pParams
,
int
paramcount
,
HOBJECT
*
pObject
)
{
sCNNCellBuf
*
pobj
;
int
i
;
pobj
=
(
sCNNCellBuf
*
)
malloc
(
sizeof
(
sCNNCellBuf
));
if
(
pobj
==
NULL
)
return
-
1
;
*
pObject
=
0
;
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_CNN_BUF
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
cnncell_buf
,
hdl4se_unit
);
DLIST_VARINIT
(
pobj
,
cnncell_buf
);
for
(
i
=
0
;
i
<
INPUTPORTCOUNT
;
i
++
)
pobj
->
input_unit
[
i
]
=
NULL
;
pobj
->
inputdata
=
bigintegerCreate
(
64
);
pobj
->
buf
=
0
;
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
)
{
IBigNumber
**
temp
=
bigintegerCreate
(
32
);
if
(
temp
!=
NULL
)
{
const
char
*
nstr
;
const
char
*
lstr
;
int
j
;
lstr
=
(
const
char
*
)
pParams
[
i
].
pvalue
;
for
(
j
=
0
;
j
<
PARAMCOUNT
;
j
++
)
{
if
(
0
==
objectCall3
(
temp
,
AssignStr
,
lstr
,
&
nstr
,
0
))
{
objectCall1
(
temp
,
GetInt32
,
&
pobj
->
__param
[
j
]);
lstr
=
nstr
;
}
}
objectRelease
(
temp
);
}
}
}
/* 返回生成的对象 */
OBJECT_RETURN_GEN
(
cnncell_buf
,
pobj
,
pObject
,
CLSID_CNN_BUF
);
return
EIID_OK
;
}
static
void
cnncell_bufDestroy
(
HOBJECT
object
)
{
sCNNCellBuf
*
pobj
;
int
i
;
pobj
=
(
sCNNCellBuf
*
)
objectThis
(
object
);
if
(
pobj
->
name
!=
NULL
)
free
(
pobj
->
name
);
for
(
i
=
0
;
i
<
INPUTPORTCOUNT
;
i
++
)
objectRelease
(
pobj
->
input_unit
[
i
]);
objectRelease
(
pobj
->
inputdata
);
memset
(
pobj
,
0
,
sizeof
(
sCNNCellBuf
));
free
(
pobj
);
}
static
int
cnncell_bufValid
(
HOBJECT
object
)
{
sCNNCellBuf
*
pobj
;
pobj
=
(
sCNNCellBuf
*
)
objectThis
(
object
);
return
1
;
}
static
int
cnncell_buf_hdl4se_unit_GetName
(
HOBJECT
object
,
const
char
**
pname
)
{
sCNNCellBuf
*
pobj
;
pobj
=
(
sCNNCellBuf
*
)
objectThis
(
object
);
*
pname
=
pobj
->
name
;
return
0
;
}
static
int
cnncell_buf_hdl4se_unit_Connect
(
HOBJECT
object
,
int
index
,
HOBJECT
from
,
int
fromindex
)
{
int
i
,
inputind
;
#define CONNECTPORT(ind, innerind) \
if (index == ind) { \
if (0 == objectQueryInterface(from, IID_HDL4SEUNIT, (void**)&unit)) { \
objectRelease(pobj->input_unit[innerind]); \
pobj->input_unit[innerind] = unit; \
pobj->input_index[innerind] = fromindex; \
} \
}
sCNNCellBuf
*
pobj
;
IHDL4SEUnit
**
unit
=
NULL
;
pobj
=
(
sCNNCellBuf
*
)
objectThis
(
object
);
CONNECTPORT
(
1
,
0
);
/* nwReset */
inputind
=
1
;
for
(
i
=
0
;
i
<
READPORT
;
i
++
)
{
CONNECTPORT
(
3
+
i
*
6
,
1
+
i
*
3
);
/* wDataRead_i */
CONNECTPORT
(
5
+
i
*
6
,
2
+
i
*
3
);
/* bDataReadAddr_i */
CONNECTPORT
(
7
+
i
*
6
,
3
+
i
*
3
);
/* wDataReadComplete_i */
}
CONNECTPORT
(
27
,
13
);
/* wDataWrite */
CONNECTPORT
(
28
,
14
);
/* bDataWriteAddr */
CONNECTPORT
(
29
,
15
);
/* bDataWriteData */
CONNECTPORT
(
30
,
16
);
/* wDataWriteComplete */
return
0
;
}
static
int
cnncell_buf_hdl4se_unit_GetValue
(
HOBJECT
object
,
int
index
,
int
width
,
IBigNumber
**
value
)
{
sCNNCellBuf
*
pobj
;
pobj
=
(
sCNNCellBuf
*
)
objectThis
(
object
);
if
(
index
==
26
)
{
if
(
width
<=
0
)
{
objectCall1
(
value
,
SetUnsigned
,
1
);
objectCall1
(
value
,
SetWidth
,
1
);
}
objectCall1
(
value
,
AssignInt32
,
pobj
->
writeenable_reg
);
}
else
{
int
port
;
int
offset
;
port
=
(
index
-
2
)
/
6
;
offset
=
(
index
-
2
)
%
6
;
if
(
offset
==
0
)
{
/* wDataReadEnable_i */
}
else
{
}
}
return
0
;
}
static
int
cnncell_buf_hdl4se_unit_ClkTick
(
HOBJECT
object
)
{
sCNNCellBuf
*
pobj
;
pobj
=
(
sCNNCellBuf
*
)
objectThis
(
object
);
return
0
;
}
static
int
cnncell_buf_hdl4se_unit_Setup
(
HOBJECT
object
)
{
int
i
;
sCNNCellBuf
*
pobj
;
pobj
=
(
sCNNCellBuf
*
)
objectThis
(
object
);
pobj
->
writeenable_reg
=
pobj
->
writeenable
;
for
(
i
=
0
;
i
<
READPORT
;
i
++
)
{
pobj
->
readport
[
i
].
read_reg
=
pobj
->
readport
[
i
].
readcmd
;
pobj
->
readport
[
i
].
readaddr_reg
=
pobj
->
readport
[
i
].
readaddr
;
pobj
->
readport
[
i
].
readcomplete_reg
=
pobj
->
readport
[
i
].
readcomplete
;
}
return
0
;
}
examples/hdl4secnn/cnn/cnncell/cnncell_buf_r4.c
0 → 100644
浏览文件 @
ae406627
/*
** 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.
*/
/*
* cnncell_buf_r4.c
修改记录:
202107061436: rxh, initial version
*/
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "object.h"
#include "dlist.h"
#include "cnncell.h"
#include "bignumber.h"
#include "hdl4secell.h"
#define HDL4SEDEBUG 0
/*
(*
HDL4SE="LCOM",
CLSID="9AA0D743-5FFB-4649-ACEC-4B4675AE2A57",
softmodule="hdl4se"
*)
module hdl4se_cnn_buf_r4
#(parameter wordsize=32, wordcount=1024)
(
0 input wClk,
1 input nwReset,
2 output wDataReadEnable_0,
3 input wDataRead_0,
4 output wDataReadValid_0,
5 input [31:0] bDataReadAddr_0,
6 output [31:0]bDataReadData_0,
7 input wDataReadComplete_0,
8 output wDataReadEnable_1,
9 input wDataRead_1,
10 output wDataReadValid_1,
11 input [31:0] bDataReadAddr_1,
12 output [31:0]bDataReadData_1,
13 input wDataReadComplete_1,
14 output wDataReadEnable_2,
15 input wDataRead_2,
16 output wDataReadValid_2,
17 input [31:0] bDataReadAddr_2,
18 output [31:0]bDataReadData_2,
19 input wDataReadComplete_2,
20 output wDataReadEnable_3,
21 input wDataRead_3,
22 output wDataReadValid_3,
23 input [31:0] bDataReadAddr_3,
24 output [31:0]bDataReadData_3,
25 input wDataReadComplete_3,
26 output wDataWriteEnable,
27 input wDataWrite,
28 input [31:0] bDataWriteAddr,
29 input [31:0] bDataWriteData,
30 input wDataWriteComplete
);
endmodule
*/
/* wClk不算 */
#define INPUTPORTCOUNT 17
#define PARAMCOUNT 2
#define READPORT 4
typedef
struct
_sCNNCellBufR4
{
OBJECT_HEADER
INTERFACE_DECLARE
(
IHDL4SEUnit
)
HDL4SEUNIT_VARDECLARE
DLIST_VARDECLARE
IHDL4SEModule
**
parent
;
char
*
name
;
IBigNumber
**
inputdata
;
IHDL4SEUnit
**
input_unit
[
INPUTPORTCOUNT
];
int
input_index
[
INPUTPORTCOUNT
];
unsigned
char
*
buf
;
union
{
struct
{
int
wordsize
;
int
wordcount
;
};
int
__param
[
PARAMCOUNT
];
};
struct
sReadPortSingal
{
/* input */
int
readcmd
,
read_reg
;
int
readaddr
,
readaddr_reg
;
int
readcomplete
,
readcomplete_reg
;
/* output */
int
datareadenable
,
datareadenable_reg
;
}
readport
[
READPORT
];
int
writeenable
,
writeenable_reg
;
}
sCNNCellBufR4
;
OBJECT_FUNCDECLARE
(
cnncell_buf_r4
,
CLSID_CNN_BUF_R4
);
HDL4SEUNIT_FUNCDECLARE
(
cnncell_buf_r4
,
CLSID_CNN_BUF_R4
,
sCNNCellBufR4
);
DLIST_FUNCIMPL
(
cnncell_buf_r4
,
CLSID_CNN_BUF_R4
,
sCNNCellBufR4
);
OBJECT_FUNCIMPL
(
cnncell_buf_r4
,
sCNNCellBufR4
,
CLSID_CNN_BUF_R4
);
QUERYINTERFACE_BEGIN
(
cnncell_buf_r4
,
CLSID_CNN_BUF_R4
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sCNNCellBufR4
)
QUERYINTERFACE_ITEM
(
IID_DLIST
,
IDList
,
sCNNCellBufR4
)
QUERYINTERFACE_END
static
const
char
*
cnncell_buf_r4ModuleInfo
()
{
return
"0.3.0-20210706.1436 CNN Buf R4 cell"
;
}
static
int
cnncell_buf_r4Create
(
const
PARAMITEM
*
pParams
,
int
paramcount
,
HOBJECT
*
pObject
)
{
sCNNCellBufR4
*
pobj
;
int
i
;
pobj
=
(
sCNNCellBufR4
*
)
malloc
(
sizeof
(
sCNNCellBufR4
));
if
(
pobj
==
NULL
)
return
-
1
;
*
pObject
=
0
;
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_CNN_BUF_R4
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
cnncell_buf_r4
,
hdl4se_unit
);
DLIST_VARINIT
(
pobj
,
cnncell_buf_r4
);
for
(
i
=
0
;
i
<
INPUTPORTCOUNT
;
i
++
)
pobj
->
input_unit
[
i
]
=
NULL
;
pobj
->
inputdata
=
bigintegerCreate
(
64
);
pobj
->
buf
=
0
;
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
)
{
IBigNumber
**
temp
=
bigintegerCreate
(
32
);
if
(
temp
!=
NULL
)
{
const
char
*
nstr
;
const
char
*
lstr
;
int
j
;
lstr
=
(
const
char
*
)
pParams
[
i
].
pvalue
;
for
(
j
=
0
;
j
<
PARAMCOUNT
;
j
++
)
{
if
(
0
==
objectCall3
(
temp
,
AssignStr
,
lstr
,
&
nstr
,
0
))
{
objectCall1
(
temp
,
GetInt32
,
&
pobj
->
__param
[
j
]);
lstr
=
nstr
;
}
}
objectRelease
(
temp
);
}
}
}
/* 返回生成的对象 */
OBJECT_RETURN_GEN
(
cnncell_buf_r4
,
pobj
,
pObject
,
CLSID_CNN_BUF_R4
);
return
EIID_OK
;
}
static
void
cnncell_buf_r4Destroy
(
HOBJECT
object
)
{
sCNNCellBufR4
*
pobj
;
int
i
;
pobj
=
(
sCNNCellBufR4
*
)
objectThis
(
object
);
if
(
pobj
->
name
!=
NULL
)
free
(
pobj
->
name
);
for
(
i
=
0
;
i
<
INPUTPORTCOUNT
;
i
++
)
objectRelease
(
pobj
->
input_unit
[
i
]);
objectRelease
(
pobj
->
inputdata
);
memset
(
pobj
,
0
,
sizeof
(
sCNNCellBufR4
));
free
(
pobj
);
}
static
int
cnncell_buf_r4Valid
(
HOBJECT
object
)
{
sCNNCellBufR4
*
pobj
;
pobj
=
(
sCNNCellBufR4
*
)
objectThis
(
object
);
return
1
;
}
static
int
cnncell_buf_r4_hdl4se_unit_GetName
(
HOBJECT
object
,
const
char
**
pname
)
{
sCNNCellBufR4
*
pobj
;
pobj
=
(
sCNNCellBufR4
*
)
objectThis
(
object
);
*
pname
=
pobj
->
name
;
return
0
;
}
static
int
cnncell_buf_r4_hdl4se_unit_Connect
(
HOBJECT
object
,
int
index
,
HOBJECT
from
,
int
fromindex
)
{
int
i
,
inputind
;
#define CONNECTPORT(ind, innerind) \
if (index == ind) { \
if (0 == objectQueryInterface(from, IID_HDL4SEUNIT, (void**)&unit)) { \
objectRelease(pobj->input_unit[innerind]); \
pobj->input_unit[innerind] = unit; \
pobj->input_index[innerind] = fromindex; \
} \
}
sCNNCellBufR4
*
pobj
;
IHDL4SEUnit
**
unit
=
NULL
;
pobj
=
(
sCNNCellBufR4
*
)
objectThis
(
object
);
CONNECTPORT
(
1
,
0
);
/* nwReset */
inputind
=
1
;
for
(
i
=
0
;
i
<
READPORT
;
i
++
)
{
CONNECTPORT
(
3
+
i
*
6
,
1
+
i
*
3
);
/* wDataRead_i */
CONNECTPORT
(
5
+
i
*
6
,
2
+
i
*
3
);
/* bDataReadAddr_i */
CONNECTPORT
(
7
+
i
*
6
,
3
+
i
*
3
);
/* wDataReadComplete_i */
}
CONNECTPORT
(
27
,
13
);
/* wDataWrite */
CONNECTPORT
(
28
,
14
);
/* bDataWriteAddr */
CONNECTPORT
(
29
,
15
);
/* bDataWriteData */
CONNECTPORT
(
30
,
16
);
/* wDataWriteComplete */
return
0
;
}
static
int
cnncell_buf_r4_hdl4se_unit_GetValue
(
HOBJECT
object
,
int
index
,
int
width
,
IBigNumber
**
value
)
{
sCNNCellBufR4
*
pobj
;
pobj
=
(
sCNNCellBufR4
*
)
objectThis
(
object
);
if
(
index
==
26
)
{
if
(
width
<=
0
)
{
objectCall1
(
value
,
SetUnsigned
,
1
);
objectCall1
(
value
,
SetWidth
,
1
);
}
objectCall1
(
value
,
AssignInt32
,
pobj
->
writeenable_reg
);
}
else
{
int
port
;
int
offset
;
port
=
(
index
-
2
)
/
6
;
offset
=
(
index
-
2
)
%
6
;
if
(
offset
==
0
)
{
/* wDataReadEnable_i */
}
else
{
}
}
return
0
;
}
static
int
cnncell_buf_r4_hdl4se_unit_ClkTick
(
HOBJECT
object
)
{
sCNNCellBufR4
*
pobj
;
pobj
=
(
sCNNCellBufR4
*
)
objectThis
(
object
);
return
0
;
}
static
int
cnncell_buf_r4_hdl4se_unit_Setup
(
HOBJECT
object
)
{
int
i
;
sCNNCellBufR4
*
pobj
;
pobj
=
(
sCNNCellBufR4
*
)
objectThis
(
object
);
pobj
->
writeenable_reg
=
pobj
->
writeenable
;
for
(
i
=
0
;
i
<
READPORT
;
i
++
)
{
pobj
->
readport
[
i
].
read_reg
=
pobj
->
readport
[
i
].
readcmd
;
pobj
->
readport
[
i
].
readaddr_reg
=
pobj
->
readport
[
i
].
readaddr
;
pobj
->
readport
[
i
].
readcomplete_reg
=
pobj
->
readport
[
i
].
readcomplete
;
}
return
0
;
}
examples/hdl4secnn/cnn/cnncell/cnncell_coeffbuf.c
浏览文件 @
ae406627
...
@@ -138,11 +138,13 @@ static int cnncell_coeffbufCreate(const PARAMITEM* pParams, int paramcount, HOBJ
...
@@ -138,11 +138,13 @@ static int cnncell_coeffbufCreate(const PARAMITEM* pParams, int paramcount, HOBJ
pobj
->
parent
=
(
IHDL4SEModule
**
)
pParams
[
i
].
pvalue
;
pobj
->
parent
=
(
IHDL4SEModule
**
)
pParams
[
i
].
pvalue
;
}
}
else
if
(
pParams
[
i
].
name
==
PARAMID_HDL4SE_UNIT_INSTANCE_PARAMETERS
)
{
else
if
(
pParams
[
i
].
name
==
PARAMID_HDL4SE_UNIT_INSTANCE_PARAMETERS
)
{
sprintf
(
pobj
->
filename
,
"%s/%s"
,
DATADIR
,
(
const
char
*
)
pParams
[
i
].
pvalue
);
sprintf
(
pobj
->
filename
,
"%s/%s"
,
DATADIR
,
((
const
char
*
)
pParams
[
i
].
pvalue
)
+
1
);
pobj
->
filename
[
strlen
(
pobj
->
filename
)
-
1
]
=
0
;
pobj
->
pCoeffFile
=
fopen
(
pobj
->
filename
,
"r"
);
pobj
->
pCoeffFile
=
fopen
(
pobj
->
filename
,
"r"
);
}
}
}
}
if
(
pobj
->
pCoeffFile
==
NULL
)
{
if
(
pobj
->
pCoeffFile
==
NULL
)
{
printf
(
"File %s open failed
\n
"
,
pobj
->
filename
);
return
-
1
;
return
-
1
;
}
}
...
...
examples/hdl4secnn/cnn/cnncell/cnncell_convolution.c
浏览文件 @
ae406627
...
@@ -87,7 +87,7 @@ endmodule
...
@@ -87,7 +87,7 @@ endmodule
/* wClk不算 */
/* wClk不算 */
#define INPUTPORTCOUNT 7
#define INPUTPORTCOUNT 7
#define PARAMCOUNT 1
4
#define PARAMCOUNT 1
3
typedef
struct
_sCNNCellConvolution
{
typedef
struct
_sCNNCellConvolution
{
OBJECT_HEADER
OBJECT_HEADER
INTERFACE_DECLARE
(
IHDL4SEUnit
)
INTERFACE_DECLARE
(
IHDL4SEUnit
)
...
...
examples/hdl4secnn/cnn/cnncell/cnncell_dataoutput.c
0 → 100644
浏览文件 @
ae406627
/*
** 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.
*/
/*
* cnncell_dataoutput.c
修改记录:
202107061554: rxh, initial version
*/
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "object.h"
#include "dlist.h"
#include "cnncell.h"
#include "bignumber.h"
#include "hdl4secell.h"
#define HDL4SEDEBUG 0
/*
(*
HDL4SE="LCOM",
CLSID="CC51DF54-F7AF-407C-A4B3-24D67139E17E",
softmodule="hdl4se"
*)
module hdl4se_cnn_dataoutput
#(parameter WIDTH=1, HEIGHT=1, COMPONENT=1000)
(
0 input wClk,
1 input nwReset,
2 input wDataReadEnable,
3 output wDataRead,
4 input wDataReadValid,
5 output[31:0] bDataReadAddr,
6 input[31:0] bDataReadData,
7 output wDataReadComplete
);
endmodule
*/
/* wClk不算 */
#define INPUTPORTCOUNT 4
#define PARAMCOUNT 3
typedef
struct
_sCNNCellDataOutput
{
OBJECT_HEADER
INTERFACE_DECLARE
(
IHDL4SEUnit
)
HDL4SEUNIT_VARDECLARE
DLIST_VARDECLARE
IHDL4SEModule
**
parent
;
char
*
name
;
IBigNumber
**
inputdata
;
IHDL4SEUnit
**
input_unit
[
INPUTPORTCOUNT
];
int
input_index
[
INPUTPORTCOUNT
];
union
{
struct
{
int
w
,
h
,
c
;
};
int
__param
[
PARAMCOUNT
];
};
int
index
;
int
index_out
;
int
complete
;
int
complete_out
;
int
cur_w
,
cur_h
,
cur_c
;
int
cur_w_out
,
cur_h_out
,
cur_c_out
;
}
sCNNCellDataOutput
;
OBJECT_FUNCDECLARE
(
cnncell_dataoutput
,
CLSID_CNN_DATAOUTPUT
);
HDL4SEUNIT_FUNCDECLARE
(
cnncell_dataoutput
,
CLSID_CNN_DATAOUTPUT
,
sCNNCellDataOutput
);
DLIST_FUNCIMPL
(
cnncell_dataoutput
,
CLSID_CNN_DATAOUTPUT
,
sCNNCellDataOutput
);
OBJECT_FUNCIMPL
(
cnncell_dataoutput
,
sCNNCellDataOutput
,
CLSID_CNN_DATAOUTPUT
);
QUERYINTERFACE_BEGIN
(
cnncell_dataoutput
,
CLSID_CNN_DATAOUTPUT
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sCNNCellDataOutput
)
QUERYINTERFACE_ITEM
(
IID_DLIST
,
IDList
,
sCNNCellDataOutput
)
QUERYINTERFACE_END
static
const
char
*
cnncell_dataoutputModuleInfo
()
{
return
"0.3.0-20210706.1554 CNN DataOutput cell"
;
}
static
int
cnncell_dataoutputCreate
(
const
PARAMITEM
*
pParams
,
int
paramcount
,
HOBJECT
*
pObject
)
{
sCNNCellDataOutput
*
pobj
;
int
i
;
pobj
=
(
sCNNCellDataOutput
*
)
malloc
(
sizeof
(
sCNNCellDataOutput
));
if
(
pobj
==
NULL
)
return
-
1
;
*
pObject
=
0
;
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_CNN_DATAOUTPUT
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
cnncell_dataoutput
,
hdl4se_unit
);
DLIST_VARINIT
(
pobj
,
cnncell_dataoutput
);
for
(
i
=
0
;
i
<
INPUTPORTCOUNT
;
i
++
)
pobj
->
input_unit
[
i
]
=
NULL
;
pobj
->
inputdata
=
bigintegerCreate
(
64
);
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
)
{
IBigNumber
**
temp
=
bigintegerCreate
(
32
);
if
(
temp
!=
NULL
)
{
const
char
*
nstr
;
const
char
*
lstr
;
int
j
;
lstr
=
(
const
char
*
)
pParams
[
i
].
pvalue
;
for
(
j
=
0
;
j
<
PARAMCOUNT
;
j
++
)
{
if
(
0
==
objectCall3
(
temp
,
AssignStr
,
lstr
,
&
nstr
,
0
))
{
objectCall1
(
temp
,
GetInt32
,
&
pobj
->
__param
[
j
]);
lstr
=
nstr
;
}
}
objectRelease
(
temp
);
}
}
}
/* 返回生成的对象 */
OBJECT_RETURN_GEN
(
cnncell_dataoutput
,
pobj
,
pObject
,
CLSID_CNN_DATAOUTPUT
);
return
EIID_OK
;
}
static
void
cnncell_dataoutputDestroy
(
HOBJECT
object
)
{
sCNNCellDataOutput
*
pobj
;
int
i
;
pobj
=
(
sCNNCellDataOutput
*
)
objectThis
(
object
);
if
(
pobj
->
name
!=
NULL
)
free
(
pobj
->
name
);
for
(
i
=
0
;
i
<
INPUTPORTCOUNT
;
i
++
)
objectRelease
(
pobj
->
input_unit
[
i
]);
objectRelease
(
pobj
->
inputdata
);
memset
(
pobj
,
0
,
sizeof
(
sCNNCellDataOutput
));
free
(
pobj
);
}
static
int
cnncell_dataoutputValid
(
HOBJECT
object
)
{
sCNNCellDataOutput
*
pobj
;
pobj
=
(
sCNNCellDataOutput
*
)
objectThis
(
object
);
return
1
;
}
static
int
cnncell_dataoutput_hdl4se_unit_GetName
(
HOBJECT
object
,
const
char
**
pname
)
{
sCNNCellDataOutput
*
pobj
;
pobj
=
(
sCNNCellDataOutput
*
)
objectThis
(
object
);
*
pname
=
pobj
->
name
;
return
0
;
}
static
int
cnncell_dataoutput_hdl4se_unit_Connect
(
HOBJECT
object
,
int
index
,
HOBJECT
from
,
int
fromindex
)
{
#define CONNECTPORT(ind, innerind) \
if (index == ind) { \
if (0 == objectQueryInterface(from, IID_HDL4SEUNIT, (void**)&unit)) { \
objectRelease(pobj->input_unit[innerind]); \
pobj->input_unit[innerind] = unit; \
pobj->input_index[innerind] = fromindex; \
} \
}
sCNNCellDataOutput
*
pobj
;
IHDL4SEUnit
**
unit
=
NULL
;
pobj
=
(
sCNNCellDataOutput
*
)
objectThis
(
object
);
CONNECTPORT
(
1
,
0
);
/* nwReset */
CONNECTPORT
(
2
,
1
);
/* wDataWriteEnable */
CONNECTPORT
(
4
,
2
);
/* wDataReadValid */
CONNECTPORT
(
6
,
3
);
/* bDataReadData */
return
0
;
}
static
int
cnncell_dataoutput_hdl4se_unit_GetValue
(
HOBJECT
object
,
int
index
,
int
width
,
IBigNumber
**
value
)
{
sCNNCellDataOutput
*
pobj
;
pobj
=
(
sCNNCellDataOutput
*
)
objectThis
(
object
);
if
(
index
==
3
)
{
if
(
width
<=
0
)
{
objectCall1
(
value
,
SetUnsigned
,
1
);
objectCall1
(
value
,
SetWidth
,
1
);
}
objectCall1
(
value
,
AssignInt32
,
!
pobj
->
complete_out
);
}
else
if
(
index
==
4
)
{
if
(
width
<=
0
)
{
objectCall1
(
value
,
SetUnsigned
,
1
);
objectCall1
(
value
,
SetWidth
,
32
);
}
objectCall1
(
value
,
AssignInt32
,
pobj
->
index_out
);
}
else
if
(
index
==
6
)
{
if
(
width
<=
0
)
{
objectCall1
(
value
,
SetUnsigned
,
1
);
objectCall1
(
value
,
SetWidth
,
1
);
}
objectCall1
(
value
,
AssignInt32
,
pobj
->
complete_out
);
}
return
0
;
}
static
int
cnncell_dataoutput_hdl4se_unit_ClkTick
(
HOBJECT
object
)
{
#define GetInputValue(ind, v) \
do { \
objectCall3(pobj->input_unit[ind], GetValue, pobj->input_index[ind], 32, pobj->inputdata); \
objectCall1(pobj->inputdata, GetUint32, &v); \
} while (0)
int
reset
;
sCNNCellDataOutput
*
pobj
;
pobj
=
(
sCNNCellDataOutput
*
)
objectThis
(
object
);
/* 复位时,index和complete都设置为零 */
GetInputValue
(
0
,
reset
);
if
(
reset
==
0
)
{
/* 低电平有效 */
pobj
->
index
=
0
;
pobj
->
complete
=
0
;
pobj
->
cur_w
=
0
;
pobj
->
cur_h
=
0
;
pobj
->
cur_c
=
0
;
}
else
{
if
(
pobj
->
complete_out
==
0
)
{
int
writeenable
;
GetInputValue
(
1
,
writeenable
);
if
(
writeenable
)
{
pobj
->
index
=
pobj
->
index_out
+
1
;
pobj
->
complete
=
0
;
if
(
pobj
->
cur_c_out
==
(
pobj
->
c
-
1
))
{
pobj
->
cur_c
=
0
;
if
(
pobj
->
cur_w_out
==
(
pobj
->
w
-
1
))
{
pobj
->
cur_w
=
0
;
if
(
pobj
->
cur_h_out
==
(
pobj
->
h
-
1
))
{
pobj
->
cur_h
=
0
;
pobj
->
complete
=
1
;
}
else
{
pobj
->
cur_h
=
pobj
->
cur_h_out
+
1
;
}
}
else
{
pobj
->
cur_w
=
pobj
->
cur_w_out
+
1
;
//pobj->cur_h = pobj->cur_h_out;
}
}
else
{
pobj
->
cur_c
=
pobj
->
cur_c_out
+
1
;
//pobj->cur_w = pobj->cur_w_out;
//pobj->cur_h = pobj->cur_h_out;
}
}
/*
else {
pobj->index = pobj->index_out;
pobj->complete = pobj->complete_out;
pobj->cur_w = pobj->cur_w_out;
pobj->cur_h = pobj->cur_h_out;
}*/
}
/*
else {
pobj->index = pobj->index_out;
pobj->complete = pobj->complete_out;
pobj->cur_w = pobj->cur_w_out;
pobj->cur_h = pobj->cur_h_out;
}*/
}
return
0
;
}
static
int
cnncell_dataoutput_hdl4se_unit_Setup
(
HOBJECT
object
)
{
sCNNCellDataOutput
*
pobj
;
pobj
=
(
sCNNCellDataOutput
*
)
objectThis
(
object
);
pobj
->
index_out
=
pobj
->
index
;
pobj
->
complete_out
=
pobj
->
complete
;
pobj
->
cur_w_out
=
pobj
->
cur_w
;
pobj
->
cur_h_out
=
pobj
->
cur_h
;
pobj
->
cur_c_out
=
pobj
->
cur_c
;
return
0
;
}
examples/hdl4secnn/cnn/cnncell/cnncell_lrn.c
0 → 100644
浏览文件 @
ae406627
/*
** 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.
*/
/*
* cnncell_lrn.c
修改记录:
202107061559: rxh, initial version
*/
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "object.h"
#include "dlist.h"
#include "cnncell.h"
#include "bignumber.h"
#include "hdl4secell.h"
#define HDL4SEDEBUG 0
/*
`define LRN_NormRegion_ACROSS_CHANNELS 0
`define LRN_NormRegion_WITHIN_CHANNEL 1
(*
HDL4SE="LCOM",
CLSID="59076B10-44F2-46E4-B950-179B8D2959B6",
softmodule="hdl4se"
*)
module hdl4se_cnn_lrn
#(parameter WIDTH=1024, HEIGHT=1000, COMPONENT=1,
LRN_NORMREGION = `LRN_NormRegion_ACROSS_CHANNELS)
(
0 input wClk,
1 input nwReset,
2 input wDataReadEnable,
3 output wDataRead,
4 input wDataReadValid,
5 output[31:0] bDataReadAddr,
6 input[31:0] bDataReadData,
7 output wDataReadComplete,
8 input wDataWriteEnable,
9 output wDataWrite,
10 output[31:0] bDataWriteAddr,
11 output[31:0] bDataWriteData,
12 output wDataWriteComplete
);
endmodule
*/
/* wClk不算 */
#define INPUTPORTCOUNT 5
#define PARAMCOUNT 4
typedef
struct
_sCNNCellLRN
{
OBJECT_HEADER
INTERFACE_DECLARE
(
IHDL4SEUnit
)
HDL4SEUNIT_VARDECLARE
DLIST_VARDECLARE
IHDL4SEModule
**
parent
;
char
*
name
;
IBigNumber
**
inputdata
;
IHDL4SEUnit
**
input_unit
[
INPUTPORTCOUNT
];
int
input_index
[
INPUTPORTCOUNT
];
union
{
struct
{
int
input_w
,
input_h
,
input_c
;
int
method
;
};
int
__param
[
PARAMCOUNT
];
};
int
datavalid
;
}
sCNNCellLRN
;
OBJECT_FUNCDECLARE
(
cnncell_lrn
,
CLSID_CNN_LRN
);
HDL4SEUNIT_FUNCDECLARE
(
cnncell_lrn
,
CLSID_CNN_LRN
,
sCNNCellLRN
);
DLIST_FUNCIMPL
(
cnncell_lrn
,
CLSID_CNN_LRN
,
sCNNCellLRN
);
OBJECT_FUNCIMPL
(
cnncell_lrn
,
sCNNCellLRN
,
CLSID_CNN_LRN
);
QUERYINTERFACE_BEGIN
(
cnncell_lrn
,
CLSID_CNN_LRN
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sCNNCellLRN
)
QUERYINTERFACE_ITEM
(
IID_DLIST
,
IDList
,
sCNNCellLRN
)
QUERYINTERFACE_END
static
const
char
*
cnncell_lrnModuleInfo
()
{
return
"0.3.0-20210706.1559 CNN LRN cell"
;
}
static
int
cnncell_lrnCreate
(
const
PARAMITEM
*
pParams
,
int
paramcount
,
HOBJECT
*
pObject
)
{
sCNNCellLRN
*
pobj
;
int
i
;
pobj
=
(
sCNNCellLRN
*
)
malloc
(
sizeof
(
sCNNCellLRN
));
if
(
pobj
==
NULL
)
return
-
1
;
*
pObject
=
0
;
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_CNN_LRN
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
cnncell_lrn
,
hdl4se_unit
);
DLIST_VARINIT
(
pobj
,
cnncell_lrn
);
for
(
i
=
0
;
i
<
INPUTPORTCOUNT
;
i
++
)
pobj
->
input_unit
[
i
]
=
NULL
;
pobj
->
inputdata
=
bigintegerCreate
(
64
);
pobj
->
datavalid
=
0
;
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
)
{
IBigNumber
**
temp
=
bigintegerCreate
(
32
);
if
(
temp
!=
NULL
)
{
const
char
*
nstr
;
const
char
*
lstr
;
int
j
;
lstr
=
(
const
char
*
)
pParams
[
i
].
pvalue
;
for
(
j
=
0
;
j
<
PARAMCOUNT
;
j
++
)
{
if
(
0
==
objectCall3
(
temp
,
AssignStr
,
lstr
,
&
nstr
,
0
))
{
objectCall1
(
temp
,
GetInt32
,
&
pobj
->
__param
[
j
]);
lstr
=
nstr
;
}
}
objectRelease
(
temp
);
}
}
}
/* 返回生成的对象 */
OBJECT_RETURN_GEN
(
cnncell_lrn
,
pobj
,
pObject
,
CLSID_CNN_LRN
);
return
EIID_OK
;
}
static
void
cnncell_lrnDestroy
(
HOBJECT
object
)
{
sCNNCellLRN
*
pobj
;
int
i
;
pobj
=
(
sCNNCellLRN
*
)
objectThis
(
object
);
if
(
pobj
->
name
!=
NULL
)
free
(
pobj
->
name
);
for
(
i
=
0
;
i
<
INPUTPORTCOUNT
;
i
++
)
objectRelease
(
pobj
->
input_unit
[
i
]);
objectRelease
(
pobj
->
inputdata
);
memset
(
pobj
,
0
,
sizeof
(
sCNNCellLRN
));
free
(
pobj
);
}
static
int
cnncell_lrnValid
(
HOBJECT
object
)
{
sCNNCellLRN
*
pobj
;
pobj
=
(
sCNNCellLRN
*
)
objectThis
(
object
);
return
1
;
}
static
int
cnncell_lrn_hdl4se_unit_GetName
(
HOBJECT
object
,
const
char
**
pname
)
{
sCNNCellLRN
*
pobj
;
pobj
=
(
sCNNCellLRN
*
)
objectThis
(
object
);
*
pname
=
pobj
->
name
;
return
0
;
}
static
int
cnncell_lrn_hdl4se_unit_Connect
(
HOBJECT
object
,
int
index
,
HOBJECT
from
,
int
fromindex
)
{
#define CONNECTPORT(ind, innerind) \
if (index == ind) { \
if (0 == objectQueryInterface(from, IID_HDL4SEUNIT, (void**)&unit)) { \
objectRelease(pobj->input_unit[innerind]); \
pobj->input_unit[innerind] = unit; \
pobj->input_index[innerind] = fromindex; \
} \
}
sCNNCellLRN
*
pobj
;
IHDL4SEUnit
**
unit
=
NULL
;
pobj
=
(
sCNNCellLRN
*
)
objectThis
(
object
);
CONNECTPORT
(
1
,
0
);
/* nwReset */
CONNECTPORT
(
2
,
1
);
/* wDataReadEnable */
CONNECTPORT
(
4
,
2
);
/* wDataReadValid */
CONNECTPORT
(
6
,
3
);
/* bDataReadData */
CONNECTPORT
(
8
,
4
);
/* wDataWriteEnable */
return
0
;
}
static
int
cnncell_lrn_hdl4se_unit_GetValue
(
HOBJECT
object
,
int
index
,
int
width
,
IBigNumber
**
value
)
{
int
i
;
int
outputwidth
=
0
;
sCNNCellLRN
*
pobj
;
pobj
=
(
sCNNCellLRN
*
)
objectThis
(
object
);
if
(
pobj
->
datavalid
==
0
)
{
pobj
->
datavalid
=
1
;
}
if
(
width
<=
0
)
{
objectCall1
(
value
,
SetUnsigned
,
1
);
objectCall1
(
value
,
SetWidth
,
outputwidth
);
}
// objectCall1(value, Assign, pobj->out_data);
return
0
;
}
static
int
cnncell_lrn_hdl4se_unit_ClkTick
(
HOBJECT
object
)
{
sCNNCellLRN
*
pobj
;
pobj
=
(
sCNNCellLRN
*
)
objectThis
(
object
);
return
0
;
}
static
int
cnncell_lrn_hdl4se_unit_Setup
(
HOBJECT
object
)
{
sCNNCellLRN
*
pobj
;
pobj
=
(
sCNNCellLRN
*
)
objectThis
(
object
);
pobj
->
datavalid
=
0
;
return
0
;
}
examples/hdl4secnn/cnn/cnncell/cnncell_pooling.c
0 → 100644
浏览文件 @
ae406627
/*
** 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.
*/
/*
* cnncell_pooling.c
修改记录:
202107061612: rxh, initial version
*/
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "object.h"
#include "dlist.h"
#include "cnncell.h"
#include "bignumber.h"
#include "hdl4secell.h"
#define HDL4SEDEBUG 0
/*
`define CNN_POOLING_MAX 0
`define CNN_POOLING_AVE 1
`define CNN_POOLING_RAN 2
(*
HDL4SE="LCOM",
CLSID="3B2E096B-5572-47E2-A4BC-3139419D3321",
softmodule="hdl4se"
*)
module hdl4se_cnn_pooling
#(parameter
INW=224, INH=224, INC=3,
OUTW=224, OUTH=224, OUTC=3,
W=7, H=7, SW=2, SH=2, PW=3, PH=3,
POOLING_METHOD=`CNN_POOLING_MAX)
(
0 input wClk,
1 input nwReset,
2 input wDataReadEnable,
3 output wDataRead,
4 input wDataReadValid,
5 output[31:0] bDataReadAddr,
6 input[31:0] bDataReadData,
7 output wDataReadComplete,
8 input wDataWriteEnable,
9 output wDataWrite,
10 output[31:0] bDataWriteAddr,
11 output[31:0] bDataWriteData,
12 output wDataWriteComplete
);
endmodule
*/
/* wClk不算 */
#define INPUTPORTCOUNT 5
#define PARAMCOUNT 13
typedef
struct
_sCNNCellPooling
{
OBJECT_HEADER
INTERFACE_DECLARE
(
IHDL4SEUnit
)
HDL4SEUNIT_VARDECLARE
DLIST_VARDECLARE
IHDL4SEModule
**
parent
;
char
*
name
;
IBigNumber
**
inputdata
;
IHDL4SEUnit
**
input_unit
[
INPUTPORTCOUNT
];
int
input_index
[
INPUTPORTCOUNT
];
union
{
struct
{
int
input_w
,
input_h
,
input_c
;
int
output_w
,
output_h
,
output_c
;
int
kw
,
kh
,
sw
,
sh
,
pw
,
ph
;
int
method
;
};
int
__param
[
PARAMCOUNT
];
};
int
datavalid
;
}
sCNNCellPooling
;
OBJECT_FUNCDECLARE
(
cnncell_pooling
,
CLSID_CNN_POOLING
);
HDL4SEUNIT_FUNCDECLARE
(
cnncell_pooling
,
CLSID_CNN_POOLING
,
sCNNCellPooling
);
DLIST_FUNCIMPL
(
cnncell_pooling
,
CLSID_CNN_POOLING
,
sCNNCellPooling
);
OBJECT_FUNCIMPL
(
cnncell_pooling
,
sCNNCellPooling
,
CLSID_CNN_POOLING
);
QUERYINTERFACE_BEGIN
(
cnncell_pooling
,
CLSID_CNN_POOLING
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sCNNCellPooling
)
QUERYINTERFACE_ITEM
(
IID_DLIST
,
IDList
,
sCNNCellPooling
)
QUERYINTERFACE_END
static
const
char
*
cnncell_poolingModuleInfo
()
{
return
"0.3.0-20210706.1612 CNN Pooling cell"
;
}
static
int
cnncell_poolingCreate
(
const
PARAMITEM
*
pParams
,
int
paramcount
,
HOBJECT
*
pObject
)
{
sCNNCellPooling
*
pobj
;
int
i
;
pobj
=
(
sCNNCellPooling
*
)
malloc
(
sizeof
(
sCNNCellPooling
));
if
(
pobj
==
NULL
)
return
-
1
;
*
pObject
=
0
;
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_CNN_POOLING
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
cnncell_pooling
,
hdl4se_unit
);
DLIST_VARINIT
(
pobj
,
cnncell_pooling
);
for
(
i
=
0
;
i
<
INPUTPORTCOUNT
;
i
++
)
pobj
->
input_unit
[
i
]
=
NULL
;
pobj
->
inputdata
=
bigintegerCreate
(
64
);
pobj
->
datavalid
=
0
;
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
)
{
IBigNumber
**
temp
=
bigintegerCreate
(
32
);
if
(
temp
!=
NULL
)
{
const
char
*
nstr
;
const
char
*
lstr
;
int
j
;
lstr
=
(
const
char
*
)
pParams
[
i
].
pvalue
;
for
(
j
=
0
;
j
<
PARAMCOUNT
;
j
++
)
{
if
(
0
==
objectCall3
(
temp
,
AssignStr
,
lstr
,
&
nstr
,
0
))
{
objectCall1
(
temp
,
GetInt32
,
&
pobj
->
__param
[
j
]);
lstr
=
nstr
;
}
}
objectRelease
(
temp
);
}
}
}
/* 返回生成的对象 */
OBJECT_RETURN_GEN
(
cnncell_pooling
,
pobj
,
pObject
,
CLSID_CNN_POOLING
);
return
EIID_OK
;
}
static
void
cnncell_poolingDestroy
(
HOBJECT
object
)
{
sCNNCellPooling
*
pobj
;
int
i
;
pobj
=
(
sCNNCellPooling
*
)
objectThis
(
object
);
if
(
pobj
->
name
!=
NULL
)
free
(
pobj
->
name
);
for
(
i
=
0
;
i
<
INPUTPORTCOUNT
;
i
++
)
objectRelease
(
pobj
->
input_unit
[
i
]);
objectRelease
(
pobj
->
inputdata
);
memset
(
pobj
,
0
,
sizeof
(
sCNNCellPooling
));
free
(
pobj
);
}
static
int
cnncell_poolingValid
(
HOBJECT
object
)
{
sCNNCellPooling
*
pobj
;
pobj
=
(
sCNNCellPooling
*
)
objectThis
(
object
);
return
1
;
}
static
int
cnncell_pooling_hdl4se_unit_GetName
(
HOBJECT
object
,
const
char
**
pname
)
{
sCNNCellPooling
*
pobj
;
pobj
=
(
sCNNCellPooling
*
)
objectThis
(
object
);
*
pname
=
pobj
->
name
;
return
0
;
}
static
int
cnncell_pooling_hdl4se_unit_Connect
(
HOBJECT
object
,
int
index
,
HOBJECT
from
,
int
fromindex
)
{
#define CONNECTPORT(ind, innerind) \
if (index == ind) { \
if (0 == objectQueryInterface(from, IID_HDL4SEUNIT, (void**)&unit)) { \
objectRelease(pobj->input_unit[innerind]); \
pobj->input_unit[innerind] = unit; \
pobj->input_index[innerind] = fromindex; \
} \
}
sCNNCellPooling
*
pobj
;
IHDL4SEUnit
**
unit
=
NULL
;
pobj
=
(
sCNNCellPooling
*
)
objectThis
(
object
);
CONNECTPORT
(
1
,
0
);
/* nwReset */
CONNECTPORT
(
2
,
1
);
/* wDataReadEnable */
CONNECTPORT
(
4
,
2
);
/* wDataReadValid */
CONNECTPORT
(
6
,
3
);
/* bDataReadData */
CONNECTPORT
(
8
,
4
);
/* wDataWriteEnable */
return
0
;
}
static
int
cnncell_pooling_hdl4se_unit_GetValue
(
HOBJECT
object
,
int
index
,
int
width
,
IBigNumber
**
value
)
{
int
i
;
int
outputwidth
=
0
;
sCNNCellPooling
*
pobj
;
pobj
=
(
sCNNCellPooling
*
)
objectThis
(
object
);
if
(
pobj
->
datavalid
==
0
)
{
pobj
->
datavalid
=
1
;
}
if
(
width
<=
0
)
{
objectCall1
(
value
,
SetUnsigned
,
1
);
objectCall1
(
value
,
SetWidth
,
outputwidth
);
}
// objectCall1(value, Assign, pobj->out_data);
return
0
;
}
static
int
cnncell_pooling_hdl4se_unit_ClkTick
(
HOBJECT
object
)
{
sCNNCellPooling
*
pobj
;
pobj
=
(
sCNNCellPooling
*
)
objectThis
(
object
);
return
0
;
}
static
int
cnncell_pooling_hdl4se_unit_Setup
(
HOBJECT
object
)
{
sCNNCellPooling
*
pobj
;
pobj
=
(
sCNNCellPooling
*
)
objectThis
(
object
);
pobj
->
datavalid
=
0
;
return
0
;
}
examples/hdl4secnn/cnn/cnncell/cnncell_softmax.c
0 → 100644
浏览文件 @
ae406627
/*
** 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.
*/
/*
* cnncell_softmax.c
修改记录:
202107061618: rxh, initial version
*/
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "object.h"
#include "dlist.h"
#include "cnncell.h"
#include "bignumber.h"
#include "hdl4secell.h"
#define HDL4SEDEBUG 0
/*
(*
HDL4SE="LCOM",
CLSID="5B646EF4-FE9E-44BF-925F-AF98566AEB23",
softmodule="hdl4se"
*)
module hdl4se_cnn_softmax
#(parameter WIDTH=224, HEIGHT=224, COMPONENT=3)
(
0 input wClk,
1 input nwReset,
2 input wDataReadEnable,
3 output wDataRead,
4 input wDataReadValid,
5 output[31:0] bDataReadAddr,
6 input[31:0] bDataReadData,
7 output wDataReadComplete,
8 input wDataWriteEnable,
9 output wDataWrite,
10 output[31:0] bDataWriteAddr,
11 output[31:0] bDataWriteData,
12 output wDataWriteComplete
);
endmodule
*/
/* wClk不算 */
#define INPUTPORTCOUNT 5
#define PARAMCOUNT 3
typedef
struct
_sCNNCellSoftmax
{
OBJECT_HEADER
INTERFACE_DECLARE
(
IHDL4SEUnit
)
HDL4SEUNIT_VARDECLARE
DLIST_VARDECLARE
IHDL4SEModule
**
parent
;
char
*
name
;
IBigNumber
**
inputdata
;
IHDL4SEUnit
**
input_unit
[
INPUTPORTCOUNT
];
int
input_index
[
INPUTPORTCOUNT
];
union
{
struct
{
int
w
,
h
,
c
;
};
int
__param
[
PARAMCOUNT
];
};
int
datavalid
;
}
sCNNCellSoftmax
;
OBJECT_FUNCDECLARE
(
cnncell_softmax
,
CLSID_CNN_SOFTMAX
);
HDL4SEUNIT_FUNCDECLARE
(
cnncell_softmax
,
CLSID_CNN_SOFTMAX
,
sCNNCellSoftmax
);
DLIST_FUNCIMPL
(
cnncell_softmax
,
CLSID_CNN_SOFTMAX
,
sCNNCellSoftmax
);
OBJECT_FUNCIMPL
(
cnncell_softmax
,
sCNNCellSoftmax
,
CLSID_CNN_SOFTMAX
);
QUERYINTERFACE_BEGIN
(
cnncell_softmax
,
CLSID_CNN_SOFTMAX
)
QUERYINTERFACE_ITEM
(
IID_HDL4SEUNIT
,
IHDL4SEUnit
,
sCNNCellSoftmax
)
QUERYINTERFACE_ITEM
(
IID_DLIST
,
IDList
,
sCNNCellSoftmax
)
QUERYINTERFACE_END
static
const
char
*
cnncell_softmaxModuleInfo
()
{
return
"0.3.0-20210706.1618 CNN Softmax cell"
;
}
static
int
cnncell_softmaxCreate
(
const
PARAMITEM
*
pParams
,
int
paramcount
,
HOBJECT
*
pObject
)
{
sCNNCellSoftmax
*
pobj
;
int
i
;
pobj
=
(
sCNNCellSoftmax
*
)
malloc
(
sizeof
(
sCNNCellSoftmax
));
if
(
pobj
==
NULL
)
return
-
1
;
*
pObject
=
0
;
HDL4SEUNIT_VARINIT
(
pobj
,
CLSID_CNN_SOFTMAX
);
INTERFACE_INIT
(
IHDL4SEUnit
,
pobj
,
cnncell_softmax
,
hdl4se_unit
);
DLIST_VARINIT
(
pobj
,
cnncell_softmax
);
for
(
i
=
0
;
i
<
INPUTPORTCOUNT
;
i
++
)
pobj
->
input_unit
[
i
]
=
NULL
;
pobj
->
inputdata
=
bigintegerCreate
(
64
);
pobj
->
datavalid
=
0
;
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
)
{
IBigNumber
**
temp
=
bigintegerCreate
(
32
);
if
(
temp
!=
NULL
)
{
const
char
*
nstr
;
const
char
*
lstr
;
int
j
;
lstr
=
(
const
char
*
)
pParams
[
i
].
pvalue
;
for
(
j
=
0
;
j
<
PARAMCOUNT
;
j
++
)
{
if
(
0
==
objectCall3
(
temp
,
AssignStr
,
lstr
,
&
nstr
,
0
))
{
objectCall1
(
temp
,
GetInt32
,
&
pobj
->
__param
[
j
]);
lstr
=
nstr
;
}
}
objectRelease
(
temp
);
}
}
}
/* 返回生成的对象 */
OBJECT_RETURN_GEN
(
cnncell_softmax
,
pobj
,
pObject
,
CLSID_CNN_SOFTMAX
);
return
EIID_OK
;
}
static
void
cnncell_softmaxDestroy
(
HOBJECT
object
)
{
sCNNCellSoftmax
*
pobj
;
int
i
;
pobj
=
(
sCNNCellSoftmax
*
)
objectThis
(
object
);
if
(
pobj
->
name
!=
NULL
)
free
(
pobj
->
name
);
for
(
i
=
0
;
i
<
INPUTPORTCOUNT
;
i
++
)
objectRelease
(
pobj
->
input_unit
[
i
]);
objectRelease
(
pobj
->
inputdata
);
memset
(
pobj
,
0
,
sizeof
(
sCNNCellSoftmax
));
free
(
pobj
);
}
static
int
cnncell_softmaxValid
(
HOBJECT
object
)
{
sCNNCellSoftmax
*
pobj
;
pobj
=
(
sCNNCellSoftmax
*
)
objectThis
(
object
);
return
1
;
}
static
int
cnncell_softmax_hdl4se_unit_GetName
(
HOBJECT
object
,
const
char
**
pname
)
{
sCNNCellSoftmax
*
pobj
;
pobj
=
(
sCNNCellSoftmax
*
)
objectThis
(
object
);
*
pname
=
pobj
->
name
;
return
0
;
}
static
int
cnncell_softmax_hdl4se_unit_Connect
(
HOBJECT
object
,
int
index
,
HOBJECT
from
,
int
fromindex
)
{
#define CONNECTPORT(ind, innerind) \
if (index == ind) { \
if (0 == objectQueryInterface(from, IID_HDL4SEUNIT, (void**)&unit)) { \
objectRelease(pobj->input_unit[innerind]); \
pobj->input_unit[innerind] = unit; \
pobj->input_index[innerind] = fromindex; \
} \
}
sCNNCellSoftmax
*
pobj
;
IHDL4SEUnit
**
unit
=
NULL
;
pobj
=
(
sCNNCellSoftmax
*
)
objectThis
(
object
);
CONNECTPORT
(
1
,
0
);
/* nwReset */
CONNECTPORT
(
2
,
1
);
/* wDataReadEnable */
CONNECTPORT
(
4
,
2
);
/* wDataReadValid */
CONNECTPORT
(
6
,
3
);
/* bDataReadData */
CONNECTPORT
(
8
,
4
);
/* wDataWriteEnable */
return
0
;
}
static
int
cnncell_softmax_hdl4se_unit_GetValue
(
HOBJECT
object
,
int
index
,
int
width
,
IBigNumber
**
value
)
{
int
i
;
int
outputwidth
=
0
;
sCNNCellSoftmax
*
pobj
;
pobj
=
(
sCNNCellSoftmax
*
)
objectThis
(
object
);
if
(
pobj
->
datavalid
==
0
)
{
pobj
->
datavalid
=
1
;
}
if
(
width
<=
0
)
{
objectCall1
(
value
,
SetUnsigned
,
1
);
objectCall1
(
value
,
SetWidth
,
outputwidth
);
}
// objectCall1(value, Assign, pobj->out_data);
return
0
;
}
static
int
cnncell_softmax_hdl4se_unit_ClkTick
(
HOBJECT
object
)
{
sCNNCellSoftmax
*
pobj
;
pobj
=
(
sCNNCellSoftmax
*
)
objectThis
(
object
);
return
0
;
}
static
int
cnncell_softmax_hdl4se_unit_Setup
(
HOBJECT
object
)
{
sCNNCellSoftmax
*
pobj
;
pobj
=
(
sCNNCellSoftmax
*
)
objectThis
(
object
);
pobj
->
datavalid
=
0
;
return
0
;
}
examples/hdl4secnn/cnn/verilog/cnncell.v
浏览文件 @
ae406627
...
@@ -89,12 +89,6 @@ module hdl4se_cnn_buf
...
@@ -89,12 +89,6 @@ module hdl4se_cnn_buf
);
);
endmodule
endmodule
/*
// {9AA0D743-5FFB-4649-ACEC-4B4675AE2A57}
DEFINE_GUID(<<name>>,
0x9aa0d743, 0x5ffb, 0x4649, 0xac, 0xec, 0x4b, 0x46, 0x75, 0xae, 0x2a, 0x57);
*/
(
*
(
*
HDL4SE
=
"LCOM"
,
HDL4SE
=
"LCOM"
,
CLSID
=
"9AA0D743-5FFB-4649-ACEC-4B4675AE2A57"
,
CLSID
=
"9AA0D743-5FFB-4649-ACEC-4B4675AE2A57"
,
...
@@ -373,12 +367,6 @@ module hdl4se_cnn_concat4
...
@@ -373,12 +367,6 @@ module hdl4se_cnn_concat4
endmodule
endmodule
/*
// {59076B10-44F2-46E4-B950-179B8D2959B6}
DEFINE_GUID(<<name>>,
0x59076b10, 0x44f2, 0x46e4, 0xb9, 0x50, 0x17, 0x9b, 0x8d, 0x29, 0x59, 0xb6);
*/
`define
LRN_NormRegion_ACROSS_CHANNELS 0
`define
LRN_NormRegion_ACROSS_CHANNELS 0
`define
LRN_NormRegion_WITHIN_CHANNEL 1
`define
LRN_NormRegion_WITHIN_CHANNEL 1
(
*
(
*
...
@@ -417,23 +405,18 @@ module hdl4se_cnn_lrn
...
@@ -417,23 +405,18 @@ module hdl4se_cnn_lrn
endmodule
endmodule
/*
// {3B2E096B-5572-47E2-A4BC-3139419D3321}
DEFINE_GUID(<<name>>,
0x3b2e096b, 0x5572, 0x47e2, 0xa4, 0xbc, 0x31, 0x39, 0x41, 0x9d, 0x33, 0x21);
*/
`define
CNN_POOLING_MAX 0
`define
CNN_POOLING_MAX 0
`define
CNN_POOLING_AVE 1
`define
CNN_POOLING_AVE 1
`define
CNN_POOLING_RAN 2
`define
CNN_POOLING_RAN 2
(
*
(
*
HDL4SE
=
"LCOM"
,
HDL4SE
=
"LCOM"
,
CLSID
=
"3B2E096B-5572-47E2-A4BC-3139419D3321"
,
CLSID
=
"3B2E096B-5572-47E2-A4BC-3139419D3321"
,
softmodule
=
"hdl4se"
softmodule
=
"hdl4se"
*
)
*
)
module
hdl4se_cnn_pooling
module
hdl4se_cnn_pooling
#(
parameter
WIDTH
=
224
,
HEIGHT
=
224
,
COMPONENT
=
3
,
#(
parameter
INW
=
224
,
INH
=
224
,
INC
=
3
,
OUTW
=
224
,
OUTH
=
224
,
OUTC
=
3
,
W
=
7
,
H
=
7
,
SW
=
2
,
SH
=
2
,
PW
=
3
,
PH
=
3
,
W
=
7
,
H
=
7
,
SW
=
2
,
SH
=
2
,
PW
=
3
,
PH
=
3
,
POOLING_METHOD
=
`CNN_POOLING_MAX
)
POOLING_METHOD
=
`CNN_POOLING_MAX
)
(
(
...
@@ -464,11 +447,6 @@ module hdl4se_cnn_pooling
...
@@ -464,11 +447,6 @@ module hdl4se_cnn_pooling
endmodule
endmodule
/*
// {5B646EF4-FE9E-44BF-925F-AF98566AEB23}
DEFINE_GUID(<<name>>,
0x5b646ef4, 0xfe9e, 0x44bf, 0x92, 0x5f, 0xaf, 0x98, 0x56, 0x6a, 0xeb, 0x23);
*/
(
*
(
*
HDL4SE
=
"LCOM"
,
HDL4SE
=
"LCOM"
,
CLSID
=
"5B646EF4-FE9E-44BF-925F-AF98566AEB23"
,
CLSID
=
"5B646EF4-FE9E-44BF-925F-AF98566AEB23"
,
...
@@ -504,11 +482,6 @@ module hdl4se_cnn_softmax
...
@@ -504,11 +482,6 @@ module hdl4se_cnn_softmax
endmodule
endmodule
/*
// {70B19638-03B9-466D-972A-5D31ABD448D4}
DEFINE_GUID(<<name>>,
0x70b19638, 0x3b9, 0x466d, 0x97, 0x2a, 0x5d, 0x31, 0xab, 0xd4, 0x48, 0xd4);
*/
(
*
(
*
HDL4SE
=
"LCOM"
,
HDL4SE
=
"LCOM"
,
CLSID
=
"70B19638-03B9-466D-972A-5D31ABD448D4"
,
CLSID
=
"70B19638-03B9-466D-972A-5D31ABD448D4"
,
...
@@ -529,12 +502,6 @@ module hdl4se_cnn_datasource
...
@@ -529,12 +502,6 @@ module hdl4se_cnn_datasource
endmodule
endmodule
/*
// {CC51DF54-F7AF-407C-A4B3-24D67139E17E}
DEFINE_GUID(<<name>>,
0xcc51df54, 0xf7af, 0x407c, 0xa4, 0xb3, 0x24, 0xd6, 0x71, 0x39, 0xe1, 0x7e);
*/
(
*
(
*
HDL4SE
=
"LCOM"
,
HDL4SE
=
"LCOM"
,
CLSID
=
"CC51DF54-F7AF-407C-A4B3-24D67139E17E"
,
CLSID
=
"CC51DF54-F7AF-407C-A4B3-24D67139E17E"
,
...
...
examples/hdl4secnn/googlenet/verilog/googlenet.c
浏览文件 @
ae406627
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
/*
/*
* Created by HDL4SE @ Tue Jul 6
08:45:3
6 2021
* Created by HDL4SE @ Tue Jul 6
16:31:2
6 2021
* Don't edit it.
* Don't edit it.
*/
*/
...
@@ -6017,7 +6017,7 @@ IHDL4SEUnit** hdl4seCreate_001D(IHDL4SEModule** parent, const char* instancepara
...
@@ -6017,7 +6017,7 @@ IHDL4SEUnit** hdl4seCreate_001D(IHDL4SEModule** parent, const char* instancepara
objectCall3
(
modules
[
223
],
Connect
,
10
,
nets
[
1304
],
0
);
objectCall3
(
modules
[
223
],
Connect
,
10
,
nets
[
1304
],
0
);
objectCall3
(
modules
[
223
],
Connect
,
11
,
nets
[
1305
],
0
);
objectCall3
(
modules
[
223
],
Connect
,
11
,
nets
[
1305
],
0
);
objectCall3
(
modules
[
223
],
Connect
,
12
,
nets
[
1306
],
0
);
objectCall3
(
modules
[
223
],
Connect
,
12
,
nets
[
1306
],
0
);
modules
[
224
]
=
hdl4seCreateUnit2
(
module
,
"5B646EF4-FE9E-44BF-925F-AF98566AEB23"
,
"1, 1, 1000
, 1, 1, 1000
"
,
"softmax_168"
);
modules
[
224
]
=
hdl4seCreateUnit2
(
module
,
"5B646EF4-FE9E-44BF-925F-AF98566AEB23"
,
"1, 1, 1000"
,
"softmax_168"
);
objectCall3
(
modules
[
224
],
Connect
,
0
,
unit
,
0
);
objectCall3
(
modules
[
224
],
Connect
,
0
,
unit
,
0
);
objectCall3
(
modules
[
224
],
Connect
,
1
,
unit
,
1
);
objectCall3
(
modules
[
224
],
Connect
,
1
,
unit
,
1
);
objectCall3
(
modules
[
224
],
Connect
,
2
,
nets
[
1307
],
0
);
objectCall3
(
modules
[
224
],
Connect
,
2
,
nets
[
1307
],
0
);
...
...
examples/hdl4secnn/googlenet/verilog/googlenet.dump.v
浏览文件 @
ae406627
...
@@ -865,9 +865,12 @@ endmodule
...
@@ -865,9 +865,12 @@ endmodule
*
)
*
)
module
hdl4se_cnn_pooling
module
hdl4se_cnn_pooling
#(
#(
parameter
WIDTH
=
224
,
parameter
INW
=
224
,
parameter
HEIGHT
=
224
,
parameter
INH
=
224
,
parameter
COMPONENT
=
3
,
parameter
INC
=
3
,
parameter
OUTW
=
224
,
parameter
OUTH
=
224
,
parameter
OUTC
=
3
,
parameter
W
=
7
,
parameter
W
=
7
,
parameter
H
=
7
,
parameter
H
=
7
,
parameter
SW
=
2
,
parameter
SW
=
2
,
...
@@ -3231,8 +3234,7 @@ module googlenet
...
@@ -3231,8 +3234,7 @@ module googlenet
hdl4se_cnn_buf
#(
32
,
1000
)
cnn_buf_167
(
wClk
,
nwReset
,
wDataReadEnable_168
,
wDataRead_168
,
wDataReadValid_168
,
bDataReadAddr_168
hdl4se_cnn_buf
#(
32
,
1000
)
cnn_buf_167
(
wClk
,
nwReset
,
wDataReadEnable_168
,
wDataRead_168
,
wDataReadValid_168
,
bDataReadAddr_168
,
bDataReadData_168
,
wDataReadComplete_168
,
wDataWriteEnable_167
,
wDataWrite_167
,
bDataWriteAddr_167
,
bDataReadData_168
,
wDataReadComplete_168
,
wDataWriteEnable_167
,
wDataWrite_167
,
bDataWriteAddr_167
,
bDataWriteData_167
,
wDataWriteComplete_167
);
,
bDataWriteData_167
,
wDataWriteComplete_167
);
hdl4se_cnn_softmax
#(
1
,
1
,
1000
,
1
,
1
,
1000
hdl4se_cnn_softmax
#(
1
,
1
,
1000
)
softmax_168
(
wClk
,
nwReset
,
wDataReadEnable_168
,
wDataRead_168
,
wDataReadValid_168
,
bDataReadAddr_168
)
softmax_168
(
wClk
,
nwReset
,
wDataReadEnable_168
,
wDataRead_168
,
wDataReadValid_168
,
bDataReadAddr_168
,
bDataReadData_168
,
wDataReadComplete_168
,
wDataWriteEnable_168
,
wDataWrite_168
,
bDataWriteAddr_168
,
bDataReadData_168
,
wDataReadComplete_168
,
wDataWriteEnable_168
,
wDataWrite_168
,
bDataWriteAddr_168
,
bDataWriteData_168
,
wDataWriteComplete_168
);
,
bDataWriteData_168
,
wDataWriteComplete_168
);
hdl4se_cnn_buf
#(
32
,
1000
)
cnn_buf_168
(
wClk
,
nwReset
,
wDstDataReadEnable
,
wDstDataRead
,
wDstDataReadValid
,
bDstDataReadAddr
hdl4se_cnn_buf
#(
32
,
1000
)
cnn_buf_168
(
wClk
,
nwReset
,
wDstDataReadEnable
,
wDstDataRead
,
wDstDataReadValid
,
bDstDataReadAddr
...
...
examples/hdl4secnn/googlenet/verilog/googlenet.v
浏览文件 @
ae406627
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
/*
/*
* 由googlenet程序生成
* 由googlenet程序生成
* 生成时间:Tue Jul 6 1
0:26:28
2021
* 生成时间:Tue Jul 6 1
6:30:30
2021
* 请不要手工修改。
* 请不要手工修改。
*/
*/
`include
"hdl4secell.v"
`include
"hdl4secell.v"
...
@@ -6751,8 +6751,7 @@ module googlenet(
...
@@ -6751,8 +6751,7 @@ module googlenet(
/* 归一化分类层 168:loss3/loss3 */
/* 归一化分类层 168:loss3/loss3 */
hdl4se_cnn_softmax
#(
hdl4se_cnn_softmax
#(
1
,
1
,
1000
,
/* 输入大小 */
1
,
1
,
1000
/* 输入输出大小 */
1
,
1
,
1000
/* 输出大小 */
)
)
softmax_168
(
softmax_168
(
wClk
,
nwReset
,
wClk
,
nwReset
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录