Przykładowe fragmenty kodu w VHDL i Verilog(R)
Logo Katedry
Strona główna
Katedra Systemów Mikroelektronicznych, Wydział Elektroniki, Telekomunikacji i Informatyki, Politechnika Gdańska Logo Wydziału
English English version

Przykładowe fragmenty kodu w VHDL i Verilog®


Proces sekwencyjny z asynchronicznym resetem:

VHDL: Verilog®:
process (clk,rst)
begin
  if rst='1' then
         
... tutaj następuje obsługa resetu...
  elsif clk'event and clk='1' then
         
... tutaj następuje obsługa zbocza zegara...
  end if;
end process;
always @(posedge clk or posedge rst)
if (rst)
  begin
         
... tutaj następuje obsługa resetu...
  end
else
  begin
         
... tutaj następuje obsługa zbocza zegara...
  end

Generacja sygnału zegara w testbenchu:

signal clk : std_logic := '0';
...
clk <= not clk after 10ns;

Sygnał clk

Generacja sygnału nieokresowego w testbenchu:

signal we1 : std_logic;
...
we1 <= '0', '1' after 10ns, '0' after 25ns, '1' after 30ns;

Sygnał we1

Osadzanie komponentów:

Plik: a.vhd:
----------- ENTITY A: ------------------------------
library ieee;
use ieee.std_logic_1164.all;

entity a is
  port (
    a1 : in std_logic;
    a2 : in std_logic;
    a3 : out std_logic
  );
end entity;

architecture beh of a is
begin
  ...
end architecture;
----------------------------------------------------

Plik: b.vhd:
----------- ENTITY B: ------------------------------
library ieee;
use ieee.std_logic_1164.all;

entity b is
  port (
    b1 : in std_logic;
    b2 : in std_logic;
    b3 : in std_logic;
    b4 : out std_logic
  );
end entity;

architecture beh of b is

  signal tmp : std_logic;
  component a is
    port (
      a1 : in std_logic;
      a2 : in std_logic;
      a3 : out std_logic
    );
  end component;

begin

  X1: a port map (a1 => b1, a2 => b2, a3 => tmp);
  X2: a port map (a1 => tmp, a2 => b3, a3 => b4);

end architecture;
----------------------------------------------------
osadzanie komponentów