我是靠谱客的博主 耍酷往事,这篇文章主要介绍序列检测功能的时序电路(verilog 01110),现在分享给大家,希望可以做个参考。

 

上代码:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
module timecheck(CLR,CLK,A,B,Z); input CLR,CLK,A,B; output Z; reg Z; wire [1:0]DATA_IN; reg [3:0]STATE; parameter   state_idle     =  4'b00x0,              state_match1   =  4'b0000,              state_match2   =  4'b0001,              state_match3   =  4'b0011,              state_match4   =  4'b0111; assign       DATA_IN = {A,B};            initial begin     STATE =state_idle; end always @(posedge CLK or posedge CLR) begin          if(~CLR)         begin             Z<=0;             STATE <=state_idle;         end         else          case(STATE)                  state_idle:               if((DATA_IN==2'b00) || (DATA_IN==2'b10 ))         begin             STATE <=state_idle;             Z<=0;         end         else if(DATA_IN==2'b01)         begin             STATE <=state_match2;             Z<=0;         end         else if(DATA_IN==2'b11)         begin             STATE <=state_match3;             Z<=0;         end                  state_match1:               if((DATA_IN==2'b00) || (DATA_IN==2'b10 ))         begin             STATE <=state_idle;             Z<=0;         end         else if(DATA_IN==2'b01)         begin             STATE <=state_match2;             Z<=0;         end         else if(DATA_IN==2'b11)         begin             STATE <=state_match1;             Z<=0;         end                  state_match2:              if((DATA_IN==2'b00) || (DATA_IN==2'b10 ))         begin             STATE <=state_idle;             Z<=0;         end         else if(DATA_IN==2'b01)         begin             STATE <=state_match2;             Z<=0;         end         else if(DATA_IN==2'b11)         begin             STATE <=state_match4;             Z<=0;         end                  state_match3:               if(DATA_IN==2'b00)         begin             STATE <=state_idle;             Z<=0;         end         else if(DATA_IN==2'b01)         begin             STATE <=state_match2;             Z<=0;         end         else if(DATA_IN==2'b11)         begin             STATE <=state_match1;             Z<=0;         end         else if(DATA_IN==2'b10)         begin             STATE <=state_match1;             Z<=1;         end                  state_match4:               if(DATA_IN==2'b00)         begin             STATE <=state_idle;             Z<=1;         end         else if(DATA_IN==2'b10)         begin             STATE <=state_idle;             Z<=0;         end         else if(DATA_IN==2'b01)         begin             STATE <=state_match1;             Z<=1;         end         else if(DATA_IN==2'b11)         begin             STATE <=state_match1;             Z<=0;         end endcase end  endmodule


测试代码:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
`timescale 1ns / 1ns module tb_timecheck(); reg clr,clk,a,b; wire z; parameter data_input = 20'b1010_1110_0111_0111_0001; reg [4:0] i; timecheck tb_time(.CLR(clr),.CLK(clk),.A(a),.B(b),.Z(z)); initial begin     clr= 0;     a=0;     b=0;     clk=0;     i=5'd0;     #5     clr =1; end  always  #5 clk = ~ clk; always @(posedge clk or posedge clr)  begin      if(~clr)        begin              i<=5'd0;        end     else if (i<5'd20)         begin             a<=data_input[i];             b<=data_input[i+1];             i<=i+5'd2;        end        else        begin             i<=5'd2;             a<=data_input[0];             b<=data_input[1];        end end  endmodule

综合电路图:

仿真波形:

同学做的比我好多了,上图:

 

 

 

 

 

 

 

 

 

 

 

最后

以上就是耍酷往事最近收集整理的关于序列检测功能的时序电路(verilog 01110)的全部内容,更多相关序列检测功能的时序电路(verilog内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(90)

评论列表共有 0 条评论

立即
投稿
返回
顶部