SRAMを参考にCPLDの回路を組んでみた。
今回は書き込みのみとした。また、外部から
SPIでデータを取り込みそのデータをSRAMに
書き込むという形にしてある。
PIC-SPIバス-CPLD-SRAM
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 book is port( --spi transfer sclk:in std_logic; sin:in std_logic; sout:out std_logic; --sram control we:out std_logic;--pull up oe:out std_logic;--pull up cs:out std_logic;--pull up --sram data data:inout std_logic_vector(0 to 7); --sram address add: out std_logic_vector(14 downto 0)); end book; architecture Behavioral of book is signal I:std_logic_vector(2 downto 0):="111"; signal in_data:std_logic_vector(7 downto 0); signal cmd: std_logic_vector(7 downto 0); signal in_add:std_logic_vector(14 downto 0):="111111111111111"; begin --spi transfer(get) process (sclk) begin if sclk'event and sclk='0' then if I="010" then cs<='1'; oe<='1'; in_add<=in_add+1;--address increment elsif I="100" then--cs asert cs<='0';--sram control possible elsif I="111" then--start writeing oe<='0';--out enable data<=in_data;--data set end if; I<=I+1; in_data<=in_data(6 downto 0) & sin;--shift register end if; end process; add<=in_add;--内部registerとsramのaddressを接続 end Behavioral;
これで結果は

上3つがspi用のピンです。今回は、spi_outは使っていません。
次のweも未使用です。
次がoe,csでcsをlow西手からeoをlowにして、その瞬間に、データを
送りたいデータに入れ替えています。