桶形移位寄存器即循环移位寄存器,在浮点加减运算、压缩/解压缩和图像处理算法中有应用,常用的是组合逻辑实现的桶形移位寄存器。
从面积的角度来说,这种设计方式的确可以节省资源,但是在高速时序电路中,这样的设计就很不合理了。
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
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有