【正文】
state=B。 end B: if (x==0) begin state=C。 end else begin state=F。 end C: if(x==1) begin state=D。 end else begin state=G。 end D: if(x==0) begin state=E。 end else begin state=A。 end E: if(x==0) begin state=C。 end else begin state=A。 end F: if(x==1) begin state=A。 end else begin state=B。 end G: if(x==1) begin state=F。 end default: state=IDLE。 endcase endmodule 測試用代碼: `timescale 1ns/1ns module t。 reg clk, rst。 reg [23:0] data。 wire z,x。 assign x=data[23]。 initial begin clk=0。 rst=1。 2 rst=0。 30 rst=1。 //復位信號 data=39。b1100_1001_0000_1001_0100。 //碼流數(shù)據(jù) end always 10 clk=~clk。 //時鐘信號 always @ (posedge clk) // 移位輸出碼流 data={data[22:0],data[23]}。 seqdet m ( .x(x), .z(z), .clk(clk), .rst(rst))。 //調(diào)用序列檢測器模塊 // Enter fixture code here endmodule // t 其中、 X碼流的產(chǎn)生,我們采用了移位寄存器的方式,以方便更改測試數(shù)據(jù)。仿真結果如下圖所示: 從波形中,我們可以看到程序代碼正確地完成了所要設計的邏輯功能。另外, 編寫,采用了可綜合的 Verilog HDL 風格,它可以通過綜合器的綜合最終實現(xiàn)到 FPGA中。