verilog代码:

// Build a 100-bit left/right rotator, with synchronous load and left/right enable.
//A rotator shifts-in the shifted-out bit from the other end of the register,
// unlike a shifter that discards the shifted-out bit and shifts in a zero. If enabled,
// a rotator rotates the bits around and does not modify/discard them. // 移出的一位不会丢弃而是补在空缺的位置,即就是题目中的a rotator要求
// load: Loads shift register with data[99:0] instead of rotating.
// ena[1:0]: Chooses whether and which direction to rotate.
// 2'b01 rotates right by one bit
// 2'b10 rotates left by one bit
// 2'b00 and 2'b11 do not rotate.
// q: The contents of the rotator.
module top_module(
input clk,
input load,
input [1:0] ena,
input [99:0] data,
output reg [99:0] q);
always @(posedge clk)
begin
if(load)begin
q <= data;
end
else begin
case(ena)
2'b01: q <= {q[0],q[99:1]};//拼接运算符号{,} ,向右移动1bit
2'b10: q <= {q[98:0],q[99]};//向左边移动1bit
2'b00,2'b11:q <= q; // 保持
default:
q<= q; //所有情况考虑完整的情况下,此处可以省略
endcase
end
end
endmodule

RTL原理图:

最新文章

  1. ubuntu处理中文时设置locale
  2. 【BZOJ 2005】【NOI 2010】能量采集 数论+容斥原理
  3. Java的自动装箱和拆箱的简单讲解
  4. xcode7.3 升级 xcode8.0 后权限设置问题(升级xcode 8.0 后构建版本不显示问题)
  5. GML、SVG、VML的比较
  6. wxWidgets+wxSmith版电子词典
  7. Mock原理学习
  8. docker installation on ubuntu
  9. OC语言(六)
  10. kafka 集群
  11. MVC Views文件夹下js无法访问问题解决方案
  12. exec 命令简单用法 和 find 搭配用法示例
  13. gcc生成含有C信息的汇编
  14. Solve Error: nafxcw.lib(afxmem.obj) : error LNK2005: &quot;void * __cdecl operator new[](unsigned int)&quot; (??_U@YAPAXI@Z) already defined in libcpmt.lib(newaop.obj)
  15. MT【234】正方形染色(二)
  16. Unity3d跨平台原理
  17. SpringCloud+Boot简单例子笔记
  18. 更改MySQL数据库目录位置[zz]
  19. 玩转mongodb(一):初识mongodb
  20. 【转载】C++创建对象的两种方法

热门文章

  1. FPGA MIG调试bug(二)
  2. Day13 字符串的常用方法
  3. vue项目去掉网页滚动条
  4. 查看git的用户名和密码
  5. linux中安装doker
  6. Django里ORM常用关键字
  7. xpath、css元素定位
  8. c--&gt;static关键字的使用
  9. Windows10 WSL开启SSH登录
  10. 性能测试-Jmeter无图型界面运行模式