HDLBits(5)----D latch

2021/11/16 23:40:34

本文主要是介绍HDLBits(5)----D latch,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

目录

    • 1. D latch
    • 2. Exams/m2014 q4d
    • 3. Exams/2014 q4a
    • 4. Exams/ece241 2014 q

1. D latch

Implement the following circuit:
在这里插入图片描述Note that this is a latch, so a Quartus warning about having inferred a latch is expected.

module top_module (
    input d, 
    input ena,
    output q);
    
    always@(*)
        begin
            if(ena) q <= d;     
        end
endmodule

2. Exams/m2014 q4d

在这里插入图片描述

module top_module (
    input clk,
    input in, 
    output out);
    
    always@(posedge clk)
        begin
           out<= out ^in; 
        end

endmodule

3. Exams/2014 q4a

在这里插入图片描述

module top_module (
    input clk,
    input w, R, E, L,
    output reg Q
);
    wire mid_a;
    wire mid_b;
    assign mid_b = L ? R :mid_a;
    assign mid_a = E ? w :Q;
    always@(posedge clk)
        begin
            Q <= mid_b;
            
        end

endmodule

4. Exams/ece241 2014 q

在这里插入图片描述

module top_module (
    input clk,
    input x,
    output z
); 
    reg a,b,c;
    wire D_a,D_b,D_c;
    assign D_a = x ^a;
    assign D_b = x & (!b);
    assign D_c = x | (!c);
    assign z = !(a|b|c);
    always @(posedge clk)
        begin
           a <= D_a;
           b <= D_b;
            c <= D_c;
            
        end

endmodule



这篇关于HDLBits(5)----D latch的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程