HDLbits—— 3-input look-up-table
2024-10-10 16:14:46
// a 3-input look-up-table
// In this question, you will design a circuit for an 8x1 memory,
// where writing to the memory is accomplished by shifting-in bits,
// and reading is "random access", as in a typical RAM.
// You will then use the circuit to realize a 3-input logic function.
// First, create an 8-bit shift register with 8 D-type flip-flops. D触发器
// Label the flip-flop outputs from Q[0]...Q[7]. The shift register input should be called S,
// which feeds the input of Q[0] (MSB is shifted in first).
// The enable input controls whether to shift.
// Then, extend the circuit to have 3 additional inputs A,B,C and an output Z.
// The circuit's behaviour should be as follows:
// when ABC is 000, Z=Q[0], when ABC is 001, Z=Q[1], and so on.
// Your circuit should contain ONLY the 8-bit shift register,
// and multiplexers. (Aside: this circuit is called a 3-input look-up-table (LUT)).
module top_module (
input clk,
input enable,
input S,
input A, B, C,
output reg Z );
reg [7:0] Q;
always @(posedge clk) begin
if(enable)begin
Q <= {Q[6:0],S};
end
else Q <=Q;
end
always @(*) begin
case ({A,B,C})
3'b000: Z = Q[0];
3'b001: Z = Q[1];
3'b010: Z = Q[2];
3'b011: Z = Q[3];
3'b100: Z = Q[4];
3'b101: Z = Q[5];
3'b110: Z = Q[6];
3'b111: Z = Q[7];
endcase
end
endmodule
测试结果
RTL原理图
最新文章
- python笔记
- linux用户不在sudoers文件中
- Intellij IDEA 常用快捷键
- JAG Summer 2012 Day 4 C Connect
- OneSQL助力永辉超市大卖特卖
- Get&;Post简单说明
- C#多线程:使用ReaderWriterLock类实现多用户读/单用户写同步
- MySQL数据库迁移(转)
- JAVA 环境变量设置 (windows + Linux)
- Oracle日期时间
- 初学C++,开博第一篇
- 【转】Android手机客户端关于二维码扫描的源码--不错
- Effective C++_笔记_条款03_尽可能使用const
- javascript运动框架(三)
- oracle 数据字典和动态性能视图
- pwnable.tw dubblesort 分析
- Nikto and whatweb
- D - Dice Game (BFS)
- java-webService(调用wsdl接口)
- 第一个spring,第五天。
热门文章
- python-异常/文件/时间/随机数
- 使用navicat进行数据传输报错ERROR: permission denied for table xxx
- windows 10中Microsoft Edge Beta登录账户提示:以管理员身份运行 Microsoft Edge 时不支持登录。请以非管理员身份重新启动 Microsoft Edge,然后重新尝试登录。的解决方案
- Open vSwitch虚拟交换机实践
- centos系统时间与硬件时间不一致
- Java基础——Scanner扫描字符数组出现问题
- HIVE- lag函数和lead函数
- JavaScript基础知识整理(ES5创建对象)
- vue+vant打包,vue+vant-ui小程序,微信支付
- C语言标准 —— C89(C90)、C99、C11、C17、C2X