HDLBits个人刷题详解合集17-Verification:Reading Simulations-Finding bugs in code-HDBits题目分析

Bugs mux2

此 8 位宽 2 对 1 多路复用器不工作。修复错误。

代码如下:

module top_module (

    input sel,

    input [7:0] a,

    input [7:0] b,

    output [7:0] out  );


    //assign out = (~sel & a) | (sel & b);按位与

    assign out = sel ? a : b;

endmodule

Bugs nand3

这个三输入 NAND 门不起作用。修复错误。

您必须使用提供的 5 输入 AND 门:

module andgate ( output out, input a, input b, input c, input d, input e );

代码如下:

module top_module (input a, input b, input c, output out);//

wire outt;

    //andgate inst1 ( a, b, c, out );例化操作

    andgate inst1 (outt, a, b, c, 1'b1, 1'b1);

assign out = ~outt;

endmodule

Bugs mux4

此 4 对 1 多路复用器不起作用。修复错误。

为您提供无错误的 2 对 1 多路复用器:

module mux2 (

    input sel,

    input [7:0] a,

    input [7:0] b,

    output [7:0] out

);

代码如下:

module top_module (

    input [1:0] sel,

    input [7:0] a,

    input [7:0] b,

    input [7:0] c,

    input [7:0] d,

    output [7:0] out  ); //


    /*

    1、线的名称和模块例化的名称应该不一样;

    2、定义线的位宽应改为8位;

    3、sel[1]

    wire mux0, mux1;

    mux2 mux0 ( sel[0],    a,    b, mux0 );

    mux2 mux1 ( sel[1],    c,    d, mux1 );

    mux2 mux2 ( sel[1], mux0, mux1,  out );*/

    wire [7:0] mux0, mux1;

    mux2 mux_0 ( sel[0],    a,    b, mux0 );

    mux2 mux_1 ( sel[0],    c,    d, mux1 );

    mux2 mux_2 ( sel[1], mux0, mux1,  out );


endmodule

Bugs addsubz

以下带有零标志的加法器-减法器不起作用。修复错误。

代码如下:

// synthesis verilog_input_version verilog_2001

module top_module (

    input do_sub,

    input [7:0] a,

    input [7:0] b,

    output reg [7:0] out,

    output reg result_is_zero

);//


    always @(*) begin

        case (do_sub)

          0: out = a+b;

          1: out = a-b;

        endcase

//锁存器

        if (!out)

            result_is_zero = 1;

        else

            result_is_zero = 0;

    end


endmodule

Bugs case

这个组合电路应该识别键 0 到 9 的 8 位键盘扫描码。它应指示 10 个案例中的一个是否被识别(有效),如果是,则检测到哪个密钥。修复错误。

代码如下:

module top_module (

    input [7:0] code,

    output reg [3:0] out,

    output reg valid );//


    always @(*)begin

        out = 0;

        valid = 1;

        case (code)

            8'h45: out = 0;

            8'h16: out = 1;

            8'h1e: out = 2;

            8'h26: out = 3;

            8'h25: out = 4;

            8'h2e: out = 5;

            8'h36: out = 6;

            8'h3d: out = 7;

            8'h3e: out = 8;

            8'h46: out = 9;

            default: valid = 0;

        endcase

    end

endmodule

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当你遇到 "/usr/bin/ssh-copy-id: ERROR: Host key verification failed." 错误时,这意味着SSH主机密钥验证失败。主机密钥验证是SSH连接过程中的一个安全步骤,用于确保你连接的主机是可信的。 解决这个问的一个方法是通过在ssh命令中添加选项来禁用主机密钥验证。你可以使用下面的命令来完成这个操作: ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@192.168.125.112 这个命令中的"-o StrictHostKeyChecking=no"选项将禁用主机密钥验证,"-o UserKnownHostsFile=/dev/null"选项将指定一个空文件来存储已知主机密钥。 另一个可能的原因是你尝试在本地计算机上添加一个密钥,但是在目标主机上找不到相应的密钥文件。你可以使用ssh-keygen命令生成一对新的密钥,并将公钥复制到目标主机上的正确位置。下面是一个生成新密钥并复制到目标主机的步骤: 1. 在本地计算机上使用ssh-keygen命令生成一对新的密钥。你可以使用以下命令: ssh-keygen 2. 进入生成的密钥文件所在的目录。默认情况下,它们将位于~/.ssh/目录下。 cd ~/.ssh/ 3. 复制公钥文件到目标主机上的正确位置。你可以使用以下命令: ssh-copy-id -i id_rsa.pub root@192.168.125.112 请确保将以上命令中的 "root@192.168.125.112" 替换为目标主机的用户名和IP地址。 4. 输入目标主机的密码以完成复制过程。 请尝试以上方法,并确保你的密钥正确复制到了目标主机上的正确位置。如果问仍然存在,请检查目标主机上的SSH配置和主机密钥文件是否正确,并确保你的连接设置正确。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值