Codice VHDL

Strumenti informatici per la matematica applicata, le simulazioni, il disegno: Mathcad, Matlab, Scilab, Microcap, PSpice, AutoCad ...

Moderatori: Foto Utenteg.schgor, Foto Utentedimaios

Avatar utente
Foto UtenteNunziox
221 2 9
Frequentatore
Frequentatore
Messaggi: 152
Iscritto il: 28 ott 2012, 0:38
0
voti

[21] Re: Codice VHDL

Messaggioda Foto UtenteNunziox » 28 apr 2014, 14:29

metti il codice dentro il tag code.
Poi non hai fatto una modifica dentro il primo if.
Stai usando il testbench che ti ha scritto rini?

Avatar utente
Foto UtenteCastello
6 2
New entry
New entry
Messaggi: 60
Iscritto il: 3 apr 2014, 11:21
0
voti

[22] Re: Codice VHDL

Messaggioda Foto UtenteCastello » 28 apr 2014, 14:38

ho fatto quella modifica dentro l'if . ma niente... come prima , la dout sempre bassa.
Comunque non sto seguendo il consiglio di rini perche non ho capito cosa volesse dire...

Avatar utente
Foto UtenteCastello
6 2
New entry
New entry
Messaggi: 60
Iscritto il: 3 apr 2014, 11:21
0
voti

[23] Re: Codice VHDL

Messaggioda Foto UtenteCastello » 28 apr 2014, 14:39

Codice: Seleziona tutto

entity ese_4 is
  Port (SEL : in std_logic; -- Ingresso di selezione
DOUT : out std_logic; -- Uscita dato seriale
CLK : in std_logic; -- Clock
RESET : in std_logic); -- Reset
end ese_4;

architecture Behavioral of ese_4 is
signal SEGN : std_logic_vector(6 downto 0); -- Registro per pattern
signal SELC : std_logic; -- Registro selezione pattern
signal CNT : integer; -- Contatore bit uscita
begin
process(CLK, RESET, SEL)
begin
if CLK'event and RESET='1' then
SEGN <= "0100111"; -- Pattern d'uscita
SELC <= '0'; -- Selezione di default
CNT <= 0; -- Contatore
DOUT <= SEGN(6) xor SELC;
elsif CLK'event and CLK='1' then
-- Rotazione registro pattern
SEGN <= SEGN(5 downto 0)&SEGN(6);
-- Contatore
if CNT = 6 then
CNT <= 0;
SELC <= SEL; -- Lettura e memorizzazione valore di SEL
else
CNT <= CNT + 1; -- Incremento contatore
end if;
DOUT <= SEGN(6) xor SELC;
end if;      
end process;
-- Assegnazione uscita e negazione


end Behavioral;

            

Avatar utente
Foto UtenteNunziox
221 2 9
Frequentatore
Frequentatore
Messaggi: 152
Iscritto il: 28 ott 2012, 0:38
0
voti

[24] Re: Codice VHDL

Messaggioda Foto UtenteNunziox » 28 apr 2014, 14:40

Il problema è che dentro quell'else if

Codice: Seleziona tutto

else if CLK'event and CLK='1' then

secondo me non ci sta entrando!!!

Ma come stai generando il clock senza il testbench?

Avatar utente
Foto UtenteCastello
6 2
New entry
New entry
Messaggi: 60
Iscritto il: 3 apr 2014, 11:21
0
voti

[25] Re: Codice VHDL

Messaggioda Foto UtenteCastello » 28 apr 2014, 14:44

Scusa ma che significa che dentro quell elsif non ci sto entrando?!! e comunque certo che ho generato il fule di testbench... dopo aver scritto il codice vhdl , mi genero il file di testbench

Avatar utente
Foto UtenteNunziox
221 2 9
Frequentatore
Frequentatore
Messaggi: 152
Iscritto il: 28 ott 2012, 0:38
2
voti

[26] Re: Codice VHDL

Messaggioda Foto UtenteNunziox » 28 apr 2014, 15:55

Guarda con le modifiche che ti ho suggerito a me sembra funzionare! Controlla tu se la logica è corretta!

Immagine

DOUT è U ( uninitialized) quando non si inizia con il file di RESET alto.
Ti allego testbench e codice VHDL

Codice VHDL:

Codice: Seleziona tutto

library ieee;
use ieee.std_logic_1164.all;

entity ese_4 is Port (SEL : in std_logic; -- Ingresso di selezione
    DOUT : out std_logic; -- Uscita dato seriale
    CLK : in std_logic; -- Clock
    RESET : in std_logic); -- Reset
end ese_4;

architecture Behavioral of ese_4 is
    signal SEGN : std_logic_vector(6 downto 0); -- Registro per pattern
    signal SELC : std_logic; -- Registro selezione pattern
    signal CNT : integer; -- Contatore bit uscita
    begin
    process(CLK, RESET, SEL)
    begin
   
    if RESET='1' then
     SEGN <= "0100111"; -- Pattern d'uscita
     SELC <= '0'; -- Selezione di default
     CNT <= 0; -- Contatore
    elsif CLK'event and CLK='1' then
    -- Rotazione registro pattern
     SEGN <= SEGN(5 downto 0)&SEGN(6);
    -- Contatore
     if CNT = 6 then
      CNT <= 0;
      SELC <= SEL; -- Lettura e memorizzazione valore di SEL
     else
      CNT <= CNT + 1; -- Incremento contatore
     end if;
     DOUT <= SEGN(6) xor SELC;
     end if;     
    end process;
    -- Assegnazione uscita e negazione
 end Behavioral;

Testbench:

Codice: Seleziona tutto

library ieee;
use ieee.std_logic_1164.all;

entity TestBench01 is
end TestBench01;

architecture behavior of TestBench01 is

   component ese_4
   port (
      SEL : in std_logic; -- Ingresso di selezione
      DOUT : out std_logic; -- Uscita dato seriale
      CLK : in std_logic; -- Clock
      RESET : in std_logic -- Reset
       );
   end component;

   
   signal SEL1 : std_logic := '0';
   signal CLK1 : std_logic := '0';
   signal RESET1 : std_logic := '0';
   signal DOUT1 : std_logic;
   
begin

  uut: ese_4 PORT MAP(
      SEL => SEL1,
      CLK => CLK1,
      RESET => RESET1,
      DOUT => DOUT1
   );
   
   process
   begin
      CLK1 <= '1';
      wait for 5 ms;
     CLK1 <= '0';
     wait for 5 ms;
   end process;
   
   
       -- Descrizione dei tuoi ingressi
      SEL1 <= '0' after 10ms,'1' after 20ms,'0' after 26ms;
      RESET1 <= '1' after 10ms,'0' after 20ms,'0' after 26ms;
end;

Avatar utente
Foto UtenteCastello
6 2
New entry
New entry
Messaggi: 60
Iscritto il: 3 apr 2014, 11:21
0
voti

[27] Re: Codice VHDL

Messaggioda Foto UtenteCastello » 28 apr 2014, 16:22

mi spiace dirlo , ma a me non funziona questo codice.. :(


Torna a “Programmi applicativi: simulatori, CAD ed altro”