1. บอร์ด Altera FPGA (WARRIOR CYCLONE3 DEV) ชิปหมายเลข EP3C10E144C8 1 บอร์ด
2. สายดาวน์โหลด ByteBlaster II Cable หรือ สายดาวน์โหลดUSB Blaster Cab 1 ชุด
3. เครื่องคอมพิวเตอร์ 1 ชุด4. ออสซิลโลสโคป 1 เครื่อง
5. Mini 4x4 Matrix Keyboard board 1 อัน
6. ตัวต้านทาน 470 โอม 4 ตัว
7. สายไฟ - เส้น
http://www.parallax.com/sites/default/files/styles/full-size-product/public/27899.png?itok=zmmewvUT
http://images.elektroda.net/79_1296684161.gif
code
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity keypad is
port (
dataout : out std_logic_vector(3 downto 0);
LEDin : in std_logic_vector(3 downto 0) := "0000";
LEDout : out std_logic_vector(3 downto 0) := "0000";
CLK : in std_logic
);
end keypad ;
architecture behav of keypad is
type state_type is (S0,S1,S2,S3);
signal staterow : state_type := S0;
signal count : integer :=0;
signal data : std_logic_vector(3 downto 0);
signal LEDdata : std_logic_vector(3 downto 0);
begin
process(CLK) begin
if rising_edge(CLK) then
count<=count+1;
case staterow is
when S0 =>
data <= "1000";
LEDdata <= LEDin;
if(count=500000) then
staterow <= S1;
count <=0;
end if;
when S1 =>
data <= "0100";
LEDdata <= LEDin;
if(count=500000) then
staterow <= S2;
count <=0;
end if;
when S2 =>
data <= "0010";
LEDdata <= LEDin;
if(count=500000) then
staterow <= S3;
count <=0;
end if;
when S3 =>
data <= "0001";
LEDdata <= LEDin;
if(count=500000) then
staterow <= S0;
count <=0;
end if;
end case;
end if;
dataout <= data;
LEDout <= LEDdata;
end process;
end behav;
ภาพการทดลอง



ไม่มีความคิดเห็น:
แสดงความคิดเห็น