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

推荐订阅源

博客园 - Franky
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
Y
Y Combinator Blog
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Check Point Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
博客园 - 司徒正美
I
InfoQ
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
U
Unit 42

博客园 - 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 输出PS2数据流-HDLbits PS2数据流检测状态机-HDLbits 独热码状态机-HDLbits 旅鼠4-HDLbits 旅鼠游戏3-HDLbits 旅鼠游戏2-HDLbits 旅鼠游戏--HDLbits 水库水位控制问题-HDLbits 康威生命游戏-hdlbits
串行数据流输出其中的数据位-HDLbits
yf.x · 2025-12-19 · via 博客园 - yf.x

把检测到成功收到的串行数据流中的8位数据位输出。

module top_module(
input clk,
input in,
input reset, // Synchronous reset
output [7:0] out_byte,
output done
); //
reg [9:0]data_in;
parameter IDLE=0,START=1,BIT0=2,BIT1=3,BIT2=4,BIT3=5,BIT4=6,
BIT5=7,BIT6=8,BIT7=9,STOP=10,ERROR=11;
reg[3:0]state,next_state;
// Use FSM from Fsm_serial
always @(*)
case(state)
IDLE:next_state=in?IDLE:START;
START:next_state=BIT0;
BIT0:next_state=BIT1;
BIT1:next_state=BIT2;
BIT2:next_state=BIT3;
BIT3:next_state=BIT4;
BIT4:next_state=BIT5;
BIT5:next_state=BIT6;
BIT6:next_state=BIT7;
BIT7:next_state=in?STOP:ERROR;
STOP:next_state=in?IDLE:START;
ERROR:next_state=in?IDLE:ERROR;
default:next_state=IDLE;
endcase

always @(posedge clk)
if(reset)
state<=IDLE;
else
state<=next_state;
assign done=state==STOP;

// New: Datapath to latch input bits.
always @(posedge clk)
if(reset)
data_in<=10'h0;
else
data_in<={in,data_in[9:1]};

assign out_byte=(state==STOP)?data_in[8:1]:10'hx;
endmodule