Advanced Search
Search Results
18 total results found
1. Understanding Testbench in VHDL
A VHDL testbench is a non-synthesizable VHDL entity used to simulate and verify the functionality of another VHDL entity, often referred to as the Unit Under Test (UUT). Think of it as a virtual lab environment where you can apply a sequence of inputs (stimulu...
2. Components of a Testbench
2.1 Entity Declaration The testbench entity is declared without any ports. It's a self-contained module because it doesn't connect to any higher-level design; it is the top-level entity for the simulation. entity project_tb is -- Empty because testbench do...
3. Testbench Architecture Models
3.1 Testbench for Combinational Circuit There are three architectural models for changing the value of inputs in a testbench. For example, if we want to make a testbench for a half adder entity below, we could use three methods: library IEEE; use IEEE.STD_LOGI...
4. Assert and Report Statement
4.1 Assert Statement The assert statement is used for creating self-checking testbenches. It acts like an automated check that constantly monitors a condition. If the condition is false, it "asserts" a message, alerting us to a problem without requiring us to ...
5. File I/O in VHDL
In VHDL, we can perform file handling using the TextIO library. This feature is very useful for documenting the results of a program that has been created. To use the TextIO library, we need to add it at the beginning of our program as follows: use std.textio....
Extra: Array in VHDL
6.1 Array In VHDL, an array is a collection of elements that share the same data type. You can think of an array as a variable that holds many elements of the same type, and these elements are indexed to be accessed. The index can be a number or another indexa...
1. Main Concept of Hash Map
Hashing is the process of converting data of any size (like a string, number, or object) into a fixed-length integer value. This integer value is called a "hash value," "hash code," or simply "hash." The primary data structure that uses this concept is called ...
2. Collision Handling
A Collision occurs when two or more different keys produce the same hash value (index). For example, "Budi" and "Dina" are both hashed to row #5. We can't overwrite Budi's data. We must have a strategy to handle this. 2.1. Separate Chaining This is the most c...
3. Load Factor and Rehashing
3.1. Load Factor (λ) The Load Factor (λ) is a measure of how full the hash table is. It is a critical metric for performance. Formula: λ = m/n n = total number of items stored in the table. m = total size of the hash table (number of buckets). Impact on Pe...
4. Example: Full Manual Implementation
This chapter combines all the concepts from Chapters 2 and 3 into a single, complete MyHashMap class. This class handles insertion, searching, deletion, and automatic rehashing. 4.1. Manual Implementation Using Separate Chaining #include <iostream> #include <s...
5. Hashing Implementation with C++ STL
In C++, instead of creating a Hash Table manually, you could use Standard Template Library (STL). The STL implementation automatically handles hash functions, collisions, and rehashing when the load factor gets too high. 5.1. std::unordered_map (Key-Value) std...
6. Custom Struct Keys
A notable limitation of the C++ STL's std::unordered_map and std::unordered_set is their inability to natively support user-defined types (such as a struct or class) as keys. An attempt to instantiate a map with a custom struct, as shown below, will result in ...
1. Graphs Concept
A Graph is a non-linear data structure consisting of nodes and edges. The nodes are formally called vertices, and the edges are lines or arcs that connect any two nodes in the graph. Graphs are used to solve many real-world problems. They are used to represen...
2. Graph Representations
A graph is an abstract concept. To store one in a computer's memory, we must translate this idea of vertices and edges into a concrete data structure. The choice of representation is critical, as it dictates the performance and space efficiency of our graph al...
3. Stack and Queue
Before diving into graph traversal, we must understand the two key data structures that power them: std::stack (for DFS) and std::queue (for BFS). 3.1 Introduction to std::stack std::stack is a container adapter in the C++ STL. It's not a container itself, bu...
4. Graph Traversal: Breadth-First Search (BFS)
Breadth-First Search (BFS) is a traversal algorithm that explores the graph "level by level." It starts at a source vertex, explores all of its immediate neighbors, then all of their neighbors, and so on. 4.1 BFS Analogy and Illustration Imagine a ripple effec...
5. Graph Traversal: Depth-First Search (DFS)
Depth-First Search (DFS) is a traversal algorithm that explores the graph by going as "deep" as possible down one path before backtracking. 5.1 DFS Analogy and Illustration Imagine exploring a maze with only one path. You pick a direction (an edge) and follow...
6. Example: Full Code Implementation
This chapter combines all the concepts into a single Graph class using the C++ STL for the adjacency list. #include <iostream> #include <vector> #include <list> // For Adjacency List #include <queue> // For BFS #include <stack> // For Iterative DFS #...