打印

独热码的使用

[复制链接]
2250|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zrsing|  楼主 | 2013-2-22 20:22 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在状态机中我们经常使用独热码,独热码的一个优势就是可以非常方便的取出一位就可以表示状态,免除复杂的比较电路,下面的代码定义了状态和状态信号提取.
reg  [6:0]   txresp_state;

localparam      RD_FIFO       = 8'h01;
localparam      START_RESP    = 8'h02;
localparam      WAIT_DATA1    = 8'h04;
localparam      WAIT_DATA2    = 8'h08;
localparam      SEND_FIRST    = 8'h10;
localparam      SEND_MAX      = 8'h20;
localparam      SEND_LAST     = 8'h40;


// State machine output assignments

assign   rd_fifo    = txresp_state[0];            
assign   start_resp = txresp_state[1];      
assign   wait_data1 = txresp_state[2];   
assign   wait_data2 = txresp_state[3];   
assign   send_first = txresp_state[4];   
assign   send_max   = txresp_state[5];
assign   send_last  = txresp_state[6];

相关帖子

沙发
zrsing|  楼主 | 2013-2-22 20:22 | 只看该作者
看看吧~

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

10

主题

119

帖子

0

粉丝