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




沒有留言:

張貼留言

2026 作業3 RFID+ Telegram 練習

 2026 作業3  RFID+ Telegram  練習 (Wokwi 與 Telegram 二者溝通訊息反映比較慢 ) 歡迎 Alex 使用 RFID 控制系統 /on : 開啟 LED /off : 關閉 LED /flash : 閃爍模式 /timer : 開啟 5 秒 ...