Skip to content

Commit 34b1aad

Browse files
authoredMar 14, 2022
Update spi.vhd
1 parent b0b71f0 commit 34b1aad

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed
 

‎spi.vhd

+13-15
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ library ieee;
22
use ieee.std_logic_1164.all;
33
use ieee.numeric_std.all;
44

5-
--Tested on FPGA
5+
--Tested on FPGA, 10Mhz, upto 512bits
66
entity spi_master is
77
generic (
8-
transaction_length : natural := 8 * 8);
8+
transaction_length : natural := 1 * 8);
99
port (
1010
clock :in std_logic;
1111
clr : in std_logic;
1212

1313
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
1715

1816
data_rx : out std_logic_vector(transaction_length - 1 downto 0); -- data recieved from slave
1917
data_rx_rdy : out std_logic; -- data ready to be read from data_rx register
@@ -84,16 +82,16 @@ begin
8482
end process ; -- bit_count_pr
8583

8684
-- 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
9795

9896
data_rx_rdy <= cs_s;
9997

0 commit comments

Comments
 (0)