算上单周期数据路径前导零 [英] count leading zero in single cycle datapath

查看:342
本文介绍了算上单周期数据路径前导零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家都可能知道,MIPS指令集支持CLZ(计数前导零)如下:

As you all might know that the MIPS instruction set supports clz (count leading zero) as follows:

CLZ $ T0,T1 $计数前导零T0 = t1中的前导零#

clz $t0,$t1 count leading zeros t0 = # of leading zeros in t1

我写的Verilog一个周期数据通路和只是想知道什么ALU需求,以支持我这样做...任何想法??

I am writing a single cycle datapath in verilog and was just wondering what the ALU needs to support in order for me to do this... any ideas??

推荐答案

下面是一个可能的方法(我忽略为0的输入,这是作为一个特殊的情况下,可能是最好的治疗的情况下):

Here's a possible approach (I'm ignoring the case of an input of 0, which is probably best treated as a special case):


  • 前导零的一个32位数字的号码可以是:

    • 前导零的前16位的数目,如果任何高16位的非零;或

    • 16,加上前导零的低16位的数量,如果该高16位均为零

    在Verilog的,它可能是这个样子:

    In Verilog, it might look something like this:

    result[4] = (value[31:16] == 16'b0);
    val16     = result[4] ? value[15:0] : value[31:16];
    result[3] = (val16[15:8] == 8'b0);
    val8      = result[3] ? val16[7:0] : val16[15:8];
    result[2] = (val8[7:4] == 4'b0);
    val4      = result[2] ? val8[3:0] : val8[7:4];
    result[1] = (val4[3:2] == 2'b0);
    result[0] = result[1] ? ~val4[1] : ~val4[3];
    

    这篇关于算上单周期数据路径前导零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