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

推荐订阅源

V
Visual Studio Blog
I
InfoQ
H
Help Net Security
GbyAI
GbyAI
博客园 - 叶小钗
Recent Announcements
Recent Announcements
Engineering at Meta
Engineering at Meta
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
Y
Y Combinator Blog
L
LangChain Blog
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
G
Google Developers Blog
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
博客园 - Franky
D
Docker
Jina AI
Jina AI
罗磊的独立博客

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