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

最新文章

  1. python笔记
  2. linux用户不在sudoers文件中
  3. Intellij IDEA 常用快捷键
  4. JAG Summer 2012 Day 4 C Connect
  5. OneSQL助力永辉超市大卖特卖
  6. Get&amp;Post简单说明
  7. C#多线程:使用ReaderWriterLock类实现多用户读/单用户写同步
  8. MySQL数据库迁移(转)
  9. JAVA 环境变量设置 (windows + Linux)
  10. Oracle日期时间
  11. 初学C++,开博第一篇
  12. 【转】Android手机客户端关于二维码扫描的源码--不错
  13. Effective C++_笔记_条款03_尽可能使用const
  14. javascript运动框架(三)
  15. oracle 数据字典和动态性能视图
  16. pwnable.tw dubblesort 分析
  17. Nikto and whatweb
  18. D - Dice Game (BFS)
  19. java-webService(调用wsdl接口)
  20. 第一个spring,第五天。

热门文章

  1. python-异常/文件/时间/随机数
  2. 使用navicat进行数据传输报错ERROR: permission denied for table xxx
  3. windows 10中Microsoft Edge Beta登录账户提示:以管理员身份运行 Microsoft Edge 时不支持登录。请以非管理员身份重新启动 Microsoft Edge,然后重新尝试登录。的解决方案
  4. Open vSwitch虚拟交换机实践
  5. centos系统时间与硬件时间不一致
  6. Java基础——Scanner扫描字符数组出现问题
  7. HIVE- lag函数和lead函数
  8. JavaScript基础知识整理(ES5创建对象)
  9. vue+vant打包,vue+vant-ui小程序,微信支付
  10. C语言标准 —— C89(C90)、C99、C11、C17、C2X