1. 程式人生 > 其它 >桶形移位暫存器(二)

桶形移位暫存器(二)

桶形移位暫存器即迴圈移位暫存器,在浮點加減運算、壓縮/解壓縮和影象處理演算法中有應用,常用的是組合邏輯實現的桶形移位暫存器。

從面積的角度來說,這種設計方式的確可以節省資源,但是在高速時序電路中,這樣的設計就很不合理了。

module bshift(
clk,
rst,
din,
rotate_cnt,
dout
 );
parameterWIDTH = 8;
parameterCNT_SIZE = 3;
inputclk,rst;
input [CNT_SIZE -1 : 0] rotate_cnt;
input [WIDTH - 1 : 0] din;
output [WIDTH - 1 : 0] dout;
reg [WIDTH - 1 : 0] dout;
wire [WIDTH - 1 : 0] barrel,temp;
wire [2*WIDTH - 1 : 0] bar_temp;
assign bar_temp = {din,din}<<rotate_cnt;
assign {barrel,temp} = {din,din}<<rotate_cnt;
always @(posedge clk or posedge rst)
begin
if(rst)
dout<='b0;
else
dout<=barrel;
end
endmodule