Connect one input a to three outputs y1, y2, and y3 using wires. All outputs must always match the input.
Requirements:
Module Name: top_module
Inputs: a (1-bit)
Outputs: y1, y2, y3 (1-bit each)

Every design in Verilog starts with a module. A module is like a “box” with inputs and outputs that describes how signals are connected or processed.
Structure:
module module_name (
input a, // Port declarations
input b,
output y
);
// Internal signals (optional)
wire w;
// Logic description
assign y = a & b; // continuous assignment
endmodule

Equivalent verilog code:
// Sample top_module (and gate) in verilog
module top_module(
input a, // for all input/output default type is wire
input b,
output y
);
assign y = a & b;
endmodule
How to Use wire
Characteristics of wire
Multiple Drivers
👉 Beginners don’t usually need this immediately, but it explains why fan-out (1 source → many loads) is fine, but fan-in (many sources → 1 wire) needs caution.
đź’ˇAnalogy for Beginners
Think of a wire as a hose:
Bitwise NOT (~)
Flips every bit. Directly maps to NOT gate.
Example:
assign y = ~a; // Inverter
Truth table:
| a | y |
|---|---|
| 0 | 1 |
| 1 | 0 |
Bitwise AND (&)
The result is 1 if both inputs are 1. Directly maps to AND gate.
Example:
assign y = a & b; // AND gate
Bitwise OR (|)
The result is 1 if at least one input is 1. Directly maps to OR gate.
Example:
assign y = a | b; // OR gate
Bitwise XOR (^)
The result is 1 if inputs are different. Directly maps to XOR gate.
Example:
assign y = a ^ b; // XOR gate