2021年5月11日 星期二

HBLbits_Verilog Basic_Sim/circuit10

 HBLbits_Verilog Basic_Sim/circuit10

This is a sequential circuit. The circuit consists of combinational logic and one bit of memory (i.e., one flip-flop). The output of the flip-flop has been made observable through the output state.

Read the simulation waveforms to determine what the circuit does, then implement it.

module top_module (
    input clk,
    input a,
    input b,
    output q,
    output state  );
    always@(posedge clk)begin
        if(a == b)begin
        state <= a;
        end
    end
    
    always@(*)begin
        q = a & ~b & ~state | ~a & ~b & state | a & b & state | ~a & b & ~state;
    end
endmodule


//另一方法

module top_module (
    input clk,
    input a,
    input b,
    output q,
    output state  );
   
    always@(posedge clk)begin
        if(a == b)begin
        state <= a;
        end
    end
    assign q = (a == b) ? state : ~state;
endmodule

沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...