@@ -2,18 +2,16 @@ library ieee;
2
2
use ieee.std_logic_1164.all ;
3
3
use ieee.numeric_std.all ;
4
4
5
- -- Tested on FPGA
5
+ -- Tested on FPGA, 10Mhz, upto 512bits
6
6
entity spi_master is
7
7
generic (
8
- transaction_length : natural := 8 * 8 );
8
+ transaction_length : natural := 1 * 8 );
9
9
port (
10
10
clock :in std_logic ;
11
11
clr : in std_logic ;
12
12
13
13
data_tx : in std_logic_vector (transaction_length - 1 downto 0 ); -- data to be sent
14
- data_tx_rdy : in std_logic ; -- data ready to be written from data_tx register and starts the transimision in the next clock cycle
15
-
16
- -- data_reg : out std_logic_vector(transaction_length - 1 downto 0);
14
+ data_tx_rdy : in std_logic ; -- (load) data ready to be written from data_tx register and starts the transimision in the next clock cycle
17
15
18
16
data_rx : out std_logic_vector (transaction_length - 1 downto 0 ); -- data recieved from slave
19
17
data_rx_rdy : out std_logic ; -- data ready to be read from data_rx register
@@ -84,16 +82,16 @@ begin
84
82
end process ; -- bit_count_pr
85
83
86
84
-- miso
87
- -- miso_pr : process(sck_s,clr)
88
- -- begin
89
- -- if clr = '0' then
90
- -- data_rx_reg <= (others => '0');
91
- -- elsif falling_edge(sck_s) and cs_s = '0' then
92
- -- data_rx_reg(0) <= miso;
93
- -- data_rx_reg(transaction_length - 1 downto 1 ) <= data_rx_reg(transaction_length - 2 downto 0) ;
94
- -- -- data_rx_reg(transaction_length - 1 - bit_count) <= miso;
95
- -- end if;
96
- -- end process ; -- miso_pr
85
+ miso_pr : process (sck_s,clr)
86
+ begin
87
+ if clr = '0' then
88
+ data_rx_reg <= (others => '0' );
89
+ elsif falling_edge (sck_s) and cs_s = '0' then
90
+
91
+ data_rx_reg(transaction_length - 1 - bit_count ) <= miso ;
92
+
93
+ end if ;
94
+ end process ; -- miso_pr
97
95
98
96
data_rx_rdy <= cs_s;
99
97
0 commit comments