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合集

相关推荐
三三木木七18 分钟前
AI超级智能体学习笔记
笔记·学习
一只小风华~1 小时前
Vue Router 的三种历史模式详解
前端·javascript·vue.js·笔记·学习·前端框架·ecmascript
易享电子1 小时前
基于单片机电器断路器保护器系统Proteus仿真(含全部资料)
单片机·嵌入式硬件·fpga开发·51单片机·proteus
酌量2 小时前
路径平滑优化详解(二次规划): 数学建模与目标函数推导
经验分享·笔记·学习·机器人·自动驾驶
爱倒腾的老唐4 小时前
01、如何学习单片机
单片机·嵌入式硬件·学习
于小汐在咯9 小时前
词根学习笔记 | Agri系列
笔记·学习
霜绛10 小时前
Unity:Json笔记——Json文件格式、JsonUtlity序列化和反序列化
学习·unity·json·游戏引擎
我命由我1234511 小时前
Excel - Excel 列出一列中所有不重复数据
经验分享·学习·职场和发展·word·powerpoint·excel·职场发展
璞致电子12 小时前
fpga开发板ZYNQ 璞致 PZ7010/7020 邮票孔核心板简介-ZYNQ7000系列小系统学习板
linux·嵌入式硬件·学习·fpga开发·fpga·fpga开发板·xilinx开发板
Miki Makimura12 小时前
Reactor 模式实现:从 epoll 到高并发调试
运维·服务器·c++·学习