Verilog语言——序列检测器
2010-04-03 00:22
267 查看
设计一个序列检测器,检测器在有“101”序列输入时输出为1,其他输入情况下,输出为0。
module xuliejiance(x,z,clk,rst,state);
input x,clk,rst;
output z;
output[2:0] state;
reg[2:0] state;
wire z;
parameter IDLE='d0,A='d1,B='d2,C='d3,G='D4;
assign z=(state==C&&x==1)?1:0;
always @(posedge clk)
if(!rst)
begin
state <= IDLE;
end
else
casex(state)
IDLE : if(x==1)
begin
state <= A;
end
A: if(x==0)
begin
state <= B;
end
B: if(x==1)
begin
state <= C;
end
else
begin
state <= G;
end
C: if(x==1)
begin
state <= A;
end
else
begin
state <= G;
end
G: if(x==1)
begin
state <= A;
end
default:state=IDLE; //缺省状态为初始状态。
endcase
endmodule
module xuliejiance(x,z,clk,rst,state);
input x,clk,rst;
output z;
output[2:0] state;
reg[2:0] state;
wire z;
parameter IDLE='d0,A='d1,B='d2,C='d3,G='D4;
assign z=(state==C&&x==1)?1:0;
always @(posedge clk)
if(!rst)
begin
state <= IDLE;
end
else
casex(state)
IDLE : if(x==1)
begin
state <= A;
end
A: if(x==0)
begin
state <= B;
end
B: if(x==1)
begin
state <= C;
end
else
begin
state <= G;
end
C: if(x==1)
begin
state <= A;
end
else
begin
state <= G;
end
G: if(x==1)
begin
state <= A;
end
default:state=IDLE; //缺省状态为初始状态。
endcase
endmodule
相关文章推荐
- verilog 有限状态机的小小实例演示及仿真——序列检测器
- 10010序列检测器的三段式状态机实现(verilog)
- [试验]10010序列检测器的三段式状态机实现(verilog)
- 第一次verilog实验——序列检测器的实现
- 6-1 Verilog Mealy状态机之序列检测器
- 10010序列检测器的verilog实现
- Verilog序列检测器-两例
- 最大子序列问题及其求解----C 语言学习
- Verilog HDL语言学习笔记
- Verilog HDL语言always块未声明positive或negative导致的时钟不对准
- 用Verilog语言实现奇数倍分频电路3分频、5分频、7分频
- JavaScript挺入服务器端开发语言序列
- Verilog语言——20分频器
- 用verilog实现m序列生成
- 用verilog语言设计一个2s的呼吸灯
- 任意分频的verilog语言实现
- Verilog HDL语言的用户自定义元件
- 计161_Problem K: C语言实验——分数序列
- 序列检测器改编
- 【转载】Verilog语言中wire与reg的区别