Circuits--Verification--Finding Bug

  1. MUX

    module top_module (
    input sel,
    input [7:0] a,
    input [7:0] b,
    output [7:0] out );

    复制代码
     assign out = sel ? a : b;

    endmodule

2.NAND

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

    wire t;
    andgate inst1 (t,a,b,c,1'b1,1'b1);
    assign out = ~t;

endmodule
  1. 4-1MUX

    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 ); //

    复制代码
     wire [7:0]m0, m1;
     mux2 mux0 ( sel[0],    a,    b, m0 );
     mux2 mux1 ( sel[0],    c,    d, m1 );
     mux2 mux2 ( sel[1], m0, m1,  out );

    endmodule

4.Add/Sub

复制代码
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

    end
    always@(*)
        begin
            if (out == 0)
            	result_is_zero = 1;
            else
                result_is_zero = 0;
        end
        
endmodule

5.Case Statement

复制代码
module top_module (
    input [7:0] code,
    output reg [3:0] out,
    output reg valid);//

     always @(*) begin
         case (code)
            8'h45: out = 4'd0;
            8'h16: out = 4'd1;
            8'h1e: out = 4'd2;
            8'h26: out = 4'd3;
            8'h25: out = 4'd4;
            8'h2e: out = 4'd5;
            8'h36: out = 4'd6;
            8'h3d: out = 4'd7;
            8'h3e: out = 4'd8;
            8'h46: out = 4'd9;
            default: out = 4'd0;
        endcase

         if(out == 4'd0 && code != 8'h45) 
            valid = 1'b0;
        else
            valid = 1'b1;
     end
     		              
endmodule
相关推荐
国科安芯26 分钟前
航天电子模拟前端三大支柱:精密运放、高速运放与电压监控的协同设计方法——ASL8522S/ASL622S/ASL706S技术解析
前端·单片机·嵌入式硬件·fpga开发·架构·安全性测试
泰晶科技35 分钟前
【前装供应链实操笔记:车规晶振背后AEC-Q100与Q200的绑定关系】
笔记
神明不懂浪漫1 小时前
【第四章】CSS(二)——文本外观属性与复合选择器
前端·css·经验分享·笔记
栈溢出了4 小时前
Redis 分片集群与哈希槽笔记
java·redis·笔记·spring
我命由我123454 小时前
复利极简理解
经验分享·笔记·学习·职场和发展·求职招聘·职场发展·学习方法
AOwhisky5 小时前
Python 学习笔记(第三期)——流程控制核心知识点自测与详解
开发语言·笔记·python·学习·云原生·运维开发·流程控制
我命由我123456 小时前
72 法则极简理解
经验分享·笔记·学习·职场和发展·求职招聘·职场发展·学习方法
xian_wwq7 小时前
【学习笔记】OpenAI 兼容 API 服务化:从协议到 LLM Gateway(19/35)
笔记·学习
醉城夜风~9 小时前
SQL DQL数据查询语言全套学习笔记(基础查询→执行顺序全解析)
笔记·sql·学习
小L~~~9 小时前
MLIR学习笔记
笔记·学习·mlir