赞
踩
// 检测序列:1801816 module Seq_scan(in,out,clk,rst); input wire [3:0] in; input wire clk,rst; output reg out; reg [3:0] n_std,c_std; parameter std0=0,std1=1,std2=2,std3=3,std4=4,std5=5,std6=6,std7=7; //1.part always @(posedge clk or negedge rst) begin if(!rst) c_std=4'b0; else c_std=n_std; end //2.part always @(c_std,rst,in) begin if(!rst) n_std=0; else case(c_std) std0:begin if(in==4'b0001)n_std=std1;else n_std=std0;end std1:begin if(in==4'b1000)n_std=std2; else if(in==4'b0001)n_std=std1; else n_std=std0;end std2:begin if(in==4'b0000)n_std=std3; else if(in==4'b0001) n_std=std1; else n_std=std0;end std3:begin if(in==4'b0001)n_std=std4;else n_std=std0; end std4:begin if(in==4'b1000)n_std=std5; else if(in==4'b0001)n_std=std1; else n_std=std0;end std5:begin if(in==4'b0001)n_std=std6; else if (in==4'b0000) n_std=std3; else n_std=std0; end std6:begin if(in==4'b0110)n_std=std7; else if(in==4'b1000)n_std=std2; else if(in==4'b0001)n_std=std1; else n_std=std0; end std7:begin if(in==4'b0001)n_std=std1;else n_std=std0;end endcase end //3.part always @(c_std,rst) begin if(!rst) out=0; else if(c_std==std7) out=1; else out=0; end endmodule
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。