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图:
高调做事,低调做人
查看全文
相关阅读:
NodeJS笔记:处理非utf8编码
SQL Server存储过程中的异常处理
"岛主" 同学给我出的算法题
学 Win32 汇编[18]: 关于压栈(PUSH)与出栈(POP) 之二
如何在数据表中存取图片 回复 "三足乌" 的问题
学 Win32 汇编[19]: 查看二进制等相关函数
如何删除动态数组的指定元素 回复 "Splendour" 的部分问题
学 Win32 汇编[17]: 关于压栈(PUSH)与出栈(POP) 之一
学 Win32 汇编[22] 逻辑运算指令: AND、OR、XOR、NOT、TEST
学 Win32 汇编[20]: 洞察标志寄存器
原文地址:https://www.cnblogs.com/oneseven/p/1551744.html
最新文章
HTML5手机游戏将迎美好未来
Windows phone7 动态添加控件
brother bPAC sdk开发包
winXP vc6行号显示插件VC6LineNumberAddin方法可用无需注册
S7200 PLC内部+5VDC电源的负载能力
S71200视频教程: S71200的功能与特点跟我学 1/112
捷达换电瓶多少钱?
资料共享源代码视频教程PLCOpenCVC++MFC
s7200高速脉冲输出与高速计数器讲解
成都公积金提取流程(自住住房贷款)
热门文章
S71200视频教程: S71200的功能与特点跟我做 2/112
VM virtualBox中文版 v6.0.12.133076官方版(64/虚拟机
C#同步网络时间
C# 汉字转拼音(支持GB2312字符集中所有汉字)
恶补基础之ASP.NET控件缩写大全
C#的访问修饰符Protected
C# 序列化与反序列化几种格式的转换
C#中的继承
C#获取URL参数值
SQL Server 非聚集索引(如何预先估算其大小空间) (转载)
Copyright © 2011-2022 走看看