Friday, December 31, 2010

VHDL 360, Write More Complex Models Continued

  • While Loop
  • For Loop
  • Exercise 1: Serial In Parallel Out
  • Wait Statement
  • Conversion Functions
  • Lab 1.a: Write the Code for a Fibonacci Sequence
  • Lab 1.b: Write the Code for Knight Rider LEDs

uCOS-III VS uCOS-II (File Names and Contents)

Introduction
This is the second post out of five under the same topic. In the first post in the comparison, I pointed out the difference in features. In this post, I will point the difference in file names and contents in both kernels. Difference can be summed up to 13.

Changes in File Names and Contents
1- os_app_hooks.c is added to uCOS-III for convenience so the user can add application hooks. Copy this file to the application directory and edit the contents of the file.
2- os_cfg_app.h is added to uCOS-III. In old uCOS-II, all configurations were stored in os_cfg.h. In uCOS-III, application specific configurations are moved from os_cfg.h to os_cfg_app.h.
3- os_cfg_r.h used in uCOS-II as a starting point for configuring the kernel is now changed to os_cfg.h in uCOS-II. The new file is reserved for configuring non-application specific kernel features.
4- Porting files are the same but some variables and function names are changed.
  • OSIntNesting to OSIntNestingCtr
  • OSTCBCur to OSTCBCurPtr
  • OSTCBHighRdy to OSTCBHighRdyPtr
  • OSInitHookBegin to OSInitHook
  • OSTaskStatHook to OSStatTaskHook
  • OSTaskIdleHook to OSIdelTaskHook
  • OSInitHookEnd and OSTCBInitHook are removed
  • OSTaskStkInit in the new kernel has different arguments. Instead of taking the task's stack start address, it takes the task's stack size and its stack base address. This implies a slight change in this function code in uCOS-III.
5- os_dbg.c is a must in uCOS-III compared to its counter part, os_dbg_r.c, in uCOS-II.
6- os_int.c is added to uCOS-III to support the new feature called interrupt queuing in uCOS-III. This feature allows posting calls from ISRs to be deferred to a task level handler. The goal behind this feature is to reduce interrupt latency.
7- os_pend_multi.c is added to uCOS-III to allow tasks to pend on multiple kernel objects. The old code was written in os_core.c in uCOS-II.
8- os_prio.c is added to uCOS-III to isolate the code that determines the highest priority task ready to run. A port developer can re-implement this file in assembly equivalent if this will improve the performance.
9- A message mailbox is simply a message queue with one entry. That's why the file os_mbox.c is no longer available in uCOS-II.
10- os_msg.c is added to uCOS-III to encapsulate the management of messages in message queues.
11- os_stat.c is added to uCOS-III to extract the statistics task code from os_core.c.
12- os_type.h is added to uCOS-III. This file is used to adapt the data types sizes to the cpu architecture rather than being assumed by the port developer as in uCOS-II.
13- os.h is added to uCOS-III to act as the main header file and replace ucos_ii.h in uCOS-II.

Friday, December 17, 2010

VHDL 360, Simulation Using ModelSim

  • Command Line Simulation
  • Compile and Simulate
  • Add Signals to Wave
  • Applying Inputs
  • Run Simulation
  • Make Files
  • Interactive Simulation

VHDL 360, Write More Complex Models

  • Statements
  • Process Description
  • Sequential Assignments
  • Data Objects
  • Objects Scope
  • Data Objects Example
  • Skills Check
  • Case Statement
  • Exercise 1: 2x4 by Decoder
  • If Statement
  • Exercise 2: D FF with Synchronous Reset
  • Exercise 3: Simple Comparator

Monday, October 4, 2010

uCOS-III VS uCOS-II (Features)

Introduction
Migrating from uCOS-II to uCOS-III was a humming question in my head and the heads of many. I started trying to answer this question with the idea that uCOS-III is totally a new kernel but with roots into uCOS-II. My survey is based on uCOS-II source code and the Win32 for uCOS-III evaluation I got recently.

Differences between uCOS-III and uCOS-II can be classified under 5 categories:
  1. Features
  2. Source file names and contents
  3. Conventions
  4. Variable names
  5. API changes
These areas are of great importance for those who are willing to port uCOS-II applications to uCOS-III.

I will try to explain briefly each category in a separate post.

