zoukankan
html css js c++ java
【原创】等效采样状态机控制工程(测试通过,待完善说明书)
工程文件:/Files/lwpo2008/SampleLogic.rar
module
SampleLogic(
input
rst_n,
input
iclk,
input
trig,
output
reg
oclk
);
parameter
IDLE
=
4
'
b0001,
WAIT_RISE
=
4
'
b0010,
WAIT_FALL
=
4
'
b0100,
WAIT_END
=
4
'
b1000;
parameter
PULSE_WIDTH
=
9
'
d50;
parameter
LENGTH
=
9
'
d306;
reg
[
3
:
0
] current_state,
//
state
next_state;
reg
r_data_in0,
//
detect the risingedge reg
r_data_in1,
o_rising_edge;
reg
[
8
:
0
] count,
//
count for delay
delay;
reg
[
7
:
0
] n_delta_t;
reg
count_rst_n;
reg
delay_rst_n;
reg
count_delta_t;
//
sequential circuit
always
@(
posedge
iclk,
negedge
rst_n)
begin
if
(
!
rst_n)
begin
current_state
<=
IDLE;
end
else
begin
current_state
<=
next_state;
end
end
//
combinational circuit for state logic
always
@(current_state,count,n_delta_t,o_rising_edge,delay)
begin
next_state
=
IDLE;
case
(current_state)
IDLE : next_state
=
o_rising_edge
?
WAIT_RISE : IDLE;
WAIT_RISE : next_state
=
(count
==
n_delta_t)
?
WAIT_FALL : WAIT_RISE;
WAIT_FALL : next_state
=
(delay
==
PULSE_WIDTH)
?
WAIT_END : WAIT_FALL;
WAIT_END : next_state
=
(count
>=
LENGTH)
?
IDLE : WAIT_END;
endcase
end
//
combinational circuit for output logic
always
@(
posedge
iclk,
negedge
rst_n)
begin
if
(
~
rst_n)
oclk
<=
1
'
b0;
else
begin
oclk
<=
1
'
b0;
case
(current_state)
IDLE :
begin
oclk
<=
1
'
b0;
count_rst_n
<=
1
'
b0;
delay_rst_n
<=
1
'
b0;
count_delta_t
<=
1
'
b0;
end
WAIT_RISE :
begin
oclk
<=
1
'
b0;
count_rst_n
<=
1
'
b1;
delay_rst_n
<=
1
'
b0;
count_delta_t
<=
1
'
b1;
end
WAIT_FALL :
begin
oclk
<=
1
'
b1;
count_rst_n
<=
1
'
b1;
delay_rst_n
<=
1
'
b1;
end
WAIT_END :
begin
oclk
<=
1
'
b0;
count_rst_n
<=
1
'
b1;
delay_rst_n
<=
1
'
b0;
end
endcase
end
end
//
detect the rising edge
always
@(
posedge
iclk,
negedge
rst_n)
begin
if
(
!
rst_n)
begin
r_data_in0
<=
0
;
r_data_in1
<=
0
;
end
else
begin
r_data_in0
<=
r_data_in1;
r_data_in1
<=
trig;
end
end
always
@(r_data_in0,r_data_in1)
begin
o_rising_edge
=
~
r_data_in0
&
r_data_in1;
//
o_rising_edge output
end
//
counter
always
@(
posedge
iclk)
begin
if
(
~
count_rst_n)
count
<=
9
'
b0_0000_0000;
else
count
<=
count
+
1
'
b1;
if
(
~
delay_rst_n)
delay
<=
9
'
b0_0000_0000;
else
delay
<=
delay
+
1
'
b1;
end
always
@(
posedge
count_delta_t,
negedge
rst_n)
begin
if
(
~
rst_n)
n_delta_t
<=
8
'
d0;
else
n_delta_t
<=
n_delta_t
+
1
'
b1;
end
endmodule
综合后RTL图:
高调做事,低调做人
查看全文
相关阅读:
多元化时代敏捷软件开发的崛起与传统软件工程的延续
敏捷软件开发与传统软件工程概述比较
结构化方法和面向对象方法的比较
sql server 的Maintenance Plans(维护计划)详解
sql server 如何查询出数据库作业所有者的信息并完成批量替换
sql server 运维时CPU,内存,操作系统等信息查询(用sql语句)
sql server 数据导出(入)方法总结
sql server 转置 和实现随机分配和一串代码的含义拼在一行
python 之路初(一):pycharm 安装 和 环境配置 和 中文乱码问题
Qt5.9.6 vs2015 SQlite 数据库增删改查
原文地址:https://www.cnblogs.com/oneseven/p/1551744.html
最新文章
互联网校招面试必备——Java多线程
BAT面试必备——Java 集合类
[算法总结] 13 道题搞定 BAT 面试——字符串
[算法总结] 6 道题搞定 BAT 面试——堆栈和队列
iframe onload事件触发两次
小程序生命周期
记一次寻找页面卡顿问题
vue生命周期中update的具体用法
Javascript中forEach的异步问题
JavaScript中为什么使用立即执行函数来封装模块?
热门文章
JS函数防抖和函数节流
极光笔记丨数据质量建设实践
极光笔记丨百亿级数据的实时存取优化与实践
极光笔记丨iOS 15推送新特性
【直播回顾】5步实现精细化用户触达,助力业务增长
GC回收算法--当女友跟你提分手!
假如Java对象是个人······
浅谈JVM内存模型
vue-cli(vue脚手架)详细教程
浅谈结构化方法与面向对象方法
Copyright © 2011-2022 走看看