Menu
Coddy logo textTech

Zusammenfassung – Operator-Challenge

Teil des Abschnitts Grundlagen der Verilog-Journey von Coddy — Lektion 29 von 90.

challenge icon

Aufgabe

Vervollständigen Sie den Code, indem Sie die korrekten Ausdrücke für jede Aufgabe schreiben. Diese Herausforderung deckt alle Operatoren aus diesem Kapitel ab.

Was zu tun ist:

  1. Logisch: Prüfen Sie, ob sowohl value1 als auch value2 ungleich Null sind, und speichern Sie das Ergebnis in logic_out
  2. Reduktion: Prüfen Sie, ob alle Bits von vector 1 sind, und speichern Sie das Ergebnis in reduction_out
  3. Shift: Verschieben Sie data um 2 Bits nach links und speichern Sie das Ergebnis in shift_out
  4. Verkettung: Kombinieren Sie high und low zu einem 8-Bit-Wert und speichern Sie das Ergebnis in concat_out
  5. Bedingt: Speichern Sie den größeren Wert von `a` und `b` in cond_out

Probier es selbst

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
    // Logisch
    value1 = 4'd6;
    value2 = 4'd0;
    logic_out = ______;   // Prüfen, ob sowohl value1 als auch value2 ungleich Null sind
    
    // Reduktion
    vector = 4'b1111;
    reduction_out = ______;   // Check if all bits of vector are 1
    
    // Shift
    data = 8'b00001111;
    shift_out = ______;   // Verschiebe data um 2 Bits nach links
    
    // Verkettung
    high = 4'b1010;
    low = 4'b1100;
    concat_out = ______;   // Kombiniere high und low zu einem 8-Bit-Wert
    
    // Bedingt
    a = 4'd7;
    b = 4'd12;
    cond_out = ______;   // Speichere den größeren Wert von `a` und `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

Alle Lektionen in Grundlagen