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原理图:

HDLbits——Rotate100的更多相关文章

  1. 学会使用Hdlbits网页版Verilog代码仿真验证平台

    给大家推荐一款网页版的 Verilog代码编辑仿真验证平台,这个平台是国外的一家开源FPGA学习网站,通过“https://hdlbits.01xz.net/wiki/Main_Page” 地址链接进 ...

  2. HDLBits答案——Circuits

    1 Combinational Logic 1.1 Basic Gates 1.1.1 Exams/m2014 q4h module top_module ( input in, output out ...

  3. HDLBits答案——Verification: Writing Testbenches

    1 clock module top_module ( ); reg clk; dut U1(.clk(clk)); initial begin clk = 0; end always begin # ...

  4. HDLBits答案——Verification: Reading Simulations

    1 Finding bugs in code 1.1 Bugs mux2 module top_module ( input sel, input [7:0] a, input [7:0] b, ou ...

  5. HDLBits答案——Verilog Language

    Verilog Language 1 Basics 1.1 Wire module top_module( input in, output out ); assign out = in; endmo ...

  6. HDLBits答案——Getting started

    Getting started 1 Step one module top_module( output one ); // Insert your code here assign one = 1' ...

  7. verilog常见错误列表

    Error/Warning 来源:https://hdlbits.01xz.net/wiki/ 题目: 1.Quartus Warning 10235: Warning (): Verilog HDL ...

  8. Verilog HDL

    https://wenku.baidu.com/view/9943b7acf524ccbff1218463.html https://hdlbits.01xz.net/wiki/Main_Page h ...

  9. Verilog设计技巧实例及实现

    Verilog设计技巧实例及实现 1 引言 最近在刷HDLBits的过程中学习了一些Verilog的设计技巧,在这里予以整理.部分操作可能降低代码的可读性和Debug的难度,请大家根据实际情况进行使用 ...

  10. 入行数字IC验证的一些建议

    0x00 首先,推荐你看两本书,<"胡"说IC菜鸟工程师完美进阶>(pdf版本就行)本书介绍整个流程都有哪些岗位,充分了解IC行业的职业发展方向.<SoC设计方法 ...

随机推荐

  1. python GIL解释器

    1.GIL是什么? GIL全称Global Interpreter Lock,即全局解释器锁. 作用就是,限制多线程同时执行,保证同一时间内只有一个线程在执行. GIL并不是Python的特性,它是在 ...

  2. perl的学习:将分句脚本split-sentences.perl转为python脚本

    初识perl,只为完成分句脚本的转换.因此本文具有极强的目的性,perl的很多好用功能就不研究了,主要内容围绕分句脚本展开,部分基础知识就不再赘述. 1.仓库的地址:https://gitee.com ...

  3. 在windows服务中托管asp.net.core

    参考:https://docs.microsoft.com/zh-cn/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-3.1& ...

  4. reset slave

    reset slave 所有中继日志文件都被删除,即使它们还没有被复制 SQL 线程完全执行. reset slave all 所有中继日志文件都被删除,它会清除连接参数(需要重新change mas ...

  5. java.net.ConnectException: Your endpoint configuration is wrong; For more details see: http://wiki.apache.org/hadoop/UnsetHostnameOrPort

    今天使用在hive中建表,并在hive中将查询到的语句插入到新表中时,一直开在如图所示位置不动 等待了20多分钟,然后报了这么个错 java.net.ConnectException: Your en ...

  6. “初始化 Java 工具”期间发生了内部错误, java.lang.NullPointerException

    今天刚打开eclipse就报了这个错误,我怀疑是昨晚想关电脑的时候,关闭eclipse太快,没有等待工作空间保存就关了电脑的缘故 错误如图: (图片来自下方链接博客,因为忘记截图了) 我百度后按照提示 ...

  7. Caused by: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended

    可能是多数据源使用分页pageHelper导致的: 解决方法:https://blog.csdn.net/qq_35378008/article/details/90024365 https://bl ...

  8. sxt_(008_011)_servlet

    一.servlet简介 Servlet(Server Applet)是Java Servlet的简称,称为小服务程序或服务连接器,用Java编写的服务器端程序,具有独立于平台和协议的特性,主要功能在于 ...

  9. vue项目搭建(vue2+elementUI+less)

    装node.js然后控制台输入node -v有版本号就是成功了 如是是windows系统建议装个git ,我这边习惯用命令行了 按照vue 和vue-cli vue-cli是一个vue的脚手架 按照提 ...

  10. Python系统模块os.py和sys.py常用函数

    OS模块 os模块就是对操作系统进行操作,使用该模块必须先导入模块: import os #getcwd() 获取当前工作目录(当前工作目录默认都是当前文件所在的文件夹) result = os.ge ...