APPENDICE A
In questa appendice sono riportate le descrizioni in VHDL del circuito di controllo del DLL. Per consentire una facile lettura, i vari file sono stati commentati e ordinati in base alle reti che costituiscono il circuito, e cioè “Campionatore”, “Rete finale aggancio SR”, “Campionatore barr” e “Rete digitale”.
A.1 “Circuito semi-custom finale”
-- Descrizione structural del circuito semicustom. Nella rete, -- oltre ai blocchi principali, sono inseriti anche dei flip-flop -- il cui compito è quello di ritardare di un ciclo di clock -- l'abilitazione dei vari blocchi consentendo così
-- la stabilizzazione degli ingressi.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity circuito_semicustom_finale is port( Phase1, Phase2: in STD_LOGIC;
CLK, Reset, EN: in STD_LOGIC;
controllo_shunt: out STD_LOGIC_vector(0 to 3);
hit_test, hit: in STD_LOGIC;
OUT_DLL:in STD_LOGIC_vector(0 to 60);
istante_hit: out STD_LOGIC_vector(0 to 5));
end circuito_semicustom_finale;
-- Definizione dell'architettura
architecture my_circuito_semicustom_finale of circuito_semicustom_finale is
component rete_finale_aggancio_SR is port( CLK, Reset, EN: in STD_LOGIC;
Phase1, Phase2: in STD_LOGIC;
AGG: out STD_LOGIC;
controllo_shunt: out STD_LOGIC_vector(0 to 3));
end component;
component campionatore_barr is
port( out_DLL: in STD_LOGIC_vector(0 to 60);
hit_test, Reset, EN, CLK: in STD_LOGIC;
Numero_periodi: out STD_LOGIC_vector(0 to 5);
EN_1: out STD_LOGIC);
end component;
component campionatore_circuito_semicustom is port( EN: in STD_LOGIC;
OUT_DLL: in STD_LOGIC_VECTOR(0 to 60);
hit, Reset: in STD_LOGIC;
OUT_camp: out STD_LOGIC_vector(0 to 60));
end component;
component rete_digitale is
port( N_periodi: in STD_LOGIC_vector(0 to 5);
CLK: in STD_LOGIC;
EN: in STD_LOGIC;
Reset: in STD_LOGIC;
U_DLL: in STD_LOGIC_vector(0 to 60);
istante_hit: out STD_LOGIC_vector(0 to 5));
end component;
component ff is
102
port( d, ck: in STD_LOGIC;
q: out STD_LOGIC);
end component;
signal AGG_temp, EN_1_temp, q_temp_1, q_temp_2: STD_LOGIC;
signal Numero_periodi_temp: STD_LOGIC_vector(0 to 5);
signal out_camp_temp: STD_LOGIC_vector(0 to 60);
begin
rete_finale_aggancio_SR_1: rete_finale_aggancio_SR port map( CLK => CLK,
Reset => Reset, EN => EN,
Phase1 => Phase1, Phase2 => Phase2, AGG => AGG_temp,
controllo_shunt => controllo_shunt);
ff_1: ff
port map( ck => CLK, d => AGG_temp, q => q_temp_1);
campionatore_barr_1: campionatore_barr port map( CLK => CLK,
Reset => Reset,
hit_test => hit_test, EN => q_temp_1,
Numero_periodi => Numero_periodi_temp, EN_1 => EN_1_temp,
out_DLL => OUT_DLL);
ff_2: ff
port map( ck => CLK, d => EN_1_temp, q => q_temp_2);
campionatore_circuito_semicustom_1: campionatore_circuito_semicustom port map( hit => hit,
OUT_DLL => OUT_DLL, EN => q_temp_2, Reset => Reset,
OUT_camp => out_camp_temp);
rete_digitale_1: rete_digitale port map( CLK => CLK,
Reset => Reset, EN => q_temp_2,
N_periodi => Numero_periodi_temp, U_DLL => out_camp_temp,
istante_hit => istante_hit);
end my_circuito_semicustom_finale;
A.2 “Campionatore”
-- Realizzazione del blocco "Campionatore"
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
- Dichiarazione dell'entity
entity campionatore_circuito_semicustom is port( EN: in STD_LOGIC;
OUT_DLL: in STD_LOGIC_VECTOR(0 to 60);
hit, Reset: in STD_LOGIC;
OUT_camp: out STD_LOGIC_vector(0 to 60));
end campionatore_circuito_semicustom;
-- Definizione dell'architettura
architecture my_campionatore_circuito_semicustom of campionatore_circuito_semicustom is
component ff_ab_2 is
port( D, EN, CLK, Reset: in STD_LOGIC;
Q: out STD_LOGIC);
end component;
begin
add_label:
for i in 0 to 60 generate
ff_campionatore: ff_ab_2 port map( CLK => OUT_DLL(i),
EN => EN, D => hit,
Reset => Reset, Q => OUT_camp(i));
end generate;
-- La funzione generate ha lo scopo di replicare la medesima -- struttura (in questo caso "ff_ab_2") più volte.
-- In questo modo è possibile snellire la struttura del -- programma, rendendola sicuramente più leggibile.
end my_campionatore_circuito_semicustom;
104
-- Realizzazione del flip-flop D utilizzato come -- campionatore; rispetto a quello
-- utilizzato nel circuito per il calcolo del numero -- di periodi, il clock è collegato all'uscita delle -- celle mentre D è collegato ad hit.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity ff_ab_2 is
port( D, EN, CLK, Reset: in STD_LOGIC;
Q: out STD_LOGIC);
end ff_ab_2;
-- Definizione dell'architettura
architecture my_ff_ab of ff_ab_2 is begin
process( CLK, Reset, EN) begin
if (Reset = '1' ) then Q <= '0';
elsif (EN = '0') then
if (CLK'event and CLK = '1') then
Q <= D;
end if;
end if;
end process;
end my_ff_ab;
A.3 “Rete finale aggancio SR”
-- Descrizione structural della rete per il controllo degli -- shunt capacitor e per la verifica del raggiungimento -- dell'aggancio della linea di ritardo.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity rete_finale_aggancio_SR is
port( CLK, Reset, EN: in STD_LOGIC;
Phase1, Phase2: in STD_LOGIC;
AGG: out STD_LOGIC;
controllo_shunt: out STD_LOGIC_vector(0 to 3));
end rete_finale_aggancio_SR;
-- Definizione dell'architettura
architecture my_rete_finale_aggancio_SR of rete_finale_aggancio_SR is
component rete_finale_aggancio is port( up_down: in STD_LOGIC;
CLK, Reset, EN: in STD_LOGIC;
AGG: out STD_LOGIC;
controllo_shunt: out STD_LOGIC_vector(0 to 3));
end component;
component SR is
port( S, R, Reset: in STD_LOGIC;
Q: out STD_LOGIC);
end component;
signal Q_temp: STD_LOGIC;
begin
SR_1: SR
port map( S => Phase1, R => Phase2, Reset => Reset, Q => Q_temp);
-- S è collegato a Phase1 cioè all'uscita di sinistra del rivelatore -- di fase, mentre R a Phase2, cioè all'usscita di destra
rete_finale_aggancio_1: rete_finale_aggancio port map( up_down => Q_temp,
CLK => CLK, Reset => Reset, EN => EN,
AGG => AGG,
controllo_shunt => controllo_shunt);
end my_rete_finale_aggancio_SR;
106
-- Il flip flop SR accetta in ingresso le uscite del phase detector -- decidendo se il contaore up\down deve contare avanti o indietro -- in base alla relazione fra le fasi del clock e dell'uscita -- della linea di ritardo. E' necessario realizzare la rete tenedo -- presente che il valore degli ingressi per cui il latch si trova -- nello stato di mantenimento dell'uscita non è "00" ma "11".
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Definizione dell'entity
entity SR is
port( S, R, Reset: in STD_LOGIC;
Q: out STD_LOGIC);
end SR;
-- Definizione dell'architettura
architecture my_SR of SR is begin
process ( Reset, S, R ) begin
if ( Reset = '1' ) then Q <= '0';
else
if (S = '1' and R = '0') then
Q <= '1';
elsif (S = '1' and R = '1') then null;
else
Q <= 0;
end if;
end if;
end process;
end my_SR;
-- Descrizione structural della rete per la determinazione della -- parola di controllo della delay line e del raggiungimento -- dell'aggancio partendo dalla conoscienza del segnale up\down.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity rete_finale_aggancio is port( up_down: in STD_LOGIC;
CLK, Reset, EN: in STD_LOGIC;
AGG: out STD_LOGIC;
controllo_shunt: out STD_LOGIC_vector(0 to 3));
end rete_finale_aggancio;
-- Definizione dell'architettura
architecture my_rete_finale_aggancio of rete_finale_aggancio is component cont_up_down is
port( CLK, Reset: in STD_LOGIC;
UPDOWN, EN: in STD_LOGIC;
S: out STD_LOGIC_vector(0 to 3) );
end component;
component rete_controllo is
port( UP_DOWN, CLK, Reset, EN: in STD_LOGIC;
AGGANCIO, not_AGGANCIO: out STD_LOGIC);
end component;
component ff is
port( d, ck: in STD_logic;
q: out STD_LOGIC);
end component;
component contatore_rinnovo is
port( CLK, Reset: in STD_LOGIC;
EN: in STD_LOGIC;
Rinnovo: out STD_LOGIC );
end component;
signal S_temp: STD_LOGIC_vector(0 to 3);
signal not_agg_temp, Rinnovo_temp, agg_temp: STD_LOGIC;
signal Reset_temp, EN_temp, up_down_temp: STD_LOGIC;
begin
cont_up_down_1: cont_up_down port map( CLK => CLK,
Reset => Reset, EN => EN_temp, UPDOWN => up_down, S => controllo_shunt);
EN_temp <= EN or not_agg_temp;
ff_1: ff
108
port map( d => up_down, ck => CLK,
q => up_down_temp);
rete_controllo_1: rete_controllo port map( UP_DOWN => up_down_temp,
CLK => CLK, EN => EN,
AGGANCIO => agg_temp, Reset => Reset_temp,
not_AGGANCIO => not_agg_temp);
contatore_rinnovo_1: contatore_rinnovo port map( CLK => CLK,
Reset => Reset, EN => agg_temp,
Rinnovo => Rinnovo_temp);
Reset_temp <= Reset or Rinnovo_temp;
AGG <= agg_temp;
end my_rete_finale_aggancio;
-- Descrizione di un flip-flop D
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
-- Dichiarazione dell'entity
entity ff is
port ( d, ck: in STD_LOGIC;
q: out STD_LOGIC );
end ff;
-- Definizione dell'architettura
architecture VNC of ff is begin
process begin
wait until ( ck'event and ck = '1' );
q <= d;
end process;
end VNC;
110
-- Realizzazione di un contatore up\down per il controllo dei shunt -- capacitor
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Definizione dell'entity
entity cont_up_down is
port( CLK, Reset: in STD_LOGIC;
UPDOWN, EN: in STD_LOGIC;
S: out STD_LOGIC_vector(0 to 3) );
end cont_up_down;
-- Definizione dell'architettura
architecture my_cont_up_down of cont_up_down is signal updown_t, temps: STD_LOGIC_vector(0 to 3);
begin
updown_t <= "0001" when UPDOWN = '1'else "1111" when UPDOWN ='0'else
"XXXX";
process(Reset, CLK) begin
if (Reset = '1') then
temps <= "0111";
-- Il contatore è inizializzato a 7: questo implica che metà dei -- condensatori sono attivi e questo consente di diminuire il -- tempo necessario a raggiungere l'aggancio.
elsif (EN = '0') then
if (CLK'event and CLK = '1') then temps <= temps + updown_t;
end if;
end if;
end process;
S <= temps;
end my_cont_up_down;
-- Realizzazione del contatore per la determinazione del rinnovo -- della condizione di aggancio
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Definizione dell'entity
entity contatore_rinnovo is
port( CLK, Reset: in STD_LOGIC;
EN: in STD_LOGIC;
Rinnovo: out STD_LOGIC );
end contatore_rinnovo;
-- Definizione dell'architettura
architecture my_contatore_rinnovo of contatore_rinnovo is signal temps: STD_LOGIC_vector(0 to 7);
begin
process ( Reset, CLK, EN) begin
if ( Reset = '1' ) then
temps <= "00000000";
elsif ( EN = '0' ) then
if ( CLK'event and CLK = '1' ) then temps <= temps + "00000001";
end if;
end if;
end process;
with temps select
Rinnovo <= '1' when "11111111", '0' when others;
end my_contatore_rinnovo;
112
-- Il blocco "rete_controllo", dopo aver verificato il
-- raggiungimento della condizione di regime grazie alla rete -- chiamata "controllo", genera un segnale di abilitazione per -- che rimane basso per più di un ciclo di clock.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity rete_controllo is
port( UP_DOWN, CLK, Reset, EN: in STD_LOGIC;
AGGANCIO, not_AGGANCIO: out STD_LOGIC);
end rete_controllo;
-- Definizione dell'architettura
architecture my_rete_controllo of rete_controllo is component controllo is
port( in_contr, CLK, Reset, EN: in STD_LOGIC;
aggancio: out STD_LOGIC);
end component;
component ff_ab is
port( EN, CLK, Reset: in STD_LOGIC;
Q, not_Q: out STD_LOGIC);
end component;
signal agg_temp: STD_LOGIC;
begin
controllo_1: controllo
port map( in_contr => UP_DOWN, CLK => CLK,
Reset => Reset, EN => EN,
aggancio => agg_temp);
ff_ab_1: ff_ab
port map( CLK => CLK, Reset => Reset, EN => agg_temp, Q => AGGANCIO,
not_Q => not_AGGANCIO);
end my_rete_controllo;
-- Descrizione di un flip-flop D con abilitazione utilizzato per -- generare il segnale di raggiungimento della condizione di -- aggancio.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity ff_ab is
port( EN, CLK, Reset: in STD_LOGIC;
Q, not_Q: out STD_LOGIC);
end ff_ab;
-- Definizione dell'architettura
architecture my_ff_ab of ff_ab is begin
process( CLK, Reset ) begin
if ( Reset = '1' ) then Q <= '1';
not_Q <= '0';
elsif ( EN = '1' ) then
if ( CLK'event and CLK = '1' ) then
Q <= '0';
not_Q <= '1';
end if;
end if;
end process;
end my_ff_ab;
114
-- Descrizione della rete per la verifica del raggiungimento -- dell'aggancio.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity controllo is
port( in_contr, CLK, Reset, EN: in STD_LOGIC;
aggancio: out STD_LOGIC);
end controllo;
-- Definizione dell'architettura
architecture my_controllo of controllo is
signal temp: STD_LOGIC_vector(0 to 3);
begin
process( CLK, Reset ) begin
if ( Reset = '1' ) then temp <= "0000";
elsif ( EN = '0' ) then
if ( CLK'event and CLK = '1' ) then temp(0) <= in_contr;
temp(1) <= temp(0);
temp(2) <= temp(1);
temp(3) <= temp(2);
end if;
end if;
end process;
with temp select
aggancio <= '1' when "0101", '1' when "1010", '0' when others;
end my_controllo;
A.4 “Campionatore barr”
-- Descrizione structural della rete per la determinazione del -- numero di periodi contenuti all'interno della linea di ritardo.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity campionatore_barr is
port( out_DLL: in STD_LOGIC_vector(0 to 60);
hit_test, Reset, EN, CLK: in STD_LOGIC;
Numero_periodi: out STD_LOGIC_vector(0 to 5);
EN_1: out STD_LOGIC);
end campionatore_barr;
-- Definizione dell'architettura
architecture my_campionatore_barr of campionatore_barr is
component campionatore is
port( in_camp: in STD_LOGIC_vector(0 to 60);
hit_test, Reset, EN: in STD_LOGIC;
out_camp: out STD_LOGIC_vector(0 to 60));
end component;
component barriera is
port( in_barr: in STD_LOGIC_vector(0 to 60);
out_barr: out STD_LOGIC_vector(0 to 60));
end component;
component contatore is
port( CLK, Reset: in STD_LOGIC;
EN: in STD_LOGIC;
S: out STD_LOGIC_vector(0 to 5) );
end component;
component multiplexer is
port( campione: in STD_LOGIC_vector(0 to 60);
sel: in STD_LOGIC_vector(0 to 5);
camp_succ: out STD_LOGIC);
end component;
component ff is
port( d, ck: in STD_LOGIC;
q: out STD_LOGIC );
end component;
signal out_camp_temp, out_barr_temp: STD_LOGIC_vector(0 to 60);
signal out_mux_temp, camp_succ_temp, and_temp, EN_temp: STD_LOGIC;
signal S_temp: STD_LOGIC_vector(0 to 5);
signal EN_temp_cont, q_temp: STD_LOGIC;
begin
116
EN_temp_cont <= (not hit_test) or EN or and_temp;
campionatore_1: campionatore port map( in_camp => out_DLL,
hit_test => hit_test, Reset => Reset,
EN => EN,
out_camp => out_camp_temp);
barriera_1: barriera
port map( in_barr => out_camp_temp, out_barr => out_barr_temp);
contatore_1: contatore port map( CLK => CLK,
Reset => Reset, EN => EN_temp_cont, S => S_temp);
multiplexer_1: multiplexer
port map( campione => out_barr_temp, sel => S_temp,
camp_succ => camp_succ_temp);
and_temp <= S_temp(0) and S_temp(1) and S_temp(2) and S_temp(3) and (not S_temp(4)) and (not S_temp(5));
ff_1: ff
port map( ck => CLK, d => and_temp, q => q_temp);
EN_temp <= (not camp_succ_temp) or q_temp;
contatore_2: contatore port map( CLK => CLK, Reset => Reset,
EN => EN_temp,
S => Numero_periodi);
EN_1 <= not q_temp;
end my_campionatore_barr;
-- Realizzazione di un blocco di campionamento delle uscite del DLL -- per la misura del numero dei periodi di clock.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity campionatore is
port( in_camp: in STD_LOGIC_vector(0 to 60);
hit_test, Reset, EN: in STD_LOGIC;
out_camp: out STD_LOGIC_vector(0 to 60));
end campionatore;
-- Definizione dell'architettura
architecture my_campionatore of campionatore is begin
process ( hit_test, EN, Reset ) begin
if ( Reset = '1' ) then out_camp <=
"0000000000000000000000000000000000000000000000000000000000000";
elsif ( EN = '0' ) then
if ( hit_test'event and hit_test = '1' ) then
out_camp <= in_camp;
end if;
end if;
end process;
end my_campionatore;
118
-- Realizzazione di una barriera di porte and per determinare il -- numero di transizioni 0-1 all'interno della parola campionata;
-- infatti il numero di uno all'interno del vettore in uscita dal -- blocco "barriera and" è pari al numero di commutazioni.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Definizione dell'entity entity barriera is
port( in_barr: in STD_LOGIC_vector(0 to 60);
out_barr: out STD_LOGIC_vector(0 to 60));
end barriera;
-- Definizione dell'architettura
architecture my_barriera of barriera is begin
out_barr(0) <= (not in_barr(0)) and (in_barr(1));
out_barr(1) <= (not in_barr(1)) and (in_barr(2));
out_barr(2) <= (not in_barr(2)) and (in_barr(3));
out_barr(3) <= (not in_barr(3)) and (in_barr(4));
out_barr(4) <= (not in_barr(4)) and (in_barr(5));
out_barr(5) <= (not in_barr(5)) and (in_barr(6));
out_barr(6) <= (not in_barr(6)) and (in_barr(7));
out_barr(7) <= (not in_barr(7)) and (in_barr(8));
out_barr(8) <= (not in_barr(8)) and (in_barr(9));
out_barr(9) <= (not in_barr(9)) and (in_barr(10));
out_barr(10) <= (not in_barr(10)) and (in_barr(11));
out_barr(11) <= (not in_barr(11)) and (in_barr(12));
out_barr(12) <= (not in_barr(12)) and (in_barr(13));
out_barr(13) <= (not in_barr(13)) and (in_barr(14));
out_barr(14) <= (not in_barr(14)) and (in_barr(15));
out_barr(15) <= (not in_barr(15)) and (in_barr(16));
out_barr(16) <= (not in_barr(16)) and (in_barr(17));
out_barr(17) <= (not in_barr(17)) and (in_barr(18));
out_barr(18) <= (not in_barr(18)) and (in_barr(19));
out_barr(19) <= (not in_barr(19)) and (in_barr(20));
out_barr(20) <= (not in_barr(20)) and (in_barr(21));
out_barr(21) <= (not in_barr(21)) and (in_barr(22));
out_barr(22) <= (not in_barr(22)) and (in_barr(23));
out_barr(23) <= (not in_barr(23)) and (in_barr(24));
out_barr(24) <= (not in_barr(24)) and (in_barr(25));
out_barr(25) <= (not in_barr(25)) and (in_barr(26));
out_barr(26) <= (not in_barr(26)) and (in_barr(27));
out_barr(27) <= (not in_barr(27)) and (in_barr(28));
out_barr(28) <= (not in_barr(28)) and (in_barr(29));
out_barr(29) <= (not in_barr(29)) and (in_barr(30));
out_barr(30) <= (not in_barr(30)) and (in_barr(31));
out_barr(31) <= (not in_barr(31)) and (in_barr(32));
out_barr(32) <= (not in_barr(32)) and (in_barr(33));
out_barr(33) <= (not in_barr(33)) and (in_barr(34));
out_barr(34) <= (not in_barr(34)) and (in_barr(35));
out_barr(35) <= (not in_barr(35)) and (in_barr(36));
out_barr(36) <= (not in_barr(36)) and (in_barr(37));
out_barr(37) <= (not in_barr(37)) and (in_barr(38));
out_barr(38) <= (not in_barr(38)) and (in_barr(39));
out_barr(39) <= (not in_barr(39)) and (in_barr(40));
out_barr(40) <= (not in_barr(40)) and (in_barr(41));
out_barr(41) <= (not in_barr(41)) and (in_barr(42));
out_barr(42) <= (not in_barr(42)) and (in_barr(43));
out_barr(43) <= (not in_barr(43)) and (in_barr(44));
out_barr(44) <= (not in_barr(44)) and (in_barr(45));
out_barr(45) <= (not in_barr(45)) and (in_barr(46));
out_barr(46) <= (not in_barr(46)) and (in_barr(47));
out_barr(47) <= (not in_barr(47)) and (in_barr(48));
out_barr(48) <= (not in_barr(48)) and (in_barr(49));
out_barr(49) <= (not in_barr(49)) and (in_barr(50));
out_barr(50) <= (not in_barr(50)) and (in_barr(51));
out_barr(51) <= (not in_barr(51)) and (in_barr(52));
out_barr(52) <= (not in_barr(52)) and (in_barr(53));
out_barr(53) <= (not in_barr(53)) and (in_barr(54));
out_barr(54) <= (not in_barr(54)) and (in_barr(55));
out_barr(55) <= (not in_barr(55)) and (in_barr(56));
out_barr(56) <= (not in_barr(56)) and (in_barr(57));
out_barr(57) <= (not in_barr(57)) and (in_barr(58));
out_barr(58) <= (not in_barr(58)) and (in_barr(59));
out_barr(59) <= (not in_barr(59)) and (in_barr(60));
out_barr(60) <= (not in_barr(60)) and (in_barr(0));
end my_barriera;
120
-- Realizzazione del contatore a 6 bit per il controllo del mux
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity contatore is
port( CLK, Reset: in STD_LOGIC;
EN: in STD_LOGIC;
S: out STD_LOGIC_vector(0 to 5) );
end contatore;
-- Definizione dell'architettura
architecture my_contatore of contatore is signal temps: STD_LOGIC_vector(0 to 5);
begin
process ( Reset, CLK, EN ) begin
if ( Reset = '1' ) then
temps <= "000000";
elsif ( EN = '0' ) then
if ( CLK'event and CLK = '1' ) then temps <= temps + "000001";
end if;
end if;
end process;
S <= temps;
end my_contatore;
-- Realizzazione di un multiplexer 61 to 1
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity multiplexer is
port( campione: in STD_LOGIC_vector(0 to 60);
sel: in STD_LOGIC_vector(0 to 5);
camp_succ: out STD_LOGIC);
end multiplexer;
-- Definizione dell'architettura
architecture my_multiplexer of multiplexer is subtype small_integer is integer range 0 to 63;
-- Questo passaggio è necessario per diminuire il il numero di bit -- utilizzati per rappresentare le variabili di tipo integer;
infatti,
-- per defaul il programma assegna a queste un numero di bit pari -- a 32, eccessivi per la nostra applicazione.
signal i: small_integer;
begin
i <= CONV_INTEGER(sel);
-- Questa funzione di conversione ci consente di assegnare -- all'uscita dell'accumulatore inizializzato a zero
-- il corrispetivo valore intero; in questo modo è possibile -- utilizzare il blocco "multiplex" per leggere il vettore -- ottenuto dal campionamento della linea di ritardo.
camp_succ <= campione(i);
end my_multiplexer;
122
-- Descrizione di un flip-flop D
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
-- Dichiarazione dell'entity
entity ff is
port ( d, ck: in STD_LOGIC;
q: out STD_LOGIC );
end ff;
-- Definizione dell'architettura
architecture VNC of ff is begin
process begin
wait until (ck'event and ck = '1');
q <= d;
end process;
end VNC;
A.5 “Rete Digitale”
-- Descrizione structural della rete digitale per il trattamento -- dei campioni in uscita dalla DLL.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity rete_digitale is
port( N_periodi: in STD_LOGIC_vector(0 to 5);
CLK: in STD_LOGIC;
EN: in STD_LOGIC;
Reset: in STD_LOGIC;
U_DLL: in STD_LOGIC_vector(0 to 60);
istante_hit: out STD_LOGIC_vector(0 to 5));
end rete_digitale;
-- Definizione dell'architettura
architecture my_rete_digitale of rete_digitale is component rete_per_s is
port( Np: in STD_LOGIC_vector(0 to 5);
CLK, Reset, EN: in STD_LOGIC;
abilitazione: out STD_LOGIC;
Step: out STD_LOGIC_vector(0 to 5));
end component;
component S_to_hit is
port( passo: in STD_LOGIC_vector(0 to 5);
CLK, Reset, EN: in STD_LOGIC;
out_DLL: in STD_LOGIC_vector(0 to 60);
hit: out STD_LOGIC_vector(0 to 5));
end component;
signal Step_t: STD_LOGIC_vector(0 to 5);
signal E_temp: STD_LOGIC;
begin
rete_per_s_1: rete_per_s port map( Np => N_periodi,
CLK => CLK, Reset => Reset, EN => EN,
abilitazione => E_temp, Step => Step_t);
-- Il blocco "rete_per_s" abilita il funzionamento della rete -- "S_to_hit" solo quando ha determinato il passo, cioè quando -- l'uscita del "riconoscitore" si setta.
S_to_hit_1: S_to_hit
port map( passo => Step_t, CLK => CLK, Reset => Reset,
124
EN => E_temp, out_DLL => U_DLL, hit => istante_hit);
end my_rete_digitale;
-- Descrizione structural della rete per il calcolo di s
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Definizione dell'entity
entity rete_per_s is
port ( Np: in STD_LOGIC_vector(0 to 5);
CLK, Reset, EN: in STD_LOGIC;
abilitazione: out STD_LOGIC;
Step: out STD_LOGIC_vector(0 to 5));
end rete_per_s;
architecture my_rete_per_s of rete_per_s is component accumulatore is
port (ING: in STD_LOGIC_vector(0 to 5);
CLK: in STD_LOGIC;
Reset, EN: in STD_LOGIC;
O: out STD_LOGIC_vector(0 to 5) );
end component;
component riconoscitore is
port( A: in STD_LOGIC_vector(0 to 5);
CLK, Reset: in STD_LOGIC;
Y: out STD_LOGIC);
end component;
component contatore_per_rete_digitale is port( CLK, Reset: in STD_LOGIC;
EN: in STD_LOGIC;
S: out STD_LOGIC_vector(0 to 5) );
end component;
-- Definizione dei segnali interni
signal Output_acc: STD_LOGIC_vector(0 to 5);
signal Enable, o_ric: STD_LOGIC;
begin
accumulatore_1: accumulatore port map( ING => Np,
CLK => CLK, Reset => Reset, EN => EN,
O => Output_acc);
riconoscitore_1: riconoscitore port map( A => Output_acc, Reset => Reset,
CLK => CLK, Y => o_ric);
Enable <= o_ric or EN;
contatore_1: contatore_per_rete_digitale port map( CLK => CLK,
126
Reset => Reset, EN => Enable, S => Step);
abilitazione <= not o_ric;
end my_rete_per_s;
-- Descrizione structural della rete che dalla conoscienza del -- clock e dei dati in outdalla DLL mi fornisce l'istante di -- arrivo dell'hit.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
--Dichiarazione dell'entity
entity S_to_hit is
port( passo: in STD_LOGIC_vector(0 to 5);
CLK, Reset, EN: in STD_LOGIC;
out_DLL: in STD_LOGIC_vector(0 to 60);
hit: out STD_LOGIC_vector(0 to 5));
end S_to_hit;
--Definizione dell'architettura
architecture my_S_to_hit of S_to_hit is
component accumulatore2 is
port (ING: in STD_LOGIC_vector(0 to 5);
CLK: in STD_LOGIC;
Reset, EN: in STD_LOGIC;
O: out STD_LOGIC_vector(0 to 5) );
end component;
component multiplexer is
port( campione: in STD_LOGIC_vector(0 to 60);
sel: in STD_LOGIC_vector(0 to 5);
camp_succ: out STD_LOGIC);
end component;
component contatore is
port( CLK, Reset: in STD_LOGIC;
EN: in STD_LOGIC;
S: out STD_LOGIC_vector(0 to 5) );
end component;
-- Definizione dei segnali interni
signal out_accum: STD_LOGIC_vector(0 to 5);
signal out_mux: STD_LOGIC;
signal EN_cont, EN_acc: STD_LOGIC;
begin
EN_acc <= EN or out_mux;
accumulatore_1: accumulatore2 port map( ING => passo,
CLK => CLK, EN => EN_acc, Reset => Reset,
128
O => out_accum);
multiplex_1: multiplexer
port map( campione => out_DLL, sel => out_accum,
camp_succ => out_mux);
EN_cont <= out_mux or EN;
contatore_1: contatore port map( CLK => CLK,
Reset => Reset, EN => EN_cont, S => hit);
-- Il contatore è abilitato direttamente dall'uscita del -- multiplex; questo può essere fatto perché il calcolo
-- dell'istante è ottenuto determinando il numero di zeri contenuti -- all'interno della parola in uscita dal blocco di campionamento -- visitata con un passo pari a s.
end my_S_to_hit;
-- Realizzazione del riconoscitore di zero per la determinazione -- del passo s; il passo è determinato come il
-- numero di cicli di clock necessari per annullare l'uscita -- dell'accumulatore. La rete qui descritta riconosce quando -- l'ingresso è pari a zero e produce un segnale che disabilita -- il funzionamento del blocco "contatore per rete digitale".
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
--Definizione dell'entity
entity riconoscitore is
port( A: in STD_LOGIC_vector(0 to 5);
CLK, Reset: in STD_LOGIC;
Y: out STD_LOGIC);
end riconoscitore;
-- Definizione dell'architettura
architecture my_riconoscitore of riconoscitore is begin
process (Reset, CLK) begin
if ( Reset = '1' ) then Y <= '0';
elsif ( A = "000000" ) then
if ( CLK'event and CLK = '1' ) then Y <= '1';
end if;
end if;
end process;
end my_riconoscitore;
130
-- Realizzazione del contatore per la determinazione del passo s.
-- In questo caso il contatore è stato inizializzato a -1 per -- correggere i problemi dovuti ai ritardi di commutazione -- delle porte messi in evidenza dalle simulazioni post-sintesi -- della rete per la determinazione del passo.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Definizione dell'entity
entity contatore_per_rete_digitale is port( CLK, Reset: in STD_LOGIC;
EN: in STD_LOGIC;
S: out STD_LOGIC_vector(0 to 5) );
end contatore_per_rete_digitale;
-- definizione dell'architettura
architecture my_contatore of contatore is signal temps: STD_LOGIC_vector(0 to 5);
begin
process ( Reset, CLK, EN ) begin
if ( Reset = '1' ) then
temps <= "111111";
elsif ( EN = '0' ) then
if ( CLK'event and CLK = '1' ) then
temps <= temps + "000001";
end if;
end if;
end process;
S <= temps;
end my_contatore;
-- Descrizione dell'accumulatore modulo 61 inizializzato a 60 -- per il calcolo del passo con cui visitare i campioni
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity accumulatore is
port (ING: in STD_LOGIC_vector(0 to 5);
CLK: in STD_LOGIC;
Reset, EN: in STD_LOGIC;
O: out STD_LOGIC_vector(0 to 5) );
end accumulatore;
-- Definizione dell'architettura
architecture my_accumulatore of accumulatore is component rete_combinatoria is
port ( IN1, IN2: in STD_LOGIC_vector(0 to 5);
U: out STD_LOGIC_vector(0 to 5) );
end component;
component registro_6_bit is port ( CLK: in STD_LOGIC;
Reset, EN: in STD_LOGIC;
D: in STD_LOGIC_vector(0 to 5);
Q: out STD_LOGIC_vector(0 to 5) );
end component;
-- Dichiarazione dei segnali interni alla rete
signal U1: STD_LOGIC_vector(0 to 5);
signal Utemp: STD_LOGIC_vector(0 to 5);
--Descrizione structural della rete
begin
rete_combinatoria_1: rete_combinatoria port map( IN1 => ING,
IN2 => Utemp, U => U1
);
registro_interno: registro_6_bit port map( CLK => CLK,
Reset => Reset, EN => EN,
D => U1, Q => Utemp );
O <= Utemp;
end my_accumulatore;
132
-- Descrizione di un registro precaricato a -1 per l'accumulatore -- modulo 61.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity registro_6_bit is
port (CLK: in STD_LOGIC;
Reset, EN: in STD_LOGIC;
D: in STD_LOGIC_vector(0 to 5);
Q: out STD_LOGIC_vector(0 to 5) );
end registro_6_bit;
-- Definizione dell'architettura
architecture my_registro_6_bit of registro_6_bit is begin
process ( CLK, EN, RESET ) begin
if ( RESET = '1' ) then
Q <= "111100"; -- al Reset, il registro è inizializzato a
-- 60.
elsif ( EN = '0' ) then
if ( CLK'event and CLK = '1' ) then
Q <= D;
end if;
end if;
end process;
end my_registro_6_bit;
-- Descrizione structural della rete combinatoria per
-- l'accumulatore modulo 61: questo cirucito è realizzato da due -- sommatori a 6 bit, di cui uno (somma2) ha un ingresso sempre pari -- a 3.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Definizione dell'entity
entity rete_combinatoria is
port ( IN1, IN2: in STD_LOGIC_vector(0 to 5);
U: out STD_LOGIC_vector(0 to 5));
end rete_combinatoria;
-- Definizione dell'architettura
architecture my_rete_combinatoria of rete_combinatoria is component sommatore_6_bit is
port( A: in STD_LOGIC_vector(0 to 5);
B: in STD_LOGIC_vector(0 to 5);
ADD: out STD_LOGIC_vector(0 to 5);
COUT: out STD_LOGIC);
end component;
component sommatore_6_bit_prova is
port( A: in STD_LOGIC_vector(0 to 5);
ADD: out STD_LOGIC_vector(0 to 5);
COUT: out STD_LOGIC);
end component;
component mux is
port( INGA, INGB: in STD_LOGIC_vector(0 to 5);
sel: in STD_LOGIC;
OUT_mux: out STD_LOGIC_vector(0 to 5));
end component;
-- Dichiarazione dei segnali interni alla rete
signal ADD1,ADD2: STD_LOGIC_vector(0 to 5);
signal C1: STD_LOGIC;
signal C2: STD_LOGIC;
signal C3: STD_LOGIC;
-- Realizzazione della descrizione structural della rete
begin
somma1: sommatore_6_bit port map( A => IN1,
B => IN2, COUT => C1, ADD => ADD1
);
somma2: sommatore_6_bit_prova port map( A => ADD1,
COUT => C2, ADD => ADD2
);
134
C3 <= C1 nor C2;
mux1: mux
port map( INGA => ADD1, INGB => ADD2, sel => C3, OUT_mux => U);
end my_rete_combinatoria;
-- Realizzazione di un sommatore a 6 bit per l'accumulatore modulo -- 61.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_unsigned.all;
USE IEEE.std_logic_arith.all;
-- Definizione dell' entity
entity sommatore_6_bit is
port( A, B: in STD_LOGIC_vector(0 to 5);
ADD: out STD_LOGIC_vector(0 to 5);
COUT: out STD_LOGIC);
end sommatore_6_bit;
-- Definizione dell' architettura
architecture my_sommatore_6_bit of sommatore_6_bit is signal temp: STD_LOGIC_vector(0 to 6);
begin
temp <= ('0' & A) + ('0' & B);-- per rendere possibile la
ADD <= temp(1 to 6); -- somma fra due segnali a 6 COUT <= temp(0); -- bit abbiamo definito due
end my_sommatore_6_bit; -- variabili di appoggio (A e B) -- estese a 7 bit; il bit più -- significativo rappresenta il
-- resto mentre i rimanenti bit -- il risultato.
136
-- Realizzazione di un sommatore a 6 con ingresso bit per -- l'accumulatore modulo 61
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_unsigned.all;
USE IEEE.std_logic_arith.all;
-- Definizione dell' entity
entity sommatore_6_bit_prova is
port( A, B: in STD_LOGIC_vector(0 to 5);
ADD: out STD_LOGIC_vector(0 to 5);
COUT: out STD_LOGIC);
end sommatore_6_bit_prova;
-- Definizione dell' architettura
architecture my_sommatore_6_bit_prova of sommatore_6_bit_prova is signal temp: STD_LOGIC_vector(0 to 6);
begin
temp <= ('0' & A) + "0000011"; -- Uno degli addendi del
ADD <= temp(1 to 6); -- sommatore è sempre pari a 3;
COUT <= temp(0); -- in questo modo è possibile end my_sommatore_6_bit_prova; -- far sì che l'accumulatore -- conti in modulo 61 anziché -- in modulo 64.
-- Realizzazione di un multiplexer 2 to 1 per -- l'accumulatore modulo 61.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity mux is
port( INGA, INGB: in STD_LOGIC_vector(0 to 5);
sel: in STD_LOGIC;
OUT_mux: out STD_LOGIC_vector(0 to 5));
end mux;
-- Definizione dell'architettura
architecture my_mux of mux is begin
with sel select
OUT_mux <= INGB when '0', INGA when '1',
"---" when others;
end my_mux;
138
-- Descrizione di un multiplexer 61 to 1
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity multiplexer is
port( campione: in STD_LOGIC_vector(0 to 60);
sel: in STD_LOGIC_vector(0 to 5);
camp_succ: out STD_LOGIC);
end multiplexer;
-- Definizione dell'architettura
architecture my_multiplexer of multiplexer is subtype small_integer is integer range 0 to 63;
-- Questo passaggio è necessario per diminuire il il numero di bit -- utilizzati per rappresentare le variabili di tipo integer;
infatti,
-- per defaul il programma assegna a queste un numero di bit pari -- a 32, eccessivi per la nostra applicazione.
signal i: small_integer;
begin
i <= CONV_INTEGER(sel);
-- Questa funzione di conversione ci consente di assegnare -- all'uscita dell'accumulatore inizializzato a zero
-- il corrispetivo valore intero; in questo modo è possibile -- utilizzare il blocco "multiplex" per leggere il vettore -- ottenuto dal campionamento della linea di ritardo.
camp_succ <= campione(i);
end my_multiplexer;
-- Descrizione del contatore per la determinazione dell'istante di -- arrivo dell'hit
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Definizione dell'entity
entity contatore is
port( CLK, Reset: in STD_LOGIC;
EN: in STD_LOGIC;
S: out STD_LOGIC_vector(0 to 5) );
end contatore;
-- Definizione dell'architettura
architecture my_contatore of contatore is signal temps: STD_LOGIC_vector(0 to 5);
begin
process ( Reset, CLK, EN ) begin
if ( Reset = '1' ) then
temps <= "000000";
elsif ( EN = '0' ) then
if ( CLK'event and CLK = '1' ) then temps <= temps + "000001";
end if;
end if;
end process;
S <= temps;
end my_contatore;
140
-- Descrizione structural accumulatore modulo 61 inizializzato a 0 -- per la rete S_to_hit che, dal valore di s fornisce l'istante -- di arrivo di hit.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity accumulatore2 is
port (ING: in STD_LOGIC_vector(0 to 5);
CLK: in STD_LOGIC;
Reset, EN: in STD_LOGIC;
O: out STD_LOGIC_vector(0 to 5) );
end accumulatore2;
-- Definizione dell'architettura
architecture my_accumulatore2 of accumulatore2 is component rete_combinatoria is
port ( IN1, IN2: in STD_LOGIC_vector(0 to 5);
U: out STD_LOGIC_vector(0 to 5) );
end component;
component registro_6_bit_2 is port ( CLK: in STD_LOGIC;
Reset, EN: in STD_LOGIC;
D: in STD_LOGIC_vector(0 to 5);
Q: out STD_LOGIC_vector(0 to 5) );
end component;
-- Dichiarazione dei segnali interni alla rete
signal U1: STD_LOGIC_vector(0 to 5);
signal Utemp: STD_LOGIC_vector(0 to 5);
-- Descrizione structural della rete
begin
rete_combinatoria_1: rete_combinatoria port map( IN1 => ING,
IN2 => Utemp, U => U1
);
registro_interno_1: registro_6_bit_2 port map( CLK => CLK,
Reset => Reset, EN => EN,
D => U1, Q => Utemp );
O <= Utemp;
end my_accumulatore2;
-- Realizzazione di un registro precaricato a 0 per l'accumulatore -- modulo 61 all'interno della rete S_to_hit; in questo caso non è -- necessario che il conto inizi da - 1 come accadeva
-- nell'accumulatore presente nel blocco "rete_per_s"
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
-- Dichiarazione dell'entity
entity registro_6_bit_2 is port (CLK: in STD_LOGIC;
Reset, EN: in STD_LOGIC;
D: in STD_LOGIC_vector(0 to 5);
Q: out STD_LOGIC_vector(0 to 5) );
end registro_6_bit_2;
--Definizione dell'architettura
architecture my_registro_6_bit_2 of registro_6_bit_2 is begin
process ( CLK, EN, Reset ) begin
if ( Reset = '1' ) then
Q <= "000000"; -- al Reset il registro è -- inizializzato a 0.
elsif ( EN = '0' ) then
if ( CLK'event and CLK = '1' ) then
Q <= D;
end if;
end if;
end process;
end my_registro_6_bit_2;
142