Sunteți pe pagina 1din 6

Partea II – VHDL

A. i) Să se implementeze în VHDL un model comportamental pentru circuitul proiectat


şi analizat dinamic în Partea I. În cadrul modelului se vor defini si utiliza constante generice
pentru parametrii dinamici determinaţi prin simulare (timpi de propagare clock→ieşire,
setup_time şi hold_time).
ii) Să se implementeze o entitate de test şi să se simuleze modelul de la punctul i)

Pentru modelarea circuitului am folosit tabelul cu valorile de adevar. Din tabel se deduce comportarea
circuitului. Stim ca ordinea prioritatile este: RN, SN, CKN.

Pentru modelarea circuitului am folosit tabelul cu valorile de adevar. Din tabel se deduce comportarea
circuitului. Stim ca ordinea prioritatile este: RN, SN, CKN.
Cand Rn=0 avem Q=0 si QN=1;
Cand Sn=0 avem Q=1 si QN=0;
Cand Rn=Sn=0 avem Q=1 si Qn=0;
Cand Rn=Sn=1, atunci modificarile se fac in functie de Clock si intrarea D.
Circuit DFFNSR:
library IEEE;
use IEEE.std_logic_1164.all;

--declararea entitatii
entity PC_DFFNSR is
generic ( tpLH_Q: time:=2 ns ; tpHL_Q: time:=1 ns;
tpLH_nQ: time:=2 ns; tpHL_nQ: time:=1 ns; --constatnte tip time
setup_timeLH: time:=50 ps; setup_timeHL: time:=50 ps;
hold_timeLH : time:=50 ps; hold_timeHL : time:=800 ps);

port (D,RN,SN,CKN : in std_logic; --intrarile


Q,QN : out std_logic); --iesirile
-- stagiul de verificare a setup time si hold time
begin
verificare_setup_time : process (D,CKN )
begin
if( CKN='1' and CKN'event and D='1' and D'event) then
assert ( D'last_event >= setup_timeLH ) -- comparare timpul trecut dl ultima tranzitie a D
report "incalcare SETUP TIME pentru D=0->1"
severity ERROR;
elsif( CKN='1' and CKN'event and D='0' and D'event) then
assert ( D'last_event >= setup_timeHL )--comparare timpul trecut dl ultima tranzitie a D
report "incalcare SETUP TIME pentru D=1->0"
severity ERROR;
end if;
end process verificare_setup_time ;

verificare_hold_time: process ( D ,CKN)


begin
if(CKN='1' and CKN'event and D='1' and D'event) then
assert (CKN'last_event>=hold_timeLH) --comparare timpul trecut de la ultima tranzitie a CKN
report "incalcare HOLD TIME pentru D = 0->1"
severity ERROR;
elsif( CKN='1' and CKN'event and D='0' and D'event ) then
assert (CKN'last_event>=hold_timeHL) --comparare timpul trecut de la ultima tranzitie a CKN
report "incalcare HOLD TIME pentru D =1->0"
severity ERROR;
end if;
end process verificare_hold_time;

end PC_DFFNSR;

-- declarea entitatii
architecture PC_arhitectura_DFFNSR of PC_DFFNSR is

begin
proces_DFFNSR : process (CKN,SN,RN)
begin
if((SN='0') and (RN='0')) then
Q<='1' after 1 ns ;
QN<='0' after 1 ns ;
elsif((SN='1') and (RN='0') ) then
Q<='0' after 1 ns ;
QN<='1' after 1 ns ;
elsif((SN='0') and (RN='1')) then
Q<='1' after 1 ns ;
QN<='0' after 1 ns ; -- pana aici se verifica daca Set si Reset negate blocheaza funct
bistabilului
elsif ((SN='1') and (RN='1')) then
if(D='0' and CKN'event and CKN='1' ) then
Q<='0' after tpLH_Q ;
QN<='1' after tpLH_nQ ;
elsif (D='1' and CKN'event and CKN='1') then
Q<='1' after tpHL_Q ;
QN<='0' after tpHL_nQ ;
--cand NSet si NReset sunt 1 , aici se copiaza intrarea la iesire
end if;
end if;
end process proces_DFFNSR ;
end PC_arhitectura_DFFNSR ;
Testare DFFNSR:
library ieee;
use ieee.std_logic_1164.ALL;

-- creare entitate
entity PC_entitate_testbench is
end PC_entitate_testbench;

--creare arhitectura
architecture PC_arhitectura_testbench of PC_entitate_testbench is

component PC_DFFNSR is
port ( D,RN,SN,CKN : in std_logic; --intrari
Q, QN : out std_logic ); --iesiri
end component;

signal Date, NReset, NSet,NClock, OutQ, OutNQ : std_logic;


for all: PC_DFFNSR use entity work.PC_DFFNSR(PC_arhitectura_DFFNSR); --aici se face imbinarea
componentei cu
begin -- arhitectura bistabilului
uut: PC_DFFNSR port map (Date, NReset, NSet,NClock, OutQ, OutNQ); --lipirea semnalelor

--generari de semnale
gen_NClock: process
begin
NClock <= '1';
wait for 3 ns;
NClock<= '0';
wait for 3 ns;
end process;

gen_NReset: process
begin
NReset <= '0';
wait for 15 ns;
NReset<= '1';
wait for 15 ns;
NReset <= '0';
wait for 15 ns;
NReset<= '1';
wait for 75 ns;
end process;

gen_NSet: process
begin
NSet<= '1';
wait for 15 ns;
NSet <= '0';
wait for 30 ns;
NSet <= '1';
wait for 75 ns;
end process;

gen_Date: process
begin
Date<= '0';
wait for 7 ns;
Date<= '1';
wait for 7 ns;
end process;
semnaluldone: process
begin
wait for 200 ns; --sta 200ns
assert (false) -- pt ca e (false), trece mai departe
report "Exit!"
severity failure; -- termina simularea
end process;
d architecture PC_arhitectura_testbench;

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