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
da09aee9
Commit
da09aee9
authored
4 years ago
by
Eric Kooistra
Browse files
Options
Downloads
Patches
Plain Diff
Remove separate x, y. Prepare for using in_sop as start of block.
parent
6401ff13
No related branches found
Branches containing commit
No related tags found
1 merge request
!28
Master
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libraries/dsp/si/src/vhdl/si.vhd
+25
-42
25 additions, 42 deletions
libraries/dsp/si/src/vhdl/si.vhd
libraries/dsp/si/tb/vhdl/tb_si.vhd
+39
-46
39 additions, 46 deletions
libraries/dsp/si/tb/vhdl/tb_si.vhd
with
64 additions
and
88 deletions
libraries/dsp/si/src/vhdl/si.vhd
+
25
−
42
View file @
da09aee9
...
...
@@ -38,20 +38,18 @@ USE IEEE.NUMERIC_STD.ALL;
ENTITY
si
IS
GENERIC
(
g_dat_w
:
NATURAL
:
=
18
;
g_si_dat_w
:
NATURAL
:
=
12
g_dat_w
:
NATURAL
:
=
18
);
PORT
(
in_dat_x
:
IN
STD_LOGIC_VECTOR
(
g_dat_w
-1
DOWNTO
0
);
in_dat_y
:
IN
STD_LOGIC_VECTOR
(
g_dat_w
-1
DOWNTO
0
);
in_dat
:
IN
STD_LOGIC_VECTOR
(
g_dat_w
-1
DOWNTO
0
);
in_val
:
IN
STD_LOGIC
;
in_sop
:
IN
STD_LOGIC
;
in_sync
:
IN
STD_LOGIC
;
out_dat_x
:
OUT
STD_LOGIC_VECTOR
(
g_dat_w
-1
DOWNTO
0
);
out_dat_y
:
OUT
STD_LOGIC_VECTOR
(
g_dat_w
-1
DOWNTO
0
);
out_dat
:
OUT
STD_LOGIC_VECTOR
(
g_dat_w
-1
DOWNTO
0
);
out_val
:
OUT
STD_LOGIC
;
out_sop
:
OUT
STD_LOGIC
;
out_sync
:
OUT
STD_LOGIC
;
si_en_x
:
IN
STD_LOGIC
;
si_en_y
:
IN
STD_LOGIC
;
si_en
:
IN
STD_LOGIC
;
clk
:
IN
STD_LOGIC
;
rst
:
IN
STD_LOGIC
);
...
...
@@ -59,69 +57,54 @@ END si;
ARCHITECTURE
rtl
OF
si
IS
CONSTANT
c_dat_max
:
INTEGER
:
=
2
**
(
g_
si_
dat_w
-1
)
-1
;
CONSTANT
c_dat_min
:
INTEGER
:
=
-2
**
(
g_
si_
dat_w
-1
);
CONSTANT
c_dat_max
:
INTEGER
:
=
2
**
(
g_dat_w
-1
)
-1
;
CONSTANT
c_dat_min
:
INTEGER
:
=
-2
**
(
g_dat_w
-1
);
SIGNAL
nxt_out_dat_x
:
STD_LOGIC_VECTOR
(
out_dat_x
'RANGE
);
SIGNAL
nxt_out_dat_y
:
STD_LOGIC_VECTOR
(
out_dat_y
'RANGE
);
SIGNAL
plus
:
STD_LOGIC
;
SIGNAL
nxt_plus
:
STD_LOGIC
;
SIGNAL
plus_x
:
STD_LOGIC
;
SIGNAL
plus_y
:
STD_LOGIC
;
SIGNAL
nxt_out_dat
:
STD_LOGIC_VECTOR
(
out_dat
'RANGE
);
SIGNAL
plus
:
STD_LOGIC
;
SIGNAL
nxt_plus
:
STD_LOGIC
;
SIGNAL
si_plus
:
STD_LOGIC
;
BEGIN
reg_si
:
PROCESS
(
rst
,
clk
)
reg_si
:
PROCESS
(
rst
,
clk
)
BEGIN
IF
rst
=
'1'
THEN
out_dat_x
<=
(
OTHERS
=>
'0'
);
out_dat_y
<=
(
OTHERS
=>
'0'
);
out_val
<=
'0'
;
out_sop
<=
'0'
;
out_sync
<=
'0'
;
plus
<=
'1'
;
ELSIF
rising_edge
(
clk
)
THEN
out_dat_x
<=
nxt_out_dat_x
;
out_dat_y
<=
nxt_out_dat_y
;
out_dat
<=
nxt_out_dat
;
out_val
<=
in_val
;
out_sop
<=
in_sop
;
out_sync
<=
in_sync
;
plus
<=
nxt_plus
;
END
IF
;
END
PROCESS
;
si_control
:
PROCESS
(
plus
,
in_s
ync
,
in_val
)
si_control
:
PROCESS
(
plus
,
in_s
op
,
in_val
)
BEGIN
nxt_plus
<=
plus
;
IF
in_s
ync
=
'1'
THEN
IF
in_s
op
=
'1'
THEN
nxt_plus
<=
'1'
;
ELSIF
in_val
=
'1'
THEN
nxt_plus
<=
NOT
plus
;
END
IF
;
END
PROCESS
;
plus_x
<=
plus
WHEN
si_en_x
=
'1'
ELSE
'1'
;
plus_y
<=
plus
WHEN
si_en_y
=
'1'
ELSE
'1'
;
si_plus
<=
plus
WHEN
si_en
=
'1'
ELSE
'1'
;
si_data
_x
:
PROCESS
(
plus
_x
,
in_dat
_x
)
si_data
:
PROCESS
(
si_
plus
,
in_dat
)
BEGIN
nxt_out_dat
_x
<=
in_dat
_x
;
IF
plus
_x
=
'0'
THEN
nxt_out_dat
_x
<=
STD_LOGIC_VECTOR
(
-
SIGNED
(
in_dat
_x
));
nxt_out_dat
<=
in_dat
;
IF
si_
plus
=
'0'
THEN
nxt_out_dat
<=
STD_LOGIC_VECTOR
(
-
SIGNED
(
in_dat
));
-- Clip -c_dat_min to c_dat_max instead of wrapping to c_dat_min
IF
SIGNED
(
in_dat
_x
)
=
c_dat_min
THEN
nxt_out_dat
_x
<=
STD_LOGIC_VECTOR
(
TO_SIGNED
(
c_dat_max
,
g_dat_w
));
IF
SIGNED
(
in_dat
)
=
c_dat_min
THEN
nxt_out_dat
<=
STD_LOGIC_VECTOR
(
TO_SIGNED
(
c_dat_max
,
g_dat_w
));
END
IF
;
END
IF
;
END
PROCESS
;
si_data_y
:
PROCESS
(
plus_y
,
in_dat_y
)
BEGIN
nxt_out_dat_y
<=
in_dat_y
;
IF
plus_y
=
'0'
THEN
nxt_out_dat_y
<=
STD_LOGIC_VECTOR
(
-
SIGNED
(
in_dat_y
));
-- Clip -c_dat_min to c_dat_max instead of wrapping to c_dat_min
IF
SIGNED
(
in_dat_y
)
=
c_dat_min
THEN
nxt_out_dat_y
<=
STD_LOGIC_VECTOR
(
TO_SIGNED
(
c_dat_max
,
g_dat_w
));
END
IF
;
END
IF
;
END
PROCESS
;
END
rtl
;
This diff is collapsed.
Click to expand it.
libraries/dsp/si/tb/vhdl/tb_si.vhd
+
39
−
46
View file @
da09aee9
...
...
@@ -28,9 +28,9 @@
-- . Ported from LOFAR1 rsp
-- . The tb is self-stopping, but not self checking.
LIBRARY
IEEE
,
si
_lib
;
LIBRARY
IEEE
,
common
_lib
;
USE
IEEE
.
STD_LOGIC_1164
.
ALL
;
USE
IEEE
.
NUMERIC_STD
.
ALL
;
USE
common_lib
.
common_pkg
.
ALL
;
ENTITY
tb_si
IS
END
tb_si
;
...
...
@@ -40,20 +40,18 @@ ARCHITECTURE tb OF tb_si IS
CONSTANT
c_clk_period
:
TIME
:
=
10
ns
;
CONSTANT
c_dat_w
:
NATURAL
:
=
5
;
CONSTANT
c_
si_dat_w
:
NATURAL
:
=
5
;
CONSTANT
c_
block_size
:
NATURAL
:
=
19
;
SIGNAL
in_dat_x
:
STD_LOGIC_VECTOR
(
c_dat_w
-1
DOWNTO
0
);
SIGNAL
in_dat_y
:
STD_LOGIC_VECTOR
(
c_dat_w
-1
DOWNTO
0
);
SIGNAL
nxt_in_dat_x
:
STD_LOGIC_VECTOR
(
c_dat_w
-1
DOWNTO
0
);
SIGNAL
nxt_in_dat_y
:
STD_LOGIC_VECTOR
(
c_dat_w
-1
DOWNTO
0
);
SIGNAL
in_dat
:
STD_LOGIC_VECTOR
(
c_dat_w
-1
DOWNTO
0
);
SIGNAL
nxt_in_dat
:
STD_LOGIC_VECTOR
(
c_dat_w
-1
DOWNTO
0
);
SIGNAL
in_val
:
STD_LOGIC
;
SIGNAL
in_sop
:
STD_LOGIC
;
SIGNAL
in_sync
:
STD_LOGIC
;
SIGNAL
out_dat_x
:
STD_LOGIC_VECTOR
(
c_dat_w
-1
DOWNTO
0
);
SIGNAL
out_dat_y
:
STD_LOGIC_VECTOR
(
c_dat_w
-1
DOWNTO
0
);
SIGNAL
out_dat
:
STD_LOGIC_VECTOR
(
c_dat_w
-1
DOWNTO
0
);
SIGNAL
out_val
:
STD_LOGIC
;
SIGNAL
out_sop
:
STD_LOGIC
;
SIGNAL
out_sync
:
STD_LOGIC
;
SIGNAL
si_en_x
:
STD_LOGIC
;
SIGNAL
si_en_y
:
STD_LOGIC
;
SIGNAL
si_en
:
STD_LOGIC
;
SIGNAL
clk
:
STD_LOGIC
:
=
'1'
;
SIGNAL
rst
:
STD_LOGIC
;
SIGNAL
tb_end
:
STD_LOGIC
:
=
'0'
;
...
...
@@ -64,24 +62,22 @@ ARCHITECTURE tb OF tb_si IS
BEGIN
rst
<=
'1'
,
'0'
AFTER
c_clk_period
;
clk
<=
NOT
(
clk
)
OR
tb_end
AFTER
c_clk_period
/
2
;
-- test bench clock
clk
<=
NOT
(
clk
)
OR
tb_end
AFTER
c_clk_period
/
2
;
u_si
:
ENTITY
si_lib
.
si
u_si
:
ENTITY
work
.
si
GENERIC
MAP
(
g_dat_w
=>
c_dat_w
,
g_si_dat_w
=>
c_si_dat_w
g_dat_w
=>
c_dat_w
)
PORT
MAP
(
in_dat_x
=>
in_dat_x
,
in_dat_y
=>
in_dat_y
,
in_dat
=>
in_dat
,
in_val
=>
in_val
,
in_sop
=>
in_sop
,
in_sync
=>
in_sync
,
out_dat_x
=>
out_dat_x
,
out_dat_y
=>
out_dat_y
,
out_dat
=>
out_dat
,
out_val
=>
out_val
,
out_sop
=>
out_sop
,
out_sync
=>
out_sync
,
si_en_x
=>
si_en_x
,
si_en_y
=>
si_en_y
,
si_en
=>
si_en
,
clk
=>
clk
,
rst
=>
rst
);
...
...
@@ -89,67 +85,64 @@ BEGIN
reg_stimuli
:
PROCESS
(
rst
,
clk
)
BEGIN
IF
rst
=
'1'
THEN
in_dat_x
<=
(
OTHERS
=>
'0'
);
in_dat_y
<=
(
OTHERS
=>
'0'
);
in_dat
<=
(
OTHERS
=>
'0'
);
toggle
<=
'0'
;
ELSIF
rising_edge
(
clk
)
THEN
in_dat_x
<=
nxt_in_dat_x
;
in_dat_y
<=
nxt_in_dat_y
;
in_dat
<=
nxt_in_dat
;
toggle
<=
nxt_toggle
;
END
IF
;
END
PROCESS
;
nxt_toggle
<=
NOT
toggle
;
data_counter
:
PROCESS
(
toggle
,
in_dat
_x
,
in_dat_y
)
data_counter
:
PROCESS
(
toggle
,
in_dat
)
BEGIN
nxt_in_dat_x
<=
in_dat_x
;
nxt_in_dat_y
<=
in_dat_y
;
nxt_in_dat
<=
in_dat
;
IF
toggle
=
'1'
THEN
nxt_in_dat_x
<=
STD_LOGIC_VECTOR
(
SIGNED
(
in_dat_x
)
+
3
);
nxt_in_dat_y
<=
STD_LOGIC_VECTOR
(
SIGNED
(
in_dat_y
)
+
3
);
nxt_in_dat
<=
INCR_UVEC
(
in_dat
,
1
);
END
IF
;
END
PROCESS
;
PROCESS
BEGIN
si_en
_x
<=
'1'
;
si_en_y
<=
'
1
'
;
si_en
<=
'1'
;
in_sop
<=
'
0
'
;
in_sync
<=
'0'
;
in_val
<=
'0'
;
WAIT
FOR
10
*
c_clk_period
;
-- sync followed by valid data
-- pulse in_sync, to check that it is passed on
-- sop followed by valid data
in_sync
<=
'1'
;
in_sop
<=
'1'
;
in_val
<=
'0'
;
WAIT
FOR
c_clk_period
;
in_sync
<=
'0'
;
in_sop
<=
'0'
;
in_val
<=
'1'
;
WAIT
FOR
99
*
c_clk_period
;
WAIT
FOR
c_block_size
*
c_clk_period
;
-- insert a single valid low cycle
in_sync
<=
'0'
;
in_val
<=
'0'
;
WAIT
FOR
c_clk_period
;
in_sync
<=
'0'
;
in_val
<=
'1'
;
WAIT
FOR
99
*
c_clk_period
;
WAIT
FOR
c_block_size
*
c_clk_period
;
-- insert an out of phase resync cycle
in_s
ync
<=
'1'
;
-- insert an out of phase resync
sop
cycle
in_s
op
<=
'1'
;
in_val
<=
'1'
;
WAIT
FOR
c_clk_period
;
in_s
ync
<=
'0'
;
in_s
op
<=
'0'
;
in_val
<=
'1'
;
WAIT
FOR
99
*
c_clk_period
;
WAIT
FOR
c_block_size
*
c_clk_period
;
-- insert an in phase resync cycle
in_s
ync
<=
'1'
;
-- insert an in phase resync
sop
cycle
in_s
op
<=
'1'
;
in_val
<=
'1'
;
WAIT
FOR
c_clk_period
;
in_s
ync
<=
'0'
;
in_s
op
<=
'0'
;
in_val
<=
'1'
;
WAIT
FOR
99
*
c_clk_period
;
WAIT
FOR
c_block_size
*
c_clk_period
;
tb_end
<=
'1'
;
WAIT
;
...
...
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