-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoore_mach.v
More file actions
81 lines (74 loc) · 1.46 KB
/
moore_mach.v
File metadata and controls
81 lines (74 loc) · 1.46 KB
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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 17.01.2026 13:56:41
// Design Name:
// Module Name: moore_mach
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module moore_fsm(
input data,
input clk,
input rst,
output reg out
);
reg [1:0] state, next;
// State register
always @(posedge clk or posedge rst) begin
if (rst)
state <= 2'b00;
else
state <= next;
end
// Next state & output logic
always @(*) begin
next=state;
case (state)
2'b00: begin
if (data)
next = 2'b01;
else
next = 2'b00;
end
2'b01: begin
if (data)
next = 2'b01;
else
next = 2'b10;
end
2'b10: begin
if (data)
next = 2'b11;
else
next = 2'b00;
end
2'b11:begin
if(data)
next=2'b01;
else
next=2'b00;
end
default: begin
next = 2'b00;
end
endcase
end
always@(*)begin
if(state==2'b11)
out=1'b1;
else
out=1'b0;
end
endmodule