|
楼主 |
发表于 2008-12-1 16:07:53
|
显示全部楼层
这种笔试题都是可以覆盖的
难道单一的用这个方法,研究研究,
印象中夏宇文用这个方法检测覆盖的
网上的
练练手,用verilog实现序列检测,对输入的数码流中找到10010的子序列。
设x为串行输入的某一位,z为输出。当连续五位输入分别满足10010的时
候,z就为1,否则z为0。时间序列以2nm为周期。
源代码为:
module seqdet(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:0;
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<= E;
else state<=A;
E: if(x==0)
state<= C;
else state<=A;
F: if(x==1)
state<= A;
else state<=B;
G: if(x==1)
state<= F;
else state<=G;
default: state<=IDLE;
endcase
endmodule |
|