|
我用verilog编了一个序列检测器的程序
module seqder(x,z,clk,rst);
input x,clk,rst;
output z;
//状态寄存器
reg [2:0] state;
wire z;
parameter IDLE=3'd0,
A=3'd1,
B=3'd2,
C=3'd3,
D=3'd4,
E=3'd5,
F=3'd6,
G=3'd7;
assign z=(state==D&&x==0)?1'b1:1'b0;
always@(posedge clk or negedge rst)
if(!rst)
begin
state<=IDLE;
end
else
casex(state)
IDLE:if(x==1)
state<=A;
else state<=IDLE;
A: if(x==0)
state<=B;
else state<=A;
B: if(x==0)
state<=C;
else state<=F;
C: if(x==1)
state<=D;
else state<=G;
D: if(x==0)
state<=D;
else state<=G;
E: if(x==0)
state<=C;
else state<=A;
F: if(x==1)
state<=A;
else state<=B;
G: if(x==1)
state<=A;
else state<=G;
default: state<=IDLE;
endcase
endmodule
利用test.v对他进行测试
`timescale 1ns/1ns
module test;
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=20'b1100_1001_0000_10001_0100;
end
always #10 clk=~clk;
always @(posedge clk)
data={data[22:0],data[23]};
seqder(.x(x),.z(z),.clk(clk),.rst(rst));
endmodule
但是不知道,在quartus中如何对此程序进行仿真,请大家帮帮忙。 |
|