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

推荐订阅源

J
Java Code Geeks
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
腾讯CDC
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Apple Machine Learning Research
Apple Machine Learning Research
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
MyScale Blog
MyScale Blog
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
N
Netflix TechBlog - Medium
阮一峰的网络日志
阮一峰的网络日志
博客园 - Franky
Recent Announcements
Recent Announcements
A
About on SuperTechFans
Stack Overflow Blog
Stack Overflow Blog
The GitHub Blog
The GitHub Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - 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

要求添加数据路径,把有效的PS2的3个字节的数据输出。

module top_module(
input clk,
input [7:0] in,
input reset, // Synchronous reset
output [23:0] out_bytes,
output done); //

// FSM from fsm_ps2
parameter BYTE1=2'h0,BYTE2=2'h1,BYTE3=2'h2,DONE=2'h3;
reg [1:0]state,next_state;
reg [23:0]data;
always @(*)
begin
case(state)
BYTE1:begin
next_state=in[3]?BYTE2:BYTE1;

end
BYTE2:begin
next_state=BYTE3;

end
BYTE3:begin
next_state=DONE;

end
DONE:next_state=in[3]?BYTE2:BYTE1;
default:next_state=BYTE1;
endcase
end

always @(posedge clk)
if(reset)
state<=BYTE1;
else
state<=next_state;

assign done=state==DONE;
// New: Datapath to store incoming bytes.
always @(posedge clk)
if(reset)
data<=24'h0;
else begin
data<={data[15:0],in};
end
assign out_bytes=done?data:24'hx;
endmodule