Tugas8 - 2210191006 - Filosofi Dwibakti - Lapsem
Tugas8 - 2210191006 - Filosofi Dwibakti - Lapsem
Tugas8 - 2210191006 - Filosofi Dwibakti - Lapsem
begin
process
begin
wait until Clk25Mhz' EVENT and Clk25Mhz = '1' ;
if count < max then count <= count + 1;
else count <= 0;
end if;
if count < half then Clk <= '0' ;
else Clk <= '1' ;
end if;
end process;
end Behavioral;
b. RTL Schematics
c. Technology Schematics
Counter
a. Program VHDL
- Clkdiv
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
entity clkdiv is
Port (mclk : in STD_LOGIC;
clr : in STD_LOGIC;
clk190 : out STD_LOGIC;
clk48 : out STD_LOGIC
);
end clkdiv;
- Mod10kcnt
Library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
entity mod10kcnt is
Port (clr: in STD_LOGIC;
clk: in STD_LOGIC;
q : out STD_LOGIC_VECTOR(13 downto 0)
);
end mod10kcnt;
- binBCD14
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
entity binBCD14 is
Port (b : in STD_LOGIC_VECTOR(13 downto 0);
p : out STD_LOGIC_VECTOR (16 downto 0)
);
end binBCD14;
- x7segbc
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
entity x7segbc is
port (x : in std_logic_vector(15 downto 0);
cclk : in std_logic;
clr : in std_logic;
a_to_g : out std_logic_vector(6 downto 0);
an : out std_logic_vector(3 downto 0);
dp : out std_logic );
end x7segbc;
process(s,x)
begin
case s is
when "00" => digit <= x(3 downto 0);
when "01" => digit <= x(7 downto 4);
when "10" => digit <= x(11 downto 8);
when others => digit <= x(15 downto 12);
end case;
end process;
process(digit)
begin
case digit is
when x"0" => a_to_g <= "0000001";
when x"1" => a_to_g <= "1001111";
when x"2" => a_to_g <= "0010010";
when x"3" => a_to_g <= "0000110";
when x"4" => a_to_g <= "1001100";
when x"5" => a_to_g <= "0100100";
when x"6" => a_to_g <= "0100000";
when x"7" => a_to_g <= "0001111";
when x"8" => a_to_g <= "0000000";
when x"9" => a_to_g <= "0000100";
when x"A" => a_to_g <= "0001000";
when x"B" => a_to_g <= "1100000";
when x"C" => a_to_g <= "0110001";
when x"D" => a_to_g <= "1000010";
when x"E" => a_to_g <= "0110000";
when others => a_to_g <= "0111000";
end case;
end process;
process(s,aen)
begin
an <= "1111";
if aen(conv_integer(s))= '1' then
an(conv_integer(s))<= '0' ;
end if;
end process;
process(cclk,clr)
begin
if clr= '1' then s <= "00";
elsif cclk' event and cclk= '1' then
s <= s + 1;
end if;
end process;
end Behavioral ;
- mod10kcnt_top
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity mod10kcnt_top is
port( mclk : in std_logic;
btn : in std_logic;
a_to_g : out std_logic_vector(6 downto 0);
an : out std_logic_vector(3 downto 0);
dp : out std_logic
);
end mod10kcnt_top;
component mod10kcnt is
port (clr : in STD_LOGIC;
clk : in STD_LOGIC;
q : out STD_LOGIC_VECTOR(13 downto 0)
);
end component;
component binBCD14 is
port (b : in STD_LOGIC_VECTOR(13 downto 0);
p : out STD_LOGIC_VECTOR(16 downto 0)
);
end component;
component x7segbc is
port (x : in std_logic_vector(15 downto 0);
cclk : in std_logic;
clr : in std_logic;
a_to_g : out std_logic_vector(6 downto 0);
an : out std_logic_vector(3 downto 0);
dp : out std_logic
);
end component;
begin
clr <= btn;
u1: clkdiv port map(
mclk => mclk,
clr => clr,
clk190 => clk190,
clk48 => clk48
);
u2: mod10kcnt port map(
clr => clr,
clk => clk48,
q => b
);
end Behavioral;
b. RTL Schematics
- Clkdiv
- Mod10kcnt
- BinBCD14
- X7segbc
- Mod10kcnt_top
Tugas Stopwatch
a. Program VHDL
- 2bit Counter
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity twobitcounter is
Port (clk : in STD_LOGIC;
count_out : out STD_LOGIC_vector(1 downto 0));
end twobitcounter;
architecture Behavioral of twobitcounter is
signal sig1,sig2 : std_logic;
signal count_out_sig : std_logic_vector (1 downto 0);
begin
process (clk)
begin
if clk'event and clk = '1' then
count_out_sig(0) <= sig1;
count_out_sig(1) <= sig2;
end if;
end process;
sig1 <= not count_out_sig(0);
sig2 <= count_out_sig(1) xor count_out_sig(0);
count_out <= count_out_sig;
end Behavioral;
- 16bit Counter
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use ieee.std_logic_unsigned.all;
entity sixteen_bit_countr is
Port (CEn, CLK : in STD_LOGIC;
RST : in STD_LOGIC;
OUTPUT0 : out STD_LOGIC_VECTOR (3 downto
0);
OUTPUT1 : out STD_LOGIC_VECTOR (3 downto
0);
OUTPUT2 : out STD_LOGIC_VECTOR (3 downto
0);
OUTPUT3 : out STD_LOGIC_VECTOR (3 downto
0));
end sixteen_bit_countr;
output0<=s_cnt_tenths;
output1<=s_cnt_ones;
output2<=s_cnt_tens;
output3<=s_cnt_hundos;
end Behavioral;
- 7-Segment Decoder
Library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity sev_seg_decoder is
Port (binary_num : in STD_LOGIC_VECTOR (3 downto 0);
ABCDEFG : out STD_LOGIC_VECTOR (6 downto
0));
end sev_seg_decoder;
- Multiplexer 4 to 1
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity four_to_one_mux is
Port (x0,x1,x2,x3 : in STD_LOGIC_VECTOR (6 downto 0);
sr : in STD_LOGIC_VECTOR (1 downto 0);
f : out STD_LOGIC_vector(6 downto 0));
end four_to_one_mux;
- Stopwatch
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Stopwatch is
Port ( start_stop : in STD_LOGIC;
reset : in STD_LOGIC;
clk_in : in STD_LOGIC;
DISP0 : out STD_LOGIC_VECTOR (6 downto 0);
AN : out STD_LOGIC_VECTOR (3 downto 0);
dp : out std_logic ); end Stopwatch;
component sev_seg_decoder
port (binary_num : in std_logic_vector(3 downto 0);
ABCDEFG :out std_logic_vector(6 downto 0));
end component;
component twobitcounter
port (clk : in STD_LOGIC;
count_out : out STD_LOGIC_vector(1 downto 0));
end component;
component four_to_one_mux
port (x0,x1,x2,x3 : in std_logic_vector(6 downto 0);
sr : in STD_LOGIC_VECTOR (1 downto 0);
f : out STD_LOGIC_vector(6 downto 0));
end component;
COUNTER2BIT : twobitcounter
port map (clk => temp,
count_out=>SR);
COUNTER4BIT0 : four_bit_countr
port map (clk => temp2,
OUTPUT0=>bin0,
OUTPUT1=>bin1,
OUTPUT2=>bin2,
OUTPUT3=>bin3,
CEn => start_stop,
RST => RESET
);
decode0 : sev_seg_decoder
port map (binary_num => bin0,
ABCDEFG => S_0
);
decode1 : sev_seg_decoder
port map (binary_num => bin1,
ABCDEFG => S_1
);
decode2 : sev_seg_decoder
port map (binary_num => bin2,
ABCDEFG => S_2
);
decode3 : sev_seg_decoder
port map (binary_num => bin3,
ABCDEFG => S_3
);
mux : four_to_one_mux
port map (x0 => S_0,
x1 => S_1,
x2 => s_2,
x3 => s_3,
f => DISP0,
sr =>SR
);
end Behavioral;
b. RTL Schematics
c. Technology Schematics