«Бог не меняет того, что (происходит) с людьми, пока они сами не изменят своих помыслов.» Коран, Сура 12:13

ПЦУСБ/Лекция 5 — различия между версиями

Материал из Wiki
Перейти к: навигация, поиск
(Новая страница: «{{ПЦУСБ TOC}} <slideshow style="custis" headingmark="Слайд:" incmark=":step" scaled="true"> ;title: Операторы языка VHDL ;author: Авд…»)
 
м (Слайд: Последовательный оператор loop)
Строка 27: Строка 27:
  
  
=== Слайд: Последовательный оператор loop ===
+
=== Слайд: Оператор присваивания: <tt><=</tt> ===
 +
 
 +
{{link|conditional_waveform_assignment}} ::=      [§ '''10.5.3''']
 +
  {{ref|target}} <= [ {{ref|delay_mechanism}} ] {{ref|conditional_waveforms}} ;
 +
 
 +
{{link|delay_mechanism}} ::=      [§ '''10.5.2.1''']
 +
  '''transport'''
 +
  | [ '''reject''' ''time''_expression ] '''inertial'''
 +
 
 +
Пример транспортной задержки:
 +
transmission_line : process (line_in) is
 +
begin
 +
  line_out <= '''transport''' line_in '''after''' 500 ps;
 +
end process transmission_line;
 +
 
 +
Пример инерционной задержки:
 +
inv : process (a) is
 +
begin
 +
  y <= '''inertial''' not a after 3 ns;
 +
{{Сн|'''или'''}}
 +
  y <= not a after 3 ns;
 +
end process inv;
 +
 
 +
inv : process (a) is
 +
begin
 +
  y <= '''reject''' 2 ns '''inertial''' not a after 3 ns;
 +
end process inv;
 +
 
 +
<small>
 +
* §5.2.5 Transport and Inertial Delay Mechanisms (стр. 158)
 +
</small>
 +
 
 +
 
 +
==== Слайд: Оператор присваивания: <tt><=</tt> ====
 +
 
 +
* EXAMPLE 5.10 An asymmetric delay element using transport delay
 +
 
 +
asym_delay : process (a) is
 +
  constant Tpd_01 : time := 800 ps;
 +
  constant Tpd_10 : time := 500 ps;
 +
begin
 +
  if a then
 +
    z <= transport a after Tpd_01;
 +
  else -- not a
 +
    z <= transport a after Tpd_10;
 +
  end if;
 +
end process asym_delay;
 +
 
 +
 
 +
=== Слайд: Оператор loop ===
 +
 
 +
* бесконечный цикл
 +
 
 +
loop_statement ⇐
 +
  [ loop_label : ] '''loop'''
 +
            { последовательные операторы }
 +
    '''end loop''' [ loop_label ] ;
 +
 
 +
* Пример
 +
entity counter is
 +
  port ( clk  : in  bit;
 +
          count : out natural );
 +
end entity counter;
 +
 +
architecture behavior of counter is
 +
begin
 +
  incrementer : process is
 +
    variable count_value : natural := 0;
 +
  begin
 +
    count <= count_value;
 +
    '''loop'''
 +
      wait until clk;
 +
      count_value := (count_value + 1) mod 16;
 +
      count <= count_value;
 +
    '''end loop''';
 +
  end process incrementer;
 +
end architecture behavior;
 +
 
 +
<small>
 +
* 3.4 Loop Statements (стр. 84 (76))
 +
</small>
 +
 
 +
==== Слайд: Оператор exit ====
 +
 
 +
* Выход из цикла
 +
{{link|exit_statement}} ::=      [§ '''10.2''']
 +
  [ {{ref|label}} : ] '''exit''' [ ''loop''_label ] [ '''when''' {{ref|condition}} ] ;
 +
 
 +
* Пример
 +
{|cellspacing="0" cellpadding="5" border="1"
 +
| <pre>
 +
loop
 +
  if condition then
 +
    exit;
 +
  end if;
 +
end loop;
 +
</pre>
 +
|<pre>
 +
loop
 +
  ...
 +
  exit when ''условие'';
 +
  ...
 +
end loop;
 +
...      -- Управление перейдёт сюда
 +
          -- при выполнения условия внутри цикла loop</pre>
 +
|}
 +
 
 +
