HDLBits中文版,标准参考答案 | 4.2 Build a circuit from a simulation waveform | 根据波形构建电路

关注👆 望森FPGA 👆 查看更多FPGA资讯

这是望森的第 23 期分享

作者 | 望森
来源 | 望森FPGA

目录

[1 Combinational circuit 1](#1 Combinational circuit 1)

[2 Combinational circuit 2](#2 Combinational circuit 2)

[3 Combinational circuit 3](#3 Combinational circuit 3)

[4 Combinational circuit 4](#4 Combinational circuit 4)

[5 Combinational circuit 5](#5 Combinational circuit 5)

[6 Combinational circuit 6](#6 Combinational circuit 6)

[7 Sequential circuit 7](#7 Sequential circuit 7)

[8 Sequential circuit 8](#8 Sequential circuit 8)

[9 Sequential circuit 9](#9 Sequential circuit 9)

[10 Sequential circuit 10](#10 Sequential circuit 10)


本文中的代码都能够正常运行,请放心食用😋~

练习的官方网站是:https://hdlbits.01xz.net/

注:作者将每个练习的知识点都放在了题目和答案之后


1 Combinational circuit 1

题目:

这是一个组合电路。读一下仿真波形,确定电路的功能,然后实现它。

答案:

1.真值表

|---|---|---|
| a | b | q |
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |

2.逻辑表达式

q = a & b;

3.代码

复制代码
module top_module (
    input a,
    input b,
    output q );//

    assign q = a & b; // Fix me

endmodule

2 Combinational circuit 2

题目:

这是一个组合电路。读一下仿真波形,确定电路的功能,然后实现它。

答案:

1.卡诺图化简

根据波形可得:

2.逻辑表达式

根据卡诺图可发现规律:

q = (~(a^b) && ~(c^d)) || ((a^b) && (c^d));

3.代码

复制代码
module top_module (
    input a,
    input b,
    input c,
    input d,
    output q );//

    assign q = (~(a^b) && ~(c^d)) || ((a^b) && (c^d)); // Fix me

endmodule

3 Combinational circuit 3

题目:

这是一个组合电路。读一下仿真波形,确定电路的功能,然后实现它。

答案:

1.卡诺图

2.逻辑表达式

q = a&c | a&d | b&c | b&d;

3.代码

复制代码
module top_module (
    input a,
    input b,
    input c,
    input d,
    output q );//

    assign q = a&c | a&d | b&c | b&d; // Fix me

endmodule

4 Combinational circuit 4

题目:

这是一个组合电路。读一下仿真波形,确定电路的功能,然后实现它。

答案:

1.卡诺图

2.逻辑表达式

q = b | c;

3.代码

复制代码
module top_module (
    input a,
    input b,
    input c,
    input d,
    output q );//

    assign q = b | c; // Fix me

endmodule

5 Combinational circuit 5

题目:

这是一个组合电路。读一下仿真波形,确定电路的功能,然后实现它。

答案:

复制代码
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@(*)begin
        q = 4'hf;
        case(c)
            4'h0 : q = b;
            4'h1 : q = e;
            4'h2 : q = a;
            4'h3 : q = d;
        endcase
    end
    
endmodule

6 Combinational circuit 6

题目:

这是一个组合电路。读一下仿真波形,确定电路的功能,然后实现它。

答案:

复制代码
module top_module (
    input [2:0] a,
    output [15:0] q ); 
        
    always@(*)begin
        case(a)
            3'h0 : q = 16'h1232;
            3'h1 : q = 16'haee0;
            3'h2 : q = 16'h27d4;
            3'h3 : q = 16'h5a0e;
            3'h4 : q = 16'h2066;
            3'h5 : q = 16'h64ce;
            3'h6 : q = 16'hc526;
            3'h7 : q = 16'h2f19;
        endcase
    end
    
endmodule

7 Sequential circuit 7

题目:

这是一个时序电路。读一下仿真波形,确定电路的功能,然后实现它。

答案:

复制代码
module top_module (
    input clk,
    input a,
    output q );
    
    always@(posedge clk)begin
        if(a)
            q <= 0;
        else
            q <= 1;
    end
    
endmodule

8 Sequential circuit 8

题目:

这是一个时序电路。读一下仿真波形,确定电路的功能,然后实现它。

答案:

复制代码
module top_module (
    input clock,
    input a,
    output p,
    output q );
    
    //p
    always@(*)begin
        if(clock)
            p = a;
        else
            p = p;
    end
    
    //q
    always@(negedge clock)begin
        q <= p;
    end
    
endmodule

知识点:

如图,p 为 "clock = 1"时 a 的信号,q 为时钟下降沿时 p 的信号。


9 Sequential circuit 9

题目:

这是一个时序电路。读一下仿真波形,确定电路的功能,然后实现它。

答案:

复制代码
module top_module (
    input clk,
    input a,
    output [3:0] q );
    
    always@(posedge clk)begin
        if(a)begin
            q <= 4'h4;
        end
        else if(q == 4'h6)begin
            q <= 4'h0;
        end
        else begin
            q <= q + 1;
        end
    end
    
endmodule

10 Sequential circuit 10

题目:

这是一个顺序电路。该电路由组合逻辑和一位内存(即一个触发器)组成。触发器的输出已通过输出 state 可观察。

读取模拟波形以确定电路的功能,然后实现它。

答案:

1.真值表

|---|---|-------|---|------------|
| a | b | state | q | state_next |
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |

2.电路逻辑

q:当a、b、state中高电平的个数为奇数时,q为1,即q是一个偶校验位。

state_next:

由卡诺图化简可得,state_next = a & b | a & state | b & state;

3.代码

复制代码
module top_module (
    input clk,
    input a,
    input b,
    output q,
    output state  );
    
    //q
    always@(*)begin
        q = a ^ b ^ state;
    end
    
    //state
    always@(posedge clk)begin
        if(a & b | a & state | b & state)begin
            state <= 1;
        end
        else begin
            state <= 0;
        end
    end
    
endmodule

- END -

公z号/CSDN/知乎搜索【望森FPGA】,查看更多FPGA资讯~

相关推荐文章,点击跳转:

望森FPGA的HDLBits合集

相关推荐
国科安芯15 小时前
可更换的心脏:ASP4644S2B电源模块与模块化卫星在轨可维护供电架构
单片机·fpga开发·架构·电源模块·低轨卫星·抗辐射
国科安芯16 小时前
看不见的地基:ASP4644S2B四通道电源模块与星载电源分配网络的完整性设计
网络·嵌入式硬件·fpga开发·adc·电源模块·抗辐射·载荷
叼烟扛炮18 小时前
[LangChain] 学习笔记(026):模型根本没有记忆——「多轮对话」是你每次把历史重发一遍
笔记·学习·langchain
MDYFPGA19 小时前
CO5650 Kintex-7核心板选型:DDR、接口与旧工程复用
fpga开发·fpga
MSTcheng.1 天前
【LinuxIO篇】Linux学习第二十三弹——fopen和open有什么区别?从 FILE* 到 fd,讲透 Linux 文件 IO
linux·运维·学习·io·系统调用·fd
Z21-X1 天前
云原生运维学习笔记:Kubernetes Service 发现、类型与 kube-proxy 实战
运维·笔记·学习·云原生·kubernetes
sealaugh321 天前
powerbi学习笔记(day2)powerbi进阶
笔记·学习·powerbi
LabVIEW开发2 天前
FPGA 目标未填 Resource Name 无法运行
fpga开发
叼烟扛炮2 天前
[LangChain] 学习笔记(24):流式不改总耗时,只改「多久看到第一个字」——实测差 3 倍
笔记·学习·langchain
半扇排骨3 天前
特别篇:在线 XSS 靶场 haozi 分享与通关笔记
学习·安全·靶场·xss