Posts

Showing posts with the label Digital Logic Design

Verilog 11 : Looping Statements in Verilog

Image
Looping Statements in Verilog – forever, repeat, while, and for Explained In Verilog , looping statements are used to execute a block of code multiple times , just like in traditional programming languages such as C or Python. However, in Verilog, loops are allowed only inside procedural blocks like initial or always . These loops help designers perform repetitive tasks efficiently — such as generating clocks, testing data, or initializing memories. Let’s explore the four types of looping statements in Verilog with syntax, examples, and clear explanations. 🧩 Types of Looping Statements in Verilog Verilog supports the following four types of loops: forever repeat while for 🟠 1. The forever Loop The forever statement runs continuously without end . As its name suggests, it repeats the block of code indefinitely — until the simulation is manually stopped or a $finish statement is reached. This type of loop is often used in testbenches for generating fr...

Verilog 10 : Conditional Statement in Verilog

Image
 The Conditional Statement in Verilog: if-else, case, casex, and casez Explained In digital design, conditional statements are the backbone of decision-making in hardware description languages like Verilog . They control the flow of execution in your code, determining which set of statements should execute when certain conditions are met. In this post, we’ll explore the if-else , nested if , parallel if , and case statements — including their special forms casez and casex — with clear syntax, examples, and simulation outputs. 🔹 Understanding Conditional Statements in Verilog Conditional statements help you control when and how certain parts of your Verilog code execute. These are mainly used inside procedural blocks such as always or initial . The key conditional statements are: if and if-else nested if-else parallel if case , casez , and casex ⚙️ 1. The if-else Statement in Verilog The if-else statement is used to make decisions based on conditi...

VERILOG : 6. Primitives, Gate and Switch Delays in verilog

Image
     When we design digital circuits in Verilog , we often rely on primitives —the building blocks of complex systems. These are the lowest-level components (gates, switches, buffers, etc.) that mimic real hardware behavior. Understanding how to design using primitives is crucial, especially in ASIC (Application-Specific Integrated Circuit) and library development . In this blog, we’ll cover: ✅ What Verilog primitives are ✅ How delays are modeled (rise, fall, turn-off, min/typ/max) ✅ Examples of gate delays with testbenches ✅ N-input and N-output primitives ✅ Building complex circuits (AND gate, D-Flip-Flop, Multiplexer) using primitives Let’s dive in 🚀 🔹 What are Verilog Primitives? Primitives are the basic logic gates and switches provided by Verilog. They are built-in keywords like and , or , not , buf , etc. They do not require module definitions (unlike user-defined modules). ASIC vendors often use User-Defined Primitives (UDP) and standard gate...

VERILOG :4. Hierarchical Identifiers, Nets, Registers, and Strings

Image
Verilog is one of the most widely used Hardware Description Languages (HDL) in digital system design . Whether you are building a simple counter or a complex processor, understanding the building blocks like nets, registers, strings, and hierarchical identifiers is essential. In this blog, we’ll dive into these concepts with easy-to-follow explanations, practical examples, and diagrams to support learning. 🔹 1. Hierarchical Identifiers in Verilog In Verilog, a hierarchical identifier allows you to reference variables, nets, or registers inside lower-level modules from a higher-level module (like the testbench). 👉 Why it matters? It helps in debugging and monitoring signals deep inside a design without modifying the module code. Example: Hierarchical Monitoring module full_adder ( input a, b, cin, output sum, cout ); assign {cout, sum} = a + b + cin; endmodule module adder_hier ; wire [3:0] A, B, Sum; wire Cout; full_adder u0 (A[0], B[0], 1'b0, Su...