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




沒有留言:

張貼留言

RFID TI 培訓影片系列

RFID TI 培訓影片系列  https://www.ti.com/zh-tw/video/series/rfid.html 培訓影片系列 RFID 隨著創新技術日益發展,RFID 和 RF 術語越來越容易讓人混淆。本訓練系列詳細介紹了使用案例、權衡技術優缺點,讓您清楚知道該選...