Forum: FPGA, VHDL & Co. FIFO spiegeln


von HHGG (Gast)


Lesenswert?

in Anlehnung an Herrn Millers FIFO ist folgender VHDL-Code entstanden:

adc_input  : in  std_logic_vector(0 to act_adc_dwidth-1):=(0 
=>'1',others =>'0');

type speicher is array(0 to fifo_depth -1) of std_logic_vector(0 to 
act_adc_dwidth-1);
 signal in_memory   : speicher;
  signal out_memory   : speicher;


 FILL_FIFO_Proc : process( Bus2IP_Clk ) is
  begin
    if Bus2IP_Clk'event and Bus2IP_Clk = '1' then
      if Bus2IP_Reset = '1' then
        in_count  <= 0;
      fifo_overrun <='0';
      elsif in_count<fifo_depth+1 then
       in_memory(in_count) <= adc_input;
     in_count<=in_count+1;
    end if;
     if fifo_depth = in_count then
      if 0 = out_count then
       out_memory<=in_memory;
       in_count<=0;
      else
       fifo_overrun <='1';
       end if;
      end if;
    in_test_port<=in_memory(0);
    out_test_port<=out_memory(0);
     end if;
  end process FILL_FIFO_Proc;

wenn ich das ganze simuliere steht im in_memory das richtige drin im 
out_memory aber nur einsen

wo kommen die her, was mach ich falsch?
Besten Dank für eure Ideen.
Hannes

von Lothar M. (Firma: Titel) (lkmiller) (Moderator) Benutzerseite


Lesenswert?

HHGG schrieb:
> wenn ich das ganze simuliere
Zum Glück nur zum Simulieren.... :-/

Denn das wird den Synthesizer das Kotzen lehren:
1
       out_memory<=in_memory;
Was soll hier gemacht werden? Soll da ein ganzer Speicher in 1 Takt auf 
einen anderen Speicher umkopiert werden?
Wie muss so ein Bauteil aussehen, das das kann? Es braucht genausoviele 
Datenleitungen wie es Bits hat. Nur dann kann im selben Takt jedes Bit 
auf ein anderes zugeweisen werden.

Ich würde sagen, der Ansatz taugt so nicht für die Realität...  :-(
Dass dabei die Simulation auch noch irgendwie schief geht, ist eine 
klitzekleine und unbedeutende Randerscheinung...  ;-)

von HHGG (Gast)


Lesenswert?

jo, besten dank. Es kommt halt immer wieder die c-Denke durch. jetzt 
plex ich's quasi einfach und es funktioniert(solange 
Bus2IP_Clk/extern_clk <4( Verhältniss Wortbreite adcInput zu 
IP2Bus_Data))  :

 FILL_FIFO_Proc : process( Bus2IP_Clk ) is
  begin
    if Bus2IP_Clk'event and Bus2IP_Clk = '1' then
      if Bus2IP_Reset = '1' then
         in_count  <= 0;
       fifo_overrun <='0';
     elsif in_count = fifo_depth then
      if  out_count = 0 then
       switch<= not switch;
       in_count <= 0;
      else
       fifo_overrun <='1';
       end if;
      else
      if switch = '0' then
        memory_1(in_count) <= adc_input;
      else
        memory_2(in_count) <= adc_input;

      end if;
       in_count<=in_count+1;
    end if;
    end if;
  end process FILL_FIFO_Proc;

  EMPTY_FIFO_PROC : process( slv_reg_read_sel,extern_clk) is
  begin
   if extern_clk'event and extern_clk = '1' then
     if Bus2IP_Reset = '1' then
       out_count <= 0;
    elsif slv_reg_read_sel = '1' then
    if switch = '0' then
     IP2Bus_Data(0 to 7)<=  memory_2(0);
              IP2Bus_Data(8 to 15)  <=  memory_2(1);
     IP2Bus_Data(16 to 23) <=  memory_2(2);
     IP2Bus_Data(24 to 31) <= memory_2(3);
    else
     IP2Bus_Data (0 to 7)<=memory_1(0);
     IP2Bus_Data(8 to 15) <=memory_1(1);
     IP2Bus_Data(16 to 23) <=memory_1(2);
     IP2Bus_Data(24 to 31) <=memory_1(3);
    end if;
    end if;
   end if;
  end process EMPTY_FIFO_PROC;

von HHGG (Gast)


Lesenswert?

achso, das mit out_count und damit mit fifo_overun im moment nix 
passiert ist mir klar, da arbeit ich grad wieder dran...

von Hannes H. (hhgg)


Lesenswert?

so fertsch, rein (14bit) und raus (32bit) läuft mit verschiedenen clks, 
und der overrun ist wieder an,wenns wen interessiert, kurz bemerkbar 
machen

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.