📄 shiboqi.vhd
字号:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
entity shiboqi is port(
cp,key: in std_logic;
xrdaddr,yrdaddr: out std_logic_vector(7 downto 0);
rdcp:out std_logic);
end shiboqi;
architecture shi_arc of shiboqi is
signal counter,counter2,value:integer range 0 to 150;
--signal counter_2,value_2:std_logic_vector(7 downto 0);
signal position :integer range 0 to 3;
signal timetick,timetick2,x_inti,y_inti,keyflag,greater:std_logic;
signal xrdaddress,yrdaddress,temp:std_logic_vector(7 downto 0);
COMPONENT xiaodou IS
PORT( shuru: IN STD_LOGIC; cp:IN STD_LOGIC; shuchu:OUT STD_LOGIC);
END COMPONENT;
--COMPONENT compare IS
--PORT
--(
-- dataa : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
-- datab : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
-- AgB : OUT STD_LOGIC
--);
--END COMPONENT;
begin
press:xiaodou PORT MAP(key,cp,keyflag);
--beyound:compare port map(counter_2,value_2,greater);
fenpin:process(cp)--分频 进程
begin
if cp'event and cp='1' then
if keyflag='1' then
counter<=0; counter2<=0;--counter_2<="00000000";
else
if counter=149 then
counter<=0; timetick<=not timetick;
else counter<=counter+1;
end if;
--if greater='1' then counter2<=0;counter_2<="00000000";
if counter2=value then
counter2<=0; timetick2<=not timetick2;
--counter_2<="00000000";
else counter2<=counter2+1;--counter_2<=counter_2+1;
end if;
end if;
end if;
end process fenpin;
C:process(keyflag)
begin
if keyflag'event and keyflag='1' then
case position is
when 3 =>position<=0;
when 0 =>position<=1;
when 1 =>position<=2;
when 2 =>position<=3;
when others =>position<=0;
end case;
end if;
end process C;
change_frenquency:process(cp,position)
begin
if cp'event and cp='1' then
case position is
when 0=>value<=149;--value_2<="10010101";
when 1=>value<=74;--value_2<="01001010";
when 2=>value<=49;--value_2<="00110001";
when 3=>value<=99;--value_2<="01100011";
when others=>value<=149;--value_2<="10010101";
end case;
end if;
end process change_frenquency;
sendaddr_x:process(timetick,keyflag)--送读数据的地址
begin
if timetick'event and timetick='1' then
if keyflag='1' then xrdaddress<="00000001";
elsif x_inti='0' then
xrdaddress<="00000001";
x_inti<='1';
else
xrdaddress<=xrdaddress+1;
end if;
end if;
end process sendaddr_x;
sendaddr_y:process(timetick2,keyflag)--送读数据的地址
begin
if timetick2'event and timetick2='1' then
if keyflag='1' then
if position=0 or position=2 then
yrdaddress<="01000001";
else yrdaddress<="00000001";
end if;
elsif y_inti='0' then
yrdaddress<="01000001";
y_inti<='1';
else
yrdaddress<=yrdaddress+1;
end if;
end if;
end process sendaddr_y;
xrdaddr<=xrdaddress;
yrdaddr<=yrdaddress;
rdcp<=timetick;
end shi_arc;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -