Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
饶先宏
hdl4se
提交
b0980fd1
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 搜索 >>
提交
b0980fd1
编写于
8月 02, 2021
作者:
饶先宏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
202108020625 lrn: real parameter type
上级
59673dde
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
3931 addition
and
3606 deletion
+3931
-3606
examples/hdl4secnn/cnn/cnn/cnn.c
examples/hdl4secnn/cnn/cnn/cnn.c
+0
-2
examples/hdl4secnn/cnn/cnncell/cnncell_lrn.c
examples/hdl4secnn/cnn/cnncell/cnncell_lrn.c
+47
-2
examples/hdl4secnn/googlenet/verilog/googlenet.c
examples/hdl4secnn/googlenet/verilog/googlenet.c
+3
-3
examples/hdl4secnn/googlenet/verilog/googlenet.dump.v
examples/hdl4secnn/googlenet/verilog/googlenet.dump.v
+7
-9
examples/hdl4secnn/googlenet/verilog/googlenet.v
examples/hdl4secnn/googlenet/verilog/googlenet.v
+1
-3
hdl4secell/include/hdl4secell.h
hdl4secell/include/hdl4secell.h
+2
-0
hdl4secell/src/hdl4se_general.c
hdl4secell/src/hdl4se_general.c
+7
-0
parser/verilog_moduleinst.c
parser/verilog_moduleinst.c
+13
-4
parser/verilog_parser.c
parser/verilog_parser.c
+3830
-3580
parser/verilog_parser.y
parser/verilog_parser.y
+20
-3
parser/verilog_parsetree.h
parser/verilog_parsetree.h
+1
-0
未找到文件。
examples/hdl4secnn/cnn/cnn/cnn.c
浏览文件 @
b0980fd1
...
...
@@ -981,11 +981,9 @@ int node_setup(cnn_layer_node* node, FILE * pCodeFile)
fprintf
(
pCodeFile
,
"
\t
hdl4se_cnn_lrn #(
\n
"
"
\t\t
%4d, %4d, %4d,
\t
/* 输入大小 */
\n
"
"
\t\t
%4d, %4d, %4d,
\t
/* 输出大小 */
\n
"
"
\t\t
%4d, %f, %f, %f,
\t
/* locasize, k, alpha, beta */
\n
"
"
\t\t
`%s)
\t
/* 模式 */
\n
"
,
node
->
inputsize
[
0
][
1
],
node
->
inputsize
[
0
][
0
],
node
->
inputsize
[
0
][
2
],
node
->
outputsize
[
0
][
1
],
node
->
outputsize
[
0
][
0
],
node
->
outputsize
[
0
][
2
],
pInfo
->
local_size
,
pInfo
->
k
,
pInfo
->
alpha
,
pInfo
->
beta
,
norm_region_name
[
pInfo
->
norm_region
]
);
...
...
examples/hdl4secnn/cnn/cnncell/cnncell_lrn.c
浏览文件 @
b0980fd1
...
...
@@ -33,7 +33,7 @@
* cnncell_lrn.c
修改记录:
202107061559: rxh, initial version
202107181112: rxh,
initial
version
202107181112: rxh,
macro
version
*/
#include "stdlib.h"
#include "stdio.h"
...
...
@@ -60,13 +60,25 @@ IDLIST
VID
(
wDataWriteEnable
),
VID
(
wDataWrite
),
VID
(
bDataWriteData
),
VID
(
index
),
VID
(
state
),
END_IDLIST
MODULE_DECLARE
(
cnncell_lrn
)
int
w
,
h
,
c
;
int
region
;
int
local_size
;
float
k
,
alpha
,
beta
;
float
*
buf
;
float
*
square
;
END_MODULE_DECLARE
(
cnncell_lrn
)
enum
cnncell_lrn_state
{
LRN_READ
,
LRN_CALC
,
LRN_WRITE
,
};
DEFINE_FUNC
(
cnncell_lrn_gen_read
)
{
vput
(
wDataRead
,
1
);
}
END_DEFINE_FUNC
...
...
@@ -76,16 +88,46 @@ DEFINE_FUNC(cnncell_lrn_gen_write) {
}
END_DEFINE_FUNC
DEFINE_FUNC
(
cnncell_lrn_clktick
)
{
int
state
=
vget
(
state
);
int
index
=
vget
(
index
);
if
(
vget
(
nwReset
)
==
0
)
{
state
=
LRN_READ
;
index
=
0
;
}
else
if
(
state
==
LRN_READ
)
{
}
else
if
(
state
==
LRN_CALC
)
{
}
else
if
(
state
==
LRN_WRITE
)
{
}
vput
(
state
,
state
);
vput
(
index
,
index
);
}
END_DEFINE_FUNC
DEFINE_FUNC
(
cnncell_lrn_deinit
)
{
if
(
pobj
->
buf
!=
NULL
)
free
(
pobj
->
buf
);
if
(
pobj
->
square
!=
NULL
)
free
(
pobj
->
square
);
}
END_DEFINE_FUNC
MODULE_INIT
(
cnncell_lrn
)
pobj
->
w
=
(
int
)
MODULE_PARAM
(
0
);
pobj
->
h
=
(
int
)
MODULE_PARAM
(
1
);
pobj
->
c
=
(
int
)
MODULE_PARAM
(
2
);
pobj
->
region
=
(
int
)
MODULE_PARAM
(
3
);
pobj
->
local_size
=
(
int
)
MODULE_PARAM
(
3
);
pobj
->
k
=
(
float
)
MODULE_PARAM_REAL
(
4
);
pobj
->
alpha
=
(
float
)
MODULE_PARAM_REAL
(
5
);
pobj
->
beta
=
(
float
)
MODULE_PARAM_REAL
(
6
);
pobj
->
region
=
(
int
)
MODULE_PARAM
(
7
);
pobj
->
buf
=
(
float
*
)
malloc
(
pobj
->
c
*
sizeof
(
float
));
pobj
->
square
=
(
float
*
)
malloc
((
pobj
->
c
+
pobj
->
local_size
)
*
sizeof
(
float
));
if
((
pobj
->
buf
==
NULL
)
||
(
pobj
->
square
==
NULL
))
return
-
1
;
PORT_IN
(
wClk
,
1
);
PORT_IN
(
nwReset
,
1
);
...
...
@@ -98,6 +140,9 @@ MODULE_INIT(cnncell_lrn)
GPORT_OUT
(
wDataWrite
,
1
,
cnncell_lrn_gen_write
);
GPORT_OUT
(
bDataWriteData
,
32
,
cnncell_lrn_gen_write
);
REG
(
index
,
16
);
REG
(
state
,
3
);
CLKTICK_FUNC
(
cnncell_lrn_clktick
);
DEINIT_FUNC
(
cnncell_lrn_deinit
);
...
...
examples/hdl4secnn/googlenet/verilog/googlenet.c
浏览文件 @
b0980fd1
...
...
@@ -31,7 +31,7 @@
/*
* Created by HDL4SE @
Sun Aug 1 20:55:40
2021
* Created by HDL4SE @
Mon Aug 2 06:11:45
2021
* Don't edit it.
*/
...
...
@@ -3143,7 +3143,7 @@ GEN_MODULE_INIT
", wDataWrite_4, bDataWriteData_4"
);
CELL_INST
(
"59076B10-44F2-46E4-B950-179B8D2959B6"
,
/* hdl4se_cnn_lrn */
"lrn_5"
,
"32'h38, 32'h38, 32'h40, 32'h
38, 32'h38, 32'h40, 32'h5, 32'sh1, 32'sh0, 32'sh
0, 32'h0"
,
"32'h38, 32'h38, 32'h40, 32'h
5, 1.000000, 0.000100, 0.75000
0, 32'h0"
,
"wClk, nwReset, wDataRead_5, wDataReadValid_5, bDataReadData_5, wDataWriteEnable_5"
", wDataWrite_5, bDataWriteData_5"
);
CELL_INST
(
"230946EF-3EC1-43EC-A841-CDE8A9E97314"
,
/* hdl4se_fifo */
...
...
@@ -3191,7 +3191,7 @@ GEN_MODULE_INIT
", wDataWrite_8, bDataWriteData_8"
);
CELL_INST
(
"59076B10-44F2-46E4-B950-179B8D2959B6"
,
/* hdl4se_cnn_lrn */
"lrn_10"
,
"32'h38, 32'h38, 32'hc0, 32'h
38, 32'h38, 32'hc0, 32'h5, 32'sh1, 32'sh0, 32'sh
0, 32'h0"
,
"32'h38, 32'h38, 32'hc0, 32'h
5, 1.000000, 0.000100, 0.75000
0, 32'h0"
,
"wClk, nwReset, wDataRead_10, wDataReadValid_10, bDataReadData_10, wDataWriteEnable_10"
", wDataWrite_10, bDataWriteData_10"
);
CELL_INST
(
"230946EF-3EC1-43EC-A841-CDE8A9E97314"
,
/* hdl4se_fifo */
...
...
examples/hdl4secnn/googlenet/verilog/googlenet.dump.v
浏览文件 @
b0980fd1
...
...
@@ -592,9 +592,9 @@ module hdl4se_cnn_lrn
parameter
HEIGHT
=
32'h3e8
,
parameter
COMPONENT
=
32'h1
,
parameter
localsize
=
32'h5
,
parameter
real
k
=
32
'
sh1
,
parameter
real
alpha
=
32
'
sh0
,
parameter
real
beta
=
32
'
sh0
,
parameter
real
k
=
<
type
=
1
>
,
parameter
real
alpha
=
<
type
=
1
>
,
parameter
real
beta
=
<
type
=
1
>
,
parameter
LRN_NORMREGION
=
32'h0
)
(
...
...
@@ -2273,9 +2273,8 @@ module googlenet
,
wDataWrite_4
,
bDataWriteData_4
);
hdl4se_fifo
#(
32'h20
,
32'h80
)
cnn_buf_4
(
wClk
,
nwReset
,
wDataRead_5
,
wDataReadValid_5
,
bDataReadData_5
,
wDataWriteEnable_4
,
wDataWrite_4
,
bDataWriteData_4
);
hdl4se_cnn_lrn
#(
32'h38
,
32'h38
,
32'h40
,
32'h38
,
32'h38
,
32'h40
,
32'h5
,
32
'
sh1
,
32
'
sh0
,
32
'
sh0
,
32'h0
)
lrn_5
(
wClk
,
nwReset
,
wDataRead_5
,
wDataReadValid_5
,
bDataReadData_5
,
wDataWriteEnable_5
hdl4se_cnn_lrn
#(
32'h38
,
32'h38
,
32'h40
,
32'h5
,
<
type
=
1
>
,
<
type
=
1
>
,
<
type
=
1
>
,
32'h0
)
lrn_5
(
wClk
,
nwReset
,
wDataRead_5
,
wDataReadValid_5
,
bDataReadData_5
,
wDataWriteEnable_5
,
wDataWrite_5
,
bDataWriteData_5
);
hdl4se_fifo
#(
32'h20
,
32'h80
)
cnn_buf_5
(
wClk
,
nwReset
,
wDataRead_6
,
wDataReadValid_6
,
bDataReadData_6
,
wDataWriteEnable_5
,
wDataWrite_5
,
bDataWriteData_5
);
...
...
@@ -2305,9 +2304,8 @@ module googlenet
,
wDataWriteEnable_8
,
wDataWrite_8
,
bDataWriteData_8
);
hdl4se_fifo
#(
32'h20
,
32'h180
)
cnn_buf_8
(
wClk
,
nwReset
,
wDataRead_10
,
wDataReadValid_10
,
bDataReadData_10
,
wDataWriteEnable_8
,
wDataWrite_8
,
bDataWriteData_8
);
hdl4se_cnn_lrn
#(
32'h38
,
32'h38
,
32'hc0
,
32'h38
,
32'h38
,
32'hc0
,
32'h5
,
32
'
sh1
,
32
'
sh0
,
32
'
sh0
,
32'h0
)
lrn_10
(
wClk
,
nwReset
,
wDataRead_10
,
wDataReadValid_10
,
bDataReadData_10
,
wDataWriteEnable_10
hdl4se_cnn_lrn
#(
32'h38
,
32'h38
,
32'hc0
,
32'h5
,
<
type
=
1
>
,
<
type
=
1
>
,
<
type
=
1
>
,
32'h0
)
lrn_10
(
wClk
,
nwReset
,
wDataRead_10
,
wDataReadValid_10
,
bDataReadData_10
,
wDataWriteEnable_10
,
wDataWrite_10
,
bDataWriteData_10
);
hdl4se_fifo
#(
32'h20
,
32'h180
)
cnn_buf_10
(
wClk
,
nwReset
,
wDataRead_11
,
wDataReadValid_11
,
bDataReadData_11
,
wDataWriteEnable_10
,
wDataWrite_10
,
bDataWriteData_10
);
...
...
examples/hdl4secnn/googlenet/verilog/googlenet.v
浏览文件 @
b0980fd1
...
...
@@ -31,7 +31,7 @@
/*
* 由googlenet程序生成
* 生成时间:
Sun Aug 1 20:46:55
2021
* 生成时间:
Mon Aug 2 06:11:30
2021
* 请不要手工修改。
*/
`include
"hdl4secell.v"
...
...
@@ -218,7 +218,6 @@ module googlenet(
/* 局部响应归一化层 5:pool1/norm1 */
hdl4se_cnn_lrn
#(
56
,
56
,
64
,
/* 输入大小 */
56
,
56
,
64
,
/* 输出大小 */
5
,
1.000000
,
0.000100
,
0.750000
,
/* locasize, k, alpha, beta */
`LRN_NormRegion_ACROSS_CHANNELS
)
/* 模式 */
lrn_5
(
...
...
@@ -473,7 +472,6 @@ module googlenet(
/* 局部响应归一化层 10:conv2/norm2 */
hdl4se_cnn_lrn
#(
56
,
56
,
192
,
/* 输入大小 */
56
,
56
,
192
,
/* 输出大小 */
5
,
1.000000
,
0.000100
,
0.750000
,
/* locasize, k, alpha, beta */
`LRN_NormRegion_ACROSS_CHANNELS
)
/* 模式 */
lrn_10
(
...
...
hdl4secell/include/hdl4secell.h
浏览文件 @
b0980fd1
...
...
@@ -248,6 +248,7 @@ int hdl4se_module_GetModule(sGeneralModule* pobj, int index, IHDL4SEModuleVar**
int
hdl4se_module_GetVariableCount
(
sGeneralModule
*
pobj
);
int
hdl4se_module_GetVariable
(
sGeneralModule
*
pobj
,
int
index
,
ModuleVariable
**
portinfo
);
int
hdl4se_module_GetParent
(
sGeneralModule
*
pobj
,
const
IHDL4SEModuleVar
**
parent
);
double
hdl4seGetParamReal
(
PointerArray
*
list
,
int
index
);
long
long
hdl4seGetParam
(
PointerArray
*
list
,
int
index
);
const
char
*
hdl4seGetParamStr
(
PointerArray
*
list
,
int
index
);
...
...
@@ -486,6 +487,7 @@ do { \
#define Var_idx(idx) hdl4se_module_Var(pobj->pmodule, idx)
#define MODULE_PARAM(index) hdl4seGetParam(&pobj->pmodule->parameters, index)
#define MODULE_PARAM_REAL(index) hdl4seGetParamReal(&pobj->pmodule->parameters, index)
#define MODULE_PARAM_STR(index) hdl4seGetParamStr(&pobj->pmodule->parameters, index)
DEFINE_GUID
(
PARAMID_HDL4SE_UNIT_INSTANCE_PARAMETERS
,
0xad12c414
,
0x631b
,
0x42cb
,
0xb9
,
0xbb
,
0xba
,
0xbd
,
0x78
,
0x21
,
0x3f
,
0xef
);
...
...
hdl4secell/src/hdl4se_general.c
浏览文件 @
b0980fd1
...
...
@@ -523,6 +523,13 @@ const char *hdl4seGetParamStr(PointerArray* list, int index)
return
(
const
char
*
)
list
->
array
[
index
];
}
double
hdl4seGetParamReal
(
PointerArray
*
list
,
int
index
)
{
if
(
index
<
0
||
index
>=
list
->
itemcount
)
return
0
.
0
;
return
atof
((
const
char
*
)
list
->
array
[
index
]);
}
long
long
hdl4seGetParam
(
PointerArray
*
list
,
int
index
)
{
long
long
ret
=
0
;
...
...
parser/verilog_moduleinst.c
浏览文件 @
b0980fd1
...
...
@@ -221,6 +221,10 @@ char* moduleinstanceGetParameterString(verilogModuleInstance* moduleinstance)
expr0
=
verilogExprGetData
(
paraminst
->
expr0
);
if
(
expr0
==
NULL
)
return
""
;
if
(
index
>
0
)
{
*
buf
++
=
','
;
*
buf
++
=
' '
;
}
if
(
expr0
->
exprtype
==
EXPRTYPE_STRING
)
{
const
char
*
s
;
s
=
expr0
->
value
->
string
;
...
...
@@ -237,13 +241,18 @@ char* moduleinstanceGetParameterString(verilogModuleInstance* moduleinstance)
}
*
buf
=
'\0'
;
}
else
if
(
expr0
->
exprtype
==
EXPRTYPE_REAL
)
{
const
char
*
s
;
s
=
expr0
->
value
->
string
;
while
(
*
s
)
{
*
buf
++
=
*
s
++
;
}
*
buf
=
'\0'
;
}
else
if
(
expr0
->
exprtype
!=
EXPRTYPE_BIGNUMBER
)
{
return
""
;
/* Fixed Me 参数中不能有带参数的表达式? */
}
if
(
index
>
0
)
{
*
buf
++
=
','
;
*
buf
++
=
' '
;
}
if
(
expr0
->
exprtype
==
EXPRTYPE_BIGNUMBER
)
{
if
(
0
!=
objectCall3
(
expr0
->
bignumber
,
GetStr
,
10
,
buf
,
1024
))
{
return
""
;
...
...
parser/verilog_parser.c
浏览文件 @
b0980fd1
此差异已折叠。
点击以展开。
parser/verilog_parser.y
浏览文件 @
b0980fd1
...
...
@@ -175,7 +175,7 @@
topmodule_identifier parameter_identifier
port_identifier net_identifier
module_instance_identifier
number string unsigned_number
number string unsigned_number
real
%type <ival> parameter_type
unary_operator
...
...
@@ -4871,6 +4871,13 @@ constant_primary :
NULL //IDListVarPtr attributes
);
}
| real {
$$ = verilogparseCreateValueExpr(
EXPRTYPE_REAL, //int exprtype,
$1, //IConstStringVar* value,
NULL //IDListVarPtr attributes
);
}
| parameter_identifier {
$$ = verilogparseCreateParamExpr(
EXPRTYPE_PARAM, //int exprtype,
...
...
@@ -5089,6 +5096,13 @@ primary :
NULL //IDListVarPtr attributes
);
}
| real {
$$ = verilogparseCreateValueExpr(
EXPRTYPE_REAL, //int exprtype,
$1, //IConstStringVar* value,
NULL //IDListVarPtr attributes
);
}
| var {
$$ = verilogparseCreateVariableExpr(
EXPRTYPE_HIERARCHICAL_IDENT,
...
...
@@ -5394,11 +5408,14 @@ unsigned_number :
}
;
number
:
real
:
NUM_REAL{
$$ = $1;
}
| unsigned_number {
;
number :
unsigned_number {
$$ = $1;
}
| BIN_BASE BIN_VALUE {
...
...
parser/verilog_parsetree.h
浏览文件 @
b0980fd1
...
...
@@ -124,6 +124,7 @@ enum VAR_TYPE {
enum
EXPR_TYPE
{
EXPRTYPE_NUMBER
,
EXPRTYPE_REAL
,
EXPRTYPE_BIGNUMBER
,
EXPRTYPE_PARAM
,
EXPRTYPE_LOCALPARAM
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录