HDLbits——Rotate100
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的更多相关文章
- 学会使用Hdlbits网页版Verilog代码仿真验证平台
给大家推荐一款网页版的 Verilog代码编辑仿真验证平台,这个平台是国外的一家开源FPGA学习网站,通过“https://hdlbits.01xz.net/wiki/Main_Page” 地址链接进 ...
- HDLBits答案——Circuits
1 Combinational Logic 1.1 Basic Gates 1.1.1 Exams/m2014 q4h module top_module ( input in, output out ...
- HDLBits答案——Verification: Writing Testbenches
1 clock module top_module ( ); reg clk; dut U1(.clk(clk)); initial begin clk = 0; end always begin # ...
- 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 ...
- HDLBits答案——Verilog Language
Verilog Language 1 Basics 1.1 Wire module top_module( input in, output out ); assign out = in; endmo ...
- HDLBits答案——Getting started
Getting started 1 Step one module top_module( output one ); // Insert your code here assign one = 1' ...
- verilog常见错误列表
Error/Warning 来源:https://hdlbits.01xz.net/wiki/ 题目: 1.Quartus Warning 10235: Warning (): Verilog HDL ...
- Verilog HDL
https://wenku.baidu.com/view/9943b7acf524ccbff1218463.html https://hdlbits.01xz.net/wiki/Main_Page h ...
- Verilog设计技巧实例及实现
Verilog设计技巧实例及实现 1 引言 最近在刷HDLBits的过程中学习了一些Verilog的设计技巧,在这里予以整理.部分操作可能降低代码的可读性和Debug的难度,请大家根据实际情况进行使用 ...
- 入行数字IC验证的一些建议
0x00 首先,推荐你看两本书,<"胡"说IC菜鸟工程师完美进阶>(pdf版本就行)本书介绍整个流程都有哪些岗位,充分了解IC行业的职业发展方向.<SoC设计方法 ...
随机推荐
- ubuntu 22.04 网络配置ib网卡配置
第一步:查看Ubuntu版本与内核版本 cat /etc/issue 这说明系统的版本为:Ubuntu 20.04.4 LTS \n \l uname -a Linux gacs-gm-11 5.4. ...
- linux安装datax +datax-web踩坑总结
一丶安装datax 环境:JDK8+ py2.7+ 下载地址:http://datax-opensource.oss-cn-hangzhou.aliyuncs.com/datax.tar.gz ...
- beego框架中的注解路由不生效的问题
在测试中发现 使用注解路由的话 项目需要在gopath路径下的src下才可以 并且配置文件的 runmode = dev 然后执行bee run 在路由文件夹里才会生成commentRouter文件 ...
- 利用Word文档的宏命令,仿信纸写文件报告
一,首先写好稿件内容. 二,选择合适字体,然后设置信纸下划线格式. 三,启用宏命令.文件-选项-信任中心-信任中心设置-启用所有宏. 四,创建宏命令.视图-宏-创建一个宏 Sub 字体修改()'' 字 ...
- redisTemplate实现分布式锁(释放锁用lua脚本)
package com.xxx.platform.util; import org.springframework.beans.factory.annotation.Autowired; import ...
- fastdfs虚拟机单机版搭建
说明:github搭建步骤:https://github.com/happyfish100/fastdfs/wiki#trackermkdir /home/dfs #创建数据存储目录 cd /usr/ ...
- 实验一-密码引擎-加密API研究
实验一-密码引擎-加密API研究 API:应用程序接口(API:Application Program Interface)是一组定义.程序及协议的集合,通过 API 接口实现计算机软件之间的相互通信 ...
- 处理Android的物理后退按钮
在文章.聊天.联系.相册四个页面时,用户点击Android 物理键返回,需要直接退出程序.我这里处理很简单,直接使用react-navigation的属性backbehavior就很快的解决了. &l ...
- Java基础学习:7、作用域
1.在Java中,主要的变量就是属性(成员变量)和局部变量. 2.我们说的局部变量一般是指在成员方法中定义的变量. 3.Java作用域分类: 全局变量:作用域为整个类,该类中的方法可以使用. 局部变量 ...
- git多分支-git远程仓库-ssh方式连接远程仓库-协同开发-冲突解决-线上分支合并-远程仓库回滚
目录 git多分支-git远程仓库-ssh方式连接远程仓库-协同开发-冲突解决-线上分支合并-远程仓库回滚 昨日内容回顾 今日内容概要 今日内容详细 1 git多分支 2 git远程仓库 3 ssh方 ...