Skip to content

上课时说的“比较”方法似乎行不通? #9

Answered by readygo67
QlDoors asked this question in Week2
Discussion options

You must be logged in to vote
  1. IsEqual 这个电路实现的像是GreaterOrEqual的功能.
  2. input = 8 超过了 3bits 能表示的范围,最大input 应该为7。 为了处理in[0]=8, in[1]=0的情况,将nbits= n+2, 用来表示8+8-0= 0b10000的情况. 会导致3.
  3. 理论上 2^3 借到的8是放在bit[3]上,应该检测相减之后的bit[3], 而原代码检测 n2b.outnBits-1, 这个信号的含义不明确。
    in[0] in[1] inv(5bits). inv(4bits)
    8 0 0b10000 无法表示 //5bits. 取最高位 = 1
    8 1 0b01111 0b1111 //4bits表示, 最高位=1, 2^ 3=8 没有被借走,所以in[0] >= in[1]
    7 0 0b01111 0b1111 //4bits表示, 最高位=1, 2^ 3=8 没有被借走,所以in[0] >= in[1]
    4 4 0b01000 0b1000 //4bits表示,最高位=1, 2^ 3=8 没有被借走,所以in[0] >=in[1]
    2 7 0b00011 0b0011 //4bits表示,最高位=0, 2^ 3=8 被借走,所以in[0] <in[1]

修改后的代码供参考。

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@QlDoors
Comment options

Answer selected by QlDoors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants