Posts

Showing posts with the label engineering notes

Verilog 18: Compiler Directives and Preprocessor Commands

Image
1. Why Learn Compiler Directives? Before we even write a line of HDL, let’s answer a simple question: “When the Verilog compiler reads your code, how does it know what to include, what to skip, what constants to use, and how to interpret time?” The answer lies in compiler directives — special preprocessor instructions that guide the compiler before actual synthesis or simulation begins. They don’t create flip‑flops, gates, or signals; instead, they control the environment in which your design is understood and simulated. Think of it this way: Your Verilog compiler is like a translator. Directives are the translator’s instructions : “Before you translate, read this extra file,” “Replace this word everywhere,” “If the designer says debug is on, include extra print statements,” etc. Without these, large designs become unmanageable — hundreds of modules, testbenches, and configurations would be impossible to maintain. 2. The Preprocessor: What Happens Before Compil...

Verilog 12 : Continuous Assignment Statements in Verilog

Image
 Continuous Assignment Statements in Verilog In Verilog, continuous assignment statements are used to drive nets (such as wire ). They continuously evaluate the expression on the right-hand side and update the net whenever any input signal changes. These statements are commonly used in combinational circuits , bus systems , and Tri-State buffer designs . Unlike procedural assignments (which execute sequentially inside always or initial blocks), continuous assignments operate concurrently —they always stay active. 🔹 Key Characteristics Continuous assignments drive wire nets directly. Typically used for combinational logic and Tri-State modeling . Declared outside procedural blocks ( always , initial ). They override procedural assignments to the same net. The LHS (left-hand side) must always be a net type , such as wire . Can include delay and drive strength specifications. 🧩 Syntax assign (drive_strength) #(delay) net_name = expression; d...