-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask.v
75 lines (75 loc) · 1.2 KB
/
task.v
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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 20:28:08 06/13/2021
// Design Name:
// Module Name: task
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module Task(input x,input clk,input rst,output reg out);
parameter s0 = 3'b000, s1 = 3'b001, s2 = 3'b010, s3 = 3'b100;
reg [2:0] current_state,next_state;
always @(posedge clk or posedge rst)
begin
if (rst==1)
current_state<=s0;
else
current_state<=next_state;
end
always @(current_state or x)
begin
case(current_state)
s0:
begin
if(x==1)
next_state<=s1;
else
next_state<=s0;
end
s1:
begin
if(x==1)
next_state<=s2;
else
next_state<=s1;
end
s2:
begin
if(x==1)
next_state<=s3;
else
next_state<=s2;
end
s3:
begin
if(x==1)
next_state<=s0;
else
next_state<=s3;
end
default: next_state<=0;
endcase
end
always @(current_state)
begin
case(current_state)
s0: out<=0;
s1: out<=0;
s2: out<=0;
s3: out<=1;
default: out<=0;
endcase
end
endmodule