loop_name : '''loop'''
 +
  ...
 +
  '''exit''' loop_name;
 +
  ...
 +
  '''end loop''' loop_name;
 +
 
 +
 
 +
==== Слайд: Оператор next ====
 +
 
 +
* Переход на следующую итерацию цикла
 +
 
 +
{{link|next_statement}} ::=      [§ '''10.11''']
 +
  [ {{ref|label}} : ] '''next''' [ ''loop''_label ] [ '''when''' {{ref|condition}} ] ;
 +
 
 +
 
 +
{| cellspacing="0" cellpadding="5" border="1"
 +
|<pre>
 +
loop
 +
  statement-1;
 +
  next when condition;
 +
  statement-2;
 +
end loop;</pre>
 +
|<pre>
 +
loop
 +
  statement-1;
 +
  if not condition then
 +
    statement-2;
 +
  end if;
 +
end loop;</pre>
 +
|}
 +
 
 +
 
 +
=== Слайд: Оператор цикла while..loop===
 +
 
 +
loop_statement ⇐
 +
    [ loop_label : ]
 +
    '''while''' condition '''loop'''
 +
      { sequential_statement }
 +
    '''end loop''' [ loop_label ] ;
 +
 
 +
 
 +
while index > 0 loop
 +
  ...    -- statement A: do something with index
 +
end loop;
 +
...      -- statement B
 +
 
 +
 
 +
=== Слайд: Оператор цикла for..loop===
 +
 
 +
loop_statement ⇐
 +
  [ loop_label : ]
 +
    '''for''' identifier '''in''' discrete_range '''loop'''
 +
          { sequential_statement }
 +
    '''end loop''' [ loop_label ] ;
 +
 
 +
discrete_range ⇐
 +
    simple_expression ( '''to''' | '''downto''' ) simple_expression
 +
 
 +
 
 +
'''for''' count_value '''in''' 0 '''to''' 127 '''loop'''
 +
  count_out <= count_value;
 +
  wait for 5 ns;
 +
'''end loop''';
 +
 
 +
 
 +
=== Слайд: Оператор assert ===
 +
 
 +
* проверяет условие, в случае нарушения которого может выдаваться сообщение
 +
concurrent_assertion_statement ⇐
 +
  [ label : ]
 +
    '''assert''' ''condition''
 +
  [ '''report''' ''expression'' ] [ '''severity''' ''expression'' ] ;
 +
 
 +
'''assert''' initial_value <= max_value
 +
  '''report''' "initial value too large";
 +
 
 +
'''assert''' current_character >= '0' '''and''' current_character <= '9'
 +
  '''report''' "Input number " & input_string & " contains a non-digit";
 +
 
 +
check : '''assert''' not (s and r)
 +
          '''report''' "Incorrect use of S_R_flip_flop: " &
 +
                  "s and r both '1'";
 +
 
 +
* в пакете STANDARD:
 +
'''type''' severity_level '''is''' (note, warning, error, failure);
 +
 
 +
'''assert''' free_memory >= low_water_limit
 +
  '''report''' "low on memory, about to start garbage collect"
 +
  '''severity''' note;
 +
 
 +
 
 +
=== Слайд: Оператор  ===

Версия 22:28, 7 ноября 2013

Лекции ПЦУСБ

Лекции

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

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

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

Заголовок
Операторы языка VHDL
Автор
Авдеев Н.А.
Нижний колонтитул
ПЦУСБ/Лекция 5
Дополнительный нижний колонтитул
Авдеев Н.А., 22:33, 14 ноября 2013


Содержание

Слайд: Последовательные операторы

  •  :=
  • <=
  • if
  • case
  • loop
    • next
    • exit
  • null
  • procedure call
  • return
  • assert
  • wait

Используются в:

  • process
  • функциях
  • подпрограммах


