• Designed a Sine Wave Generator Hardware, whose frequency could be controlled using a quadrature encoder.
• Coded the FPGA board in System Verilog to display a count (going from 0 to 9999) on to a seven segment board. This count that was displayed, was same as the frequency of the sine wave generated.
• Incorporated a brightness control feature for all the digits being displayed. This was done by changing the duty cycle using a push button for the PWM control.
• Included an additional feature of increasing the count and the frequency by tens, hundreds or thousands, instead of increasing by just one.
1. Loops (while and for) allow repeating a block of code multiple times based on a condition. Key loop components are the condition, statement list, and condition update.
2. Nested loops involve loops within other loops, allowing multiple levels of repetition. Variables used in inner loops may shadow those in outer loops.
3. Loop scopes determine variable visibility. Variables declared within loops are local to the loop and not accessible outside. Variables declared before loops can be accessed within and outside loops.
This document discusses using low-level techniques in Ruby like direct syscalls and memory allocation to implement semaphores and handle segmentation faults. It shows how to use the Kernel.syscall method, DL library, and libsigsegv library to perform operations directly at the OS level. The goal is to explore pushing Ruby's capabilities by interacting with lower levels of the system. Examples demonstrate creating and using semaphores for locking, allocating and modifying memory, and installing signal handlers to catch and handle segmentation faults. Further reading links are provided on related debugging and low-level Ruby topics.
Не так давно Гор Нишанов представил свой доклад: C++ Coroutines a negative overhead abstraction. В этом докладе Гор упомянул, что предложенный дизайн корутин позволяет их использовать практически в любых окружениях, в том числе и с "бедным" C++ рантаймом.
Я решил попробовать запустить корутины в следующих окружениях: обычное приложение, драйвер ОС Windows, EFI приложение. Только в одном из этих окружений есть полноценный C++ рантайм и поддержка исключений, в остальных ничего этого нет. Более того, EFI приложение вообще выполняется до старта ОС.
Я хочу рассказать о том, как мне удалось запустить корутины в этих окружениях, поговорим о том, какие проблемы существуют в асинхронном системном программировании и как их можно обойти.
The document discusses Rust, a systems programming language developed by Mozilla. It provides an agenda, introduction to the speaker and company, why Rust was chosen, basic Rust concepts, and examples of Rust code. Memory safety is emphasized as Rust avoids vulnerabilities like memory leaks and use-after-free by using a borrow checker to validate references. Examples demonstrate immutable and mutable references, structs, functions, and memory management using Box to move values.
Rust: код может быть одновременно безопасным и быстрым, Степан КольцовYandex
Последние 15 лет между разработчиками на Java и на C++ ведётся спор о том, какой язык программирования хуже — Java или C++. Программы на C++ глючат, падают, и в них утекает память. Программы на Java тормозят и требуют слишком много памяти.
Rust — новый язык программирования, разрабатываемый компанией Mozilla — решает проблемы Java и C++: программы, написанные на Rust, одновременно быстрые и безопасные. Rust является таким же низкоуровневым, close-to-metal языком программирования, как и C++, однако в язык встроены конструкции, позволяющие на этапе компиляции доказывать, что в программе не случится обращения к неинициализированной памяти (механизм borrowed pointers). Большая часть моего рассказа будет посвящена описанию этого механизма.
This C program implements a snake game using graphics. It initializes a linked list to represent the snake and randomly generates food on the screen. It uses functions to check for collisions with food/body, move the snake according to key presses, and draw the snake/food each frame. The main game loop runs continuously, checking for input, calling functions to update the snake's position and check for collisions, drawing the updated scene, and exiting if the snake collides with itself or the edge of the screen.
Tokyo APAC Groundbreakers tour - The Complete Java DeveloperConnor McDonald
A look at the techniques that middle tier developers can employ to get greater value out of their applications, simply by having an understanding of how the database works and how to make it sing.
Rust
Why do you care about Rust? Who has the time to learn all these new languages? It seems like a new one is popping up every other week and this trend is growing at an exponential rate. Good news, a fair number of them are crafted really well and efficiently solve specific problems. Bad news, how do you keep up with all of this, let alone decide which languages to include in your companies technology portfolio.
Despite the challenges of all these new languages, a majority of developers are intrigued about the idea of becoming a polyglot, but don't know where to begin or don't have the time. In my polyglot travels, there is one language of late that is the sure-fire answer to the above questions, Rust.
In this talk I’ll explore the value behind becoming more polyglotic as a developer, how to pick languages to learn, and then dive deep in the the language of Rust. Which in my opinion, is hands down the best up and coming languages to learn.
About the Presenter
Anthony Broad-Crawford has been a developer since the year 2000 with a short side stint as a semi-professional poker player. Since his transition to software development Anthony has...
1. Built 8 patent receiving technologies
2. Founded two global companies
3. Been a CTO (3x), CPO (1x), and CEO (1x)
and is currently the CTO at Fooda where he manages product, user experience, and engineering. Fooda is predominantly web and mobile technology company focused on bringing great & healthy food from the best restaurant's to people while at the office.
Through his career, in production applications Anthony has used Ruby, Java, Jave (Android), Objective-C and Swift, .NET, Erlang, Scala, Node.JS, LISP, Smalltalk, and even assembly, with his recent favorite, Rust . No, not all at the same time in the same application.
Anthony now spends his time building great teams, that leverage great technology, to build great products, but still looks to codes every chance he can get :)
1. Loops (while and for) allow repeating a block of code multiple times based on a condition. Key loop components are the condition, statement list, and condition update.
2. Nested loops involve loops within other loops, allowing multiple levels of repetition. Variables used in inner loops may shadow those in outer loops.
3. Loop scopes determine variable visibility. Variables declared within loops are local to the loop and not accessible outside. Variables declared before loops can be accessed within and outside loops.
This document discusses using low-level techniques in Ruby like direct syscalls and memory allocation to implement semaphores and handle segmentation faults. It shows how to use the Kernel.syscall method, DL library, and libsigsegv library to perform operations directly at the OS level. The goal is to explore pushing Ruby's capabilities by interacting with lower levels of the system. Examples demonstrate creating and using semaphores for locking, allocating and modifying memory, and installing signal handlers to catch and handle segmentation faults. Further reading links are provided on related debugging and low-level Ruby topics.
Не так давно Гор Нишанов представил свой доклад: C++ Coroutines a negative overhead abstraction. В этом докладе Гор упомянул, что предложенный дизайн корутин позволяет их использовать практически в любых окружениях, в том числе и с "бедным" C++ рантаймом.
Я решил попробовать запустить корутины в следующих окружениях: обычное приложение, драйвер ОС Windows, EFI приложение. Только в одном из этих окружений есть полноценный C++ рантайм и поддержка исключений, в остальных ничего этого нет. Более того, EFI приложение вообще выполняется до старта ОС.
Я хочу рассказать о том, как мне удалось запустить корутины в этих окружениях, поговорим о том, какие проблемы существуют в асинхронном системном программировании и как их можно обойти.
The document discusses Rust, a systems programming language developed by Mozilla. It provides an agenda, introduction to the speaker and company, why Rust was chosen, basic Rust concepts, and examples of Rust code. Memory safety is emphasized as Rust avoids vulnerabilities like memory leaks and use-after-free by using a borrow checker to validate references. Examples demonstrate immutable and mutable references, structs, functions, and memory management using Box to move values.
Rust: код может быть одновременно безопасным и быстрым, Степан КольцовYandex
Последние 15 лет между разработчиками на Java и на C++ ведётся спор о том, какой язык программирования хуже — Java или C++. Программы на C++ глючат, падают, и в них утекает память. Программы на Java тормозят и требуют слишком много памяти.
Rust — новый язык программирования, разрабатываемый компанией Mozilla — решает проблемы Java и C++: программы, написанные на Rust, одновременно быстрые и безопасные. Rust является таким же низкоуровневым, close-to-metal языком программирования, как и C++, однако в язык встроены конструкции, позволяющие на этапе компиляции доказывать, что в программе не случится обращения к неинициализированной памяти (механизм borrowed pointers). Большая часть моего рассказа будет посвящена описанию этого механизма.
This C program implements a snake game using graphics. It initializes a linked list to represent the snake and randomly generates food on the screen. It uses functions to check for collisions with food/body, move the snake according to key presses, and draw the snake/food each frame. The main game loop runs continuously, checking for input, calling functions to update the snake's position and check for collisions, drawing the updated scene, and exiting if the snake collides with itself or the edge of the screen.
Tokyo APAC Groundbreakers tour - The Complete Java DeveloperConnor McDonald
A look at the techniques that middle tier developers can employ to get greater value out of their applications, simply by having an understanding of how the database works and how to make it sing.
Rust
Why do you care about Rust? Who has the time to learn all these new languages? It seems like a new one is popping up every other week and this trend is growing at an exponential rate. Good news, a fair number of them are crafted really well and efficiently solve specific problems. Bad news, how do you keep up with all of this, let alone decide which languages to include in your companies technology portfolio.
Despite the challenges of all these new languages, a majority of developers are intrigued about the idea of becoming a polyglot, but don't know where to begin or don't have the time. In my polyglot travels, there is one language of late that is the sure-fire answer to the above questions, Rust.
In this talk I’ll explore the value behind becoming more polyglotic as a developer, how to pick languages to learn, and then dive deep in the the language of Rust. Which in my opinion, is hands down the best up and coming languages to learn.
About the Presenter
Anthony Broad-Crawford has been a developer since the year 2000 with a short side stint as a semi-professional poker player. Since his transition to software development Anthony has...
1. Built 8 patent receiving technologies
2. Founded two global companies
3. Been a CTO (3x), CPO (1x), and CEO (1x)
and is currently the CTO at Fooda where he manages product, user experience, and engineering. Fooda is predominantly web and mobile technology company focused on bringing great & healthy food from the best restaurant's to people while at the office.
Through his career, in production applications Anthony has used Ruby, Java, Jave (Android), Objective-C and Swift, .NET, Erlang, Scala, Node.JS, LISP, Smalltalk, and even assembly, with his recent favorite, Rust . No, not all at the same time in the same application.
Anthony now spends his time building great teams, that leverage great technology, to build great products, but still looks to codes every chance he can get :)
1. The document discusses Rust concepts like ownership, borrowing, cloning, copying, mutable references, threads and channels for parallelism, and shared memory using Arc and Mutex.
2. It provides examples of using ownership and borrowing rules to manage memory, spawning threads and using channels for inter-thread communication, and using Arc and Mutex for shared mutable memory across threads.
3. The document presents these concepts as part of an overview of Rust's approach for safe systems programming without fear of crashes or data races through its ownership and borrowing model.
The document contains code for several modules that implement basic digital logic components like D flip-flops, T flip-flops, SR latches, and JK flip-flops. It also contains code for serial-in serial-out, serial-in parallel-out, parallel-in serial-out, and parallel-in parallel-out shift registers using these basic components.
The document discusses the Rust programming language, highlighting its features like concurrency, safety, and package management. It covers Rust's syntax including expressions, attributes, pattern matching and generics. The document also discusses how Rust handles concurrency through tasks and channels to enable safe parallelism and communication between threads.
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itSergey Platonov
The talk will look at limitations of compilers when creating fast code and how to make more effective use of both the underlying micro-architecture of modern CPU's and how algorithmic optimizations may have surprising effects on the generated code. We shall discuss several specific CPU architecture features and their pros and cons in relation to creating fast C++ code. We then expand with several algorithmic techniques, not usually well-documented, for making faster, compiler friendly, C++.
Note that we shall not discuss caching and related issues here as they are well documented elsewhere.
Perl 5.10 was released in December 2007 and introduced several new features including say, switch/given statements, and improvements to the Perl regular expression engine. It is available in most Linux distributions and via ports for FreeBSD. The document provides details on installing Perl 5.10 and highlights some of its new regular expression and language features.
- The document discusses structs in C++, including defining structs, initializing struct variables, accessing struct members, passing structs as function parameters, and using pointers to structs.
- Key aspects covered include that structs allow grouping of related data of different types, struct definitions do not allocate memory, and struct variables are initialized and accessed using dot notation. Structs can be passed by value or by reference to functions. Pointers can be used to point to struct variables.
The document summarizes lambda expressions and concurrency APIs in C++. It provides examples of lambda expressions with different capture modes. It also discusses features of concurrency APIs like std::future, std::promise, std::packaged_task and how to use them to asynchronously execute tasks and retrieve/propagate results and exceptions.
The document discusses ActionScript and the ActionScript Virtual Machine 2 (AVM2). It provides examples of ActionScript bytecode (ABC) and instructions. It compares AVM1 and AVM2, and explains how AVM2 improved performance through just-in-time compilation and garbage collection. Code examples demonstrate how to compile and disassemble ABC files using tools like Flex SDK and Tamarin.
I have create slides which lists examples of oops programming concepts including looping,enums,structures,linq,threading,delegates,generics,inheritenc..so on.
Seu primeiro loop com Python AsyncIO - TDC 2016Carlos Maniero
The document discusses asynchronous programming in Python using asyncio. It begins with motivational quotes about asynchronous programming. It then provides examples of using coroutines, tasks/futures, and event loops in asyncio. It demonstrates how asyncio avoids blocking the event loop by executing slow functions in a thread pool. The document concludes by mentioning ThreadPoolExecutor and aioHTTP as topics to explore next.
The document discusses different types of linked lists including singly linked lists, doubly linked lists, and circular linked lists. It provides examples of how to implement these linked lists in C by defining node structures containing data fields and pointer fields. The document also demonstrates how to perform operations on linked lists such as inserting nodes, deleting nodes, and finding the middle node.
Евгений Крутько, Многопоточные вычисления, современный подход.Platonov Sergey
The document discusses parallel computing in modern C++. It introduces native threads, standard threads in C++11, thread pools, std::async, and examples of parallelizing real applications. It also covers potential issues like data races and tools for detecting them like Valgrind and ThreadSanitizer. Finally, it recommends using std::async, std::future and boost::thread for flexibility and OpenMP for ease of use.
Ethereum virtual machine for Developers Part 1ArcBlock
This document provides an overview of how Solidity code is compiled to Ethereum Virtual Machine (EVM) bytecode. It explains the breakdown of the bytecode into deployment code that runs the constructor, copies the contract code and data to the blockchain, and auxiliary data. Key aspects like storage layout, gas optimization, and separation of deployment from runtime are also covered. The document concludes with pointers for further reading on EVM internals.
Asterisk: PVS-Studio Takes Up TelephonyAndrey Karpov
Asterisk is a software implementation of a telephone private branch exchange (PBX); it was created in 1999 by Mark Spencer of Digium. Like any PBX, it allows attached telephones to make calls to one another, and to connect to other telephone services, such as the public switched telephone network (PSTN) and Voice over Internet Protocol (VoIP) services. Its name comes from the asterisk symbol, *.
Asterisk is released under a dual license model, using the GNU General Public License (GPL) as a free software license and a proprietary software license to permit licensees to distribute proprietary, unpublished system components.
In this article, we are going to discuss the results of the check of the Asterisk project by PVS-Studio 5.18.
The project seems to be regularly checked by the Coverity analyzer, which is indicated by comments like this one:
/* Ignore check_return warning from Coverity for ast_exists_extension below */
However, I still found some disappointing typos in the code. Let's try to figure them out as well as other potential issues. The source code was downloaded from the project's SVN repository.
The document contains code snippets from a C++ program. It includes functions and methods that process services, create new rules, set IDs, and notify CRM systems. Conditionals like if/else statements and exceptions are used for validation and error handling.
The Node.js Event Loop: Not So Single ThreadedBryan Hughes
This document contains code snippets and graphs demonstrating the difference between synchronous and asynchronous functions in JavaScript. It shows how synchronous functions like crypto.pbkdf2Sync block further code execution, while asynchronous functions like crypto.pbkdf2 and https.request allow other work to continue in parallel and complete faster overall.
Design of 17-Bit Audio Band Delta-Sigma Analog to Digital ConverterKarthik Rathinavel
• Systematically designed a delta sigma ADC with CIFF modular architecture in MATLAB Simulink with an ENOB of 19-bits.
• Designed a decimation filter to remove noise in the digital output of the delta sigma modulator.
• Observed the effect of non-idealities on the modulator such as finite gain, finite bandwidth, slew rate, analog noise and capacitor mismatch.
• Designed a Wilkinson Combiner at 30 GHz using microstrip transmission line and then at 60 GHz using coplanar waveguide.
• Simulated the Layout of the testbench using the EM Simulator at RF.
1. The document discusses Rust concepts like ownership, borrowing, cloning, copying, mutable references, threads and channels for parallelism, and shared memory using Arc and Mutex.
2. It provides examples of using ownership and borrowing rules to manage memory, spawning threads and using channels for inter-thread communication, and using Arc and Mutex for shared mutable memory across threads.
3. The document presents these concepts as part of an overview of Rust's approach for safe systems programming without fear of crashes or data races through its ownership and borrowing model.
The document contains code for several modules that implement basic digital logic components like D flip-flops, T flip-flops, SR latches, and JK flip-flops. It also contains code for serial-in serial-out, serial-in parallel-out, parallel-in serial-out, and parallel-in parallel-out shift registers using these basic components.
The document discusses the Rust programming language, highlighting its features like concurrency, safety, and package management. It covers Rust's syntax including expressions, attributes, pattern matching and generics. The document also discusses how Rust handles concurrency through tasks and channels to enable safe parallelism and communication between threads.
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itSergey Platonov
The talk will look at limitations of compilers when creating fast code and how to make more effective use of both the underlying micro-architecture of modern CPU's and how algorithmic optimizations may have surprising effects on the generated code. We shall discuss several specific CPU architecture features and their pros and cons in relation to creating fast C++ code. We then expand with several algorithmic techniques, not usually well-documented, for making faster, compiler friendly, C++.
Note that we shall not discuss caching and related issues here as they are well documented elsewhere.
Perl 5.10 was released in December 2007 and introduced several new features including say, switch/given statements, and improvements to the Perl regular expression engine. It is available in most Linux distributions and via ports for FreeBSD. The document provides details on installing Perl 5.10 and highlights some of its new regular expression and language features.
- The document discusses structs in C++, including defining structs, initializing struct variables, accessing struct members, passing structs as function parameters, and using pointers to structs.
- Key aspects covered include that structs allow grouping of related data of different types, struct definitions do not allocate memory, and struct variables are initialized and accessed using dot notation. Structs can be passed by value or by reference to functions. Pointers can be used to point to struct variables.
The document summarizes lambda expressions and concurrency APIs in C++. It provides examples of lambda expressions with different capture modes. It also discusses features of concurrency APIs like std::future, std::promise, std::packaged_task and how to use them to asynchronously execute tasks and retrieve/propagate results and exceptions.
The document discusses ActionScript and the ActionScript Virtual Machine 2 (AVM2). It provides examples of ActionScript bytecode (ABC) and instructions. It compares AVM1 and AVM2, and explains how AVM2 improved performance through just-in-time compilation and garbage collection. Code examples demonstrate how to compile and disassemble ABC files using tools like Flex SDK and Tamarin.
I have create slides which lists examples of oops programming concepts including looping,enums,structures,linq,threading,delegates,generics,inheritenc..so on.
Seu primeiro loop com Python AsyncIO - TDC 2016Carlos Maniero
The document discusses asynchronous programming in Python using asyncio. It begins with motivational quotes about asynchronous programming. It then provides examples of using coroutines, tasks/futures, and event loops in asyncio. It demonstrates how asyncio avoids blocking the event loop by executing slow functions in a thread pool. The document concludes by mentioning ThreadPoolExecutor and aioHTTP as topics to explore next.
The document discusses different types of linked lists including singly linked lists, doubly linked lists, and circular linked lists. It provides examples of how to implement these linked lists in C by defining node structures containing data fields and pointer fields. The document also demonstrates how to perform operations on linked lists such as inserting nodes, deleting nodes, and finding the middle node.
Евгений Крутько, Многопоточные вычисления, современный подход.Platonov Sergey
The document discusses parallel computing in modern C++. It introduces native threads, standard threads in C++11, thread pools, std::async, and examples of parallelizing real applications. It also covers potential issues like data races and tools for detecting them like Valgrind and ThreadSanitizer. Finally, it recommends using std::async, std::future and boost::thread for flexibility and OpenMP for ease of use.
Ethereum virtual machine for Developers Part 1ArcBlock
This document provides an overview of how Solidity code is compiled to Ethereum Virtual Machine (EVM) bytecode. It explains the breakdown of the bytecode into deployment code that runs the constructor, copies the contract code and data to the blockchain, and auxiliary data. Key aspects like storage layout, gas optimization, and separation of deployment from runtime are also covered. The document concludes with pointers for further reading on EVM internals.
Asterisk: PVS-Studio Takes Up TelephonyAndrey Karpov
Asterisk is a software implementation of a telephone private branch exchange (PBX); it was created in 1999 by Mark Spencer of Digium. Like any PBX, it allows attached telephones to make calls to one another, and to connect to other telephone services, such as the public switched telephone network (PSTN) and Voice over Internet Protocol (VoIP) services. Its name comes from the asterisk symbol, *.
Asterisk is released under a dual license model, using the GNU General Public License (GPL) as a free software license and a proprietary software license to permit licensees to distribute proprietary, unpublished system components.
In this article, we are going to discuss the results of the check of the Asterisk project by PVS-Studio 5.18.
The project seems to be regularly checked by the Coverity analyzer, which is indicated by comments like this one:
/* Ignore check_return warning from Coverity for ast_exists_extension below */
However, I still found some disappointing typos in the code. Let's try to figure them out as well as other potential issues. The source code was downloaded from the project's SVN repository.
The document contains code snippets from a C++ program. It includes functions and methods that process services, create new rules, set IDs, and notify CRM systems. Conditionals like if/else statements and exceptions are used for validation and error handling.
The Node.js Event Loop: Not So Single ThreadedBryan Hughes
This document contains code snippets and graphs demonstrating the difference between synchronous and asynchronous functions in JavaScript. It shows how synchronous functions like crypto.pbkdf2Sync block further code execution, while asynchronous functions like crypto.pbkdf2 and https.request allow other work to continue in parallel and complete faster overall.
Design of 17-Bit Audio Band Delta-Sigma Analog to Digital ConverterKarthik Rathinavel
• Systematically designed a delta sigma ADC with CIFF modular architecture in MATLAB Simulink with an ENOB of 19-bits.
• Designed a decimation filter to remove noise in the digital output of the delta sigma modulator.
• Observed the effect of non-idealities on the modulator such as finite gain, finite bandwidth, slew rate, analog noise and capacitor mismatch.
• Designed a Wilkinson Combiner at 30 GHz using microstrip transmission line and then at 60 GHz using coplanar waveguide.
• Simulated the Layout of the testbench using the EM Simulator at RF.
Digital Voltmeter displaying voltage level on a seven segment display and com...Karthik Rathinavel
• Coded an Altera FPGA board in System Verilog such that it could use the on board ADC to convert the voltage signal into a digital signal, that was displayed on a seven segment display as well as on a computer screen.
• Utilized a UART (USB to serial) to receive the voltage signal that was to be displayed on a computer.
• Controlled the selection of channel for analog input by transmitting the serial data through the UART from the computer keyboard.
Ece 523 project – fully differential two stage telescopic op ampKarthik Rathinavel
• Designed a two stage op-amp with first stage as a telescopic amplifier and second stage being a common source, in Cadence.
• Simulated the loop characteristics of the amplifier to have atleast 100 MHz Unity Gain Bandwidth, 65 dB gain and 60º phase margin (both differential loop and Common Mode) for three temperature (27,-40,100) corners.
• Extracted the layout of the design in Virtuoso (after passing DRC an LVS) and simulated the differential loop performances of the extracted netlist.
• Designed a third order Butterworth filter with 100 KHz corner frequency using the op-amp.
Designed a Switched Capacitor Low Pass Filter with a sampling frequency of 60 Hz.
Simulated the filter to have a ripple within 0.2 dB under 3.6 MHz and a stopband attenuation of atleast -51 dB after 7.2 MHz.
Applied dynamic range optimization, Dynamic Range Scaling and Chip Area scaling to get maximum output swing while occupying minimum area on chip.
Tested the filter with non-idealities of the amplifier, such as finite gain, bandwidth, offset voltage, charge injection, etc.
The document describes implementing up, down, and up/down counters using Verilog code. It includes:
1) Code for a 4-bit up counter that counts from 0 to 15 when the clock signal changes.
2) Code for a 4-bit down counter that counts from 15 to 0 when the clock signal changes.
3) Code for a 4-bit up/down counter that counts up when the up signal is high and down when the down signal is high, controlled by the clock.
I have written the code but cannot complete the assignment please help.pdfshreeaadithyaacellso
I have written the code but cannot complete the assignment please help me to complete.
Please don't just copy other s answers as your own.
// Insertion sort
/*
#include <ctime>
#include <iostream>
using namespace std;
void insertionSort(int arr[], int n) {
int i, key, j;
for (i = 1; i < n; i++) {
key = arr[i];
j = i - 1;
// Move elements of arr[0..i-1], that are greater than key, to one position ahead of their current
position
while (j >= 0 && arr[j] > key) {
arr[j + 1] = arr[j];
j = j - 1;
}
arr[j + 1] = key;
}
}
int main() {
int n;
cout << "Enter the size of the array: ";
cin >> n;
int arr[n];
cout << "Enter the elements of the array: ";
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int num = sizeof(arr) / sizeof(arr[0]);
clock_t start, end;
double timetaken;
start = clock();
insertionSort(arr, num);
end = clock();
cout << "Sorted array: \n";
for (int i = 0; i < n; i++)
cout << arr[i] << " ";
cout << endl;
timetaken = ((double) (end - start)) / CLOCKS_PER_SEC;
cout << "Time taken : " << fixed << timetaken << "s" << endl;
return 0;
}
*/
// Shell Sort
/*
#include <ctime>
#include <iostream>
using namespace std;
int shellSort(int arr[], int n) {
for (int gap = n/2; gap > 0; gap /= 2) {
for (int i = gap; i < n; i += 1) {
int temp = arr[i];
int j;
for (j = i; j >= gap && arr[j - gap] > temp; j -= gap)
arr[j] = arr[j - gap];
arr[j] = temp;
}
}
return 0;
}
void printArray(int arr[], int n) {
for (int i=0; i<n; i++)
cout << arr[i] << " ";
}
int main() {
int n;
cout << "Enter the size of the array: ";
cin >> n;
int arr[n];
cout << "Enter the elements of the array: ";
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int num = sizeof(arr) / sizeof(arr[0]);
clock_t start, end;
double timetaken;
start = clock();
shellSort(arr, num);
end = clock();
cout << "\nArray after sorting: \n";
printArray(arr, n);
cout << endl;
timetaken = (double)(end - start) / CLOCKS_PER_SEC;
cout << "Time taken : " << fixed << timetaken << "s" << endl;
return 0;
}
*/
// MergeSort
/*
#include <ctime>
#include <iostream>
using namespace std;
void merge(int arr[], int l, int m, int r) {
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;
int L[n1], R[n2];
for (i = 0; i < n1; i++)
L[i] = arr[l + i];
for (j = 0; j < n2; j++)
R[j] = arr[m + 1 + j];
i = 0;
j = 0;
k = l;
while (i < n1 && j < n2) {
if (L[i] <= R[j]) {
arr[k] = L[i];
i++;
}
else {
arr[k] = R[j];
j++;
}
k++;
}
while (i < n1) {
arr[k] = L[i];
i++;
k++;
}
while (j < n2) {
arr[k] = R[j];
j++;
k++;
}
}
void mergeSort(int arr[], int l, int r) {
if (l < r) {
int m = l + (r - l) / 2;
mergeSort(arr, l, m);
mergeSort(arr, m + 1, r);
merge(arr, l, m, r);
}
}
int main() {
int n;
cout << "Enter the size of the array: ";
cin >> n;
int arr[n];
cout << "Enter the elements of the array: ";
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int arr_size = sizeof(arr) / sizeof(arr[0]);
clock_t start;
clock_t end;
double timetaken;
start = clock();
mergeSort(arr, 0, arr_size - 1);
end = clock();
timetaken = (double)(end - start) / CLOCKS_PER_SEC;
.
This document provides C code solutions to interface four 7-segment displays on an ARM7 microcontroller and display counts from 0000 to 9999. The code defines arrays to store the digit values for the displays and uses conditions to extract the digits from the count value to display on the individual segments. Delay functions are used to control the timing of digit updates on the displays.
This document describes a microcontroller program for generating PWM waves and controlling a power converter system. It initializes an ADC to read voltage values, displays the voltage on an LCD, and allows the user to increment/decrement the target voltage value. A PWM function then generates pulses with varying duty cycles to control the converter voltage based on the target value.
PWM wave generator using microcontroller Swapnil2515
This document describes a microcontroller program for generating PWM waves and controlling a power converter system. It initializes an ADC to read voltage values, displays the voltage on an LCD, and allows the user to increment/decrement the target voltage value. A PWM function then generates pulses with varying duty cycles to control the converter voltage based on the target value.
This document describes the history and features of the MDP-Plus expert advisor (EA). It was originally based on the MillionDollarPips EA and has undergone several versions with updates and improvements made by Capella. Key features of MDP-Plus v2.1.2 include trailing stops, support for no dealing desk brokers, optimized settings, and customization of indicators and order settings. The EA uses moving averages, Bollinger Bands, and other indicators to determine entry signals and manage open positions.
The document defines constants for controlling 3 stepper motors using Arduino. It includes functions for initializing pin modes, controlling motor speed and direction, and stepping each motor. The main loop calls the motor functions to run the motors in sequences, and also controls a servo motor.
The document contains code snippets demonstrating different types of loops in C++ including for, while, do-while loops. It also shows examples of using break, continue and flag-controlled loops. Nested loops and sentinel controlled loops are presented. The output of the code snippets is also discussed in some cases.
This document includes header files and code for interfacing with GPS, compass, and SD card components. It initializes these devices and logs GPS data including latitude, longitude, and fix age to an SD card file. It also calculates distance between the current GPS position and predefined waypoints. The main loop acquires new GPS data every 250ms and prints it to the serial monitor if available.
This document defines constants for pin assignments and includes the Servo library. It controls 3 stepper motors using microstepping to move specified steps in a given direction at a specified speed. A servo motor is also controlled to two positions. The main loop calls functions to operate each motor independently in sequences, such as moving one motor forward and another backward simultaneously.
The IoT Academy IoT Training Arduino Part 3 programmingThe IOT Academy
This document provides an overview of basic Arduino code structure and programming concepts. It explains that Arduino programs have two main sections - setup() and loop(). Setup() is used to initialize inputs and outputs, and loop() contains the repeating code. It also covers digital input/output functions, variables, conditional statements, boolean logic, and interrupts. Examples are provided for blinking LEDs, reading sensors, and creating simple programs.
Program to display heart rate and heart beat waveform based on photoplethysmography (PPG). It reads values from a sensor made of photodiode and LED and displays the corresponding heart rate and waveform on an LCD screen
DomCode 2015 - Abusing phones to make the internet of thingsJan Jongboom
The document discusses abusing phone sensors to create internet of things applications. It provides examples of using light, motion, and sound sensors to control music, visualize juggling, and generate computer music. It also covers using Bluetooth beacons and the physical web to discover and interact with devices, and a sample code for connecting to a drone over Bluetooth to control its flight. The overall message is about exploring creative ways to turn phones into interfaces for interactive experiences.
Presentation about using the tech behind a couple of my projects in your own work. It contains tips about how to play music with machines and how to connect your cellphone to an Arduino.
Code for the presentation can be found here - https://github.com/neilmendoza/musicalmachines
This document describes a grey code counter module with logic to increment or decrement the counter values using a grey code sequence. The module contains registers to store the current and historical counter values. It also includes functions to increment, decrement, and convert between grey code and numeric representations of the counter values.
The document contains examples of Verilog code including:
1. A 2-D flip-flop synchronizer module and testbench.
2. Three different finite state machine (FSM) design techniques using single, two, and three always blocks.
3. A generic pipeline/repeater module and testbench.
4. Simple D flip-flop modules with synchronous and asynchronous resets and testbenches.
5. A mod-M counter module that generates a tick pulse and testbench.
6. A clock pulse generator module.
Low Noise Amplifier at 2 GHz using the transistor NE85639 in ADSKarthik Rathinavel
• Systematically designed a LNA and its biasing using non-ideal components such as Microstrip TLs resistors, capacitors etc.
• Calculated the S parameters of the Transistor and simulated the gain and bandwidth to be 10 dB and 1 GHz respectively.
• Achieved a Noise Figure of 3.2 dB and s11 of -20 dB in the final design.
• Designed a single stage folded cascode op-amp which had atleast 50 dB gain and 135 MHz Unity Gain Bandwidth for the three temperature corners (typical, slow and fast), in Cadence.
• The op-amp had a phase margin of atleast 64º and an output swing of atleast 1.46 V for the temperature corners (27,-40,100).
• Designed a common mode feedback for the amplifier and achieved a common mode accuracy of 0.01 V.
Differntial Input to Single Ended Output, Two stage Op-ampKarthik Rathinavel
This document summarizes a project to design a differential input, single ended output two-stage operational amplifier. The design approach was to bring all transistors into saturation at a common mode voltage of 0V and meet gain, phase margin, and unity gain frequency specifications. A compensation capacitor was increased to move the dominant pole in while a nulling resistor eliminated the effect of a zero, improving phase margin and unity gain frequency. Simulation results met all specifications, with an open loop gain of 67.97dB, phase margin of 75.3 degrees, and unity gain frequency of 15.29MHz. The input common mode range was -0.852V to 0.181V and output swing was -0.771V to 0
Continuous Low Pass Filter Realization using Cascaded stages of Tow-Thomas Bi...Karthik Rathinavel
Designed a Continuous Low Pass Filter using three stages of cascaded Tow-Thomas Bi-quads which met the following specifications:-
Pass band: DC to fp = 20 kHz, gain between 0 dB & 1 dB.
Stop band: f > fs = 40 kHz, gain below -50 dB
Found the transfer function, poles and zeros of the required filter using MATLAB. Used Cadence to plot the frequency response of the gain of the overall transfer function using ideal op-amps and non-ideal op-amps.Used dynamic optimization and dynamic range scaling of the elements (resistors and capacitors) such that the output of each stage had a good output swing.
1. The document describes a project that transmits digital signals through light pulses using LEDs and photodiodes. A microcontroller generates pulses that drive an LED, transmitting the signal through light. A photodiode receives the light and the microcontroller interprets and plots the signal.
2. The transmitter code generates pulses by alternating the output pin between high and low with delays. The receiver reads the photodiode voltage and sends it to a computer to plot the square wave signal graphically, showing accurate signal transmission.
3. Testing without the LED showed noise in the receiver between 1.28-1.32 volts, demonstrating the need for an optical signal to transmit data distinctly.
1) The document describes a project using an audio signal to modulate the intensity of an LED. A summing amplifier combines the audio signal with a bias voltage to vary the LED's brightness accordingly.
2) Light from the LED falls on a phototransistor, which amplifies the signal. With headphones, the transmitted audio could be heard clearly, demonstrating successful wireless transmission.
3) While proof-of-concept was achieved, the document discusses using lasers and fiber optics to transmit signals over greater distances with higher information content.
1) The document describes a project to modulate an audio signal onto a LED by varying the current through the LED.
2) The authors designed a summing amplifier circuit to modulate the audio signal onto the LED current and analyzed the input, modulated, and transmitted signals.
3) Their results showed they were successfully able to modulate the audio signal and transmit it across the LED, though the transmitted signal strength was low which could be addressed with a current amplifier.
artificial intelligence and data science contents.pptxGauravCar
What is artificial intelligence? Artificial intelligence is the ability of a computer or computer-controlled robot to perform tasks that are commonly associated with the intellectual processes characteristic of humans, such as the ability to reason.
› ...
Artificial intelligence (AI) | Definitio
Null Bangalore | Pentesters Approach to AWS IAMDivyanshu
#Abstract:
- Learn more about the real-world methods for auditing AWS IAM (Identity and Access Management) as a pentester. So let us proceed with a brief discussion of IAM as well as some typical misconfigurations and their potential exploits in order to reinforce the understanding of IAM security best practices.
- Gain actionable insights into AWS IAM policies and roles, using hands on approach.
#Prerequisites:
- Basic understanding of AWS services and architecture
- Familiarity with cloud security concepts
- Experience using the AWS Management Console or AWS CLI.
- For hands on lab create account on [killercoda.com](https://killercoda.com/cloudsecurity-scenario/)
# Scenario Covered:
- Basics of IAM in AWS
- Implementing IAM Policies with Least Privilege to Manage S3 Bucket
- Objective: Create an S3 bucket with least privilege IAM policy and validate access.
- Steps:
- Create S3 bucket.
- Attach least privilege policy to IAM user.
- Validate access.
- Exploiting IAM PassRole Misconfiguration
-Allows a user to pass a specific IAM role to an AWS service (ec2), typically used for service access delegation. Then exploit PassRole Misconfiguration granting unauthorized access to sensitive resources.
- Objective: Demonstrate how a PassRole misconfiguration can grant unauthorized access.
- Steps:
- Allow user to pass IAM role to EC2.
- Exploit misconfiguration for unauthorized access.
- Access sensitive resources.
- Exploiting IAM AssumeRole Misconfiguration with Overly Permissive Role
- An overly permissive IAM role configuration can lead to privilege escalation by creating a role with administrative privileges and allow a user to assume this role.
- Objective: Show how overly permissive IAM roles can lead to privilege escalation.
- Steps:
- Create role with administrative privileges.
- Allow user to assume the role.
- Perform administrative actions.
- Differentiation between PassRole vs AssumeRole
Try at [killercoda.com](https://killercoda.com/cloudsecurity-scenario/)
An improved modulation technique suitable for a three level flying capacitor ...IJECEIAES
This research paper introduces an innovative modulation technique for controlling a 3-level flying capacitor multilevel inverter (FCMLI), aiming to streamline the modulation process in contrast to conventional methods. The proposed
simplified modulation technique paves the way for more straightforward and
efficient control of multilevel inverters, enabling their widespread adoption and
integration into modern power electronic systems. Through the amalgamation of
sinusoidal pulse width modulation (SPWM) with a high-frequency square wave
pulse, this controlling technique attains energy equilibrium across the coupling
capacitor. The modulation scheme incorporates a simplified switching pattern
and a decreased count of voltage references, thereby simplifying the control
algorithm.
Introduction- e - waste – definition - sources of e-waste– hazardous substances in e-waste - effects of e-waste on environment and human health- need for e-waste management– e-waste handling rules - waste minimization techniques for managing e-waste – recycling of e-waste - disposal treatment methods of e- waste – mechanism of extraction of precious metal from leaching solution-global Scenario of E-waste – E-waste in India- case studies.
Advanced control scheme of doubly fed induction generator for wind turbine us...IJECEIAES
This paper describes a speed control device for generating electrical energy on an electricity network based on the doubly fed induction generator (DFIG) used for wind power conversion systems. At first, a double-fed induction generator model was constructed. A control law is formulated to govern the flow of energy between the stator of a DFIG and the energy network using three types of controllers: proportional integral (PI), sliding mode controller (SMC) and second order sliding mode controller (SOSMC). Their different results in terms of power reference tracking, reaction to unexpected speed fluctuations, sensitivity to perturbations, and resilience against machine parameter alterations are compared. MATLAB/Simulink was used to conduct the simulations for the preceding study. Multiple simulations have shown very satisfying results, and the investigations demonstrate the efficacy and power-enhancing capabilities of the suggested control system.
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Sinan KOZAK
Sinan from the Delivery Hero mobile infrastructure engineering team shares a deep dive into performance acceleration with Gradle build cache optimizations. Sinan shares their journey into solving complex build-cache problems that affect Gradle builds. By understanding the challenges and solutions found in our journey, we aim to demonstrate the possibilities for faster builds. The case study reveals how overlapping outputs and cache misconfigurations led to significant increases in build times, especially as the project scaled up with numerous modules using Paparazzi tests. The journey from diagnosing to defeating cache issues offers invaluable lessons on maintaining cache integrity without sacrificing functionality.
Discover the latest insights on Data Driven Maintenance with our comprehensive webinar presentation. Learn about traditional maintenance challenges, the right approach to utilizing data, and the benefits of adopting a Data Driven Maintenance strategy. Explore real-world examples, industry best practices, and innovative solutions like FMECA and the D3M model. This presentation, led by expert Jules Oudmans, is essential for asset owners looking to optimize their maintenance processes and leverage digital technologies for improved efficiency and performance. Download now to stay ahead in the evolving maintenance landscape.
2. logic quadA_steady1_past;
logic quadB_steady2_past;
wire count_enable = quadA_steady1 ^ quadA_steady1_past ^ quadB_steady2 ^
quadB_steady2_past;
wire count_rotation_direction = quadA_steady1 ^ quadB_steady2_past;
/////////////////////////Debouncer for QuadA///////////////////
logic hold_something1;
logic hold_something_else1;
logic [3:0] Switch_count1;
always_ff@(posedge inclk0_sig)
begin
hold_something1 <= quadA;
hold_something_else1 <= hold_something1;
end
always_ff@(posedge inclk0_sig)
if(quadA_steady1==hold_something_else1)
Switch_count1 <= 0;
else
begin
Switch_count1 <= Switch_count1 + 1; //Incrementing counter1 for
switching
if(Switch_count1 == 9)
quadA_steady1 <= ~quadA_steady1;
end
///////////////////////////////End of Quad A Debouncer//////////
/////////////////////////Debouncer for QuadB/////////////////////
logic hold_something2;
logic hold_something_else2;
logic [3:0] Switch_count2;
always_ff@(posedge inclk0_sig)
begin
hold_something2 <= quadB;
hold_something_else2 <= hold_something2;
end
always_ff@(posedge inclk0_sig)
if(quadB_steady2==hold_something_else2)
Switch_count2 <= 0;
else
begin
Switch_count2 <= Switch_count2 + 1; //Incrementing counter2 for
switching
if(Switch_count2 == 9)
quadB_steady2 <= ~quadB_steady2;
end
////////////////////////End of QuadB Debouncer///////////////////
/////////////////////////Debouncer for quad_button/////////////////////
logic hold_something3;
logic hold_something_else3;
3. logic [3:0] Switch_count3;
logic quad_button2_steady;
always_ff@(posedge inclk0_sig)
begin
hold_something3 <= quad_button2;
hold_something_else3 <= hold_something3;
end
always_ff@(posedge inclk0_sig)
if(quad_button2_steady==hold_something_else3)
Switch_count3 <= 0;
else
begin
Switch_count3 <= Switch_count3 + 1; //Incrementing counter2 for
switching
if(Switch_count3 == 9)
quad_button2_steady <= ~quad_button2_steady;
end
////////////////////////End of quad_button Debouncer///////////////////
///Making a new clock of 2HZ Frequency using 4 kHz Clock
logic [11:0] number;
logic newclock;
always_ff@(posedge c1_sig) begin
number <= number+1;
if (number< 2000)
newclock <= 1;
else if (number >= 2000 && number < 4000)
newclock <= 0;
else
number <=0;
end
////////////////
//////////////////////////////Mode of Incrementing////
logic [1:0] alpha;
logic [10:0] a_count;
logic tenblock_inc;
logic hundredblock_inc;
logic thousandblock_inc;
//assign alpha = 2'b01;
always_ff@(posedge newclock) begin
if (!quad_button2_steady)
alpha <= alpha+1;
end
always_comb begin
if (alpha ==0)
begin
a_count = 1;
tenblock_inc = 0;
hundredblock_inc = 0;
thousandblock_inc = 0;
4. end
else if (alpha ==1)
begin
a_count = 10;
tenblock_inc = 1;
hundredblock_inc = 0;
thousandblock_inc = 0;
end
else if (alpha ==2)
begin
a_count = 100;
tenblock_inc = 0;
hundredblock_inc = 1;
thousandblock_inc = 0;
end
else ///// (alpha ==3)
begin
a_count = 1000;
tenblock_inc = 0;
hundredblock_inc = 0;
thousandblock_inc = 1;
end
end
//////////////////////////////////End of Mode Incrementing////////////////////
//////////////////////////////Quad
Encoder//////////////////////////////////////////
always_ff@(posedge inclk0_sig)
begin
quadA_steady1_past <= quadA_steady1;
quadB_steady2_past <= quadB_steady2;
end
always_ff@(posedge inclk0_sig or negedge reset_button)
begin
if (!reset_button)
count <=1000;
else
begin
if(count_enable)//////////////////////////////Either Increment or
decrement count
begin
if(count_rotation_direction)
begin
if (count<9999)
count <=
count+a_count;/////////////////////////Increment Count
else
count <= count;
end
else ////////////////////////////////////////decrement count
begin
if (count>0)
count <= count-a_count;
else
count <= 0;
5. end
end
end
end
/////////////////////////////Separating
digits/////////////////////////////////////
always_ff@(posedge inclk0_sig or negedge reset_button)
begin
if (!reset_button)
begin
ones_digit <=0;
tens_digit <=0;
hundreds_digit <=0;
thousands_digit <=1;
end
else
begin
if(count_enable)//////////////////////////////Either Increment or
decrement
begin
if(count_rotation_direction)
//Clockwise Rotation
begin
if (ones_digit ==9 && tens_digit ==9 && hundreds_digit ==9 &&
thousands_digit ==9)
begin
ones_digit <=9;
tens_digit <=9;
hundreds_digit <=9;
thousands_digit <=9;
end
else
/////////Increment Digits Normally
begin
if (tenblock_inc == 0 && hundredblock_inc == 0 &&
thousandblock_inc == 0)
begin
if (ones_digit <9)
ones_digit <= ones_digit+1;
else
// Ones digit is 9
begin
ones_digit <= 0;
if (tens_digit <9)
tens_digit <= tens_digit+1;
else
//Tens digit is 9
begin
tens_digit <= 0;
if (hundreds_digit <9)
hundreds_digit <=
hundreds_digit+1;
else
//Hundreds digit is 9
begin
hundreds_digit <= 0;
if (thousands_digit <9)
thousands_digit
6. <=thousands_digit+1;
else
//Thousands digit is 9
thousands_digit <=0;
//Does'nt even happen
end
end
end
end
/////////////////Increment Digits by tens
else if (tenblock_inc == 1 && hundredblock_inc == 0 &&
thousandblock_inc == 0)
begin
if (tens_digit <9)
tens_digit <= tens_digit+1;
else
//Tens digit is 9
begin
tens_digit <= 0;
if (hundreds_digit <9)
hundreds_digit <= hundreds_digit+1;
else
//Hundreds digit is 9
begin
hundreds_digit <= 0;
if (thousands_digit <9)
thousands_digit
<=thousands_digit+1;
else
//Thousands digit is 9
thousands_digit <=9;
end
end
end
///////////////Increment Digts by Hundreds
else if (tenblock_inc == 0 && hundredblock_inc == 1 &&
thousandblock_inc == 0)
begin
if (hundreds_digit <9)
hundreds_digit <= hundreds_digit+1;
else
//Hundreds digit is 9
begin
hundreds_digit <= 0;
if (thousands_digit <9)
thousands_digit
<=thousands_digit+1;
else
//Thousands digit is 9
thousands_digit <=9;
end
end
///////////////////Increment by thousands
else //if (tenblock_inc == 0 && hundredblock_inc == 0 &&
thousandblock_inc == 1)
begin
if (thousands_digit <9)
thousands_digit <=thousands_digit+1;
else
//Thousands digit is 9
7. thousands_digit <=9;
end
end
end
/////////////////////////////////////////////////////Anticlockwise
Rotation
else
begin
if (ones_digit ==0 && tens_digit ==0 && hundreds_digit ==0 &&
thousands_digit ==0)
begin
ones_digit <=0;
tens_digit <=0;
hundreds_digit <=0;
thousands_digit <=0;
end
else
begin //////////////////////////Normal Decrement
if (tenblock_inc == 0 && hundredblock_inc == 0 &&
thousandblock_inc == 0)
begin
if (ones_digit >0 && ones_digit <10)
ones_digit <= ones_digit-1;
else
// Ones digit is 0
begin
ones_digit <=9;
if (tens_digit >0 && tens_digit <10)
tens_digit <= tens_digit-1;
else
//Tens digit is 0
begin
tens_digit<= 9;
if (hundreds_digit>0 && hundreds_digit
<10)
hundreds_digit <= hundreds_digit-
1;
else
//Hundreds Digit is 0
begin
hundreds_digit<=9;
if (thousands_digit >0 &&
thousands_digit <10)
thousands_digit <=
thousands_digit-1;
else
//Thousands Digit is 0
thousands_digit <= 9;
end
end
end
end
////////Decrement by tens
else if (tenblock_inc == 1 && hundredblock_inc == 0 &&
thousandblock_inc == 0)
begin
8. if (tens_digit >0 && tens_digit <10)
tens_digit <= tens_digit-1;
else
//Tens digit is 0
begin
tens_digit<= 9;
if (hundreds_digit>0 && hundreds_digit <10)
hundreds_digit <= hundreds_digit-
1;
else
//Hundreds Digit is 0
begin
hundreds_digit<=9;
if (thousands_digit >0 &&
thousands_digit <10)
thousands_digit <=
thousands_digit-1;
else
//Thousands Digit is 0
thousands_digit <= 0;
end
end
end
///Decrement by Hundred
else if (tenblock_inc == 0 && hundredblock_inc == 1 &&
thousandblock_inc == 0)
begin
if (hundreds_digit>0 && hundreds_digit <10)
hundreds_digit <= hundreds_digit-1;
else
//Hundreds Digit is 0
begin
hundreds_digit<=9;
if (thousands_digit >0 && thousands_digit
<10)
thousands_digit <= thousands_digit-1;
else
//Thousands Digit is 0
thousands_digit <= 0;
end
end
//////Decrement by Thousand
else if (tenblock_inc == 0 && hundredblock_inc == 0 &&
thousandblock_inc == 1)
begin
if (thousands_digit >0 && thousands_digit <10)
thousands_digit <= thousands_digit-1;
else
//Thousands Digit is 0
thousands_digit <= 0;
end
end
end
end
end
9. end
///////////////// State Machine present state becomes new state every clock
edge//////
always_ff@(posedge c0_sig)
present_state <= next_state;
///Saving the state
//Making it go to the next state. Incrementing present
state/////////////////////
always_comb
begin
unique case (present_state)
4'b0000 : next_state = 4'b0001;
//Ones Digit State
4'b0001 : next_state = 4'b0010;
//Idle State
4'b0010 : next_state = 4'b0011;
//Tens Digit State
4'b0011 : next_state = 4'b0100;
//Idle State
4'b0100 : next_state = 4'b0101;
//Hundreds Digit State
4'b0101 : next_state = 4'b0110;
//Idle State
4'b0110 : next_state = 4'b0111;
//Thousands State
4'b0111 : next_state = 4'b1000;
//Idle State
4'b1000 : next_state = 4'b0000;
//Circles Back
endcase
end
// MUX: Displaying Output of each of three digits; one after the other
always_comb
begin
if (present_state == 0)
begin
muxo = ones_digit;
// mux out is first digit
sel = 3'b000;
en3 = 1'b1;
end
else if (present_state == 1)
//Idle between States
begin
muxo = 9;
// mux out is random
sel = 3'b111;
//Nothing Happens
en3 = 1'b0;
end
else if (present_state == 2)
begin
muxo = tens_digit;
10. // mux out is tens digit
sel = 3'b001;
if (count < 10)
// Zero Supression for Tens Digit
en3 = 1'b0;
else
en3 = 1'b1;
end
else if (present_state == 3)
//Idle between States
begin
muxo = 9;
// mux out is random
sel = 3'b111;
//Nothing Happens
en3 = 1'b0;
end
else if (present_state == 4)
begin
muxo = hundreds_digit; //
mux out is hundreds digit
sel = 3'b011;
if (count < 100)
// Zero Supression for Hundreds Digit
en3 = 1'b0;
else
en3 = 1'b1;
end
else if (present_state == 5)
//Idle State
begin
muxo = 9;
// mux out is random
sel = 3'b111;
//Nothing Happens
en3 = 1'b0;
end
else if (present_state == 6)
begin
muxo = thousands_digit; //
mux out is thousands digit
sel = 3'b100;
if (count < 1000)
// Zero Supression for Thousands Digit
en3 = 1'b0;
else
en3 = 1'b1;
end
else if (present_state == 7)
//Idle State
begin
muxo = 9;
// mux out is random
sel = 3'b111;
//Nothing Happens
en3 = 1'b0;
11. end
else
begin
muxo = 9;
//Doesn't Matter
sel = 3'b011;
//Going nowhere
en3 = 1'b0;
//Also Output is disabled
end
end
///////////////////////bcd to seven segment
decoder///////////////////////////////
always_comb begin
casez (muxo) //gfedcba
4'b0000 : seven_segment = 7'b1000000; //seven
segment display of 0
4'b0001 : seven_segment = 7'b1111001; //seven
segment display of 1
4'b0010 : seven_segment = 7'b0100100; //seven
segment display of 2
4'b0011 : seven_segment = 7'b0110000; //seven
segment display of 3
4'b0100 : seven_segment = 7'b0011001; //seven
segment display of 4
4'b0101 : seven_segment = 7'b0010010; //seven
segment display of 5
4'b0110 : seven_segment = 7'b0000010; //seven
segment display of 6
4'b0111 : seven_segment = 7'b1111000; //seven
segment display of 7
4'b1000 : seven_segment = 7'b0000000; //seven
segment display of 8
4'b1001 : seven_segment = 7'b0010000; //seven
segment display of 9
4'b1111 : seven_segment = 7'b0000000; //Doesn't
Matter Not Going to Display
default : seven_segment = 7'b1000000; //seven
segment displaying 0
endcase
end
///////////////////////////////Sine Wave
Generator/////////////////////////////////
///24 bit Adder
always_comb begin
Add_out = count + DQ_out; ////Using Count
Instead of Individual Digits
end
///DQ Flip Flop
always_ff@(posedge c2_sig) begin
DQ_out <= Add_out;
end
////Extracting the higher order bits for address assignment
always_comb begin
address_sig[10:0] = DQ_out[23:13];
end
12. ////////////////////////////End of Sine Generator///////////
///////////////////////////PWM Brightness
Control/////////////////////////////////////
/////////////////////Begining of first counter block_A with 4 MHz clock
always_ff@(posedge c1_sig)
begin
cout_A <= cout_A +4'b0001;
end
////////////////////////////End of first counter blockA with 4MHz Clock
///////////////////////////Second Counter, counts when button is pushed
always_ff @(posedge newclock)
begin
if (push_steady == 0)
cout_B <= cout_B +1;
else
cout_B <= cout_B;
end
///////////////////////////////End of second counter
///////////////////////////////Comparing the two counts
always_comb
begin
if (cout_A >= cout_B)
pwm_out = 1'b1;
else
pwm_out = 1'b0;
end
//////////////////////////////////////End of PWM Brightness
Control////////////////
endmodule