Recap - Simple Math
Teil des Abschnitts Grundlagen der Verilog-Journey von Coddy. Lektion 22 von 90.
Aufgabe
Vervollständige den Code, indem du die korrekten arithmetischen und Vergleichsausdrücke schreibst.
Was zu tun ist:
- Berechne
a + bund speichere das Ergebnis inadd - Berechne
a - bund speichere das Ergebnis insub - Berechne
a * bund speichere das Ergebnis inmul - Berechne
a / bund speichere das Ergebnis indiv - Berechne
a % bund speichere das Ergebnis inmod - Prüfe, ob
agrößer alsbist, und speichere das Ergebnis ingt - Prüfe, ob
agleichbist, und speichere das Ergebnis ineq
Probier es selbst
module simple_math_challenge;
reg [3:0] a, b;
reg [7:0] add, sub, mul, div, mod;
reg gt, eq;
initial begin
a = 4'd13;
b = 4'd4;
add = ______; // a + b
sub = ______; // a - b
mul = ______; // a * b
div = ______; // a / b
mod = ______; // a % b
gt = ______; // a > b
eq = ______; // a == b
$display("13 + 4 = %d", add);
$display("13 - 4 = %d", sub);
$display("13 * 4 = %d", mul);
$display("13 / 4 = %d", div);
$display("13 %% 4 = %d", mod);
$display("13 > 4 = %d", gt);
$display("13 == 4 = %d", eq);
$finish;
end
endmoduleAlle Lektionen in Grundlagen
1Einführung
Was ist VerilogHardware vs. SoftwareIhr erstes ModulKommentareAbstraktionsebenen des Designs4Operators Part 1
Arithmetic OperatorsModulo OperatorComparison OperatorsRecap - Simple MathBitwise Operators7Assign And Gates
Continuous AssignmentAssign With OperatorsBuilt In Gate PrimitivesAND OR NOT GatesXOR XNOR GatesRecap - Logic Gate Circuit10Decision Making
If StatementIf - ElseRecap - Simple ComparatorCase StatementCasex And CasezRecap - ALU Design5Operators Part 2
Logical OperatorsReduction OperatorsShift OperatorsConcatenation OperatorConditional OperatorRecap - Operator Challenge3Number System
Binary RepresentationSized NumbersUnsized NumbersNegative NumbersSpecial Values X And ZRecap - Number Formats6Modules
Module StructureInput And Output PortsInout PortsModule InstantiationPort Mapping By NamePort Mapping By OrderRecap - Build A Module9Procedural Blocks
Always BlockInitial BlockSensitivity ListBlocking AssignmentNon Blocking AssignmentRecap - Always vs Initial15Traffic Light Controller
Defining The StatesState Machine LogicÜbe selbstständig: Online-Verilog-Compiler