惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
MyScale Blog
MyScale Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学
Vercel News
Vercel News
D
Docker
博客园 - 聂微东
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
D
DataBreaches.Net
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
美团技术团队
F
Fortinet All Blogs
MongoDB | Blog
MongoDB | Blog
T
The Blog of Author Tim Ferriss
GbyAI
GbyAI
N
Netflix TechBlog - Medium
G
Google Developers Blog
腾讯CDC

博客园 - yf.x

超声波测距#倒车雷达#DE10-Lite 按键计数器#DE10-Lite 按键消抖#DE10-Lite 流水呼吸灯v2#DE10-Lite 流水呼吸灯-v1#DE10-Lite 呼吸灯-#DE10-Lite 流水灯#DE10-Lite#Verilog HDLBits_review 2015fsm 补码FSM-HDLbits 串行数据流输出其中的数据位-HDLbits 串行数据接收判断-HDLbits 输出PS2数据流-HDLbits 独热码状态机-HDLbits 旅鼠4-HDLbits 旅鼠游戏3-HDLbits 旅鼠游戏2-HDLbits 旅鼠游戏--HDLbits 水库水位控制问题-HDLbits 康威生命游戏-hdlbits
PS2数据流检测状态机-HDLbits
yf.x · 2025-12-18 · via 博客园 - yf.x

要求检测3个字节的数据流,每个时钟收到一个字节,首字节的bit[3]是1就是起始字节,做数据流的边界判断,收到有效的3字节,输出一个时钟长度的标记信号done。

image

module top_module(
input clk,
input [7:0] in,
input reset, // Synchronous reset
output done); //
parameter BYTE1=2'h0,BYTE2=2'h1,BYTE3=2'h2,DONE=2'h3;
reg [1:0]state,next_state;
// State transition logic (combinational)
always @(*)
begin
case(state)
BYTE1:next_state=in[3]?BYTE2:BYTE1;
BYTE2:next_state=BYTE3;
BYTE3:next_state=DONE;
DONE:next_state=in[3]?BYTE2:BYTE1;
default:next_state=BYTE1;
endcase
end
// State flip-flops (sequential)
always @(posedge clk)
begin
if(reset)
state<=BYTE1;
else
state<=next_state;
end
// Output logic
assign done=state==DONE;
endmodule