본문 바로가기

Verilog/HDLbits

[HDLBits] Always if2

1. 문제 및 설명

  • 아래 코드가 의도하지 않은 래치가 발생하지 않도록 수정하시오.

2. 모듈 정의

module top_module (
    input      cpu_overheated,
    output reg shut_off_computer,
    input      arrived,
    input      gas_tank_empty,
    output reg keep_driving  );

 

 

 

3. 답

// synthesis verilog_input_version verilog_2001
module top_module (
    input      cpu_overheated,
    output reg shut_off_computer,
    input      arrived,
    input      gas_tank_empty,
    output reg keep_driving  ); //

    always @(*) begin
        if (cpu_overheated)
           shut_off_computer = 1;
    end

    always @(*) begin
        if (~arrived)
           keep_driving = ~gas_tank_empty;
    end

endmodule
 

'Verilog > HDLbits' 카테고리의 다른 글

[HDLBits] Always case2  (0) 2025.11.24
[HDLBits] Always case  (0) 2025.11.23
[HDLBits] Always if  (0) 2025.11.23
[HDLBits] Alwaysblock2  (0) 2025.11.18
[HDLBits] Alwaysblock1  (0) 2025.11.18