2021年4月25日 星期日

HBLbits_Verilog Basic_Mt2015 muxdff

HBLbits_Verilog Basic_Mt2015 muxdff

Taken from ECE253 2015 midterm question 5

Consider the sequential circuit below:


Assume that you want to implement hierarchical Verilog code for this circuit, using three instantiations of a submodule that has a flip-flop and multiplexer in it. Write a Verilog module (containing one flip-flop and multiplexer) named top_module for this submodule.

module top_module (
input clk,
input L,
input r_in,
input q_in,
output reg Q);
  wire d;
    always@(posedge clk)
        Q<=d;
    assign d=(L)?r_in:q_in;
 endmodule
//另一方法
module top_module (
input clk,
input L,
input r_in,
input q_in,
output reg Q);
    
    always @ (posedge clk) begin
        case (L)
            1'b0 : Q <= q_in;
            1'b1 : Q <= r_in;
        endcase    
    end
endmodule




沒有留言:

張貼留言

Telegram +ESP32自動發報機

  Telegram   +ESP32自動發報機 這套系統是一個典型的 IoT(物聯網)架構 ,結合了遠端配置(Python)、通訊中介(MQTT)與硬體執行(ESP32)。 以下我為您拆解這兩支程式的核心運作原理: 一、 系統架構流程 Python 端 (控制台) :使用者輸入...