Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
STITCH
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
Pascal Engeler
STITCH
Commits
00427189
Commit
00427189
authored
6 months ago
by
Pascal Engeler
Browse files
Options
Downloads
Patches
Plain Diff
Started work on distance unwrapping module
parent
fe173336
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
Resolve "Distance wrapping invalidates lock sum"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
stitch_project/stitch/DistanceUnwrapper.vhd
+158
-0
158 additions, 0 deletions
stitch_project/stitch/DistanceUnwrapper.vhd
with
158 additions
and
0 deletions
stitch_project/stitch/DistanceUnwrapper.vhd
0 → 100644
+
158
−
0
View file @
00427189
----------------------------------------------------------------------------------
-- Company: ETH Zurich
-- Engineer: Pascal Engeler <engeler.pascal@gmail.com>
--
-- Create Date: 14:32:01 09/06/2024
-- Design Name:
-- Module Name: DistanceUnwrapper - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library
IEEE
;
use
IEEE
.
STD_LOGIC_1164
.
ALL
;
use
IEEE
.
STD_LOGIC_UNSIGNED
.
ALL
;
use
IEEE
.
NUMERIC_STD
.
ALL
;
entity
DistanceUnwrapper
is
Port
(
clk100
:
in
STD_LOGIC
;
en
:
in
STD_LOGIC
;
dr
:
in
STD_LOGIC
;
distance_in
:
in
STD_LOGIC_VECTOR
(
20
downto
0
);
distance_out
:
out
STD_LOGIC_VECTOR
(
24
downto
0
);
dr_out
:
out
STD_LOGIC
);
end
DistanceUnwrapper
;
architecture
Behavioral
of
DistanceUnwrapper
is
type
STATE_T
is
(
IDLE_S
,
STATE1
,
STATE2
,
STATE3
,
STATE4
,
STATE5
,
STATE6
);
signal
current_state
:
STATE_T
:
=
IDLE_S
;
signal
currentDistance
:
STD_LOGIC_VECTOR
(
24
downto
0
)
:
=
(
others
=>
'0'
);
signal
prevDistance
:
STD_LOGIC_VECTOR
(
24
downto
0
)
:
=
(
others
=>
'0'
);
signal
distanceInWide
:
STD_LOGIC_VECTOR
(
24
downto
0
)
:
=
(
others
=>
'0'
);
signal
calcDelta
:
STD_LOGIC_VECTOR
(
24
downto
0
)
:
=
(
others
=>
'0'
);
signal
maxDelta
:
STD_LOGIC_VECTOR
(
24
downto
0
)
:
=
"0000100000000000000000000"
;
signal
corrDelta
:
STD_LOGIC_VECTOR
(
24
downto
0
)
:
=
"0001000000000000000000000"
;
signal
corrDeltaN
:
STD_LOGIC_VECTOR
(
24
downto
0
)
:
=
"1111000000000000000000000"
;
signal
currentOffset
:
STD_LOGIC_VECTOR
(
24
downto
0
)
:
=
(
others
=>
'0'
);
signal
dr_prev
:
STD_LOGIC
:
=
'0'
;
begin
distanceInWide
(
20
downto
0
)
<=
distance_in
;
distanceInWide
(
24
downto
21
)
<=
(
others
=>
'0'
);
dr_update
:
process
(
clk100
)
begin
if
rising_edge
(
clk100
)
then
dr_prev
<=
dr
;
end
if
;
end
process
;
proc
:
process
(
clk100
)
begin
if
rising_edge
(
clk100
)
then
if
en
=
'1'
then
case
current_state
is
when
IDLE_S
=>
if
dr
=
'1'
and
dr_prev
=
'0'
then
current_state
<=
STATE1
;
--calculate relevant delta distance here
if
prevDistance
>
distanceInWide
then
calcDelta
<=
prevDistance
-
distanceInWide
;
else
calcDelta
<=
distanceInWide
-
prevDistance
;
else
end
if
;
when
STATE1
=>
current_state
<=
STATE2
;
--calculate change to offset here
when
STATE2
=>
current_state
<=
STATE3
;
--calculate output distance here
when
STATE3
=>
current_state
<=
IDLE_S
;
--set output ready here
end
case
;
else
currentDistance
<=
(
others
=>
'0'
);
prevDistance
<=
(
others
=>
'0'
);
end
if
;
end
if
;
end
process
;
signal
cmd_received_sig
:
STD_LOGIC
:
=
'0'
;
signal
rxs
:
STD_LOGIC
:
=
'0'
;
signal
rx_delay_line
:
STD_LOGIC_VECTOR
(
5
downto
0
);
signal
serial_data
:
STD_LOGIC_VECTOR
(
9
downto
0
)
:
=
(
others
=>
'0'
);
signal
serial_counter
:
STD_LOGIC_VECTOR
(
9
downto
0
)
:
=
(
others
=>
'0'
);
--baud rate: 115200
signal
serial_counter_max
:
STD_LOGIC_VECTOR
(
9
downto
0
)
:
=
"1101100011"
;
--change this for baud rate change
signal
serial_counter_offset
:
STD_LOGIC_VECTOR
(
9
downto
0
)
:
=
"0110110001"
;
--change this for baud rate change
begin
sanitize_input
:
process
(
clk100
)
begin
if
rising_edge
(
clk100
)
then
rx_delay_line
(
5
)
<=
s_data_in
;
rx_delay_line
(
4
downto
0
)
<=
rx_delay_line
(
5
downto
1
);
rxs
<=
rx_delay_line
(
0
);
end
if
;
end
process
;
receive_serial
:
process
(
clk100
)
begin
if
rising_edge
(
clk100
)
then
if
(
rxs
=
'1'
)
AND
(
serial_data
(
0
)
=
'0'
)
then
serial_data
<=
"1111111111"
;
cmd_received_sig
<=
'0'
;
serial_counter
<=
serial_counter_offset
;
else
if
(
serial_counter
=
serial_counter_max
)
AND
(
serial_data
(
0
)
=
'1'
)
then
serial_counter
<=
(
others
=>
'0'
);
serial_data
(
8
downto
0
)
<=
serial_data
(
9
downto
1
);
serial_data
(
9
)
<=
NOT
rxs
;
cmd_received_sig
<=
not
serial_data
(
1
);
--this should maybe be serial_data(0) update: no, i think this is correct.
else
serial_counter
<=
serial_counter
+
1
;
cmd_received_sig
<=
'0'
;
serial_data
<=
serial_data
;
end
if
;
end
if
;
end
if
;
end
process
;
data
<=
serial_data
(
8
downto
1
);
cmd_received
<=
cmd_received_sig
;
end
Behavioral
;
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