OpenCores
URL https://opencores.org/ocsvn/socgen/socgen/trunk

Subversion Repositories socgen

[/] [socgen/] [trunk/] [common/] [opencores.org/] [cde/] [ip/] [fifo/] [rtl/] [verilog/] [fifo_def] - Rev 134

Compare with Previous | Blame | View Log

reg                             r;
reg                             w;
reg [SIZE:0]                  push_1;
reg [SIZE:0]                  pop_1;   

   always@(*)  push_1 =  (push_pointer + 1'b1);
   always@(*)  pop_1  =  (pop_pointer  + 1'b1); 


   always@(*)  r =  (pop_pointer == push_1[SIZE-1:0]);
   always@(*)  w =  (push_pointer == pop_1[SIZE-1:0]);

   

   
always@(posedge clk)
  if(reset)
                                begin
                                full         <=  1'b0;
                                empty        <=  1'b1;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= {SIZE{1'b0}};
                                pop_pointer  <= {SIZE{1'b0}};         
                                end
  else
  if(empty && !full)
       if( push && ~pop)           
                                begin
                                full         <=  1'b0;
                                empty        <=  1'b0;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= push_pointer+1;
                                pop_pointer  <= pop_pointer;
                                end
       else
       if(~push &&  pop)        
                                begin
                                full         <=  1'b0;
                                empty        <=  1'b1;
                                over_run     <=  1'b0;
                                under_run    <=  1'b1;
                                push_pointer <= push_pointer;
                                pop_pointer  <= pop_pointer;
                                end
       else
       if( push &&  pop)        
                                begin
                                full         <=  1'b0;
                                empty        <=  1'b1;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= push_pointer +  1;
                                pop_pointer  <= pop_pointer + 1;
                                end
       else
                                begin
                                full         <=  1'b0;
                                empty        <=  1'b1;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= push_pointer;
                                pop_pointer  <= pop_pointer;
                                end
   else
   if(!empty && !full)
       if( push &&  pop)        
                                begin
                                full         <=  1'b0;
                                empty        <=  1'b0;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= push_pointer +  1;
                                pop_pointer  <= pop_pointer + 1;
                                end
       else
       if( push && !pop && r)           
                                begin
                                full         <=  1'b1;
                                empty        <=  1'b0;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= push_pointer+1;
                                pop_pointer  <= pop_pointer;
                                end
       else
       if( push && !pop && !r)           
                                begin
                                full         <=  1'b0;
                                empty        <=  1'b0;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= push_pointer+1;
                                pop_pointer  <= pop_pointer;
                                end
       else
       if(~push &&  pop && w)        
                                begin
                                full         <=  1'b0;
                                empty        <=  1'b1;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= push_pointer;
                                pop_pointer  <= pop_pointer+1;
                                end
       else
       if(~push &&  pop && !w)        
                                begin
                                full         <=  1'b0;
                                empty        <=  1'b0;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= push_pointer;
                                pop_pointer  <= pop_pointer+1;
                                end
       else      
                                begin
                                full         <=  1'b0;
                                empty        <=  1'b0;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= push_pointer;
                                pop_pointer  <= pop_pointer;
                                end
  else      
  if(!empty && full)
      if( push && ~pop) 
                                begin
                                full         <=  1'b1;
                                empty        <=  1'b0;
                                over_run     <=  1'b1;
                                under_run    <=  1'b0;
                                push_pointer <= push_pointer;
                                pop_pointer  <= pop_pointer;
                                end
       else
       if(~push &&  pop)        
                                begin
                                full         <=  1'b0;
                                empty        <=  1'b0;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= push_pointer;
                                pop_pointer  <= pop_pointer+1;
                                end
       else
       if( push &&  pop)        
                                begin
                                full         <=  1'b1;
                                empty        <=  1'b0;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= push_pointer +  1;
                                pop_pointer  <= pop_pointer + 1;
                                end
       else
                                begin
                                full         <=  1'b1;
                                empty        <=  1'b0;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= push_pointer;
                                pop_pointer  <= pop_pointer;
                                end
//  full and empty at the same time should never occur

   
    else
                                begin
                                full         <=  1'b0;
                                empty        <=  1'b1;
                                over_run     <=  1'b0;
                                under_run    <=  1'b0;
                                push_pointer <= {SIZE{1'b0}};
                                pop_pointer  <= {SIZE{1'b0}};         
                                end

   



Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.