不同风格的Verilog FIFO代码。一个不工作,另一个不工作。有人能解释一下吗

不同风格的Verilog FIFO代码。一个不工作,另一个不工作。有人能解释一下吗,verilog,fifo,vlsi,Verilog,Fifo,Vlsi,我已经为fifo编写了verilog代码,使用fillcount来检查它是满的还是空的。 同一代码有两个版本。 一个是我有一个seprate始终块用于读取、写入、空/满、fillcount,还有一个用于递增指针 module FIFO (clk, reset, data_in, put, get, data_out, fillcount, empty, full); parameter DEPTHP2 = 8 ; parameter WIDTH = 8 ; input [WIDTH-1:0]

我已经为fifo编写了verilog代码,使用fillcount来检查它是满的还是空的。 同一代码有两个版本。 一个是我有一个seprate始终块用于读取、写入、空/满、fillcount,还有一个用于递增指针

module FIFO (clk, reset, data_in, put, get, data_out, fillcount, empty, full); 
parameter DEPTHP2 = 8 ;
parameter WIDTH = 8 ;
input [WIDTH-1:0] data_in;
input put, get, reset, clk; 
output fillcount;
output reg [WIDTH-1:0] data_out;
output reg empty, full; 




reg [3:0]fillcount ;
reg [WIDTH-1:0] fifo_1[0:DEPTHP2-1];
reg [2:0] rp,wp;


always@(posedge clk or posedge reset)
begin
   if( reset )
   begin
      wp <= 0;
      rp <= 0;
   end
   else
   begin
      if( !full && put )    wp <= wp + 1;
          else  wp <= wp;

      if( !empty && get )   rp <= rp + 1;
      else rp <= rp;
   end

end

always @(fillcount)
begin
if(fillcount==0)
  empty =1 ;
  else
  empty=0;

  if(fillcount==8)
   full=1;
   else
   full=0;
end

always @(posedge clk or posedge reset)
begin
   if( reset )
       fillcount <= 0;

   else if( (!full && put) && ( !empty && get ) )
       fillcount <= fillcount;

   else if( !full && put )
       fillcount <= fillcount + 1;

   else if( !empty && get )
       fillcount <= fillcount - 1;
   else
      fillcount <= fillcount;
end

always @( posedge clk or posedge reset)
begin:Reading
   if( reset )
      data_out <= 0;
   else
   begin
      if( get && !empty )
         data_out <= fifo_1[rp];

      else
         data_out <= data_out;

   end
end

always @(posedge clk)
begin:Writing

   if( put && !full )
      fifo_1[ wp ] <= data_in;

   else
      fifo_1[ wp ] <= fifo_1[ wp ];
end

endmodule
模块FIFO(时钟、复位、数据输入、输出、获取、数据输出、填充计数、空、满);
参数DEPTHP2=8;
参数宽度=8;
输入[WIDTH-1:0]数据_;
输入put、get、reset、clk;
输出填充计数;
输出reg[WIDTH-1:0]数据输出;
输出寄存器为空、满;
reg[3:0]填充计数;
reg[WIDTH-1:0]fifo_1[0:DEPTHP2-1];
reg[2:0]rp,wp;
始终@(posedge clk或posedge重置)
开始
如果(重置)
开始
wp在“读取”过程中,您无意中写入fifo内存:

fifo1[rp]<=fifo1[rp];
fifo1[rp]
fifo1[rp]<=fifo1[rp];
always@(posedge clk or posedge reset)
begin:Writing
  if(reset)
    wp<=0;
  else 
    if( put && !full)
    begin
        fifo1[wp]<=data_in;
        wp<=wp+1;
    end
    else
    begin
        fifo1[wp]<=fifo1[wp];
        wp<=wp;
    end
end
always@(posedge clk or posedge reset)
begin:Writing
  if(reset)
    wp<=0;
  else 
    if( put && !full)
    begin
        fifo1[wp]<=data_in;
        wp<=wp+1;
    end
end