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. 【面试必备】 【ES6】学Vue前必须掌握的内容(上)

    变量声明 采用 let 和 const 分别声明变量和常量. 不用var所以不存在变量提升. 解构 ① 数组解构[ ] 等号左边允许存在默认值.变量的取值按照顺序. //之前的写法 var arr=[ ...

  2. 【yum】使用新的centos 6.9系统时,遇到的Yum问题

    1,不识别域名 vi /etc/yum.conf 新增: nameserver 1.1.1.1(根据实际配置) 2,Header V3 RSA/SHA256 Signature, key ID 060 ...

  3. JavaSE——构造方法

    package com.zhao.test3; public class Student { private String name; private int age; //如果我们自己没有写任何的构 ...

  4. Qt中父子页面切换隐藏实现方法 (利用信号槽机制实现)

    首先既然你打开了这篇文章,那你一定想到过,将子界面作为父界面的一个属性来实现,但是这样父界面通知子界面会很轻松,但子界面通知父界面怎么搞呢?很显然不能再子界面再实例化父界面(因为这样做会循环引用),那 ...

  5. Lua文件夹及文件操作

    转载于:CSDN-刘长栋 -[[ @引用:require("FileLib") @调用:fileLib.createFolder(path) @功能: 1.创建文件夹 2.连续创建 ...

  6. js判断图片链接是否有效

    let checkImgExists = function(url) { return new Promise(function(resolve, reject) { let ImgObj = new ...

  7. 课程表及事件提醒app-界面原型设计

    前端设计: 暂定为8个主要界面:程序初始界面.主界面(首页).课表界面."我的"界面.登录界面.注册界面.创建事件界面.新建课表界面 设计思路: 项目结构 三个主要界面 首页: 课 ...

  8. Selenium私房菜系列4 -- Selenium IDE的使用【QQ】

    前面说过,Selenium IDE是Firefox的一个插件,是可以进行脚本录制以及案例转换,所以Selenium IDE+Firebug会成为你日后写测试案例的两大助手(IE下可以使用Seleniu ...

  9. 【azw3】麻省理工深度思考法:从模型及动力机制来思考现象

    书本详情 标题:麻省理工深度思考法:从模型及动力机制来思考现象作者:[日]平井孝志 著:张玉虹 译年份:2018出版社:北京:中国华侨出版社ISBN:9787511373441,7511373445格 ...

  10. KVM虚拟机的认知

    Kernel-based Virtual Machine简称KVM,是一个开源的系统虚拟化模块,自Linux 2.6.20之后集成在Linux的各个主要发行版本中.它使用Linux自身的调度器进行管理 ...