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. 最全面 think php 实现微信公众号回复编号进行投票,自定义菜单功能

    前期准备工作 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_standard_messag ...

  2. Oracle 的merge into 语法转postgre

    Oracle的merge into 语法 MERGE INTO t1 USING (SELECT id,name FROM t2) t2 ON ( t1.id=t2.id)   //主键 WHEN M ...

  3. 安卓调试打包错误Error executing aapt: Return code -1073741819 Error while running zipalign

    之前开发完的安卓app项目,再次打开,突然抽风报错. 1.调试运行报错:Error executing aapt: Return code -1073741819 2.打包失败报错: Error wh ...

  4. 发布 Net8预览版1(Announcing .NET 8 Preview 1)

    发布 net8预览版1(Announcing .NET 8 Preview 1) 1.对Net持续看好,对未来更加充满信心. 2.我主要关注Asp.Net Core .NET 8 中的新增功能 Wha ...

  5. jinkens设置工作主目录

    linux下,默认jenkins的主目录,位于当前用户下的.jenkins目录,需要自定义该目录位置的时候,可以通过设定环境变量 JENKINS_HOME 然后重启jenkins nohup java ...

  6. oracle 导出导入表 不到出指定表

    导出多个表 exp LSXYYSZHMRMS/******@PK99SERVICE file=d:\fuhcx.dmp  tables=(fhcxgxxx,fhcxjcxx,fhcxlbxx,fhcx ...

  7. 02. C语言基础知识

    一.注释   注释 就是对代码进行解释说明的文字,注释的内容不会参与编译和运行,仅仅是对代码的解释说明.在 C语言 中注释主要分为以下两类: 单行注释://,注释内容从 // 始到本行和结尾 多行注释 ...

  8. 【SQL SERVER】DATEDIFF() :两个日期的日期差

    定义用法 DATEDIFF() 函数返回两个日期之间的日期差. 语法 DATEDIFF(datepart,startdate,enddate) startdate 和 enddate 参数是合法的日期 ...

  9. Canvas布局下使用附加属性使控件岁鼠标移动

    定义附加属性 public class MoveBehavior { public static readonly DependencyProperty IsMoveAbleProperty = De ...

  10. db2存储过程 动态拼接sql 、输出数据集示例

    *****部分都是表名.因为隐私关系,替换为*了. 1 CREATE PROCEDURE "BI_DM"."SP_GCYP_REPORT" ( 2 startd ...