Build a circuit from a simulation waveform

HDLBits链接


前言

今天更新HDLBits习题由波形图描述电路的部分,看图写代码。


题库

Combinational circuit 1

由图可见,q=a&b

Solution

module top_module (input a,input b,output q );//assign q = a & b; // Fix meendmodule

Combinational circuit 2

由图列出卡诺图描述出来即可。

Solution

module top_module (input a,input b,input c,input d,output q );//assign q = ~a & ~b & ~c & ~d | ~a & ~b & c & d | ~a & b & ~c & d | ~a & b & c & ~d | a & ~b & ~c & d | a & ~b & c & ~d | a & b & ~c & ~d | a & b & c & d; // Fix meendmodule

Combinational circuit 3

由波形图列出卡诺图化简可得。

Solution:

module top_module (input a,input b,input c,input d,output q );//assign q = b & d | b & c | a & d | a & c; // Fix meendmodule

Combinational circuit 4

与上题同理

Solution

module top_module (input a,input b,input c,input d,output q );//assign q = b | c; // Fix meendmodule

Combinational circuit 5

由波形图可见这是个多路选择器,通过c路信号进行信号选择;

Solution:

module top_module (input [3:0] a,input [3:0] b,input [3:0] c,input [3:0] d,input [3:0] e,output [3:0] q );always @(*) begincase(c)4'd0:    q <= b;4'd1:   q <= e;4'd2:   q <= a;4'd3:   q <= d;default:q <= 4'hf;endcaseendendmodule

Combinational circuit 6

Solution

module top_module (input [2:0] a,output [15:0] q ); always @(*) begincase(a)3'd0:  q <= 16'h1232;3'd1:   q <= 16'haee0;3'd2:   q <= 16'h27d4;3'd3:   q <= 16'h5a0e;3'd4:   q <= 16'h2066;3'd5:   q <= 16'h64ce;3'd6:   q <= 16'hc526;default:q <= 16'h2f19;endcaseendendmodule

Sequential circuit 7

Solution

module top_module (input clk,input a,output q );always @(posedge clk) beginq <= ~a;endendmodule

Sequential circuit 8

由图可见,p为a在clock为高电平时的选通信号,q为clock下降沿触发的信号,存放p的值。

Solution:

module top_module (input clock,input a,output p,output q );reg clk_0;assign p = clock ? a : p;always @(negedge clock) beginq <= p;endendmodule

Sequential circuit 9

由图可见,q应当是一个从0-6的计数器,当a为高电平时,q保持为4,直到a为低电平时,再继续计数;

Solution

module top_module (input clk,input a,output [3:0] q );always @(posedge clk) beginif(a) beginq <= 4'd4;endelse if(q == 4'd6) beginq <= 4'd0;endelse beginq <= q + 4'd1;endendendmodule

Sequential circuit 10

q为a,b和state的组合逻辑,列出真值表即可;

Solution

module top_module (input clk,input a,input b,output q,output state  );assign q = a ^ b ^ state;always @(posedge clk) beginif(a & b) beginstate <= 1'b1;endelse if(~a & ~b) beginstate <= 1'b0;endelse beginstate <= state;endendendmodule

结语

该小结就算更新结束了,胜利就在眼前,哈哈哈!本章的解法并不唯一,大家有什么其他思路欢迎在评论区讨论交流。

