SystemVerilog

Verilog

A programming language for describing hardware. Lets you programmatically describe the behavior you want, giving you the ability to test things beforehand with simulation. Help prevents hurting your hardware.

Syntax can be similar to C, but behavior is different. SystemVerilog is a superset of the older Verilog. Will refer to SV as Verilog.

Primitives

Nets (wire): transmit value of a connected source.

Variables (reg): variable Voltage source.

Values

Modules

Execution

You can't turn wires off. They transmit voltages near instantly. Gates and modules are constantly performing computation, which can be hard to keep track of.

In pure hardware, there is no notion of initialization. Wires can naturally pick up voltages from their enviornment.

Structural Verilog

// SystemVerilog code for AND-OR-INVERT circuit
module AOI (F, A, B, C, D);
    output logic F;                     // each variable
    input logic A, B, C, D;             // is 1-bit (logic)

    assign F = ~((A & B) | (C & D));    // continuous assignment
endmodule
// end of SystemVerilog code

Equivalently with wires

// SystemVerilog code for AND-OR-INVERT circuit
module AOI (F, A, B, C, D);
    output logic F;
    input logic A, B, C, D;
    logic AB, CD, O; // now necessary

    assign AB = A & B;
    assign CD = C & D;
    assign O = AB | CD;
    assign F = ~O;
endmodule

Equivalently with gates

// SystemVerilog code for AND-OR-INVERT circuit
module AOI (F, A, B, C, D);
    output logic F;
    input logic A, B, C, D;
    logic AB, CD, O; // now necessary

    // and is the module name. a1 is the instance name
    // AB, A, B are port connections
    and a1(AB, A, B);
    and a2(CD, C, D);
    or o1(O, AB, CD);
    not n1(F, O);
endmodule

2-input MUX

// SystemVerilog code for AND-OR-INVERT circuit
module AOI (F, A, B, C, D);
    output logic F;
    input logic A, B, C, D;

    assign F = ~((A & B)|(C & D));
endmodule
// 2:1 multiplexer built on top of AOI module
module MUX2 (V, SEL, I, J);
    output logic V;
    input logic SEL, I, J;
    logic SELN, VN;

    not G1 (SELN, SEL);
    // order of ports matter. this is explicit
    // port assignment
    AOI G2 (.F(VN), .A(I), .B(SEL), .C(SELN), .D(J));
    not G3 (V, VN);
endmodule