Documente Academic
Documente Profesional
Documente Cultură
INTERFACING PROGRAMS HEX KEY PAD library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity TKHKY1 is Port ( pkeyret : in std_logic_vector(3 downto 0); pkeyscn : out std_logic_vector(3 downto 0); pdspseg : out std_logic_vector (6 downto 0); pdspmux : out std_logic_vector (3 downto 0); pledind : out std_logic_vector (7 downto 0); pclk100K : in std_logic ); end TKHKY1; architecture behavioral of TKHKY1 is signal skeyval : integer range 0 to 15; signal skeyhit : std_logic; signal skeyscn : std_logic_vector(3 downto 0); signal sclkdiv : std_logic_vector(7 downto 0); signal skeyclk : std_logic; begin -- process keypress process(pkeyret) begin case pkeyret is when "1110" => skeyhit <= '1'; when "1101" => skeyhit <= '1'; when "1011" => skeyhit <= '1'; when "0111" => skeyhit <= '1'; when others => skeyhit <= '0'; end case; end process; -- process keyval process(skeyhit) begin if( rising_edge(skeyhit)) then if(skeyscn = "1110" and pkeyret = "1110")
-- process for key scan clkscan process(skeyclk) begin if(rising_edge(skeyclk)) then if skeyscn = "1110" then skeyscn <= "1101"; elsif skeyscn = "1101" then skeyscn <= "1011"; elsif skeyscn = "1011" then skeyscn <= "0111"; elsif skeyscn = "0111" then skeyscn <= "1110"; else skeyscn <= "1110"; end if; end if; pkeyscn <= skeyscn; end process; -- process display 7seg process(skeyval) type tseg7 is array(0 to 15) of std_logic_vector (6 downto 0); constant segval : tseg7 := ("0111111","0000110","1011011","1001111","1100110","1101101","1111101", "0000111","1111111","1101111","1110111","1111100","1011000","1011110", "1111001","1110001"); begin pdspseg <= segval(skeyval); pdspmux <= "1110"; end process; -- process display ledind process(skeyval) type tled8 is array(0 to 15) of std_logic_vector (7 downto 0); constant led8val : tled8 := ("00000000","00000001","00000010","00000100", "00001000","00010000","00100000","01000000", "10000000","00001001","00001010","00001011", "00001100","00001101","00001110","00001111"); begin pledind <= led8val(skeyval); end process; end behavioral; ELEVATOR library IEEE; use IEEE.STD_LOGIC_1164.ALL;
skeyclk <= sclkdiv(6); sflrclk <= sclkdiv(15); end process; -- process for key scan clkscan process(skeyclk) begin if(rising_edge(skeyclk)) then if skeyscn = "1110" then skeyscn <= "1101"; elsif skeyscn = "1101" then skeyscn <= "1011"; elsif skeyscn = "1011" then skeyscn <= "0111"; elsif skeyscn = "0111" then skeyscn <= "1110"; else skeyscn <= "1110"; end if; end if; pkeyscn <= skeyscn; end process; -- process floor motion process(sflrclk) begin if(rising_edge(sflrclk)) then if(not (skeyflr = scurflr) ) then if(skeyflr > scurflr) then scurflr <= scurflr+1; else scurflr <= scurflr-1; end if; end if; end if; end process; -- process display 7seg process(scurflr) type tseg7 is array(0 to 15) of std_logic_vector (6 downto 0); constant segval : tseg7 := ("0111111","0000110","1011011","1001111","1100110","1101101","1111101", "0000111","1111111","1101111","1110111","1111100","1011000","1011110", "1111001","1110001"); begin pdspseg <= segval(scurflr); pdspmux <= "1110"; end process; end behavioral;
---
end behavioral; DC MOTOR -- ALS NIFC37 DC motor -- connect J4-pin 26 to GND -- connect J4-pin 25 to +5V -- connect J4-pin 5 to CPLD pin 9 (pdcm)
tchr1 <= mystr(vdspnum); plcddat <= std_logic_vector(to_unsigned(character'pos(tchr1),8)); end if; plcdrw <= '0'; if(vdspseq < 4) then plcdrs <= '0'; else plcdrs <= '1'; end if; end process; end behavioral; DAC-SQUARE WAVE library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; -- Uncomment the following lines to use the declarations that are -- provided for instantiating Xilinx primitive components. --library UNISIM; --use UNISIM.VComponents.all; entity sqdac1 is Port ( din : out std_logic_vector(7 downto 0); clk : in std_logic); end sqdac1; architecture Behavioral of sqdac1 is signal count:std_logic_vector(4 downto 0):="00000"; begin process(clk) begin if clk'event and clk='1' then if count<"10000" then count<=count+'1'; din <="10000000"; elsif