«Работать добросовестно — значит: работать, повышая свою квалификацию, проявляя инициативу в совершенствовании продукции, технологий, организации работ, оказывая не предусмотренную должностными инструкциями помощь другим сотрудникам (включая и руководителей) в общей им всем работе.

ПЦУСБ/Лекция 3

Материал из Wiki
< ПЦУСБ
Версия от 08:44, 9 июня 2014; ANA (обсуждение | вклад)

(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск
Лекции ПЦУСБ

Лекции

Практические
Тесты

Лабораторные

Доп. материалы

Заголовок
Базовые цифровые устройства
Автор
Авдеев Н.А.
Нижний колонтитул
ПЦУСБ/Лекция 3
Дополнительный нижний колонтитул
Авдеев Н.А., 08:44, 9 июня 2014


Содержание

Слайд: Содержание

  • Логические элементы (И, ИЛИ, НЕ, Исключающее ИЛИ)
  • Комбинационные схемы [1], [2]:
    • Дешифратор [3] /Шифратор
    • Мультиплексор/Демультиплексор
    • Сумматор
    • Компаратор
  • Последовательностные схемы
    • Триггеры
      • Синхронные
        • по фронту
        • по уровню
      • Асинхронные
    • Регистры
    • Автоматы
    • Счетчики

Слайд: Логические элементы

В алгебре логики известны три основные логические операции:

  1. Логическое умножение (конъюнкция или операция И). Записывается как F = A Λ B, F = A & B, F = A·B, F = AB, читается – A и B.
  2. Логическое сложение (дизъюнкция или операция ИЛИ). Записывается как F = A V B, F = A | B, F = A+B, читается – F = A или B.
  3. Логическое отрицание (инверсия или операция НЕ). Записывается F = A , читается – F = “не” A.

Слайд:Таблица истинности логических элементов

Image80.gif


Аргументы Логические операции (булевы функции)
А В И ИЛИ НЕ
A·B A+B A B
0 0 0 0 1 1
0 1 0 1 1 0
1 0 0 1 0 1
1 1 1 1 0 0
Операторы VHDL A and B A or B not A not B


Комментарий

Таким образом, выполнение сколь угодно сложной логической операции может быть сведено к трем вышеперечисленным операциям. Следовательно, имея некоторые технические устройства, реализующие операции И, ИЛИ, НЕ, можно построить сколь угодно сложное цифровое устройство. Такие устройства называются соответственно логическими элементами И, ИЛИ, НЕ (рис. 2) и образуют основной базис или функционально полную систему логических элементов.


Слайд: Дешифратор (DC)

  • комбинационная схема, преобразующее n-разрядный двоичныйв -ичный одноединичный (позиционный) код
image234.png

Слайд:Дешифратор (VHDL модель)

entity dc is
  port (
    x : in  std_logic_vector(2 downto 0);
    y : out std_logic_vector(7 downto 0));
end dc;
 
architecture beh of dc is
begin 
  y <=
    "00000001" when x = "000" else
    "00000010" when x = "001" else
    "00000100" when x = "010" else
    "00001000" when x = "011" else
    "00010000" when x = "100" else
    "00100000" when x = "101" else
    "01000000" when x = "110" else
    "10000000" when x = "111" else
    "00000000";
end beh;

Слайд:Шифратор

  • комбинационная схема, выполняющее преобразование одноединичный (позиционного) n-разрядного кода в m-разрядный двоичный код.
image232.png


Слайд:Шифратор (VHDL модель 1)

VHDL модель 1 VHDL модель 2
entity cd is
 
  port (
    x : in  std_logic_vector(7 downto 0);
    y : out std_logic_vector(2 downto 0));
 
end dc;
 
architecture beh1 of cd is
 
begin  
 
  y <=
    "000" when x(0) = "1" else
    "001" when x(1) = "1" else
    "010" when x(2) = "1" else
    "011" when x(3) = "1" else
    "100" when x(4) = "1" else
    "101" when x(5) = "1" else
    "110" when x(6) = "1" else
    "111" when x(7) = "1" else
    "000";    
 
end beh1;
entity cd is
 
  port (
    x : in  std_logic_vector(7 downto 0);
    y : out std_logic_vector(2 downto 0));
 
end dc;
 
architecture beh2 of cd is
 
begin 
 
  y(0) <= x(1) or x(3) or x(5) or x(7);
  y(1) <= x(2) or x(3) or x(6) or x(7);
  y(2) <= x(4) or x(5) or x(6) or x(7);
 
end beh2;

Слайд: Мультиплексор

  • комбинационная схема, которая передает сигнал с одного из информационных входов Xi на единственный выход Y, причем номер выбираемого входа задается с помощью управляющих сигналов (адресных входов ai).
tabl5.gif
y = OE(x0*a1*a0 + x1*a1*a0 + x2*a1*a0 + x3*a1*a0)


Слайд:Мультиплексор (Схема)

6.htm1.gif
MS_S.gif

Слайд:Мультиплексор (VHDL модель)

entity mux is
 
  port (
    x : in  std_logic_vector(3 downto 0);
    a : in  std_logic_vector(1 downto 0);
    y : out std_logic);
 
end mux;
 
architecture beh of mux is
begin
  y <=
    x(0) when a = "00" else
    x(1) when a = "01" else
    x(2) when a = "10" else
    x(3) when a = "11" else
    '0';
end beh;


Слайд:Мультиплексор (Особенность)

  • с помощью мультиплексора можно реализовать любую логическую функцию
arhitektura-pc-60.png

Слайд:Мультиплексор (Особенность)

6.htm8.jpg

Слайд: Демультиплексор [4] [5]

  • комбинационная схема, которая выполняет функцию, обратную мультиплексору, т.е. в соответствии с принятой адресацией Ai направляет информацию с единственного входа D на один из M выходов Fj. При этом на остальных выходах будут логические нули (единицы).
Входы Выходы
A1 A0 F3 F2 F1 F0
0 0 0 0 0 D
0 1 0 0 D 0
1 0 0 D 0 0
1 1 D 0 0 0

Слайд: Демультиплексор (Схема)

uch_cifr_t4_45_image016.gif uch_cifr_t4_45_image015.gif uch_cifr_t4_45_image017.gif

Слайд: Демультиплексор (VHDL модель)

entity dms is
  port (
    x : in  std_logic;
    a : in  std_logic_vector(1 downto 0);
    y : out std_logic_vector(3 downto 0));
end dms;
 
architecture beh of dms is
begin
  y <=
    "000" & x      when a = "00" else
    "00" & x & '0' when a = "01" else
    '0' & x & "00" when a = "10" else
    x & "000"      when a = "11" else
    "0000";
end beh;

Слайд: Сумматор

Слайд: Классификация триггеров

Слайд: Триггеры [6] [7]

Ссылки:

Слайд: УГО триггеров

Alib3-triggers.png

Слайд: VHDL-минимум для описания триггеров (1)

  • Атрибуты — это различные характеристики объектов VHDL
Атрибуты сигналов (S)
Атрибут Описание
S'active TRUE, если было присвоение, но текущее значение еще прежнее
S'delayed(t) Значение сигнала, существовавшее на время t перед вычислением данного атрибута
S'event TRUE, если происходит изменение сигнала
S'last_active Время от последнего присвоения значения сигналу до момента вычисления атрибута
S'last_event Время от последнего изменения сигнала до момента вычисления атрибута
S'last_value Последнее присвоенное сигналу значение
S'stable(t) TRUE, если не происходило изменение сигнала в течение времени t
S'transaction TRUE, если происходит очередное присвоение значения сигналу
S'quiet FALSE, если было присвоение, но текущее значение еще прежнее


Слайд: VHDL-минимум для описания триггеров (2)

clock_edge ::=
   RISING_EDGE(clk_signal_name)
   или FALLING_EDGE(clk_signal_name)
   или clock_level and event_expr
   или event_expr and clock_level
clock_level ::=
   clk_signal_name = '0' или clk_signal_name = '1'
event_expr ::=
   clk_signal_name'EVENT
   или not clk_signal_name'STABLE
  • функции RISING_EDGE и FALLING_EDGE описаны для типов:
    • BIT, BOOLEAN и др. (пакет STANDARD в VHDL'2008)
    • std_logic, std_ulogic (std_logic_1164)

Слайд: VHDL-минимум для описания триггеров (3)

Положительный фронт (переход 0 → 1)
RISING_EDGE(clk_signal_name)
clk_signal_name'EVENT and clk_signal_name = '1'
clk_signal_name = '1' and clk_signal_name'EVENT
not clk_signal_name'STABLE and clk_signal_name = '1'
clk_signal_name = '1' and not clk_signal_name'STABLE


Отрицательный фронт (переход 1 → 0)
FALLING_EDGE(clk_signal_name)
clk_signal_name'EVENT and clk_signal_name = '0'
clk_signal_name = '0' and clk_signal_name'EVENT
not clk_signal_name'STABLE and clk_signal_name = '0'
clk_signal_name = '0' and not clk_signal_name'STABLE
  • Все записи в столбцах эквивалентны

Слайд: VHDL-минимум для описания триггеров. Оператор Process (3)

  • Оператор процесса
LABEL: process [ ( имя сигнала {, имя сигнала } ) ]
      объявление в процессе
begin
      последовательный оператор[ы]
end process;

  • Пример
Пример c process Сокращённая запись
entity A2 is
  port (
    A, B : in  std_logic;
    C : out std_logic);
end A2;
 
architecture beh of A2 is
begin 
 process (A, B) 
 begin
   C <= A and B;
 end process;
end beh;
entity A2 is
  port (
    A, B : in  std_logic;
    C : out std_logic);
end A2;
 
architecture beh of A2 is
begin 
  C <= A and B;
end beh;


Слайд: VHDL-минимум для описания триггеров. Оператор if

  • Оператор условия if (последовательный оператор)
if Условие_1 then
   Выражение1
elsif Условие_2 then
   Выражение2
else
   Выражение3
end if;


Пример 1 Пример 2
  IF    (s0='0' AND s1='0') THEN
    output <= in0;
  ELSIF (s0='1' AND s1='0') THEN
    output <= in1;
  ELSE
    output <= 'X';
  END IF;
  IF    (s0='0' AND s1='0') THEN
    output <= in0;
  ELSE
    output <= 'X';
  END IF;
Пример 3 Пример 4
  IF    (s0='0' AND s1='0') THEN
    output <= in0;
  ELSIF (s0='1' AND s1='0') THEN
    output <= 'X';
  END IF;
  IF (s0='0' AND s1='0') THEN
    output <= in0;
  END IF;

Слайд: VHDL-минимум для описания триггеров (4)

D-Триггер без сброса
 DFF: process(CLOCK)
 begin
   if CLOCK'EVENT and CLOCK = '1' then
     Q <= D; -- тактироваие передним фронтом
   end if;
 end process;


D-Триггер со сбросом и установкой
 AS_DFF: process (CLOCK, RESET, SET)
 begin
   if RESET = '1' then
     Q <= '0';
   elsif SET = '1' then
     Q <= '1';
   elsif CLOCK'EVENT and CLOCK = '1' then
     Q <= D;
   end if;
 end process;

Слайд: VHDL-модели триггеров (fdp)

  • D-Триггер, синхронизируемый положительным фронтом, с парафазным выходом
Fdp.png
library ieee;
use ieee.std_logic_1164.all;
entity fdp is
  -- pragma synthesis_off
  generic (
    del : time := 900 ps);
  -- pragma synthesis_on
  port (
    d : in  std_logic;
    c : in  std_logic;
    q : out std_logic;
    qn : out std_logic);
end fdp;
architecture beh of fdp is
begin
  p1 : process (c)
  begin
    if c'event and c = '1' then
      q <= to_x01(d) after del;
      qn <= not to_x01(d) after del;
    end if;
  end process p1;
end beh;

Слайд: VHDL-модели триггеров (fld)

  • D-Триггер, синхронизируемый отрицательным фронтом
Fld.png
library ieee;
use ieee.std_logic_1164.all;
entity fld is
  -- pragma synthesis_off
  generic (
    del : time := 900 ps);
  -- pragma synthesis_on
  port (
    d : in  std_logic;
    c : in  std_logic;
    q : out std_logic);
end fld;
architecture beh of fld is
begin
  p1 : process (c)
  begin
    if c'event and c = '0' then
      q <= to_x01(d) after del;
    end if;
  end process p1;
end beh;

Слайд: VHDL-модели триггеров (fdrs)

  • D-Триггер, синхронизируемый положительным фронтом, с асинхронным сбросом и установкой
Fdrs.png
library ieee;
use ieee.std_logic_1164.all;
entity fdrs is
  -- pragma synthesis_off
  generic (
    del : time := 900 ps);
  -- pragma synthesis_on
  port (
    d : in  std_logic;
    c : in  std_logic;
    r : in  std_logic;
    s : in  std_logic;
    q : out std_logic);
end fdrs;
architecture beh of fdrs is
begin
  p1 : process (r, s, c)
  begin
    if r = '1' then
      q <= '0' after del;
    elsif s = '1' then
      q <= '1' after del;
    elsif c'event and c = '1' then
      q <= to_x01(d) after del;
    end if;
  end process p1;
end beh;
  • D-Триггер, синхронизируемый положительным фронтом, с асинхронным сбросом
Fdr.png
library ieee;
use ieee.std_logic_1164.all;
entity fdr is
  -- pragma synthesis_off
  generic (
    del : time := 900 ps);
  -- pragma synthesis_on
  port (
    d : in  std_logic;
    c : in  std_logic;
    r : in  std_logic;
    q : out std_logic);
end fdr;
architecture beh of fdr is
begin
  ff : process (r, c)
  begin
    if r = '1' then
      q <= '0' after del;
    elsif c'event and c = '1' then
      q <= to_x01(d) after del;
    end if;
  end process ff;
end beh;
  • D-Триггер (fdrp) с прямым и инверсным выходом, синхронизируемый положительным фронтом, с асинхронным сбросом
library ieee;
use ieee.std_logic_1164.all;
entity fdrp is
  -- pragma synthesis_off
  generic (
    del : time := 900 ps);
  -- pragma synthesis_on
  port (
    d : in  std_logic;
    c : in  std_logic;
    r : in  std_logic;
    q : out std_logic;
    qn: out std_logic);
end fdrp;
architecture beh of fdrp is
begin
  ff : process (r, c)
  begin
    if r = '1' then
      q <= '0' after del;
      qn <= '1' after del;
    elsif c'event and c = '1' then
      q <= to_x01(d) after del;
      qn <= not to_x01(d) after del;
    end if;
  end process ff;
end beh;
  • D-Триггер с сигналом разрешения записи данных, синхронизируемый положительным фронтом
Fe.png
library ieee;
use ieee.std_logic_1164.all;
entity fe is
  -- pragma synthesis_off
  generic (
    del : time := 900 ps);
  -- pragma synthesis_on
  port (
    d : in  std_logic;
    e : in  std_logic;
    c : in  std_logic;
    q : out std_logic);
end fe;
architecture beh of fe is
begin
  p1 : process (c)
  begin
    if c'event and c = '1' then
      if e = '1' then
        q <= to_x01(d) after del;
      end if;
    end if;
  end process p1;
end beh;
  • D-Триггер с сигналом разрешения записи данных, синхронизируемый положительным фронтом, с асинхронным сбросом и установкой
Fers.png
library ieee;
use ieee.std_logic_1164.all;
entity fers is
  -- pragma synthesis_off
  generic (
    del : time := 900 ps);
  -- pragma synthesis_on
  port (
    d : in  std_logic;
    e : in  std_logic;
    c : in  std_logic;
    r : in  std_logic;
    s : in  std_logic;
    q : out std_logic);
end fers;
architecture beh of fers is
begin
  p1 : process (r, s, c)
  begin
    if r = '1' then
      q <= '0' after del;
    elsif s = '1' then
      q <= '1' after del;
    elsif c'event and c = '1' then
      if e = '1' then
        q <= to_x01(d) after del;
      end if;
    end if;
  end process p1;
end beh;
  • D-Триггер, синхронизируемый положительным уровнем
Ld.png
library ieee;
use ieee.std_logic_1164.all;
entity ld is
  -- pragma synthesis_off
  generic (
    del : time := 900 ps);
  -- pragma synthesis_on
  port (
    d : in  std_logic;
    c : in  std_logic;
    q : out std_logic);
end ld;
architecture beh of ld is
begin
  p1 : process (c, d)
  begin
    if c = '1' then
      q <= to_x01(d);
    end if;
  end process p1;
end beh;
  • D-Триггер, синхронизируемый положительным уровнем, с асинхронным сбросом
Ldr.png
library ieee;
use ieee.std_logic_1164.all;
entity ldr is
  -- pragma synthesis_off
  generic (
    del : time := 900 ps);
  -- pragma synthesis_on
  port (
    d : in  std_logic;
    c : in  std_logic;
    r : in  std_logic;
    q : out std_logic);
end ldr;
architecture beh of ldr is
begin
  p1 : process (r, c, d)
  begin
    if r = '1' then
      q <= '0' after del;
    elsif c='1' then
      q <= to_x01(d) after del;
    end if;
  end process p1;
end beh;
  • асинхронный RS-триггер
Lrs.png
library ieee;
use ieee.std_logic_1164.all;
entity lrs is
  -- pragma synthesis_off
  generic (
    del : time := 900 ps);
  -- pragma synthesis_on
  port (
    r : in  std_logic;
    s : in  std_logic;
    q : out std_logic);
end lrs;
architecture beh of lrs is
begin
  p1 : process (r, s)
  begin
    if r = '1' then
      q <= '0' after del;
    elsif s = '1' then
      q <= '1' after del;
    end if;
  end process p1;
end beh;
  • D-Триггер, синхронизируемый низким уровнем
Lld.png
library ieee;
use ieee.std_logic_1164.all;
entity lld is
  -- pragma synthesis_off
  generic (
    del : time := 900 ps);
  -- pragma synthesis_on
  port (
    d  : in  std_logic;
    cl : in  std_logic;
    q  : out std_logic);
end lld;
architecture beh of lld is
begin
  p1 : process (cl, d)
  begin
    if cl = '0' then
      q <= to_x01(d) after del;
    end if;
  end process p1;
end beh;
  • T-триггер, синхронизируемый положительным фронтом
Fts.png
library ieee;
use ieee.std_logic_1164.all;
entity fts is
  -- pragma synthesis_off
  generic (
    del : time := 900 ps);
  -- pragma synthesis_on
  port (
    c : in  std_logic;
    s : in  std_logic;
    q : out std_logic);
end fts;
architecture beh of fts is
  signal q_i : std_logic;
begin
  ff : process (s, c)
  begin
    if s = '1' then
      q_i <= '1' after del;
    elsif c'event and c = '1' then
      q_i <= not q_i after del;
    end if;
  end process ff;
  q <= q_i;
end beh;

Слайд: Счетчики. Классификация

  • Счетчиком называется цифровой блок, предназначенный для подсчета входных сигналов.
  • Модуль счета: число возможных состояний счетчика.

Слайд: Описание регистра

entity reg is
 
  port (
    di         : in  std_logic;
    d          : in  std_logic_vector(7 downto 0);
    shift_load : in  std_logic;
    left_right : in  std_logic;
    clk        : in  std_logic;         -- reset
    reset      : in  std_logic;
    q          : out std_logic_vector(7 downto 0);
    qi         : out std_logic);
 
end reg;
 
architecture beh of reg is
  signal qq : std_logic_vector(7 downto 0);
begin  -- beh
 
  p1: process (clk, reset)
  begin  -- process p1
    if reset = '1' then 
      qq(7 downto 0) <= "00000000";      -- (others => '0')
     elsif clk'event and clk = '1' then  -- rising clock edge
       if shift_load = '0' then
         if left_right = '0' then
           qq <= qq(6 downto 0) & di ;
           qi <= qq(7);
         else
           -- left_right = '1'
           qq <= di & qq(7 downto 1);
           qi <= qq(0);
         end if;
       else
         -- shift_load = '1' - load mode
         qq <= d;
       end if;
    end if;
  end process p1;
 
  q <= qq;
end beh;

Слайд: END