Menu
Coddy logo textTech

복습 - 연산자 챌린지

Coddy Verilog 여정의 기초 섹션에 포함된 레슨 — 90개 중 29번째.

challenge icon

챌린지

각 작업에 대한 올바른 표현식을 작성하여 코드를 완성하세요. 이 챌린지는 이 장의 모든 연산자를 다룹니다.

수행할 작업:

  1. Logical: value1value2가 모두 non-zero인지 Check하고, logic_out에 Store하세요.
  2. Reduction: vector의 all bits가 1인지 Check하고, reduction_out에 Store하세요.
  3. Shift: data를 left로 2 bits만큼 Shift하고, shift_out에 Store하세요.
  4. Concatenation: highlow를 8-bit 값으로 Combine하여 concat_out에 Store하세요.
  5. Conditional: `a`와 `b` 중 larger한 값을 cond_out에 Store하세요.

직접 해보기

module operator_challenge;
  reg [3:0] value1, value2;
  reg logic_out;
  
  reg [3:0] vector;
  reg reduction_out;
  
  reg [7:0] data;
  reg [7:0] shift_out;
  
  reg [3:0] high, low;
  reg [7:0] concat_out;
  
  reg [3:0] a, b;
  reg [3:0] cond_out;
  
  initial begin
    // 논리
    value1 = 4'd6;
    value2 = 4'd0;
    logic_out = ______;   // value1과 value2가 모두 0이 아닌지 확인
    
    // 리덕션
    vector = 4'b1111;
    reduction_out = ______;   // Check if all bits of vector are 1
    
    // Shift
    data = 8'b00001111;
    shift_out = ______;   // data를 왼쪽으로 2비트 시프트
    
    // 연결
    high = 4'b1010;
    low = 4'b1100;
    concat_out = ______;   // high와 low를 8비트 값으로 결합
    
    // 조건
    a = 4'd7;
    b = 4'd12;
    cond_out = ______;   // `a`와 `b` 중 더 큰 값을 저장
    
    $display("6 && 0 = %d", logic_out);
    $display("&4'b1111 = %d", reduction_out);
    $display("00001111 << 2 = %b", shift_out);
    $display("{1010, 1100} = %b", concat_out);
    $display("max(7, 12) = %d", cond_out);
    $finish;
  end
endmodule

기초의 모든 레슨