Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HDL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RTSD
HDL
Commits
21a4ef1a
Commit
21a4ef1a
authored
1 year ago
by
Eric Kooistra
Browse files
Options
Downloads
Patches
Plain Diff
Example for FSM.
parent
b5ff6fbe
No related branches found
No related tags found
No related merge requests found
Pipeline
#50212
passed
1 year ago
Stage: linting
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc/rtl_fsm_example.vhd
+93
-0
93 additions, 0 deletions
doc/rtl_fsm_example.vhd
with
93 additions
and
0 deletions
doc/rtl_fsm_example.vhd
0 → 100644
+
93
−
0
View file @
21a4ef1a
LIBRARY
IEEE
;
USE
IEEE
.
STD_LOGIC_1164
.
ALL
;
USE
IEEE
.
NUMERIC_STD
.
ALL
;
ENTITY
fsm_example
IS
GENERIC
(
g_nof_inputs
:
NATURAL
:
=
6
);
PORT
(
dp_rst
:
IN
STD_LOGIC
;
dp_clk
:
IN
STD_LOGIC
;
-- Inputs
buf_busy
:
IN
STD_LOGIC
;
reg_record_all_rw
:
IN
STD_LOGIC
;
reg_record_enable_rw
:
IN
STD_LOGIC
;
reg_dump_enables_rw
:
IN
STD_LOGIC_VECTOR
(
g_nof_inputs
-1
DOWNTO
0
);
-- Outputs
record_all
:
OUT
STD_LOGIC
;
record_enable
:
OUT
STD_LOGIC
;
dump_enables
:
OUT
STD_LOGIC_VECTOR
(
g_nof_inputs
-1
DOWNTO
0
)
);
END
fsm_example
;
ARCHITECTURE
rtl
OF
fsm_example
IS
-- FSM states
TYPE
t_fsm
IS
(
s_idle
,
s_recording
,
s_dumping
);
-- RTL state registers
TYPE
t_state
IS
RECORD
fsm
:
t_fsm
;
-- other RTL state, not used in this example with only a FSM
END
RECORD
;
CONSTANT
c_state_rst
:
t_state
:
=
(
fsm
=>
s_idle
);
-- reset values
SIGNAL
q
:
t_state
;
-- stored state with latency one
SIGNAL
d
:
t_state
;
-- zero latency state
BEGIN
-- p_state
q
<=
d
WHEN
rising_edge
(
dp_clk
);
p_comb
:
PROCESS
(
dp_rst
,
q
,
buf_busy
,
reg_record_all_rw
,
reg_record_enable_rw
,
reg_dump_enables_rw
)
VARIABLE
v
:
t_state
;
BEGIN
-- Default
v
:
=
q
;
-- keep values
-- Other RTL functionality
-- . not used in this example with only a FSM
-- FSM
CASE
q
.
fsm
IS
WHEN
s_idle
=>
record_all
<=
reg_record_all_rw
;
record_enable
<=
'0'
;
dump_enables
<=
(
OTHERS
=>
'0'
);
IF
reg_record_enable_rw
=
'1'
AND
buf_busy
=
'0'
THEN
v
.
fsm
:
=
s_recording
;
END
IF
;
IF
UNSIGNED
(
reg_dump_enables_rw
)
>
0
AND
buf_busy
=
'0'
THEN
v
.
fsm
:
=
s_recording
;
dump_enables
<=
reg_dump_enables_rw
;
END
IF
;
WHEN
s_recording
=>
IF
reg_record_enable_rw
=
'1'
THEN
record_enable
<=
'1'
;
ELSE
v
.
fsm
:
=
s_idle
;
record_enable
<=
'0'
;
END
IF
;
WHEN
s_dumping
=>
IF
UNSIGNED
(
reg_dump_enables_rw
)
=
0
THEN
v
.
fsm
:
=
s_idle
;
dump_enables
<=
(
OTHERS
=>
'0'
);
END
IF
;
WHEN
OTHERS
=>
-- try to recover from undefined FSM state
v
.
fsm
:
=
s_idle
;
END
CASE
;
-- Reset (synchronous)
IF
dp_rst
=
'1'
THEN
v
:
=
c_state_rst
;
END
IF
;
-- Result
d
<=
v
;
END
PROCESS
;
END
rtl
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment