VishwanathAmbli
Member level 1
- Joined
- May 23, 2012
- Messages
- 33
- Helped
- 4
- Reputation
- 8
- Reaction score
- 4
- Trophy points
- 1,288
- Activity points
- 1,466
I am implementing SPI bus protocol in vhdl, the data should be transmitted during +ve rising edge of clock
i have written this code but i am unable to get the desired result, am i implementing the right way or no???? any help is appreciated:
i have written this code but i am unable to get the desired result, am i implementing the right way or no???? any help is appreciated:
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity spi1 is
port(sclk:in std_logic; ssbar : in std_logic;
mbuff,sbuff: in std_logic_vector(7 downto 0);
mosi,miso: inout std_logic_vector(7 downto 0));
--sdo,sdi:out std_logic_vector(7 downto 0));
end spi1;
architecture Behavioral of spi1 is
signal i: integer range 0 to 255;
--signal temp1,temp2: std_logic_vector(7 downto 0):="00000000";
begin
mosi<=mbuff;
miso<=sbuff;
process(sclk)
begin
--temp1<= mosi && miso;
--i<=0;
if(ssbar='1') then
mosi<="ZZZZZZZZ";
miso<="ZZZZZZZZ";
end if;
--if(sclk'event and sclk ='1') then
--end if;
if(sclk'event and sclk='1') then
--for i in 0 to 15 loop
mosi(1)<=mosi(0);
mosi(2)<=mosi(1);
mosi(3)<=mosi(2);
mosi(4)<=mosi(3);
mosi(5)<=mosi(4);
mosi(6)<=mosi(5);
mosi(7)<=mosi(6);
miso(0)<=mosi(7);
miso(1)<=miso(0);
miso(2)<=miso(1);
miso(3)<=miso(2);
miso(4)<=miso(3);
miso(5)<=miso(4);
miso(6)<=miso(5);
miso(7)<=miso(6);
--mosi(0)<=miso(7);
--temp2(0)<=temp1(7);
--temp1(i+1)<=temp1(i);
--temp2(i+1)<=temp2(i);
--i<=i+1;
--if(i=7) then
--i<=0;
--end loop;
end if;
--sdo<=;
end process;
end Behavioral;