Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
饶先宏
hdl4se
提交
730dcd86
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 搜索 >>
提交
730dcd86
编写于
5月 19, 2021
作者:
饶先宏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
202105191152
上级
106935bf
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
277 addition
and
91 deletion
+277
-91
examples/counter/include/counter.h
examples/counter/include/counter.h
+2
-0
examples/counter/src/counter.c
examples/counter/src/counter.c
+75
-44
examples/counter/src/main.c
examples/counter/src/main.c
+8
-2
examples/counter/verilog/main_asm.v
examples/counter/verilog/main_asm.v
+176
-41
hdl4secell/include/hdl4secell.h
hdl4secell/include/hdl4secell.h
+2
-2
hdl4secell/verilog/hdl4secell.ppt
hdl4secell/verilog/hdl4secell.ppt
+0
-0
hdl4sesim/include/hdl4sesim.h
hdl4sesim/include/hdl4sesim.h
+3
-1
hdl4sesim/src/hdl4sesim.c
hdl4sesim/src/hdl4sesim.c
+11
-1
未找到文件。
examples/counter/include/counter.h
浏览文件 @
730dcd86
...
...
@@ -33,3 +33,5 @@
* counter.h
202105180851: rxh, initial version
*/
IHDL4SEUnit
**
hdl4seCreateMain
(
IHDL4SEModule
**
parent
,
char
*
instanceparam
,
char
*
name
);
\ No newline at end of file
examples/counter/src/counter.c
浏览文件 @
730dcd86
...
...
@@ -74,20 +74,20 @@ static IHDL4SEUnit** hdl4seCreateDec2seg(IHDL4SEModule** parent, char* instancep
wire_const
[
i
]
=
hdl4seCreateUnit
(
module_dec2seg
,
CLSID_HDL4SE_WIRE
,
"8"
,
tempname
);
sprintf
(
tempname
,
"const_cst%d"
,
i
);
unit_const
[
i
]
=
hdl4seCreateUnit
(
module_dec2seg
,
CLSID_HDL4SE_CONST
,
constparam
[
i
],
tempname
);
objectCall
5
(
wire_const
[
i
],
Connect
,
0
,
unit_const
[
i
],
0
,
0
,
8
);
objectCall
3
(
wire_const
[
i
],
Connect
,
0
,
unit_const
[
i
],
0
);
}
/* 生成数据选择器unit_mux */
unit_mux16
=
hdl4seCreateUnit
(
module_dec2seg
,
CLSID_HDL4SE_MUX16
,
"8"
,
"mux_dec"
);
/*mux的输入连接到输入端口dec和线网constall上*/
objectCall
5
(
unit_mux16
,
Connect
,
0
,
unit_dec2seg
,
0
,
0
,
4
);
objectCall
3
(
unit_mux16
,
Connect
,
0
,
unit_dec2seg
,
0
);
for
(
i
=
0
;
i
<
10
;
i
++
)
{
objectCall
5
(
unit_mux16
,
Connect
,
i
+
1
,
wire_const
[
i
],
0
,
0
,
8
);
objectCall
3
(
unit_mux16
,
Connect
,
i
+
1
,
wire_const
[
i
],
0
);
}
for
(;
i
<
16
;
i
++
)
{
objectCall
5
(
unit_mux16
,
Connect
,
i
+
11
,
wire_const
[
10
],
0
,
0
,
8
);
objectCall
3
(
unit_mux16
,
Connect
,
i
+
11
,
wire_const
[
10
],
0
);
}
/* 译码模块的输出seg连接到数据先择器的输出*/
objectCall
5
(
unit_dec2seg
,
Connect
,
1
,
unit_mux16
,
17
,
0
,
8
);
objectCall
3
(
unit_dec2seg
,
Connect
,
1
,
unit_mux16
,
17
);
/*释放module接口*/
objectRelease
(
module_dec2seg
);
/*返回unit接口*/
...
...
@@ -116,38 +116,38 @@ static IHDL4SEUnit** hdl4seCreateCounter(IHDL4SEModule** parent, char* instancep
IHDL4SEUnit
**
wire_wireout_bCurrentCounter
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
temp
,
"wireout_bCurrentCounter"
);
IHDL4SEUnit
**
reg_bCurrentCounter
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_REG
,
temp
,
"bCurrentCounter"
);
/*寄存器和线网连接在一起*/
objectCall5
(
reg_bCurrentCounter
,
Connect
,
0
,
wire_wirein_bCurrentCounter
,
0
,
0
,
width
);
objectCall5
(
wire_wireout_bCurrentCounter
,
Connect
,
0
,
reg_bCurrentCounter
,
1
,
0
,
width
);
objectCall3
(
reg_bCurrentCounter
,
Connect
,
0
,
wire_wirein_bCurrentCounter
,
0
);
objectCall3
(
wire_wireout_bCurrentCounter
,
Connect
,
0
,
reg_bCurrentCounter
,
1
);
objectCall3
(
unit_counter
,
Connect
,
2
,
wire_wireout_bCurrentCounter
,
0
);
/*定义一个寄存器来表示计数器是否溢出*/
IHDL4SEUnit
**
wire_wirein_wOverflow
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
"1"
,
"wirein_wOverflow"
);
IHDL4SEUnit
**
wire_wireout_wOverflow
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
"1"
,
"wireout_wOverflow"
);
IHDL4SEUnit
**
reg_wOverflow
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_REG
,
"1, 0"
,
"wOverflow"
);
/*寄存器和线网连接在一起*/
objectCall5
(
reg_wOverflow
,
Connect
,
0
,
wire_wirein_wOverflow
,
0
,
0
,
1
);
objectCall5
(
wire_wireout_wOverflow
,
Connect
,
0
,
reg_wOverflow
,
1
,
0
,
1
);
objectCall5
(
unit_counter
,
Connect
,
2
,
wire_wireout_bCurrentCounter
,
0
,
0
,
width
);
objectCall5
(
unit_counter
,
Connect
,
3
,
wire_wireout_wOverflow
,
0
,
0
,
1
);
objectCall3
(
reg_wOverflow
,
Connect
,
0
,
wire_wirein_wOverflow
,
0
);
objectCall3
(
wire_wireout_wOverflow
,
Connect
,
0
,
reg_wOverflow
,
1
);
objectCall3
(
unit_counter
,
Connect
,
3
,
wire_wireout_wOverflow
,
0
);
sprintf
(
temp
,
"%d"
,
width
);
IHDL4SEUnit
**
wire_bConst_MAXVALUE
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
temp
,
"bConst_MAXVALUE"
);
sprintf
(
temp
,
"%d, %d"
,
width
,
maxvalue
);
IHDL4SEUnit
**
unit_const_MAXVALUE
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_CONST
,
temp
,
"const_MAXVALUE"
);
objectCall
5
(
wire_bConst_MAXVALUE
,
Connect
,
0
,
unit_const_MAXVALUE
,
0
,
0
,
width
);
objectCall
3
(
wire_bConst_MAXVALUE
,
Connect
,
0
,
unit_const_MAXVALUE
,
0
);
sprintf
(
temp
,
"%d"
,
width
);
IHDL4SEUnit
**
wire_bConst_RESETVALUE
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
temp
,
"bConst_RESETVALUE"
);
sprintf
(
temp
,
"%d, %d"
,
width
,
resetvalue
);
IHDL4SEUnit
**
unit_const_RESETVALUE
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_CONST
,
temp
,
"const_RESETVALUE"
);
objectCall
5
(
wire_bConst_RESETVALUE
,
Connect
,
0
,
unit_const_RESETVALUE
,
0
,
0
,
width
);
objectCall
3
(
wire_bConst_RESETVALUE
,
Connect
,
0
,
unit_const_RESETVALUE
,
0
);
IHDL4SEUnit
**
wire_wEQ_bCurrentCounter_MAXVALUE
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
"1"
,
"wEQ_bCurrentCounter_MAXVALUE"
);
sprintf
(
temp
,
"%d, %d, 1, %d"
,
width
,
width
,
BINOP_EQ
);
IHDL4SEUnit
**
unit_binop_EQ_bCurrentCounter_MAXVALUE
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_BINOP
,
temp
,
"binop_EQ_bCurrentCounter_MAXVALUE"
);
objectCall
5
(
unit_binop_EQ_bCurrentCounter_MAXVALUE
,
Connect
,
0
,
wire_wireout_bCurrentCounter
,
0
,
0
,
width
);
objectCall
5
(
unit_binop_EQ_bCurrentCounter_MAXVALUE
,
Connect
,
1
,
wire_bConst_MAXVALUE
,
0
,
0
,
width
);
objectCall
5
(
wire_wEQ_bCurrentCounter_MAXVALUE
,
Connect
,
0
,
unit_binop_EQ_bCurrentCounter_MAXVALUE
,
2
,
0
,
1
);
objectCall
3
(
unit_binop_EQ_bCurrentCounter_MAXVALUE
,
Connect
,
0
,
wire_wireout_bCurrentCounter
,
0
);
objectCall
3
(
unit_binop_EQ_bCurrentCounter_MAXVALUE
,
Connect
,
1
,
wire_bConst_MAXVALUE
,
0
);
objectCall
3
(
wire_wEQ_bCurrentCounter_MAXVALUE
,
Connect
,
0
,
unit_binop_EQ_bCurrentCounter_MAXVALUE
,
2
);
/* bCurrentCounter+1 用加法器实现 */
/* 常数 1 */
...
...
@@ -155,44 +155,75 @@ static IHDL4SEUnit** hdl4seCreateCounter(IHDL4SEModule** parent, char* instancep
IHDL4SEUnit
**
wire_bConst_One
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
temp
,
"bConst_One"
);
sprintf
(
temp
,
"%d, %d"
,
width
,
1
);
IHDL4SEUnit
**
unit_const_One
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_CONST
,
temp
,
"const_One"
);
objectCall
5
(
wire_bConst_One
,
Connect
,
0
,
unit_const_One
,
0
,
0
,
width
);
objectCall
3
(
wire_bConst_One
,
Connect
,
0
,
unit_const_One
,
0
);
/* bCurrentCounter + 1 */
sprintf
(
temp
,
"%d"
,
width
);
IHDL4SEUnit
**
wire_bCurrentCounterPlusOne
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
temp
,
"bCurrentCounterPlusOne"
);
sprintf
(
temp
,
"%d, %d, 1, %d"
,
width
,
width
,
BINOP_ADD
);
IHDL4SEUnit
**
unit_binop_bCurrentCounter
Inc
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_BINOP
,
temp
,
"binop_bCurrentCounterInc"
);
objectCall
5
(
unit_binop_bCurrentCounterInc
,
Connect
,
0
,
wire_wireout_bCurrentCounter
,
0
,
0
,
width
);
objectCall
5
(
unit_binop_bCurrentCounterInc
,
Connect
,
1
,
wire_bConst_One
,
0
,
0
,
width
);
objectCall
5
(
wire_bCurrentCounterPlusOne
,
Connect
,
0
,
unit_binop_bCurrentCounterInc
,
2
,
0
,
width
);
IHDL4SEUnit
**
unit_binop_bCurrentCounter
PlusOne
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_BINOP
,
temp
,
"binop_bCurrentCounterInc"
);
objectCall
3
(
unit_binop_bCurrentCounterPlusOne
,
Connect
,
0
,
wire_wireout_bCurrentCounter
,
0
);
objectCall
3
(
unit_binop_bCurrentCounterPlusOne
,
Connect
,
1
,
wire_bConst_One
,
0
);
objectCall
3
(
wire_bCurrentCounterPlusOne
,
Connect
,
0
,
unit_binop_bCurrentCounterPlusOne
,
2
);
/* if语句用数据选择器实现 */
sprintf
(
temp
,
"%d"
,
width
*
2
);
IHDL4SEUnit
**
wire_bMuxIn
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
temp
,
"bMuxIn"
);
sprintf
(
temp
,
"%d, %d"
,
width
,
width
);
IHDL4SEUnit
**
unit_bind2to1
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_BINDING2TO1
,
temp
,
"bMuxIn"
);
objectCall5
(
unit_bind2to1
,
Connect
,
0
,
wire_bCurrentCounterPlusOne
,
0
,
0
,
width
);
objectCall5
(
unit_bind2to1
,
Connect
,
1
,
wire_bConst_RESETVALUE
,
0
,
0
,
width
);
objectCall5
(
wire_bMuxIn
,
Connect
,
0
,
unit_bind2to1
,
2
,
0
,
width
);
sprintf
(
temp
,
"%d, %d, %d"
,
1
,
2
*
width
,
width
);
IHDL4SEUnit
**
unit_muxCurrentCouter
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_MUX
,
temp
,
"muxCurrentCouter"
);
objectCall5
(
unit_muxCurrentCouter
,
Connect
,
0
,
wire_wEQ_bCurrentCounter_MAXVALUE
,
0
,
0
,
1
);
objectCall5
(
unit_muxCurrentCouter
,
Connect
,
1
,
wire_bMuxIn
,
0
,
0
,
width
*
2
);
objectCall5
(
wire_wireout_bCurrentCounter
,
Connect
,
0
,
unit_muxCurrentCouter
,
2
,
0
,
width
);
IHDL4SEUnit
**
wire_bConst_10
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
"2"
,
"bConst_10"
);
IHDL4SEUnit
**
unit_const_10
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_CONST
,
"2, 2"
,
"const_10"
);
objectCall5
(
wire_bConst_10
,
Connect
,
0
,
unit_const_10
,
0
,
0
,
2
);
IHDL4SEUnit
**
unit_muxOverflow
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_MUX
,
"1,2,1"
,
"muxOverflow"
);
objectCall5
(
unit_muxOverflow
,
Connect
,
0
,
wire_wEQ_bCurrentCounter_MAXVALUE
,
0
,
0
,
1
);
objectCall5
(
unit_muxOverflow
,
Connect
,
1
,
wire_bConst_10
,
0
,
0
,
2
);
objectCall5
(
wire_wirein_wOverflow
,
Connect
,
0
,
unit_muxOverflow
,
2
,
0
,
1
);
sprintf
(
temp
,
"%d"
,
width
);
IHDL4SEUnit
**
wire_bCurrentCounter_if_wCounterIt
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
temp
,
"bCurrentCounter_if_wCounterIt"
);
IHDL4SEUnit
**
unit_muxCurrentCouter
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_MUX2
,
temp
,
"mux_bCurrentCounter_if_wCounterIt"
);
objectCall3
(
unit_muxCurrentCouter
,
Connect
,
0
,
wire_wEQ_bCurrentCounter_MAXVALUE
,
0
);
objectCall3
(
unit_muxCurrentCouter
,
Connect
,
1
,
wire_bCurrentCounterPlusOne
,
0
);
objectCall3
(
unit_muxCurrentCouter
,
Connect
,
2
,
wire_bConst_RESETVALUE
,
0
);
objectCall3
(
wire_bCurrentCounter_if_wCounterIt
,
Connect
,
0
,
unit_muxCurrentCouter
,
3
);
IHDL4SEUnit
**
wire_wConst_0
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
"1"
,
"wConst_0"
);
IHDL4SEUnit
**
unit_const_0
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_CONST
,
"1, 0"
,
"const_0"
);
objectCall3
(
wire_wConst_0
,
Connect
,
0
,
unit_const_0
,
0
);
IHDL4SEUnit
**
wire_wConst_1
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
"1"
,
"wConst_1"
);
IHDL4SEUnit
**
unit_const_1
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_CONST
,
"1, 1"
,
"const_1"
);
objectCall3
(
wire_wConst_1
,
Connect
,
0
,
unit_const_1
,
0
);
IHDL4SEUnit
**
wire_wOverflow_if_wCounterIt
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
"1"
,
"wOverflow_if_wCounterIt"
);
IHDL4SEUnit
**
unit_mux_wOverflow_if_wCounterIt
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_MUX2
,
"1"
,
"mux_wOverflow_if_wCounterIt"
);
objectCall3
(
unit_mux_wOverflow_if_wCounterIt
,
Connect
,
0
,
wire_wEQ_bCurrentCounter_MAXVALUE
,
0
);
objectCall3
(
unit_mux_wOverflow_if_wCounterIt
,
Connect
,
1
,
wire_wConst_0
,
0
);
objectCall3
(
unit_mux_wOverflow_if_wCounterIt
,
Connect
,
2
,
wire_wConst_1
,
0
);
objectCall3
(
wire_wOverflow_if_wCounterIt
,
Connect
,
0
,
unit_mux_wOverflow_if_wCounterIt
,
3
);
sprintf
(
temp
,
"%d"
,
width
);
IHDL4SEUnit
**
wire_bCurrentCounter_if_nwReset
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
temp
,
"bCurrentCounter_if_nwReset"
);
IHDL4SEUnit
**
unit_mux_bCurrentCounter_if_nwReset
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_MUX2
,
temp
,
"mux_bCurrentCounter_if_nwReset"
);
objectCall3
(
unit_mux_bCurrentCounter_if_nwReset
,
Connect
,
0
,
module_counter
,
1
);
objectCall3
(
unit_mux_bCurrentCounter_if_nwReset
,
Connect
,
1
,
wire_wireout_bCurrentCounter
,
0
);
objectCall3
(
unit_mux_bCurrentCounter_if_nwReset
,
Connect
,
2
,
wire_bCurrentCounter_if_wCounterIt
,
0
);
objectCall3
(
wire_bCurrentCounter_if_nwReset
,
Connect
,
0
,
unit_mux_bCurrentCounter_if_nwReset
,
3
);
IHDL4SEUnit
**
wire_wOverflow_if_nwReset
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_WIRE
,
"1"
,
"wOverfloat_if_nwReset"
);
IHDL4SEUnit
**
unit_mux_wOverflow_if_nwReset
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_MUX2
,
"1"
,
"mux_wOverflow_if_nwReset"
);
objectCall3
(
unit_mux_wOverflow_if_nwReset
,
Connect
,
0
,
module_counter
,
1
);
objectCall3
(
unit_mux_wOverflow_if_nwReset
,
Connect
,
1
,
wire_wireout_wOverflow
,
0
);
objectCall3
(
unit_mux_wOverflow_if_nwReset
,
Connect
,
2
,
wire_wOverflow_if_wCounterIt
,
0
);
objectCall3
(
wire_wOverflow_if_nwReset
,
Connect
,
0
,
unit_mux_wOverflow_if_nwReset
,
3
);
IHDL4SEUnit
**
unit_mux_bCurrentCounter
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_MUX2
,
temp
,
"mux_bCurrentCounter"
);
objectCall3
(
unit_mux_bCurrentCounter
,
Connect
,
0
,
module_counter
,
1
);
objectCall3
(
unit_mux_bCurrentCounter
,
Connect
,
1
,
wire_bConst_RESETVALUE
,
0
);
objectCall3
(
unit_mux_bCurrentCounter
,
Connect
,
2
,
wire_bCurrentCounter_if_nwReset
,
0
);
objectCall3
(
wire_wirein_bCurrentCounter
,
Connect
,
0
,
unit_mux_bCurrentCounter
,
3
);
IHDL4SEUnit
**
unit_mux_wOverflow
=
hdl4seCreateUnit
(
module_counter
,
CLSID_HDL4SE_MUX2
,
"1"
,
"mux_wOverflow"
);
objectCall3
(
unit_mux_wOverflow
,
Connect
,
0
,
module_counter
,
1
);
objectCall3
(
unit_mux_wOverflow
,
Connect
,
1
,
wire_wireout_wOverflow
,
0
);
objectCall3
(
unit_mux_wOverflow
,
Connect
,
2
,
wire_wOverflow_if_wCounterIt
,
0
);
objectCall3
(
wire_wirein_wOverflow
,
Connect
,
0
,
unit_mux_wOverflow
,
3
);
/*释放module接口*/
objectRelease
(
module_counter
);
/*返回unit接口*/
return
unit_counter
;
}
IHDL4SEUnit
**
hdl4seCreateMain
(
IHDL4SEModule
**
parent
,
char
*
instanceparam
,
char
*
name
)
{
/* module main */
}
\ No newline at end of file
examples/counter/src/main.c
浏览文件 @
730dcd86
...
...
@@ -33,10 +33,16 @@
#include "stdlib.h"
#include "stdio.h"
#include "object.h"
#include "hdl4secell.h"
#include "hdl4sesim.h"
#include "counter.h"
IHDL4SEModule
**
sim
;
IHDL4SEUnit
**
topmodule
;
int
main
(
int
argc
,
char
*
argv
[])
{
printf
(
"Hello, World!"
);
sim
=
hdl4sesimCreateSimulator
();
hdl4seCreateMain
(
sim
,
""
,
"main"
);
return
0
;
}
\ No newline at end of file
examples/counter/verilog/main_asm.v
浏览文件 @
730dcd86
...
...
@@ -211,10 +211,10 @@ module main(input wClk,
/* 以下是计数器连接 */
wire
nwResetCount
;
assign
wCounterin0
=
wCounterIt
;
wire
wCount
in0
,
wCountin1
,
wCount
in2
,
wCount
in3
,
wCountin4
,
wCount
in5
,
wCount
in6
,
wCountin7
,
wCount
in8
,
wCountin9
;
wire
wCount
erin0
,
wCounterin1
,
wCounter
in2
,
wCount
erin3
,
wCounterin4
,
wCounter
in5
,
wCount
erin6
,
wCounterin7
,
wCounter
in8
,
wCount
er
in9
;
wire
[
3
:
0
]
bCount0
,
bCount1
,
bCount2
,
bCount3
,
bCount4
,
bCount5
,
bCount6
,
bCount7
,
bCount8
,
bCount9
;
counter
#(
4
,
9
,
0
)
counter0
(
wClk
,
nwCounterReset
,
wCounterin0
,
bCount0
,
wCounterin1
);
...
...
@@ -228,11 +228,11 @@ module main(input wClk,
counter
#(
4
,
9
,
0
)
counter8
(
wClk
,
nwCounterReset
,
wCounterin8
,
bCount8
,
wCounterin9
);
counter
#(
4
,
9
,
0
)
counter9
(
wClk
,
nwCounterReset
,
wCounterin9
,
bCount9
,
.
wCounterOverflow
());
wire
[
WIDTH
-
1
:
0
]
wirein_wCounterIt
,
wireout_wCounterIt
;
wire
wEn_wCounterIt
;
hdl4se_reg
#(
1
,
0
)
wCounterIt
(
w
Clk
,
nwReset
,
wEn_wCounterIt
,
wire
in_wCounterIt
,
wire
out_wCounterIt
wire
wirein_wCounterIt
,
wireout_wCounterIt
;
hdl4se_reg
#(
1
)
wCounterIt
(
wClk
,
w
irein_wCounterIt
,
wireout_wCounterIt
);
wire
wButton0NotPressed
;
hdl4se_unop
#(
1
,
1
,
UNOP_NOT
)
Button0NotPressed
(
wButton0Pressed
,
wButton0NotPressed
);
...
...
@@ -279,8 +279,8 @@ dec2seg dec9(bCount9, code9);
晚一拍出来,所以变化情况也寄存一拍。
*/
wire
[
2
:
0
]
wirein_bCounterChanged
,
wireout_bCounterChanged
;
hdl4se_reg
#(
3
,
0
)
wCounterIt
(
wClk
,
nwReset
,
hdl4se_reg
#(
3
)
reg_
wCounterIt
(
wClk
,
wirein_bCounterChanged
,
wireout_bCounterChanged
);
...
...
@@ -318,35 +318,170 @@ dec2seg dec9(bCount9, code9);
.
wireout3
(),
);
reg
wWrite
;
reg
[
31
:
0
]
bWriteAddr
;
reg
[
31
:
0
]
bWriteData
;
reg
[
3
:
0
]
bWriteMask
;
wWrite
:
~
nwReset
->
1'b0
nwReset
always
@
posedge
wClk
)
if
(
~
nwReset
)
begin
wWrite
<=
1'b0
;
bWriteAddr
<=
32'b0
;
bWriteData
<=
32'b0
;
bWriteMask
<=
4'b0
;
end
else
begin
wWrite
<=
1'b0
;
if
(
bCounterChanged
[
2
])
begin
wWrite
<=
1'b1
;
bWriteMask
<=
4'b1100
;
bWriteAddr
<=
32'hf0000018
;
bWriteData
<=
{
16'b0
,
code9
,
code8
}
;
end
else
if
(
bCounterChanged
[
1
])
begin
wWrite
<=
1'b1
;
bWriteAddr
<=
32'hf0000014
;
bWriteData
<=
{
code7
,
code6
,
code5
,
code4
}
;
end
else
if
(
bCounterChanged
[
0
])
begin
wWrite
<=
1'b1
;
bWriteAddr
<=
32'hf0000010
;
bWriteData
<=
{
code3
,
code2
,
code1
,
code0
}
;
end
end
wire
wirein_wWrite
,
wireout_wWrite
;
hdl4se_reg
#(
1
)
reg_wWrite
(
wClk
,
wirein_wWrite
,
wireout_wWrite
);
wire
[
31
:
0
]
wirein_bWriteAddr
,
wireout_bWriteAddr
;
hdl4se_reg
#(
32
)
reg_bWriteAddr
(
wClk
,
wirein_bWriteAddr
,
wireout_bWriteAddr
);
wire
[
31
:
0
]
wirein_bWriteData
,
wireout_bWriteData
;
hdl4se_reg
#(
32
)
reg_bWriteData
(
wClk
,
wirein_bWriteData
,
wireout_bWriteData
);
wire
[
3
:
0
]
wirein_bWriteMask
,
wireout_bWriteMask
;
hdl4se_reg
#(
4
)
reg_bWriteMask
(
wClk
,
wirein_bWriteMask
,
wireout_bWriteMask
);
wire
[
3
:
0
]
b8b0
;
hdl4se_const
#(
8
,
0
)
const_b8b0
(
b8b0
);
wire
[
3
:
0
]
b4b0000
;
hdl4se_const
#(
4
,
0
)
const_b4b0000
(
b4b0000
);
wire
[
3
:
0
]
b4b1100
;
hdl4se_const
#(
4
,
4'b1100
)
const_b4b1100
(
b4b1100
);
wire
[
31
:
0
]
b32b0
;
hdl4se_const
#(
32
,
0
)
const_b32b0
(
b32b0
);
wire
[
31
:
0
]
b32hf0000018
;
hdl4se_const
#(
32
,
32'hf0000018
)
const_b32hf0000018
(
b32hf0000018
);
wire
[
31
:
0
]
b32hf0000014
;
hdl4se_const
#(
32
,
32'hf0000014
)
const_b32hf0000014
(
b32hf0000014
);
wire
[
31
:
0
]
b32hf0000010
;
hdl4se_const
#(
32
,
32'hf0000010
)
const_b32hf0000018
(
b32hf0000010
);
wire
[
31
:
0
]
b0098
;
wire
[
31
:
0
]
b7654
;
wire
[
31
:
0
]
b3210
;
hdl4se_bind4
(
8
,
8
,
8
,
8
)
bind_0098
(
code8
,
code9
,
b8b0
,
b8b0
,
b0098
);
hdl4se_bind4
(
8
,
8
,
8
,
8
)
bind_7654
(
code4
,
code5
,
code6
,
code7
,
b7654
);
hdl4se_bind4
(
8
,
8
,
8
,
8
)
bind_3210
(
code0
,
code1
,
code2
,
code3
,
b3210
);
wire
[
3
:
0
]
wire_bWriteMask_if_bCounterChanged0
;
hdl4se_mux2
#(
4
)
mux_bWriteMask_if_bCounterChanged0
(
wCounterChanged0
,
wireout_bWriteMask
,
b4b0000
,
wire_bWriteMask_if_bCounterChanged0
);
wire
[
31
:
0
]
wire_bWriteAddr_if_bCounterChanged0
;
hdl4se_mux2
#(
32
)
mux_bWriteAddr_if_bCounterChanged0
(
wCounterChanged0
,
wireout_bWriteAddr
,
b3210
,
wire_bWriteAddr_if_bCounterChanged0
);
wire
[
31
:
0
]
wire_bWriteData_if_bCounterChanged0
;
hdl4se_mux2
#(
32
)
mux_bWriteData_if_bCounterChanged0
(
wCounterChanged0
,
wireout_bWriteData
,
b32hf0000010
,
wire_bWriteData_if_bCounterChanged0
);
wire
[
3
:
0
]
wire_bWriteMask_if_bCounterChanged1
;
hdl4se_mux2
#(
4
)
mux_bWriteMask_if_bCounterChanged1
(
wCounterChanged1
,
wireout_bWriteMask
,
b4b0000
,
wire_bWriteMask_if_bCounterChanged1
);
wire
[
31
:
0
]
wire_bWriteAddr_if_bCounterChanged1
;
hdl4se_mux2
#(
32
)
mux_bWriteAddr_if_bCounterChanged1
(
wCounterChanged1
,
wireout_bWriteAddr
,
b3210
,
wire_bWriteAddr_if_bCounterChanged1
);
wire
[
31
:
0
]
wire_bWriteData_if_bCounterChanged1
;
hdl4se_mux2
#(
32
)
mux_bWriteData_if_bCounterChanged1
(
wCounterChanged1
,
wireout_bWriteData
,
b32hf0000010
,
wire_bWriteData_if_bCounterChanged1
);
wire
[
3
:
0
]
wire_bWriteMask_if_bCounterChanged2
;
hdl4se_mux2
#(
4
)
mux_bWriteMask_if_bCounterChanged2
(
wCounterChanged2
,
wireout_bWriteMask
,
b4b0000
,
wire_bWriteMask_if_bCounterChanged2
);
wire
[
31
:
0
]
wire_bWriteAddr_if_bCounterChanged2
;
hdl4se_mux2
#(
32
)
mux_bWriteAddr_if_bCounterChanged1
(
wCounterChanged2
,
wireout_bWriteAddr
,
b3210
,
wire_bWriteAddr_if_bCounterChanged2
);
wire
[
31
:
0
]
wire_bWriteData_if_bCounterChanged2
;
hdl4se_mux2
#(
32
)
mux_bWriteData_if_bCounterChanged2
(
wCounterChanged2
,
wireout_bWriteData
,
b32hf0000010
,
wire_bWriteData_if_bCounterChanged2
);
wire
[
3
:
0
]
wire_bWriteMask_if_nwReset
;
hdl4se_mux2
#(
4
)
mux_bWriteMask_if_nwReset
(
nwReset
,
wireout_bWriteMask
,
b4b0000
,
wire_bWriteMask_if_nwReset
);
wire
[
31
:
0
]
wire_bWriteAddr_if_nwReset
;
hdl4se_mux2
#(
32
)
mux_bWriteAddr_if_nwReset
(
nwReset
,
wireout_bWriteAddr
,
b3210
,
wire_bWriteAddr_if_nwReset
);
wire
[
31
:
0
]
wire_bWriteData_if_nwReset
;
hdl4se_mux2
#(
32
)
mux_bWriteData_if_nwReset
(
nwReset
,
wireout_bWriteData
,
b32hf0000010
,
wire_bWriteData_if_nwReset
);
hdl4se_mux2
#(
4
)
mux_bWriteMask_if_nwReset
(
nwReset
,
wireout_bWriteMask
,
b4b0000
,
wire_bWriteMask_if_nwReset
);
hdl4se_mux2
#(
32
)
mux_bWriteAddr_if_nwReset
(
nwReset
,
wireout_bWriteAddr
,
b3210
,
wire_bWriteAddr_if_nwReset
);
hdl4se_mux2
#(
32
)
mux_bWriteData_if_nwReset
(
nwReset
,
wireout_bWriteData
,
b32hf0000010
,
wire_bWriteData_if_nwReset
);
/*
wWrite <= nwReset & (bCounterChanged[0] | bCounterChanged[1] | bCounterChanged[2])
nwReset==0 ::
bWriteMask <= 4'b0000; bWriteAddr <= 32'b0; bWriteData <= 32'b0;
nwReset & bCounterChanged[2] :
bWriteMask <= 4'b1100; bWriteAddr <= 32'hf0000018; bWriteData <= {16'b0, code9, code8};
nwReset & ~bCounterChanged[2] & bCounterChanged[1]:
bWriteMask <= 4'b0000; bWriteAddr <= 32'hf0000014; bWriteData <= {code7, code6, code5, code4};
nwReset & ~bCounterChanged[2] & ~bCounterChanged[1] & bCounterChanged[0]:
bWriteMask <= 4'b0000; bWriteAddr <= 32'hf0000010; bWriteData <= {code3, code2, code1, code0};
nwReset & ~bCounterChanged[2] & ~bCounterChanged[1] & ~bCounterChanged[0]
bWriteMask <= bWriteMask; bWriteAddr <= bWriteAddr; bWriteData <= bWriteData;
*/
endmodule
hdl4secell/include/hdl4secell.h
浏览文件 @
730dcd86
...
...
@@ -52,7 +52,7 @@ DEFINE_GUID(IID_HDL4SEUNIT, 0x57521e7a, 0xfdc5, 0x4682, 0x94, 0xc8, 0x8d, 0x2d,
typedef
struct
sIHDL4SEUnit
{
OBJECT_INTERFACE
int
(
*
Connect
)(
HOBJECT
object
,
int
index
,
HOBJECT
from
,
int
fromindex
,
int
width
);
int
(
*
Connect
)(
HOBJECT
object
,
int
index
,
HOBJECT
from
,
int
fromindex
);
int
(
*
GetValue
)(
HOBJECT
object
,
int
index
,
int
width
,
HDL4SEUINT32
*
value
);
}
IHDL4SEUnit
;
...
...
@@ -60,7 +60,7 @@ typedef struct sIHDL4SEUnit {
#define HDL4SEUNIT_VARINIT(_objptr, _sid)
#define HDL4SEUNIT_FUNCDECLARE(_obj, _clsid, _localstruct) \
static int _obj##_hdl4se_unit_Connect(HOBJECT object, int index, HOBJECT from, int fromindex
, int width
); \
static int _obj##_hdl4se_unit_Connect(HOBJECT object, int index, HOBJECT from, int fromindex); \
static int _obj##_hdl4se_unit_GetValue(HOBJECT object, int index, int width, HDL4SEUINT32 *value); \
static const IHDL4SEUnit _obj##_hdl4se_unit_interface = { \
INTERFACE_HEADER(_obj, IHDL4SEUnit, _localstruct) \
...
...
hdl4secell/verilog/hdl4secell.ppt
浏览文件 @
730dcd86
无法预览此类型文件
hdl4sesim/include/hdl4sesim.h
浏览文件 @
730dcd86
...
...
@@ -33,4 +33,6 @@
* hdl4sesim.h
修改记录:
202105180851: rxh, initial version
*/
\ No newline at end of file
*/
IHDL4SEModule
**
hdl4sesimCreateSimulator
();
\ No newline at end of file
hdl4sesim/src/hdl4sesim.c
浏览文件 @
730dcd86
...
...
@@ -33,4 +33,14 @@
* hdl4sesim.c
修改记录:
202105180851: rxh, initial version
*/
\ No newline at end of file
*/
#include "stdlib.h"
#include "stdio.h"
#include "object.h"
#include "hdl4secell.h"
#include "hdl4sesim.h"
IHDL4SEModule
**
hdl4sesimCreateSimulator
()
{
return
NULL
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录