วันศุกร์ที่ 7 พฤศจิกายน พ.ศ. 2557

การทดลองวันที่ wed 102914 โจทย์ข้อ 2


การทดลองที่ 6.2
ออกแบบวงจรนับ Binary counter

วัตถุประสงค์

  • ออกแบบวงจรนับ binary counter ขนาด 32 บิต โดยใช้ภาษา VHDL ได้
  • ฝึกการใช้งานบนบอร์ด FPGA เพื่อทดลองวงจรที่ออกแบบได้
  • เข้าใจการทำงานของโปรแกรม ในการสร้างวงจรนับ binary counter

อุปกรณ์การทดลอง

  • บอร์ด FPGA                                       1  อัน
  • คอมพิวเตอร์ที่มีโปรแกรม  Quartus II

ขั้นตอนการทดลอง

  1. ออกแบบวงจรตามโจทย์ปฏิบัติดังนี้
    - ออกแบบวงจรนับ binary counter ขนาด 32 บิต
    - มีอินพุต CLK ความถี่ 50MHz (ได้จากวงจรความถี่บนบอร์ด FPGA)
    - มีขา LED(7:0) ซึ่งเป็นเอาต์พุตและต่อกับ LED บนบอร์ด FPGA และให้แสดงสถานะลอจิกของตัวนับ 8 บิต นับจากซ้ายสุด (บิตที่ 31 ..24)
    - ให้ออกแบบโดยใช้ภาษา VHDL
  2. ทดลองวงจรในบอร์ด FPGA
  3. เขียนรายงานการทดลอง

ผลการทดลอง

-- File: BinaryCounters.vhd
-- Target Board: Cyclone III, EP3C10E144C8
 -- Pin Assignments -- PIN_22 to CLK
-- q output (7:0)
-- PIN_50 to LEDS[7]
-- PIN_49 to LEDS[6]
-- PIN_46 to LEDS[5]
-- PIN_44 to LEDS[4]
-- PIN_43 to LEDS[3]
-- PIN_42 to LEDS[2]
-- PIN_39 to LEDS[1]
-- PIN_38 to LEDS[เ0]
-- LCD_E PIN_54 in pin planner

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity BinaryCounters is
  port(clk: in std_logic;
           q : out std_logic_vector(7 downto 0));
end BinaryCounters;

architecture impl of BinaryCounters is
  signal counter : std_logic_vector(31 downto 0) := (others=>'0');
--ให้ตัวแปร counter เป็นสัญญาณนับ 32 bit (เริ่มต้นที่เป็น 0 ทุกบิต)
begin
  count_process: process(clk)
  begin
   if rising_edge(clk) then -- ถ้า clk เป็นขอบขาขึ้น (clk = ‘1’)
    counter<=counter+1; -- ให้ counter เพิ่มขึ้น 1
    q(7 downto 0) <= counter(31 downto 24);
-- ให้ output q (7:0) รับค่าจาก counter ตำแหน่ง 8 บิตสุดท้าย
   end if; -- จบเงื่อนไข clk ขาขึ้น
  end process; --จบ process clk
end impl; -- จบ architecture impl

วิดีโอการทดลอง :

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

แสดงความคิดเห็น