library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
Entity AD_RD is
Port (
clk,io,st:in std_logic;
sclk,ce:buffer std_logic;
dat:out integer range 0 to 255
);
End AD_RD;
Architecture main of AD_RD is
signal sp:integer range 0 to 31:=0;
signal sp2:integer range 0 to 1;
signal temst:std_logic:='0';
begin
process(clk)
variable temdat:std_logic_vector(0 to 7):="00000000";
begin
if clk'event and clk='1' then
case sp2 is
when 0 =>
if st='1' then
temst <= '1';
sp2<=1;
end if;
when 1 =>
if st='0' then
sp2<=0;
end if;
end case;
if temst = '1' then
sp<=sp+1;
case sp is
when 0 =>
ce<='0';
when 5 =>
sclk <='1';
temdat(0):=io;
when 6 =>
sclk <='0';
when 7 =>
sclk <='1';
temdat(1):=io;
when 8 =>
sclk <='0';
when 9 =>
sclk <='1';
temdat(2):=io;
when 10 =>
sclk <='0';
when 11 =>
sclk <='1';
temdat(3):=io;
when 12 =>
sclk <='0';
when 13 =>
sclk <='1';
temdat(4):=io;
when 14 =>
sclk <='0';
when 15 =>
sclk <='1';
temdat(5):=io;
when 16 =>
sclk <='0';
when 17 =>
sclk <='1';
temdat(6):=io;
when 18 =>
sclk <='0';
when 19 =>
sclk <='1';
temdat(7):=io;
when 20 =>
sclk <='0';
when 21 =>
dat<= conv_integer(temdat);
when 22 =>
ce<='1';
temst <= '0';
sp<=0;
when others => null;
end case;
end if;
end if;
end process;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
Entity AD_RD is
Port (
clk,io,st:in std_logic;
sclk,ce:buffer std_logic;
dat:out integer range 0 to 255
);
End AD_RD;
Architecture main of AD_RD is
signal sp:integer range 0 to 31:=0;
signal sp2:integer range 0 to 1;
signal temst:std_logic:='0';
begin
process(clk)
variable temdat:std_logic_vector(0 to 7):="00000000";
begin
if clk'event and clk='1' then
case sp2 is
when 0 =>
if st='1' then
temst <= '1';
sp2<=1;
end if;
when 1 =>
if st='0' then
sp2<=0;
end if;
end case;
if temst = '1' then
sp<=sp+1;
case sp is
when 0 =>
ce<='0';
when 5 =>
sclk <='1';
temdat(0):=io;
when 6 =>
sclk <='0';
when 7 =>
sclk <='1';
temdat(1):=io;
when 8 =>
sclk <='0';
when 9 =>
sclk <='1';
temdat(2):=io;
when 10 =>
sclk <='0';
when 11 =>
sclk <='1';
temdat(3):=io;
when 12 =>
sclk <='0';
when 13 =>
sclk <='1';
temdat(4):=io;
when 14 =>
sclk <='0';
when 15 =>
sclk <='1';
temdat(5):=io;
when 16 =>
sclk <='0';
when 17 =>
sclk <='1';
temdat(6):=io;
when 18 =>
sclk <='0';
when 19 =>
sclk <='1';
temdat(7):=io;
when 20 =>
sclk <='0';
when 21 =>
dat<= conv_integer(temdat);
when 22 =>
ce<='1';
temst <= '0';
sp<=0;
when others => null;
end case;
end if;
end if;
end process;
end main;
一周热门 更多>