If any of my results are not accurate enough due to the lackness of uCOS-III source code, please feel free to email me at amraldo@hotmail.com to correct it in this post.

Changes in Features
uCOS-III is introduced in 2009 while uCOS-II was first introduced in 1998. For both kernels, books and source code are available. But for uCOS-III, Micrium followed a new model. The source code is made available only to licensed users.

Unlike uCOS-II, uCOS-III has no limitation on numbers of tasks (255 tasks mazimum in uCOS-II) nor on the number of tasks at each priority level. Consequently, RR scheduling was introduced in uCOS-III.

uCOS-III kept all services available except for the message mailbox. It was totally removed. Although a message mail box can be used exactly like a binary semaphore, in addition for message passing, but after all it is indeed a message queue with a single entry. Another breakthrough is that mutexes and task's suspension resumption now support nesting.

Advances in performance were considered in the design of uCOS-III compared to uCOS-II. Smaller code size, support for run-time configurability, less interrupt latency, enhanced built-in measurements, time stamping on posting APIs, optimize schedulers in assembly are dreams coming into reality.

uCOS-III is working on being a safety-critical certified software. It is compliant with
MISRA C 2004 (except for 8 rules) and the certificaion is in progress to achieve DO178B Level A, EUROCAE ED-12B, SIL3/SIL4, and IEC 61508.

Friday, August 27, 2010

VHDL 360, Create Your First Model for a Simple Logic Circuit

  • Entity
  • Exercise 1: Write the Entity of a 1-bit Full Adder
  • Architecture
  • Internal Signals
  • Expressions & Operators
  • Exercise 2: Write the Architecture of a 1-bit Full Adder
  • With-Select
  • When-Else
  • Exercise 3: Write the Entity and Architecture of 2x4 Decoder and 4x2 Encoder using With-Select and When-Else

Sunday, July 25, 2010

FreeRTOS Course - Semaphore/Mutex Management

  • Binary Semaphore
  • Counting Semaphore
  • Mutex
  • More about Semaphore/Mutex
  • Semaphore/Mutex Management APIs
  • Lab4: Semaphore Mutex Management

Saturday, July 3, 2010

Free RTOS Course - Queue Management

  • Queues
  • More About Queues
  • Queue Management APIs
  • Lab 3: Queue Management

Friday, July 2, 2010

VHDL 360, Introduction to VHDL

  • What is VHDL?
  • VHDL History
  • Uses of VHDL
  • Basic Design Flow
  • VHDL Model
  • Entity
  • Architecture
  • Concurrency
  • Simple Example

Wednesday, June 30, 2010

VHDL 360, a Contribution from the SAMs

About VHDL

VHDL is a powerful language developed in the 1980's by the US department of defense, afterwards adopted by the IEEE to be a standard in 1987. Many enhancements & new features were added afterwards in the 1993, 2002 & 2008 standards...

VHDL is widely used around the word in the design & verification processes of High & Very High Scale integrated circuits design (HSI & VHSI)

About the Free Course, VHDL 360

VHDL 360 is a free course. During the course, SAMS will try to guide & teach students how to write efficient VHDL code to model digital circuits, the course outline will be as follows:

  • Introduction to VHDL
  • Writing 1st Model
  • Writing more complex Models
  • Building Hierarchy
  • Modeling FSMs & Memories
  • Code Reuse
  • Verification

The course is based on VHDL IEEE 1076 - 1993 standard. It is vendor independent. Any text editor and tools you have license for can be used. Any consultation with regards to tools setup or support will not be provided and trainees should consult their own vendor for any of the issues or problems they face with this regards.

Feel free to post any comments, questions, and feedback through the blog. We promise to answer your questions as soon as possible Insha'Allah.

This VHDL course is for free use as long as the original copyright is reproduced. Feel free to spread and share. Knowledge is every body's right just like air and water.

Sunday, June 27, 2010

Free FreeRTOS Course - Task Management

  • Task C/Cs
  • Task States and Transitions
  • Task Priorities
  • Implementing a Task
  • Task's Hook
  • Idle Task
  • Idle Task Hook
  • Task Management APIs
  • Lab 2: Task Management

Monday, June 21, 2010