HDLBits答案(24)_由波形图描述电路相关推荐

  1. HDLBits答案(6)_硬件模块设计的思考方式

    硬件模块设计的思考方式 HDLBits链接 基本的逻辑门操作 题目描述1:将输入端口in和输出端口out连接. Solution1: module top_module (input in,outpu ...

  2. HDLBits答案(25)_编写Testbench

    Verification:Writing Testbenches HDLBits链接 前言 今天更新HDLBits最后一章的习题:编写Testbench. 题库 Clock 提供了如下描述的模块: m ...

  3. HDLBits答案(9)_卡诺图与最简SOP式

    卡诺图与最简SOP式 HDLBits链接 真值表 定义 真值表是表征逻辑事件输入和输出之间全部可能状态的表格.以1表示真,0表示假. 从真值表到标准式 SOP标准式:找出真值表中所有输出为1的表项,按 ...

  4. HDLBits答案(4)_如何避免生成锁存器?

    HDLBits_Verilog Language_Procedures HDLBits链接 组合逻辑的always块 [David说]: 考虑到硬件的可综合性,有两种always块是有意义的: 组合: ...

  5. HDLBits答案(22)_基于有限状态机的计数器

    基于有限状态机的计数器 HDLBits链接 前言 今天更新搭建更大的电路部分的习题,内容主要跟计数器和有限状态机有关. 题库 Counter with period 1000 构造一个0-999的计数 ...

  6. HDLBits答案(23)_找BUG

    Finding bugs in code HDLBits链接 前言 今天更新HDLBits习题部分找BUG部分,比较简单,大家看一下即可. 题库 8bit_2_1_Mux 原Code: module ...

  7. 刷完这套题,我才发现Verilog原来如此简单----HDLBits答案系列---- Latches and Flip-Flops

    写在前面 全部答案汇总:刷完这套题,我才发现Verilog原来如此简单----HDLBits答案汇总 今天更新Circuits章节中Sequential Logic的1个小节:Latches and ...

  8. 创意c语言程序设计,重庆理工大学-c语言程序设计基础教程_习题答案(纪纲_金艳).doc...

    重庆理工大学-c语言程序设计基础教程_习题答案(纪纲_金艳).doc 还剩 56页未读, 继续阅读 下载文档到电脑,马上远离加班熬夜! 亲,很抱歉,此页已超出免费预览范围啦! 如果喜欢就下载吧,价低环 ...

  9. 西安交通大学计算机笔试题,《大学计算机基础试题与答案》_西安交通大学

    <大学计算机基础试题与答案>_西安交通大学 (11页) 本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦! 14.9 积分 . . . . .< ...

最新文章

  1. python学习笔记:(三)list(列表)常用的内置方法
  2. Mysql insert语句的优化
  3. Entity Framework简介
  4. 线程的状态 Thread.State||NEW,RUNNABLE,BLOCKED,WAITING,TIMED_WAITING,TERMINATED
  5. MS CRM 2011 C#中获取Web Resource
  6. 信息学奥赛一本通(2017:【例4.2】输出偶数)
  7. vim打造成C++的IDE
  8. 搭建大数据分析平台的必要性
  9. BZOJ2191:Splite
  10. acs880变频器静态辨识_ACS880变频器PID控制参数设置
  11. 基于Dlib库构建人脸识别数据集
  12. 计算机信息技术在教学中的发展,浅析信息技术在教学中的创新作用
  13. php显示动态的文字,动态文字制作软件,视频上制作动感文字/动态字幕条
  14. uni-app相关知识积累
  15. 打开对方CMD的三种方法
  16. 网络流——最大流问题
  17. 浏览器首页被2345、hao123锁定了,怎么办
  18. matlab单个像素面积,我用MATLAB计算出了图像目标区域的像素点个数,请问知道了目标区域的像素点怎么计算目标区域的面积?...
  19. ApiPost与PostMan,你可以任选一款不错的接口管理工具
  20. 微信小程序运营怎么做?技巧盘点

热门文章

  1. hybris测试数据的存放位置
  2. SM_INTEGRATION_SRV
  3. SAP Fiori extension hook added via note
  4. when and where is createContent called
  5. nodejs应用错误消息PayloadTooLarge的处理
  6. new Grammar in 740 - Internal table group by
  7. Cannot find source code based button in SE24 - modification assistant
  8. Report not added to business roles
  9. CRM and S4 Fiori UI coexistence
  10. SAP 客户主数据表BUT000的extractor