hudson1011的个人空间 https://blog.eetop.cn/663936 [收藏] [复制] [分享] [RSS]

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

[转]FIFO 先进先出模块中 理解 verilog 阻塞与非阻塞执行顺序

已有 987 次阅读| 2013-9-13 16:53 |个人分类:FIFO

   `define DEPTH  9'h4
//511 =1FFh
`define DEPTHBIT  3'd2

//0~8 9位 511
module FIFO_MOD(
Data,
Clock, 
WrEn, 
RdEn, 
Reset, 
Q, 
Empty, 
Full
);
input  [127:0] Data/* synthesis syn_ramstyle. = "block_ram" */;
    input  Clock;
    input  WrEn;
    input  RdEn;
    input  Reset;
    output reg [127:0] Q/* synthesis syn_ramstyle. = "block_ram" */;
output Empty;
    output Full;
wire[`DEPTHBIT:0] Count;

reg[`DEPTHBIT:0] DeCount;

reg directory;

reg[127:0] ram[`DEPTH-1:0]/* synthesis syn_ramstyle. = "block_ram" */;
reg[`DEPTHBIT-1:0] InputIndex;
reg[`DEPTHBIT-1:0] OutputIndex;   


always@ ( posedge Clock)
if(!Reset)
begin
InputIndex<=0;
OutputIndex<=0;
directory<=0;
//Count<=0;
DeCount<= `DEPTH;
end
else
begin
case ({(WrEn&~Full),(RdEn&~Empty)})
2'b10:
begin
ram[InputIndex]<=Data;
InputIndex<=InputIndex+1;
DeCount<=DeCount-1 ;
end
2'b01:
begin
Q<=ram[OutputIndex];
OutputIndex<=OutputIndex+1;
DeCount<=DeCount+1;
end
2'b11:
begin
   ram[InputIndex]<=Data;
Q<=ram[OutputIndex];
InputIndex<=InputIndex+1;
OutputIndex<=OutputIndex+1;
end
default:
begin
Q<={127{1'b0}};
end
endcase  
end   
assign Full=(DeCount==0);
assign Empty=(DeCount==`DEPTH);
assign Count=(`DEPTH-DeCount);

endmodule
上面是我写的一个先进先出 模块,这里要注意的是 阻塞赋值与非阻塞赋值在一个模块中的执行顺序
经过观察波形可以看到
模块先执行的是非阻塞赋值后进行的阻塞赋值即先计算完DeCount;得到最新的Decount值在计算的Count值


点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 0

    关注
  • 4

    粉丝
  • 0

    好友
  • 1

    获赞
  • 1

    评论
  • 382

    访问数
关闭

站长推荐 上一条 /1 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-4 11:54 , Processed in 0.023339 second(s), 14 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部