Free FreeRTOS Course - Introduction to FreeRTOS

  • At the Beginning
  • FreeRTOS in Literature
  • FreeRTOS History
  • FreeRTOS V6.0.0
  • FreeRTOS Features
  • Related Products
  • Licensing
  • FreeRTOS Variants
  • Free Support
  • Lab 0: Getting Started

Thursday, June 17, 2010

FreeRTOS Free Course

FreeRTOS the Real-Time Kernel

FreeRTOS is a small, yet powerful real-time operating system developed by Richard Barry and FreeRTOS Team and described in his book "Using the FreeRTOS Real-Time Kernel – a Practical Guide". The operating system is highly CPU independent and has been ported to numerous microprocessor platforms. The source code is available via this web site. It is distributed under the GPL with an optional exception. The exception permits users' proprietary code to remain closed source while maintaining the kernel itself as open source, thereby facilitating the use of FreeRTOS in proprietary applications.

FreeRTOS is designed to be small and simple. The kernel itself consists of only three or four C files. To make the code readable, easy to port, and maintainable, it is written mostly in C, but there are a few assembler functions included where needed (mostly in architecture specific scheduler routines). The download contains prepared configurations and demonstrations for every port and compiler, allowing rapid application design.

There are two forks of this OS; OpenRTOS and SafeRTOS. OpenRTOS, which has an identical code base to FreeRTOS but with different licensing. The OpenRTOS license removes all reference to the GPL and its implications. For example, one of the conditions of using FreeRTOS in a commercial product is that the user is made aware of the use of FreeRTOS and the source code must be provided upon request. OpenRTOS doesn't have this requirement. The other spin, SafeRTOS, is based on the FreeRTOS code base but has been updated, documented, tested and audited to enable its use in safety-critical products.

About the Free Course

The course scope is to teach students how to use FreeRTOS APIs. The course is based on V6.05. The course is organized in 8 modules. They are:

· Introduction to FreeRTOS

· Kernel Structure

· Task Management

· Queue Management

· Semaphore/Mutex Management

· Co-Routine Management

· Advanced Features

· FreeRTOS Porting

The labs for these modules are available based on the 80x86 industrial ports that use the open watcom compiler and ARM 7/Cortex that use the Keil compiler. Labs are only available commercially to our customers.

Feel free to post any comments, questions, ad feedback through the blog. I promise I will answer your post within 5 working days ISA.

This free course is for free use as long as the original copyright is reproduced. Feel free to spread, share, modify, or any other verb you can do with the material. Knowledge is every body's right just like air and water.

FreeRTOS GUI

After the course, I will publish a post on how to port an open source GUI for FreeRTOS. This post will help in demonstrating the power of FReeRTOS and how easily it can be extend with middleware. I have tested it only my PC. Work is currently on progress to test it on one of STM32 boards based on the ARM Cortex M3 processors.

Saturday, May 29, 2010

Adding Interrupts to uCOS-II Running on Microsoft Windows

How to Simulate Interrupts?

In the past few days, I was asked that question many times. So, I decided to make a small software example to show how uCOS-II interrupts can be simulated under Windows.

I modified the uCOS-II port to support 8 interrupts at the same level of priority. Moreover, these interrupts can occur simultaneously but their ISR execution order depends on the implementation. I followed the uCOS-II tasks's priority schema with interrupts (i.e. the smaller the interrupt number, the faster it will be executed).

The implementation core is done by creating a Win32 thread as a generic IRQ handler in os_cpu.c. In addition, 2 utilities were added in the file pc.c. They are used to register and unregister user ISRs. ISRs will be written only in C.

Testing the Interrupts Implementation

My test code is based on the 1st example in uCOS-II book. I modified this code to have 5 tasks with the highest priority to be interrupt-driven. Each task of the 5 will wait for a semaphore before printing its number on the screen. ISRs will trigger these tasks by signaling the semaphores. The test code can be found here.

To automate this test, I wrote a utility that generates these 5 interrupts randomly every 2 milliseconds. The code for this utility can be found here. I just run my test code then run the interrupt generation utility. To distinguish the interrupt-driven tasks from others, I modified their code to print their IDs in a new color scheme. The interrupt generation utility code is found here.

Fig 1 shows the application running with interrupts. Numbers with blue background are those printed by tasks driven by interrupts.

Figure 1: Example 1 Modified to Run with Interrupts