
VHDL
Đề THI MÔN THIếT Kế Hệ THốNG Số
Trình độ: Cao đẳng
Thời gian: 45 phút
Chương trình được viết và mô phỏng trên phần mềm Active- HDL
1. Thiết kế và mô phỏng Flip-Flop DFF đồng bộ tín hiệu reset.
1b. DFF cớ enable.
2. Thiết kế và mô phỏng Flip-Flop DFF không đồng bộ tín hiệu reset
3. Thiết kế và mô phỏng Flip-Flop JKFF đồng bộ tín hiệu reset.
4. Thiết kế và mô phỏng Flip-Flop JKFF không đồng bộ tín hiệu reset.
5. Thiết kế và mô phỏng Flip-Flop RSFF đồng bộ tín hiệu reset.
6. Thiết kế và mô phỏng Flip-Flop RSFF không đồng bộ tín hiệu reset.
7. Thiết kế và mô phỏng mạch có 3 đầu vào A, B, C khi hai trong 3 đầu vào có giá
trị bằng một thì đầu ra mang giá trị bằng 1.
8. Thiết kế và mô phỏng mạch 3 trạng thái.
9. Viết chương trình và mô phỏng chức năng của IC 74139 ( viết bằng các lệnh song
song).
10. Viết chương trình và mô phỏng chức năng của IC 74139 ( viết bằng các lệnh nối
tiếp).
11. Viết chương trình và mô phỏng chức năng của IC 74138 ( viết bằng các lệnh song
song).
12. Viết chương trình và mô phỏng chức năng của IC 74138 ( viết bằng các lệnh nối
tiếp).
13. Thiết kế và mô phỏng mạch đếm tiến với Kd bất kỳ.
14. Thiết kế và mô phỏng mạch đếm lùi với Kd bất kỳ.
15. Thiết kế và mô phỏng bộ ghép kênh 4-1
16. Thiết kế và mô phỏng bộ ghép kênh 8-1
17. Thiết kế và mô phỏng bộ phân kênh 1-4
18. Thiết kế và mô phỏng bộ phân kênh 1-8
19. Viết chương trình thiết kế và mô phỏng bộ so sánh 4 bit
20. Thiết kế và mô phỏng thanh ghi dịch có độ dài 4 bit
21. Viết chương trình thiết kế và mô phỏng bộ cộng n bit
22. Viết chương trình thiết kế và mô phỏng chuyển mã BCD sang LED 7 thanh.
23. Viết chương trình thiết kế và mô phỏng chuyển mã BCD sang thập phân.
24. Viết chương trình thiết kế và mô phỏng chuyển mã HEX sang LED 7 thanh.
25. Viết chương trình thiết kế và mô phỏng kiểm tra tính chẵn lẻ của chuỗi n bit
26. Viết chương trình thiêt kế và mô phỏng thực hiện bộ ALU 8 bit với 2 đầu vào 8
bit và tín hiệu điều khiển có chức năng như sau:
a. Thực hiện phép cộng khi đầu vào điều khiên nhận giá trị “00”.
b. Thực hiện phép trừ khi đầu vào điều khiển nhận giá trị “01”.
c. Thực hiện phép toán AND khi đầu vào điều khiển nhận giá trị “10”
d. Thực hiện phép toán OR khi đầu vào điều khiển nhận giá trị “11”.
27. Viết chương trình thiết kế và mô phỏng đếm số số 1 trong chuỗi đầu vào 8 bit.
28. Viết chương trình thiết kế và mô phỏng đếm số số 0 trong chuỗi đầu vào 8 bit.
29. Thiết kế và mô phỏng bộ chia tần số với hệ số chia bất kỳ..
30. Thiết kế bộ mã hóa 3-8.
31. Thiết kế bộ giải mã 8 -3.
32. Thiết kế và mô phỏng mạch tìm mã bù 2 của một số.
33. them:-thiet ke chuong trinh dieu khien 4led,8led sang lai tat
BÀI TẬP 1:DFF ĐỒNG BỘ
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity DFF is
port(
rst : in STD_LOGIC;
d : in STD_LOGIC;
clk : in STD_LOGIC;
q : out STD_LOGIC
);
end DFF;
architecture DFF of DFF is
begin
process
begin
wait until(clk'event and clk='1');
if (rst='1') then
q<='0';
elsif(clk'event and clk='1')then
q<=d;
end if;
end process;
end DFF;
BAI TAP 2:DFF KHONG ĐỒNG BỘ
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY dff IS
PORT ( d, clk, rst: IN STD_LOGIC;
q: OUT STD_LOGIC);
END dff;
ARCHITECTURE behavior OF dff IS
BEGIN
PROCESS (rst, clk)
BEGIN
IF (rst='1') THEN
q <= '0';
ELSIF (clk'EVENT AND clk='1') THEN
q <= d;
END IF;
END PROCESS;
END behavior;
Bai tap 4:JK KHÔNG ĐỒNG BỘ
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity jk is
port(clk : in STD_LOGIC;
rst : in STD_LOGIC;
x : in STD_LOGIC_VECTOR(0 to 1);
y : buffer STD_LOGIC );
end jk;
architecture jk of jk is
begin
process(clk,rst)
variable temp: std_logic;
begin
if(rst='1') then temp:='0';
elsif(clk'event and clk='1')then
if(x="00") then temp:=temp;
elsif (x="01")then
temp:='1';
elsif(x="10")then
temp:='0';
elsif(x="11")then
temp:=not temp;
end if;
end if;
y<=temp;
end process;
end jk;
BÀI TẬP 5:RS ĐỒNG BỘ
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity rs is
port( r : in STD_LOGIC;
s : in STD_LOGIC;
clk : in STD_LOGIC;
rst : in STD_LOGIC;
q :buffer STD_LOGIC );
end rs;
architecture rs of rs is
begin
process
variable temp:std_logic;
wait until (clk'event and clk='1');
begin
if (rst='1')then
temp:='0';
elsif (clk'event and clk='1')then
if(r='0'and s='0')then
temp:=temp;
elsif(r='0'and s='1')then
temp:='0';
elsif(r='1' and s='0')then
temp:='1';
elsif(r='1' and s='1')then
temp:='Z';
end if;
end if;
q<=temp;
end process;
end rs;
BÀI TẬP 7 :MẠCH BA ĐÀU VÀO
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity mach is
port(x: in std_logic_vector (2 downto 0);
y : out std_logic
);
end mach;
architecture mach of mach is
begin
process(x)
begin
case x is
when "011"=>y<='1';
when "101"=>y<='1';
when "110"=>y<='1';
when others =>y<='0';
end case;
end process;
end mach;
BÀI TẬ 8: MẠCH BA TRẠNG THÁI
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity mach is
port( d : in STD_LOGIC_vector(7 downto 0);
ena : in STD_LOGIC;
y : out STD_LOGIC_vector(7 downto 0) );
end mach;
architecture mach of mach is
begin
y<=d when (ena='0')else
(others=>'Z');
end mach;
BÀI TẬP 9:LS 139 (THEO KIÊU SONG SONG)
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity ls is
port(x : in STD_LOGIC_VECTOR(2 downto 0);
y : out STD_LOGIC_VECTOR(3 downto 0) );
end ls;
architecture ls of ls is
begin
process(x)
begin
case x is
when "000"=>y<="0111";
when "001"=>y<="1011";
when "010"=>y<="1101";
when "011"=>y<="1110";
when others=>y<="1111";
end case;
end process;
end ls;
BÀI TẬP 10 :LS139 ( tuan tu)
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity ls is
port( x : in STD_LOGIC_VECTOR(5 downto 0);
y : out STD_LOGIC_VECTOR(7 downto 0) );
end ls;
architecture ls of ls is
begin
PROCESS(X)
BEGIN
CASE X IS
WHEN"001000"=>Y<="01111111";
when"001001" =>Y<="10111111";
when"001010"=>Y<="11011111" ;
when"001011"=>Y<="11101111";
when"001100" =>Y<="11110111";
when"001101"=>Y<="11111011";
when"001110"=>Y<="11111101";
when"001111"=>Y<="11111110";
WHEN OTHERS =>Y<="11111111";
END CASE ;
END PROCESS :
BÀI TẬP 11:LS 138 (SONG SONG)
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity ls is
port( x : in STD_LOGIC_VECTOR(5 downto 0);
y : out STD_LOGIC_VECTOR(7 downto 0) );
end ls;
architecture ls of ls is
begin
y<="01111111" whenelse
"10111111"whenelse
"11011111"when else
"11101111"whenelse
"11110111" whenelse
"11111011"whenelse
"11111101"whenelse
"11111110"whenelse
"11111111";
end ls;
BÀI 13:TẬP BỘ ĐẾM THUẬN
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity bodem is
port(
clk : in STD_LOGIC;
q : out INTEGER range 0 to 9
);
end bodem;
architecture bodem of bodem is
begin
process(clk)
variable count:integer range 0 to 10 ;
begin
if(clk'event and clk='1')then
count:=count+1;
if(count=10)then count:=0;
end if;
end if;
q<=count;
end process;
end bodem;
BÀI 14:TẬP BỘ ĐẾM NGHỊCH
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity bodem is
port( clk : in STD_LOGIC;
q : out INTEGER range 0 to 9
);
end bodem;
architecture bodem of bodem is
begin
process(clk)
variable temp: integer range 9 downto 0;
begin
if(clk'event and clk='1')then
temp:=temp-1;
if(temp=0)then temp:=0;
end if;
end if;
q<=temp;
end process ;
end bodem;
BÀI 15:TẬP MUX 4-1
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity mux is
port( a : in STD_LOGIC;
b : in STD_LOGIC;
c : in STD_LOGIC;
d : in STD_LOGIC;
sel:in std_logic_vector (1 downto 0);
y : out STD_LOGIC);
end mux;
architecture mux of mux is
begin
y<=a when else
b when else
c when else
d;
end mux;
BÀI TẬP16: MUX 8-1
ibrary IEEE;
use IEEE.STD_LOGIC_1164.all;
entity mux8_1 is
port( a : in STD_LOGIC;
b : in STD_LOGIC;
c : in STD_LOGIC;
d : in STD_LOGIC;
e : in STD_LOGIC;
f : in STD_LOGIC;
h : in STD_LOGIC;
g : in STD_LOGIC;
sel:in std_logic_vector(2 downto 0);
y : out STD_LOGIC );
end mux8_1;
architecture mux8_1 of mux8_1 is
begin
y<=a whenelse
b whenelse
c when else
d whenelse
e when sel ="100"else
f when else
h whenelse
g;
end mux8_1;
BÀI TẬP17: MUX 1-4
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity mux is
port( y : out STD_LOGIC_vector(3 downto 0);
a : in STD_LOGIC_VECTOR(1 downto 0) );
end mux;
architecture mux of mux is
begin
y<="1000"whenelse
"0100" whenelse
"0010"whenelse
"0001";
end mux;
BÀI TẬP 18: MUX 1-8
ibrary IEEE;
use IEEE.STD_LOGIC_1164.all;
entity mux is
port( a : in STD_LOGIC_VECTOR(2 downto 0);
y : out STD_LOGIC_VECTOR(7 downto 0));
end mux;
architecture mux of mux is
begin
y<="10000000"whenelse
"01000000"whenelse
"00100000"whenelse
"00010000"whenelse
"00001000"whenelse
"00000100"whenelse
"00000010"whenelse
"00000001";
end mux;
BÀI 19:TẬP SO SANH 4 BIT
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity sosanh is
port( x1 : out STD_LOGIC;
x2 : out STD_LOGIC;
x3 : out STD_LOGIC;
a : in STD_LOGIC_VECTOR(3 downto 0);
b : in STD_LOGIC_VECTOR(3 downto 0));
end sosanh;
architecture sosanh of sosanh is
begin
x1<='1' when a>b else '0';
x2<='1' when a=b else '0';
x3<='1' when a<b else '0';
end sosanh;
BÀI TẬP 20:THANH GHI DỊCH
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity thanhghi is
generic (n:integer :=4);
port( d : in STD_LOGIC;
clk : in STD_LOGIC;
rst : in STD_LOGIC;
q : out STD_LOGIC);
end thanhghi;
architecture thanhghi of thanhghi is
signal temp :std_logic_vector (n-1 downto 0):="0000";
begin
process(clk,rst)
begin
if(rst='1')then
temp<=(others=>'0');
elsif (clk'event and clk='1')then
temp<=d&temp(temp'left downto 1);
end if;
q<=temp(0);
end process;
end thanhghi;
BÀI TẬP 21: BỘ CỘNG
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity bocong is
generic (n:integer:=4);
port(
cin : in STD_LOGIC;
a : in STD_LOGIC_VECTOR(n-1downto 0);
b : in STD_LOGIC_VECTOR(n-1 downto 0);
cout : out STD_LOGIC;
s : out STD_LOGIC_VECTOR(n-1 downto 0)
);
end bocong;
architecture bocong of bocong is
signal c:std_logic_vector (n downto 0);
begin
c(0)<=cin;
g1:for i in 0 to n-1 generate
s(i)<=a(i)xor b(i) xor c(i);
c(i+1)<= (a(i)and b(i))or (a(i)and c(i))or (b(i)and c(i));
end generate;
cout<=c(n);
end bocong;
BÀI TậP 22:BCD LED
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity chyendoi is
port(
x : in STD_LOGIC_VECTOR(3 downto 0);
y : out STD_LOGIC_VECTOR(6 downto 0)
);
end chyendoi;
architecture chyendoi of chyendoi is
begin
y <= "1111110" whenelse
"0110000" whenelse
"1101101" whenelse
"1111001" whenelse
"0110011" whenelse
"1011011" whenelse
"1011111" whenelse
"1110000" whenelse
"1111111" whenelse
"1111011" whenelse
"0000000";
end chyendoi;
BÀI TẬP 23:BCDTHẬP PHÂN
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity bcd is
port( x : in STD_LOGIC_VECTOR(3 downto 0);
y : out STD_LOGIC_VECTOR(9 downto 0) );
end bcd;
architecture bcd of bcd is
begin
y<="1000000000"whenelse
"0100000000"whenelse
"0010000000"whenelse
"0001000000"whenelse
"0000100000"whenelse
"0000010000"whenelse
"0000001000"whenelse
"0000000100"whenelse
"0000000010"whenelse
"0000000001"whenelse
"0000000000";
end bcd;
BÀI TẬP 24:HEXLED
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity \chuyen ma\ is
port( a : in STD_LOGIC_VECTOR(3 downto 0);
y : out STD_LOGIC_VECTOR(6downto 0) );
end \chuyen ma\;
architecture \chuyen ma\ of \chuyen ma\ is
begin
with a select
y<="1111110"when"0000",
"0110000"when"0001",
"1101101"when"0010",
"1111001"when"0011",
"0110011"when"0100",
"1011011"when"0101",
"1011111"when"0110",
"1110000"when"0111",
"1111111"when"1000",
"1111011"when"1001",
"1110111"when"1010",
"0011111"when"1011",
"1001110"when"1100",
"0111101"when"1101",
"1001111"when"1110",
"1000111"when"1111",
"ZZZZZZZ" when others;
end \chuyen ma\;
BÀI TẬP 25: MẠCH KIỂM TRA CHẴN LẺ
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity patity is
generic (n:integer:=7);
port( input : in BIT_vector(n downto 0);
output : out BIT );
end patity;
architecture patity of patity is
begin
process (input)
variable temp:bit;
begin
temp:='0';
for i in input'range loop
temp:=temp xor input(i);
end loop;
output<=temp;
end process;
end patity;
BÀI TậP 26:ALU
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use ieee.std_logic_unsigned.all;
entity alu is
port( a : in STD_LOGIC_VECTOR(2 downto 0);
b : in STD_LOGIC_VECTOR(2 downto 0);
sel : in STD_LOGIC_VECTOR( 1 downto 0);
y : out STD_LOGIC_VECTOR(2 downto 0) );
end alu;
architecture alu of alu is
signal airth,logic:std_logic_vector (2 downto 0);
begin
with sel(1 downto 0) select
airth<=a+b when "00",
a-b when "01",
"ZZZ" when others;
with sel(1 downto 0)select
logic<=a and b when "10",
a or b when "11",
"ZZZ" when others;
with sel(0) select
y<=airth when '0',
logic when others;
end alu:
BÀI TẬP 27: ĐẾM SỐ 1
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity bodem1 is
port(
a : in STD_LOGIC_VECTOR(7 downto 0);
q : out INTEGER range 0 to 8
);
end bodem1;
architecture bodem1 of bodem1 is
begin
process (a)
variable temp:integer range 0 to 8;
begin
temp:=0;
for i in 0 to 7 loop
if (a(i)='1')then
temp:=temp+1;
end if;
end loop;
q<=temp;
end process;
end bodem1;
BÀI TẬP 28:BỘ ĐẾM SỐ 0
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity bodem is
port(
din : in STD_LOGIC_VECTOR(7 downto 0);
q : out INTEGER range 8 downto 0
);
end bodem;
architecture bodem of bodem is
begin
process (din)
vAriable temp:integer range 8 downto 0;
BEGIN
temp:=0;
for i in 0 to 7 loop
if(din(i)='0')then
temp:=temp+1;
end if;
END LOOP;
q<=temp;
end process;
end bodem;
BÀI TẬP 30:MÃ HÓA
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity mahoa is
port(x : in STD_LOGIC_VECTOR(7 downto 0);
y : out STD_LOGIC_VECTOR(2 downto 0) );
end mahoa;
architecture mahoa of mahoa is
begin
y<= "000" whenelse
"001" whenelse
"010"whenelse
"011"whenelse
"100"whenelse
"101"whenelse
"110"whenelse
"111"whenelse
"ZZZ";
end mahoa;
BÀI TẬP 31:GIẢI MÃ
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity giaima is
port( ena : in STD_LOGIC;
sel : in STD_LOGIC_VECTOR(2 downto 0);
x : out STD_LOGIC_VECTOR(7 downto 0) );
end giaima;
architecture giaima of giaima is
begin
process(ena,sel)
variable temp1:std_logic_vector(X'HIGH downto 0);
variable temp2:integer range 0 to X'high;
begin
temp1:= (others => '1');
temp2:= 0;
if (ena='1')then
for i in sel'range loop
if (sel(i)='1')then
temp2:=2*temp2+1;
else
temp2:=2*temp2;
end if;
end loop;
temp1(temp2):='0';
end if;
x<=temp1;
end process;
Bạn đang đọc truyện trên: Truyen247.Pro