Слайд: Оператор присваивания: <=

conditional_waveform_assignment ::=      [§ 10.5.3]
  target <= [ delay_mechanism ] conditional_waveforms ;
delay_mechanism ::=      [§ 10.5.2.1]
  transport
  | [ reject time_expression ] inertial

Пример транспортной задержки:

transmission_line : process (line_in) is
begin
  line_out <= transport line_in after 500 ps;
end process transmission_line;

Пример инерционной задержки:

inv : process (a) is
begin
  y <= inertial not a after 3 ns;
или
  y <= not a after 3 ns;
end process inv;
inv : process (a) is
begin
  y <= reject 2 ns inertial not a after 3 ns;
end process inv;

  • §5.2.5 Transport and Inertial Delay Mechanisms (стр. 158)


Слайд: Оператор присваивания: <=

  • EXAMPLE 5.10 An asymmetric delay element using transport delay
asym_delay : process (a) is
  constant Tpd_01 : time := 800 ps;
  constant Tpd_10 : time := 500 ps;
begin
  if a then
    z <= transport a after Tpd_01;
  else -- not a
    z <= transport a after Tpd_10;
  end if;
end process asym_delay;


Слайд: Оператор loop

  • бесконечный цикл
loop_statement ⇐
  [ loop_label : ] loop
           { последовательные операторы }
    end loop [ loop_label ] ;
  • Пример
entity counter is
  port ( clk   : in  bit;
         count : out natural );
end entity counter;

architecture behavior of counter is
begin
  incrementer : process is
    variable count_value : natural := 0;
  begin
    count <= count_value;
    loop
      wait until clk;
      count_value := (count_value + 1) mod 16;
      count <= count_value;
    end loop;
  end process incrementer;
end architecture behavior;

  • 3.4 Loop Statements (стр. 84 (76))

Слайд: Оператор exit

  • Выход из цикла
exit_statement ::=      [§ 10.2]
  [ label : ] exit [ loop_label ] [ when condition ] ;
  • Пример
 loop
   if condition then
     exit;
   end if;
 end loop;
 loop
   ...
   exit when ''условие'';
   ...
 end loop;
 ...      -- Управление перейдёт сюда
          -- при выполнения условия внутри цикла loop
loop_name : loop
  ...
  exit loop_name;
  ...
 end loop loop_name;


Слайд: Оператор next

  • Переход на следующую итерацию цикла
next_statement ::=      [§ 10.11]
  [ label : ] next [ loop_label ] [ when condition ] ;


 loop
   statement-1;
   next when condition;
   statement-2;
 end loop;
 loop
   statement-1;
   if not condition then
     statement-2;
   end if;
 end loop;


Слайд: Оператор цикла while..loop

loop_statement ⇐
   [ loop_label : ]
    while condition loop
      { sequential_statement }
    end loop [ loop_label ] ;


while index > 0 loop
  ...    -- statement A: do something with index
end loop;
...      -- statement B


Слайд: Оператор цикла for..loop

loop_statement ⇐
  [ loop_label : ]
    for identifier in discrete_range loop
         { sequential_statement }
    end loop [ loop_label ] ;
discrete_range ⇐
   simple_expression ( to | downto ) simple_expression


for count_value in 0 to 127 loop
  count_out <= count_value;
  wait for 5 ns;
end loop;


Слайд: Оператор assert

  • проверяет условие, в случае нарушения которого может выдаваться сообщение
concurrent_assertion_statement ⇐
  [ label : ]
    assert condition
  [ report expression ] [ severity expression ] ;
assert initial_value <= max_value
  report "initial value too large";
assert current_character >= '0' and current_character <= '9'
  report "Input number " & input_string & " contains a non-digit";
check : assert not (s and r)
          report "Incorrect use of S_R_flip_flop: " &
                 "s and r both '1'";
  • в пакете STANDARD:
type severity_level is (note, warning, error, failure);
assert free_memory >= low_water_limit
  report "low on memory, about to start garbage collect"
  severity note;


Слайд: Оператор