Sunteți pe pagina 1din 5

Lucrare Laborator nr.

12
Modelarea i simularea circuitelor digitale cu ajutorul limbajului Verilog
1. Scopul lucrrii
Introducere n modelarea circuitelor digitale cu ajutorul limbajului de descriere hardware
Verilog. Comparaie VHDL-Verilog. Construcia unui modul de test pentru simularea modelelor
descrise n Verilog.

2. Modelarea unui latch D


Modelul VHDL al unui latch D este urmtorul:
library ieee;
use ieee.std_logic_1164.all;
entity D_Latch is
port( CK, D : in std_logic;
Q, QN: out std_logic);
end D_Latch;
architecture Comp of D_latch is
begin
P_Latch: process (CK, D)
begin
if (CK='1') then
Q <= D;
QN<= not D;
end if;
end process;
end Comp;
n continuare se prezint dou variante de modele Verilog pentru D_latch-ul de mai sus:
Model Verilog D_latch1
module D_Latch1 (CK, D, Q, QN);
input CK;
input D;
output Q;
output QN;
assign Q = CK ? D : Q;
assign QN = CK ? ~D : QN;
endmodule

Model Verilog D_latch2


module D_Latch2 (CK, D, Q, QN);
input CK;
input D;
output Q;
output QN;
reg Q;
reg QN;
always @(CK or D)
if (CK) begin
Q <= D;
QN <= ~D;
end
endmodule

3. Testarea modelelor pentru latch D


Pentru simularea i studierea funcionaltii modelelor de latch D se va folosi un modul de test n
cadrul cruia se va instania componenta care urmeaz a fi testat (DUT) i se vor genera forme
de und (stimuli) pentru intrrile acesteia. Modulul de test arat ca in figura de mai jos:

Fig. 1 Schema unui modul de test pentru D_latch

Descrierea VHDL a entitii de test:


library ieee;
use ieee.std_logic_1164.all;
entity Test_D_latch is end;

architecture Test of Test_D_latch is


signal D, Q, QN: std_logic;
signal CK: std_logic:='0';
component D_Latch
port( CK, D : in std_logic;
Q, QN: out std_logic);
end component;
for all: D_Latch use entity work.D_latch(Comp);
begin
DUT: D_latch port map (CK =>CK, D=>D, Q=>Q, QN=>QN);
CK<= not CK after 10 ns;
D<= '0', '1' after 5 ns, '0' after 35 ns, '1' after 37 ns, '0' after 45 ns;
end Test;
Descrierea Verilog a modului de test pentru D_Latch1
//Modul de test
`timescale 1ns/100ps
module Test_D_Latch1 ();
reg D;
reg CK;
wire Q, QN;
D_Latch1 DUT (
.CK(CK),
.D(D),
.Q(Q),
.QN(QN)
);
initial begin
CK = 0;
D = 0;
#5 D = 1;

#30 D = 0;
#2 D = 1;
#8 D = 0;
end
always #10 CK <= ~CK;
endmodule

S-ar putea să vă placă și