Lab 3 Embeded
Lab 3 Embeded
Genap 2007/2008
Lab. 3
Rangkaian Flip flop
dan Counter pada Spartan 3 FPGA Board
Materi Lab.3 :
Target :
Tujuan :
Syarat :
Persiapan Lab. :
1. Review Materi mata kuliah Rangkaian Logika, Sistem Digital dan Interfacing.
4. Pelajari dan siapkan Spartan-3 Starter Kit Board User Guide (ug130.pdf)
Perangkat Lab. :
Perangkat Jumlah
Free software ISE webpack (www.Xilinx.com) 1
Free software Model sim 1
PC dan FPGA board 1 set
Prosedure percobaan :
2. Buatlah file baru dengan nama D_FF.vhd dan tulis code berikut :
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity dflip_ent is
port(
reset_in : in std_logic;
D_in : in std_logic;
clk : in std_logic;
Q_out : out std_logic
);
end dflip_ent;
3. Compile file tersebut. Dan lanjutkan dengan membuat file baru dengan
nama D_FF_TB.vhd dan tulis code berikut :
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity dflip_tb is
end dflip_tb;
component dflip_ent
port(
reset_in : in std_logic;
D_in : in std_logic;
clk : in std_logic;
Q_out : out std_logic
);
end component;
begin
UUT : dflip_ent
port map(
reset_in => reset_in,
D_in => D_in,
clk => clk,
Q_out => Q_out
);
dflipflop: process
begin
reset_in <= '0'; wait for 50 ns ;
assert (Q_out = '0')
report " Failed on Reset = 0"
severity error;
clock_in : process
begin
clk <= not clk; wait for 50 ns ;
end process clock_in;
end dflip_tb_arch;
Tugas :
3. Buatlah program yang sama untuk komponen S-R FF, J-K FF dan T FF dan
simulasikan dengan Modelsim serta lampirkan pula gambar simulasinya.
Tujuan :
Persiapan :
Prosedure :
1. Lakukan prosedur lab. 3.1. pada lab.3.2. dengan menuliskan code berikut :
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity n_bit_counter is
generic(n : integer := 2);
port(
clk : in std_logic;
reset : in std_logic;
enable : in std_logic;
count_out : out std_logic_vector(n-1 downto 0)
);
end n_bit_counter;
2. Compile file tersebut. Dan lanjutkan dengan membuat file baru dengan
nama counter_TB.vhd dan tulis code berikut :
library ieee;
use ieee.std_logic_1164.all;
entity count_test is
end count_test;
architecture behav of count_test is
signal clk : std_logic := '0';
signal reset : std_logic;
signal enable : std_logic;
signal count_out : std_logic_vector(1 downto 0);
begin
UUT : entity work.n_bit_counter
generic map(2)
port map (clk, reset, enable, count_out);
stimuli : process
begin
reset <= '1'; wait for 25 ns;
assert (count_out = "00")
report "Error reset"
severity error;
reset <= '0'; enable <= '0'; wait for 50 ns;
reset <= '0'; enable <= '1'; wait for 500 ns;
assert (count_out = count_out)
report "Error Enable"
severity error;
end process;
process
begin
clk <= not clk; wait for 25 ns;
end process;
end behav;
3. Tentukan pin-pin dari input dan output code counter tersebut. Input clk dari
dari system clock Spartan 3 (Baca ug130.pdf tentang clock). Input enable
dari switch, input reset dari Push Button dan output Count_out ke LED (Baca
ug130.pdf untuk mengetahui address pin masing-masing input dan
output).
Tugas :
3. Gunakan gambar pada wave simulator model sim untuk analisa laporan
anda
4. Buatlah code counter 4 bit yang akan increment setelah 30 detik. (Buatlah
Clock divider sebagai delay clock 30 detik, Ingat clock Spartan adalah 50
MHz).
6. Gunakan gambar pada wave simulator model sim untuk lampiran laporan
anda.