Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
Conv TTL Blocking
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Conv TTL Blocking
Commits
081d73c1
Commit
081d73c1
authored
Sep 17, 2012
by
gilsoriano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improving whole module: better reads and writes fsm
parent
e4c9846a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
353 additions
and
316 deletions
+353
-316
spi_master_core.vhd
hdl/spi_master_multifield/rtl/spi_master_core.vhd
+291
-315
spi_master_pkg.vhd
hdl/spi_master_multifield/rtl/spi_master_pkg.vhd
+62
-1
No files found.
hdl/spi_master_multifield/rtl/spi_master_core.vhd
View file @
081d73c1
This diff is collapsed.
Click to expand it.
hdl/spi_master_multifield/rtl/spi_master_pkg.vhd
View file @
081d73c1
...
...
@@ -216,6 +216,14 @@ package spi_master_pkg is
function
f_STD_LOGIC_VECTOR
(
r_register
:
in
r_SPI2
)
return
STD_LOGIC_VECTOR
;
function
f_STD_LOGIC_VECTOR
(
r_register
:
in
r_SPI3
)
return
STD_LOGIC_VECTOR
;
function
f_read_edge
(
r_register
:
in
r_SPI0
;
spi_clk
:
in
STD_LOGIC
;
spi_clk_d0
:
in
STD_LOGIC
)
return
STD_LOGIC
;
function
f_write_edge
(
r_register
:
in
r_SPI0
;
spi_clk
:
in
STD_LOGIC
;
spi_clk_d0
:
in
STD_LOGIC
)
return
STD_LOGIC
;
function
f_min
(
a
:
NATURAL
;
b
:
NATURAL
)
return
NATURAL
;
end
spi_master_pkg
;
...
...
@@ -365,5 +373,58 @@ package body spi_master_pkg is
return
v_SPI3
;
end
f_SPI3
;
-----------------------------------------------------------------------------
--! @brief Function that determines a read edge depending upon
--! CPOL and CPHA values.
--! @param r_register SPI0 register containing CPOL and CPHA
--! spi_clk STD_LOGIC containing currently sampled spi clock value
--! spi_clk_d0 STD_LOGIC containing previously sampled spi clock value
-----------------------------------------------------------------------------
function
f_read_edge
(
r_register
:
in
r_SPI0
;
spi_clk
:
in
STD_LOGIC
;
spi_clk_d0
:
in
STD_LOGIC
)
return
STD_LOGIC
is
variable
read_edge
:
STD_LOGIC
;
begin
read_edge
:
=
'0'
;
if
(
r_register
.
CPOL
xor
r_register
.
CPHA
)
=
'0'
then
--! The read case is the rising_edge
if
spi_clk
=
'1'
and
spi_clk_d0
=
'0'
then
read_edge
:
=
'1'
;
end
if
;
else
--! The read case is the falling_edge
if
spi_clk
=
'0'
and
spi_clk_d0
=
'1'
then
read_edge
:
=
'1'
;
end
if
;
end
if
;
return
read_edge
;
end
f_read_edge
;
-----------------------------------------------------------------------------
--! @brief Function that determines a write edge depending upon
--! CPOL and CPHA values.
--! @param r_register SPI0 register containing CPOL and CPHA
--! spi_clk STD_LOGIC containing currently sampled spi clock value
--! spi_clk_d0 STD_LOGIC containing previously sampled spi clock value
-----------------------------------------------------------------------------
function
f_write_edge
(
r_register
:
in
r_SPI0
;
spi_clk
:
in
STD_LOGIC
;
spi_clk_d0
:
in
STD_LOGIC
)
return
STD_LOGIC
is
variable
write_edge
:
STD_LOGIC
;
begin
write_edge
:
=
'0'
;
if
(
r_register
.
CPOL
xor
r_register
.
CPHA
)
=
'0'
then
--! The write case is the falling_edge
if
spi_clk
=
'0'
and
spi_clk_d0
=
'1'
then
write_edge
:
=
'1'
;
end
if
;
else
--! The write case is the rising_edge
if
spi_clk
=
'1'
and
spi_clk_d0
=
'0'
then
write_edge
:
=
'1'
;
end
if
;
end
if
;
return
write_edge
;
end
f_write_edge
;
end
spi_master_pkg
;
end
spi_master_pkg
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment