Skip to content

Commit 33a2123

Browse files
committed
README [MAINTENANCE]: Update Readme file
1 parent 11b9290 commit 33a2123

File tree

1 file changed

+83
-58
lines changed

1 file changed

+83
-58
lines changed

README.md

Lines changed: 83 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,89 @@ The SPI master and SPI slave are simple controllers for communication between FP
44

55
**The SPI master and SPI slave controllers support only SPI mode 0 (CPOL=0, CPHA=0)!**
66

7-
The SPI master and SPI slave controllers were simulated and tested in hardware. If you have a question or you have a tip for improvement, send me an e-mail or create a issue.
7+
The SPI master and SPI slave controllers were simulated and tested in hardware. I use the GHDL tool for CI: automated VHDL simulations in the GitHub Actions environment ([setup-ghdl-ci](https://github.com/ghdl/setup-ghdl-ci)). If you have a question or you have a tip for improvement, send me an e-mail or create a issue.
8+
9+
## SPI master
10+
11+
### Generics:
12+
13+
```vhdl
14+
CLK_FREQ : natural := 50e6; -- set system clock frequency in Hz
15+
SCLK_FREQ : natural := 5e6; -- set SPI clock frequency in Hz (condition: SCLK_FREQ <= CLK_FREQ/10)
16+
WORD_SIZE : natural := 8; -- size of transfer word in bits, must be power of two
17+
SLAVE_COUNT : natural := 1 -- count of SPI slaves
18+
```
19+
20+
### Ports:
21+
22+
```vhdl
23+
CLK : in std_logic; -- system clock
24+
RST : in std_logic; -- high active synchronous reset
25+
-- SPI MASTER INTERFACE
26+
SCLK : out std_logic; -- SPI clock
27+
CS_N : out std_logic_vector(SLAVE_COUNT-1 downto 0); -- SPI chip select, active in low
28+
MOSI : out std_logic; -- SPI serial data from master to slave
29+
MISO : in std_logic; -- SPI serial data from slave to master
30+
-- INPUT USER INTERFACE
31+
DIN : in std_logic_vector(WORD_SIZE-1 downto 0); -- data for transmission to SPI slave
32+
DIN_ADDR : in std_logic_vector(natural(ceil(log2(real(SLAVE_COUNT))))-1 downto 0); -- SPI slave address
33+
DIN_LAST : in std_logic; -- when DIN_LAST = 1, last data word, after transmit will be asserted CS_N
34+
DIN_VLD : in std_logic; -- when DIN_VLD = 1, data for transmission are valid
35+
DIN_RDY : out std_logic; -- when DIN_RDY = 1, SPI master is ready to accept valid data for transmission
36+
-- OUTPUT USER INTERFACE
37+
DOUT : out std_logic_vector(WORD_SIZE-1 downto 0); -- received data from SPI slave
38+
DOUT_VLD : out std_logic -- when DOUT_VLD = 1, received data are valid
39+
```
40+
41+
### Simulation:
42+
43+
A simulation is prepared in the ```sim/``` folder. You can use the prepared TCL script to run simulation in ModelSim.
44+
```
45+
vsim -do spi_master_tb_msim_run.tcl
46+
```
47+
48+
Or it is possible to run the simulation using the [GHDL tool](https://github.com/ghdl/ghdl). Linux users can use the prepared bash script to run the simulation in GHDL:
49+
```
50+
./spi_master_tb_ghdl_run.sh
51+
```
52+
53+
## SPI slave
54+
55+
### Generics:
56+
57+
```vhdl
58+
WORD_SIZE : natural := 8; -- size of transfer word in bits, must be power of two
59+
```
60+
61+
### Ports:
62+
63+
```vhdl
64+
CLK : in std_logic; -- system clock
65+
RST : in std_logic; -- high active synchronous reset
66+
-- SPI SLAVE INTERFACE
67+
SCLK : in std_logic; -- SPI clock
68+
CS_N : in std_logic; -- SPI chip select, active in low
69+
MOSI : in std_logic; -- SPI serial data from master to slave
70+
MISO : out std_logic; -- SPI serial data from slave to master
71+
-- USER INTERFACE
72+
DIN : in std_logic_vector(WORD_SIZE-1 downto 0); -- data for transmission to SPI master
73+
DIN_VLD : in std_logic; -- when DIN_VLD = 1, data for transmission are valid
74+
DIN_RDY : out std_logic; -- when DIN_RDY = 1, SPI slave is ready to accept valid data for transmission
75+
DOUT : out std_logic_vector(WORD_SIZE-1 downto 0); -- received data from SPI master
76+
DOUT_VLD : out std_logic -- when DOUT_VLD = 1, received data are valid
77+
```
78+
79+
### Simulation:
80+
81+
A simulation is prepared in the ```sim/``` folder. You can use the prepared TCL script to run simulation in ModelSim.
82+
```
83+
vsim -do spi_slave_tb_msim_run.tcl
84+
```
85+
86+
Or it is possible to run the simulation using the [GHDL tool](https://github.com/ghdl/ghdl). Linux users can use the prepared bash script to run the simulation in GHDL:
87+
```
88+
./spi_slave_tb_ghdl_run.sh
89+
```
890

991
## Table of resource usage summary:
1092

@@ -28,60 +110,3 @@ Please read [README file of SPI loopback example design](example/README.md).
28110
The SPI master and SPI slave controllers are available under the GNU LESSER GENERAL PUBLIC LICENSE Version 3.
29111

30112
Please read [LICENSE file](LICENSE).
31-
32-
# SPI master
33-
34-
## Table of generics:
35-
36-
Generic name | Type | Default value | Generic description
37-
---|:---:|:---:|:---
38-
CLK_FREQ | natural | 50e6 | System clock frequency in Hz.
39-
SCLK_FREQ | natural | 5e6 | Set SPI clock frequency in Hz (condition: SCLK_FREQ <= CLK_FREQ/10).
40-
WORD_SIZE | natural | 8 | Size of transfer word in bits, must be power of two
41-
SLAVE_COUNT | natural | 1 | Count of SPI slave controllers.
42-
43-
## Table of inputs and outputs ports:
44-
45-
Port name | IN/OUT | Width [b]| Port description
46-
---|:---:|:---:|---
47-
CLK | IN | 1 | System clock.
48-
RST | IN | 1 | High active synchronous reset.
49-
--- | --- | --- | ---
50-
SCLK | OUT | 1 | SPI clock.
51-
CS_N | OUT | SLAVE_COUNT | SPI chip select, active in low.
52-
MOSI | OUT | 1 | SPI serial data from master to slave.
53-
MISO | IN | 1 | SPI serial data from slave to master.
54-
--- | --- | --- | ---
55-
DIN_ADDR | IN | log2(SLAVE_COUNT) | SPI slave address.
56-
DIN | IN | WORD_SIZE | Input data for SPI slave.
57-
DIN_LAST | IN | 1 | When DIN_LAST = 1, after transmit these input data is asserted CS_N.
58-
DIN_VLD | IN | 1 | When DIN_VLD = 1, input data are valid.
59-
DIN_RDY | OUT | 1 | When DIN_RDY = 1, valid input data are accept.
60-
DOUT | OUT | WORD_SIZE | Output data from SPI slave.
61-
DOUT_VLD | OUT | 1 | When DOUT_VLD = 1, output data are valid.
62-
63-
# SPI slave
64-
65-
## Table of generics:
66-
67-
Generic name | Type | Default value | Generic description
68-
---|:---:|:---:|:---
69-
WORD_SIZE | natural | 8 | Size of transfer word in bits, must be power of two
70-
71-
## Table of inputs and outputs ports:
72-
73-
Port name | IN/OUT | Width [b]| Port description
74-
---|:---:|:---:|---
75-
CLK | IN | 1 | System clock.
76-
RST | IN | 1 | High active synchronous reset.
77-
--- | --- | --- | ---
78-
SCLK | IN | 1 | SPI clock.
79-
CS_N | IN | 1 | SPI chip select active in low.
80-
MOSI | IN | 1 | SPI serial data from master to slave.
81-
MISO | OUT | 1 | SPI serial data from slave to master.
82-
--- | --- | --- | ---
83-
DIN | IN | WORD_SIZE | Input data for SPI master.
84-
DIN_VLD | IN | 1 | When DIN_VLD = 1, input data are valid.
85-
DIN_RDY | OUT | 1 | When DIN_RDY = 1, valid input data are accept.
86-
DOUT | OUT | WORD_SIZE | Output data from SPI master.
87-
DOUT_VLD | OUT | 1 | When DOUT_VLD = 1, output data are valid.

0 commit comments

Comments
 (0)