always@(posedge clk or negedge rst)
if(!rst)
count<=11'b0;
else
begin
case({wen,ren})
2'b00:
begin
count<=count;
end
2'b01:
begin
if(full==1'b0)
count<=count+1;
else
count<=count;
end
2'b10:
begin
if(empty==1'b0)
count<=count-1;
else
count<=count;
end
default:
begin
count<=count;
end
endcase
end
assign empty=(count==1'b0)?1:0;
assign full=(count==11'h400)?1:0;