HDLBits Left/right arithmetic shift by 1 or 8(Shift18)
Build a 64-bit arithmetic shift register, with synchronous load. The shifter can shift both left and right, and by 1 or 8 bit positions, selected by amount.
An arithmetic right shift shifts in the sign bit of the number in the shift register (q[63] in this case) instead of zero as done by a logical right shift. Another way of thinking about an arithmetic right shift is that it assumes the number being shifted is signed and preserves the sign, so that arithmetic right shift divides a signed number by a power of two.
There is no difference between logical and arithmetic left shifts.
- load: Loads shift register with data[63:0] instead of shifting.
- ena: Chooses whether to shift.
- amount: Chooses which direction and how much to shift.
- 2'b00: shift left by 1 bit.
- 2'b01: shift left by 8 bits.
- 2'b10: shift right by 1 bit.
- 2'b11: shift right by 8 bits.
- q: The contents of the shifter.
建立一個具有同步置數的64位算術移位Register。 Shifter可以向左和向右移位1或8位的位置(按不同的數字進行選擇)。
算術右移是將移位寄存器中數字(q[63])的符號位移位,而不是邏輯右移所做的零。另一種考慮算術右移的方法是,它假設移動的數是有符號的,並且保留了符號,所以算術右移將有符號的數除以2的冪。
邏輯左移和算術左移之間沒有區別。
load:data[63:0]置入移位寄存器而不是移位。
ena:選擇是否移位。
amount:選擇移位方向和移位改變多少:
amount | 操作 |
---|---|
2’b00 | 左移1位 |
2’b01 | 左移8位 |
2’b10 | 右移1位 |
2’b11 | 右移8位 |
沒有留言:
張貼留言