Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
V
vSPI
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
vSPI
Commits
f819a10f
Commit
f819a10f
authored
Feb 24, 2012
by
Mike Lyons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Now support receiving data (Cheetah->vSPI)
parent
3be23a0e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
11 deletions
+62
-11
spiifc.v
src/spi_base/spiifc.v
+47
-7
spiwrap.v
src/spi_base/spiwrap.v
+5
-4
rc-bytes.txt
test/spi_base/rc-bytes.txt
+10
-0
spiifc_tb.v
test/spi_base/spiifc_tb.v
+0
-0
spiifc_tb2.v
test/spi_base/spiifc_tb2.v
+0
-0
No files found.
src/spi_base/spiifc.v
View file @
f819a10f
...
...
@@ -38,6 +38,14 @@ module spiifc(
//
parameter
AddrBits
=
12
;
// Defines
`define
CMD_READ_START 8
'
d1
`define
CMD_READ_MORE 8
'
d2
`define
STATE_GET_CMD 8
'
d0
`define
STATE_READING 8
'
d1
//
// Input/Output defs
//
...
...
@@ -68,6 +76,9 @@ module spiifc(
reg
rcStarted
;
reg
[
2
:
0
]
rcBitIndexReg
;
reg
[
11
:
0
]
rcMemAddrReg
;
reg
[
11
:
0
]
rcMemAddrNext
;
reg
[
7
:
0
]
rcMemDataReg
;
reg
rcMemWEReg
;
reg
ssPrev
;
...
...
@@ -77,6 +88,9 @@ module spiifc(
reg
ssTurnOnReg
;
reg
ssTurnOnHandled
;
reg
[
7
:
0
]
cmd
;
reg
[
7
:
0
]
stateReg
;
//
// Wires
//
...
...
@@ -89,6 +103,8 @@ module spiifc(
wire
ssFastToggle
;
wire
[
7
:
0
]
state
;
//
// Output assigns
//
...
...
@@ -98,8 +114,8 @@ module spiifc(
assign
txMemAddr
=
0
;
assign
rcMemAddr
=
rcMemAddrReg
;
assign
rcMemData
=
rc
Byte
;
assign
rcMemWE
=
rc
ByteValid
;
assign
rcMemData
=
rc
MemDataReg
;
assign
rcMemWE
=
rc
MemWEReg
;
assign
ssFastToggle
=
(
ssPrev
==
1
&&
SPI_SS
==
0
?
~
ssFastToggleReg
:
ssFastToggleReg
)
;
...
...
@@ -112,8 +128,8 @@ module spiifc(
assign
rcStarting
=
ssTurnOn
;
assign
rcBitIndex
=
(
rcStarting
?
3'd7
:
rcBitIndexReg
)
;
//assign ssTurnOn = ~ssTurnOnHandled & (ssTurnOnReg | (ssPrev & (~SPI_SS)));
assign
ssTurnOn
=
ssSlowToggle
^
ssFastToggle
;
assign
state
=
(
rcStarting
?
`STATE_GET_CMD
:
stateReg
)
;
initial
begin
ssSlowToggle
<=
0
;
...
...
@@ -140,6 +156,7 @@ module spiifc(
always
@
(
posedge
SPI_CLK
)
begin
ssSlowToggle
<=
ssFastToggle
;
if
(
Reset
)
begin
// Resetting
...
...
@@ -152,6 +169,8 @@ module spiifc(
end
else
begin
// Not resetting
ssTurnOnHandled
<=
ssTurnOn
;
stateReg
<=
state
;
rcMemAddrReg
<=
rcMemAddrNext
;
if
(
~
SPI_SS
)
begin
rcByteReg
[
rcBitIndex
]
<=
SPI_MOSI
;
...
...
@@ -161,10 +180,31 @@ module spiifc(
// We've just received a byte (well, currently receiving the last bit)
if
(
rcByteValid
)
begin
// For now, just display on LEDs
debug_reg
<=
rcByte
;
end
if
(
rcByteValid
)
begin
// For now, just display on LEDs
debug_reg
<=
rcByte
;
if
(
`STATE_GET_CMD
==
state
)
begin
cmd
<=
rcByte
;
// Will take effect next cycle
if
(
`CMD_READ_START
==
rcByte
)
begin
rcMemAddrNext
<=
0
;
stateReg
<=
`STATE_READING
;
end
else
if
(
`CMD_READ_MORE
==
rcByte
)
begin
stateReg
<=
`STATE_READING
;
end
end
else
if
(
`STATE_READING
==
state
)
begin
rcMemDataReg
<=
rcByte
;
rcMemAddrNext
<=
rcMemAddr
+
1
;
rcMemWEReg
<=
1
;
end
end
else
begin
// Not a valid byte
rcMemWEReg
<=
0
;
end
// valid/valid' byte
end
// Reset/Reset'
end
...
...
src/spi_base/spiwrap.v
View file @
f819a10f
...
...
@@ -32,6 +32,7 @@ wire [31:0] douta_dummy;
wire
[
11
:
0
]
spi_addr
;
wire
[
7
:
0
]
spi_data
;
wire
[
31
:
0
]
rcMem_douta
;
reg
initMem
;
reg
[
9
:
0
]
initMemAddr
;
...
...
@@ -82,8 +83,8 @@ spimem spiMemRc (
.
clka
(
SysClk
)
,
.
ena
(
1'b1
)
,
.
wea
(
1'b0
)
,
.
addra
(
10'h00
0
)
,
.
douta
(
debug_out
)
,
.
addra
(
10'h00
1
)
,
.
douta
(
rcMem_douta
)
,
.
clkb
(
spi_clk
)
,
.
enb
(
1'b1
)
,
.
web
(
spi_rcMem_we
)
,
...
...
@@ -104,11 +105,11 @@ spiifc mySpiIfc (
.
rcMemAddr
(
spi_rcMem_addr
)
,
.
rcMemData
(
spi_rcMem_data
)
,
.
rcMemWE
(
spi_rcMem_we
)
,
.
debug_out
(
leds
)
.
debug_out
(
debug_out
)
)
;
//assign leds = debug_out
;
assign
leds
=
rcMem_douta
[
31
:
24
]
;
endmodule
test/spi_base/rc-bytes.txt
0 → 100644
View file @
f819a10f
01
FF
F0
33
55
12
34
56
78
9A
\ No newline at end of file
src
/spi_base/spiifc_tb.v
→
test
/spi_base/spiifc_tb.v
View file @
f819a10f
File moved
src
/spi_base/spiifc_tb2.v
→
test
/spi_base/spiifc_tb2.v
View file @
f819a10f
File moved
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