HDLbits—— 3-input look-up-table
// 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原理图

HDLbits—— 3-input look-up-table的更多相关文章
- el-popover 点击input框出现table表,可点击选中,可拼音检索完回车选中
<template> <card> <el-popover placement="right" width="400" trigg ...
- js 因加入form导致两个table之间出现空白问题
在<FORM>中加CSS <table> ....... </table> <form style="padding:0; margin:0;&qu ...
- jq 克隆 移除table
function addRow2(node){ var obj = $("tr[name='info']:last"); var objClone = $(obj).clone() ...
- java html table 转 excel,给予jdom 和 poi
maven 引入 <dependency> <groupId>org.jdom</groupId> <artifactId>jdom</artif ...
- 在 easyui中获取form表单中所有提交的数据 拼接到table列表中
form表单===== <!-- 并用药品填写信息弹框 --> <div id="usingProdctMsgDiv" style="display: ...
- 周末惊魂:因struts2 016 017 019漏洞被入侵,修复。
入侵(暴风雨前的宁静) 下午阳光甚好,想趁着安静的周末静下心来写写代码.刚过一个小时,3点左右,客服MM找我,告知客户都在说平台登录不了(我们有专门的客户qq群).看了下数据库连接数,正常.登录阿里云 ...
- jQuery九类选择器详解
(1)基本选择器 <body> <div id="div1ID">div1</div> <div id="div2ID" ...
- hive 内部表和外部表的区别和理解
1. 内部表 create table test (name string , age string) location '/input/table_data'; 注:hive默认创建的是内部表 此时 ...
- php之验证码小程序
验证码功能(个人理解): 减轻服务器的压力(如12306的验证码功能): 防止暴力注册 个人思路:在a-z,A-Z,1-9生成n位随机的数来构成新的验证码. 关于生成验证码的几个小函数 range() ...
- 【转】Hive内部表、外部表
hive内部表.外部表区别自不用说,可实际用的时候还是要小心. 1. 内部表: create table tt (name string , age string) location '/input/ ...
随机推荐
- http协议与tcp协议的理解
1.区别 tcp协议是对应于传输层,http协议是对应于应用层,从本质上来说,二者是没有可比性的.http协议是建立在tcp协议基础之上的,当浏览器需要从服务器获取网页数据的时候,会发送一次http请 ...
- Java面向对象之什么是多态?
多态 动态编译:类型:可扩展性 即同一方法可以根据发送对象的不同而采用多种不同的行为方式. 一个对象的实际类型是确定的,但可以指向对象的引用的类型有很多. 多态存在的条件: 1.有继承关系,类型转换异 ...
- JS 开始时间/结束时间和当前时间进行比较
项目需求:到截止日期一些功能不可以再使用,那么需要判断当前时间与截止时间进行比较,记录一下吧 注意: 1.橙色字体的代码换成你自己的变量 2. .valueOf()其实就是将中国时间转为时间戳 3.截 ...
- Unity Vuforia 动态替换识别图
1.在Unity里 Vuforia 用来做识别信息的是 StreamingAssets 下 Vuforia文件夹内的 Dat和XML 文件. 2.想要替换识别图需要在Vuforia官网里替换识别图 ( ...
- Oracle UNDO表空间的管理
Oracle UNDO表空间的管理 UNDO表空间的管理是Oracle DBA最重要的日常工作之一,UNDO表空间用来暂时存储DML操作的数据,其主要作用有: 1.事务回滚 2.实例恢复 3.读一致性 ...
- GIT笔记汇总
Git的存储方式: 元空间的存储方式 SVN存储方式: 文档数据库存储类似于 K -V存储 文件版本迭代 Copy ------------------------------------------ ...
- 手写Web图片懒加载~
废话不多说,直接上代码: 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>图片懒加载</title> ...
- java判断上传图片格式
由于客户上传图片将png的图片的后缀名改为jpg,所以通过后缀名判断不行,用下面这个方法可以 //判断是否是JPG格式 log.info("-1----进入JPG格式判断....." ...
- vue项目搭建(vue2+elementUI+less)
装node.js然后控制台输入node -v有版本号就是成功了 如是是windows系统建议装个git ,我这边习惯用命令行了 按照vue 和vue-cli vue-cli是一个vue的脚手架 按照提 ...
- pytorch 入门
import matplotlib.pyplot as plt from torchvision.transforms import ToTensor import torch from torch ...