Skip to main content
Advanced Search
Search Terms
Content Type

Exact Matches
Tag Searches
Date Options
Updated after
Updated before
Created after
Created before

Search Results

297 total results found

5. Pointers and Functions

Alprog - Elektro KKI Module 4 : Pointers & Dynamic Array

Pointers are essential for functions to modify variables from the calling code and to work efficiently with arrays. 5.1 Pass by Value vs Pass by Reference Pass by Value (Without Pointers): #include <stdio.h> void tryToChange(int x) { x = 100; // Only cha...

6. Pointers and Strings

Alprog - Elektro KKI Module 4 : Pointers & Dynamic Array

In C, strings are arrays of characters, so pointers work naturally with strings. 6.1 String Representation char str1[] = "Hello"; // Array notation char *str2 = "Hello"; // Pointer notation // Both represent the same thing in memory: // 'H' 'e' 'l' '...

7. Dynamic Memory Allocation & Array

Alprog - Elektro KKI Module 4 : Pointers & Dynamic Array

7.1 Introduction to Dynamic Memory Up until now, we've used static memory allocation where array sizes must be known at compile time: int arr[100]; // Size fixed at compile time Problems with static allocation: Waste memory if you allocate too much Run out ...

8. Common Pointer Pitfalls and Best Practices

Alprog - Elektro KKI Module 4 : Pointers & Dynamic Array

8.1 Uninitialized Pointers WRONG: int *ptr; // Uninitialized - contains garbage address *ptr = 42; // DANGER! Writing to unknown memory location // May cause segmentation fault CORRECT: int *ptr = NULL; // Initialize to NULL int num ...

9. Practical Examples with Dynamic Memory

Alprog - Elektro KKI Module 4 : Pointers & Dynamic Array

9.1 Dynamic Array with User Input #include <stdio.h> #include <stdlib.h> int main() { int n, *arr; printf("How many numbers do you want to enter? "); scanf("%d", &n); // Allocate memory arr = (int*)malloc(n * sizeof(int)); if...

Introduction to Looping Constructs

Digital Sistem Design (PSD/DSG) Module 6 - Looping Construct

Introduction to Looping Constructs Looping constructs are VHDL instructions that allow a program to repeat the same block of code, a process known as iteration (similar to C). Loops in VHDL are divided into two main categories based on how they function and wh...

For Loop

Digital Sistem Design (PSD/DSG) Module 6 - Looping Construct

For Loop The for loop is the most common type of sequential loop in VHDL. It is used to repeat a block of code a specific, pre-determined number of times. This makes it ideal for tasks where you know exactly how many iterations you need, such as processing the...

While Loop

Digital Sistem Design (PSD/DSG) Module 6 - Looping Construct

While Loop The while loop is used where the number of repetitions is not known from the start. A while loop continues to execute as long as a specified condition is true. Syntax The basic structure of a while loop is: loop_label: while <condition> loop --...

Loop Control - Next & Exit

Digital Sistem Design (PSD/DSG) Module 6 - Looping Construct

Loop Control - Next & Exit The two control statements, next and exit, allow you to skip an iteration or terminate the loop entirely, giving you more precise control over your sequential code. These statements can be used in both for and while loops. One, The ...

For-Generate Loop

Digital Sistem Design (PSD/DSG) Module 6 - Looping Construct

The Concurrent 'for-generate' Loop We now switch from sequential loops to a concurrent one. The for-generate statement is not a loop that executes over time inside a process. Instead, it's a command that tells the synthesizer to create multiple copies of hardw...

When & Which

Digital Sistem Design (PSD/DSG) Module 6 - Looping Construct

When & Which? Comparison Feature for Loop while Loop for-generate Statement Execution Sequential Sequential Concurrent Usage Location Inside a process Inside a process Outside a process Iteration Fixed number of times Repeats while a condition is tr...

1. Introduction to User-Defined Data Types

Alprog - Elektro KKI Module 5 : Data Types (Struct, Enum, Ty...

1.1 Why User-Defined Types? In previous modules, we learned about basic data types like int, float, char, etc. These are sufficient for simple programs, but real-world applications often require more complex data structures. Example Problem: Suppose you want t...

2. Structures (struct)

Alprog - Elektro KKI Module 5 : Data Types (Struct, Enum, Ty...

2.1 What is a Structure? A structure is a user-defined data type that groups variables of different types under a single name. Think of it as creating your own custom data type. Python vs C Comparison: Python C Uses classes or dictionaries Uses struct ...

3. Enumerations (enum)

Alprog - Elektro KKI Module 5 : Data Types (Struct, Enum, Ty...

3.1 What is an Enumeration? An enumeration is a user-defined data type consisting of a set of named integer constants. Enums make code more readable by replacing "magic numbers" with meaningful names. Python vs C Comparison: Python C No built-in enum (u...

4. Type Definitions (typedef)

Alprog - Elektro KKI Module 5 : Data Types (Struct, Enum, Ty...

4.1 What is typedef? typedef creates aliases (alternative names) for existing data types. It makes code more readable and easier to maintain. Basic Syntax: typedef existing_type new_name; 4.2 typedef with Basic Types // Create aliases for basic types typedef ...

5. File Input/Output

Alprog - Elektro KKI Module 5 : Data Types (Struct, Enum, Ty...

5.1 Why File I/O? So far, all our programs lose their data when they terminate. File I/O allows programs to: Save data permanently Read data from external sources Create logs and reports Share data between programs Python vs C File Operations: Python C ...

Procedure

Digital Sistem Design (PSD/DSG) Module 7 - Procedure, Function, and Imp...

In VHDL, a procedure is a type of language construct used to group several statements and specific tasks into a single block of code. Procedures help in organizing and simplifying the understanding of complex VHDL designs. A procedure in VHDL is similar to a v...

Function

Digital Sistem Design (PSD/DSG) Module 7 - Procedure, Function, and Imp...

In VHDL, a function is a subprogram used to perform calculations or data processing that returns a single value as a result. Functions in VHDL are similar to functions in traditional programming languages such as C or Java, where the main purpose is to compute...

Impure Function

Digital Sistem Design (PSD/DSG) Module 7 - Procedure, Function, and Imp...

In VHDL, an impure function is a special type of function that is allowed to read or modify signals, variables, or states outside its local scope. Unlike a pure function, which always produces the same output for the same input (no side effects), an impure fun...

Procedure, Function and Impure Function Synthesis

Digital Sistem Design (PSD/DSG) Module 7 - Procedure, Function, and Imp...

In VHDL, both "function" and "procedure" can be used in hardware descriptions, but it should be understood that hardware synthesis is usually more suitable for implementations based on deterministic and synchronous behavior. Therefore, there are several limita...