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 分钟前
Ⅰ人工智能学习的核心概念概述+线性回归(1)
人工智能·学习
FPGA_ADDA27 分钟前
全国产复旦微FMQL100TAI 核心板
fpga开发·信号处理·全国产·fmql100tai·zynq7国产化
2301_7833601341 分钟前
R语言 | 带重要性相关热图和贡献图如何解释?如何绘制随机森林计算结果重要性及相关性图?[学习笔记]
学习·随机森林·r语言
Terasic友晶科技1 小时前
5-基于C5G 开发板的FPGA 串口通信设计 (FT232R, Altera UART IP和Nios II系统串口收发命令)
fpga开发·串口·uart·c5g
爱敲代码的loopy1 小时前
verilog-正弦波生成器
fpga开发
潲爺1 小时前
Java IDEA学习之路:第九周课程笔记归纳
java·学习·intellij-idea
石像鬼₧魂石1 小时前
192.168.1.4(Windows 靶机)渗透测试练习全流程(详细步骤)
windows·学习
GLAB-Mary2 小时前
HCIE最优规划路线:如何系统性学习华为认证?
学习·华为·华为认证·hcie·数通
月下倩影时2 小时前
视觉学习——卷积与神经网络:从原理到应用(量大管饱)
人工智能·神经网络·学习
d111111111d2 小时前
STM32外设学习-串口数据包笔记-(程序)
笔记·stm32·单片机·嵌入式硬件·学习