-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFSM_comb.v
More file actions
63 lines (49 loc) · 1.96 KB
/
FSM_comb.v
File metadata and controls
63 lines (49 loc) · 1.96 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
// Copyright © 2024 Michal Schulz <michal.schulz@gmx.de>
// https://github.com/michalsc
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
//
// FSMComb module
// ==============
// Combinational part of main FSM, sweeping from one state to another and
// driving sequential part of FSM.
module FSMComb(
input wire ACTIVATE,
input wire LATCH,
input wire MUST_CONTINUE,
input wire MC_CLK_RISING,
input wire AS_FEEDBACK,
input wire [3:0] CURRENT,
output reg [3:0] NEXT
);
`include "global.vh"
always @(*) begin
case (CURRENT)
STATE_WAIT:
if (ACTIVATE) NEXT = STATE_ACTIVATE;
else NEXT = STATE_WAIT;
STATE_ACTIVATE: NEXT = STATE_SETUP_BUS;
STATE_SETUP_BUS: NEXT = STATE_DRIVE_AS;
STATE_DRIVE_AS:
if (AS_FEEDBACK) NEXT = STATE_DRIVE_DS;
else NEXT = STATE_DRIVE_AS;
STATE_DRIVE_DS: NEXT = STATE_WAIT_DSACK;
STATE_WAIT_DSACK:
if (LATCH) NEXT = STATE_LATCH;
else NEXT = STATE_WAIT_DSACK;
STATE_LATCH: NEXT = STATE_CLEAR_AS;
STATE_CLEAR_AS: NEXT = STATE_ON_DSACK;
STATE_ON_DSACK:
if (!AS_FEEDBACK && MC_CLK_RISING)
NEXT = STATE_FINALIZE;
else NEXT = STATE_ON_DSACK;
STATE_FINALIZE:
if (MUST_CONTINUE) NEXT = STATE_SETUP_BUS;
else NEXT = STATE_WAIT;
default: NEXT = STATE_WAIT;
endcase
end
endmodule