HDLBits 刷题之我的代码(全)—(Verification_Reading Simulations-Build a circuit from a simulation waveform)

19 篇文章 0 订阅

#1

module top_module (
    input a,
    input b,
    output q );//

    assign q = a & b; // Fix me

endmodule

#2

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

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

endmodule

#3

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

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

endmodule

#4

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

    assign q = b | c; // Fix me

endmodule

#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
        case(c)
            0: q = b;
            1: q = e;
            2: q = a;
            3: q = d;
            default: q = 'hf;
        endcase
    end
endmodule

#6

module top_module (
    input [2:0] a,
    output [15:0] q ); 
    always @(*) begin
        case(a) 
            0: q = 'h1232;
            1: q = 'haee0;
            2: q = 'h27d4;
            3: q = 'h5a0e;
            4: q = 'h2066;
            5: q = 'h64ce;
            6: q = 'hc526;
            7: q = 'h2f19;
            default: q = 'h1232;
        endcase
    end
endmodule

#7

module top_module (
    input clk,
    input a,
    output q );
    always @(posedge clk) begin
		q <= ~a;   
    end
endmodule

#8

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

#9

module top_module (
    input clk,
    input a,
    output [3:0] q );
    always @(posedge clk) begin
        if(a == 'd1) begin
            q <= 'd4;
        end
        else begin
            if(q == 'd6) 
                q <= 'd0;
            else
                q <= q + 'd1;
        end
    end
endmodule

#10

module top_module (
    input clk,
    input a,
    input b,
    output q,
    output state  );
    reg nstate;
    always @(*) begin
        case(state)
            0: begin
                if(a && b)
                    nstate <= 1;
                else
                    nstate <= 0;
            end
            1: begin
                if((~a) && (~b))
                    nstate <= 0;
                else
                    nstate <= 1;
            end
            default: nstate <= 0;
        endcase
    end
    always @(posedge clk) begin
        state <= nstate;
    end
    
    assign q = state ? (a ^~ b):(a ^ b);

endmodule

#11

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值