Showing posts with label Tutorials. Show all posts
Showing posts with label Tutorials. Show all posts

Circular Array

Circular Array = Circular Buffer = Cyclic Buffer = Ring Buffer

The magic behind Circular Array is the operator: Mod


[HW] Why do we need to separate data cache and instruction cache?

There are actually several reasons.
First and probably foremost, the data that's stored in the instruction cache is generally somewhat different than what's stored in the data cache -- along with the instructions themselves, there are annotations for things like where the next instruction starts, to help out the decoders. Some processors (E.g., Netburst, some SPARCs) use a "trace cache", which stores the result of decoding an instruction rather than storing the original instruction in its encoded form.

[Arduino] Burning the Bootloader on ATMega328 using Arduino UNO

Burning the Bootloader on ATMega328 using Arduino UNO

(Tải bootloader lên Arduino)

Burning a bootloader to an atmega328P or atmega328 using Arduino Uno version 1.6.5 or later is now easier than ever.

Step1: open and upload the sketch ArduinoISP to atmega328P on your Arduino board( without connection with another atmega328P )

Embedded System interview Question - Câu hỏi cơ bản thường gặp trong lập trình nhúng

Câu hỏi cơ bản thường gặp trong lập trình nhúng

1. What are static variables?


Static variable in a function only remain one copy of itself.
Static variable in a module can be used by any function in the module
Static function can only be called in its class


2. What are volatile variables?
Volatile variables may change its value unexpectedly in the program.
The program will check its value every time, it tries to use it.
If a variable is not volatile, the program may keep a copy of the var in its cache.


3. What do you mean by const keyword ?
A constant variable is a read only variable. You cant change its value else where except initialization.


4. What is interrupt latency?
Interrupt latency is the time between the generation of interrupt and the time for interrupt handler to process it.


5. How you can optimize it?
We may use polling and message passing for interrupt to handle interrupt immediately.

[Arduino] Build error on Arduino Eclipse plugin

If you get the following error while building an ARduino UNO application on Eclipse:

"make all
Cannot run program "make": Launching failed

Error: Program "make" not found in PATH"

Then, you can fix it by including the makefile program path into environment variable PATH.

The fix can be as below:

Step1: if you have not had makefile on your computer yet, then you can install: MinGW_Toolchains.
    It can be downloaded from:
                    http://sourceforge.net/projects/mingw-w64/files/latest/download?source=files

Step2: Assuming that you had installed MinGW_Toolchains into drive C, now you can add the path: C:\MinGW_Toolchains\mingw64\bin into your PATH variable environment.

You can update this PATH variable environment via Eclipse as below:
From Eclipse: Window --> Preferences --> C/C++ --> Environment

Variable PATH will be there, then you can update the PATH similarly as following:



Scheduling algorithm

This is an implementation of ASAP scheduling algorithm, ALAP scheduling algorithm and LIST_L scheduling algorithm.

It is assumed that:
    + ALU will do the arithmetical operations: +, -, >,<, etc.
    + Multiplier: *
    + Divisor: /

LIST_L scheduling algorithm: (adjusted from the book: Synthesis and Optimizations of Digital Circuits by Giovanni De Micheli)


{

            Repeat until all vertices determined {

                        Determined the distance label between vertex Vi and sink;

             }



Repeat until all non-leaf vertices are scheduled: {

                        Repeat for each source type

                          {

                                      Determine ready vertices U;

                                      Determine unfinished vertices T;

                                      Select S Є U;

                                      Schedule S at clock cycle l;

                           }

                            l = l + 1;

            }                                           

            return (t);

}

[Gem 5] Recover ubuntu root password in Virtualbox (reset password trong ubuntu)

some how you get lost your password. Then, I can not remember what your password is. you can reset your password.

Step1: restart your ubuntu and hold shift key until the boot screen appears.

Step2: choose the generic second boot option

Step3: the new screen appears, choose "Drop into root shell prompt"

Step4: run below command:
           >> mount -rw -o remount /

Step5: run below command to create new root password
          >> sudo passwd root


If you see some error like:
passwd: Authentication token manipulation error
passwd: password unchanged

This means that you did not run the command at step 4. If so, try to run the command at step 4 and then command at step 5.

--
Lấy lại password trong ubuntu dùng virtualbox. Theo các bước ở trên

[gem5] How to install Cuda on ubuntu 14.04

Step 1: get the suitable cuda repo from https://developer.nvidia.com/cuda-downloads
    in this case, cuda for ubuntu 14.04 is fetched using below command:
      >> wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.0-28_amd64.deb

Step 2: get cuda and install:
    >> sudo dpkg -cuda-repo-ubuntu1404_7.0-28_amd64.deb

Step 3: install cuda tookit
    >> sudo apt-get install cuda

When you are done with installation, you should set the Cuda environment variable. It is better to place below commands into your .bashrc file in your home director

export CUDA_HOME=/usr/local/cuda-7.0
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64

PATH=${CUDA_HOME}/bin:${PATH}
export PATH 


---
Cách cài đặt Cuda trên ubuntu 14.04. Theo từng bước như ở trên.

[Gem 5] Steps to compile an ARM program, run execution program and stats output

Follow steps below:

Step 1: get the program ( queen.c program is used in this case )

[~/gem5]  wget https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_14/SingleSource/Benchmarks/McGill/queens.c

Step 2: compile the program, it is recommended to compile with static flag

[~/gem5]  arm-linux-gnueabi-gcc –DUNIX –o queens queens.c –static

Step 3:run program in SE mode

[~/gem5]  ./build/ARM/gem5.opt configs/example/se.py -c queens –o 16

Step 4: display statistics:
[~/gem5] cat m5out/stats.txt

[Python] Small Python program applying Skeleton

This is an example of how to apply skeleton in the previous post.
This program is just the simplest calculator in the world. The purpose is just to prove how efficient to apply the skeleton into your project. It makes the project have a good look and well-organized.

--------------------
Chương trình máy tính python đơn giản. Cách áp dụng coding style ở bài trước
--------------------

[Python] Skeleton

A good programming habit is to have a skeleton for every new project. Below is a simple skeleton Python project which can be served as an entry point for a initial start of writing your own skeleton:

----------
Bộ khung mẫu của một chương trình trong python! Nó sẽ giúp ích trong việc tổ chức code
----------

import sys
def main():
    func1()
    func2()
    pass

def func1():
    # doing your work
    pass

def func2():
    # doing your work
    pass
    
if __name__ == '__main__':
    sys.exit(main())

[Gem5] GEM5 Installation on ubuntu 14

Just follow steps below:

step1: sudo apt-get update; sudo apt-get upgrade

step2: sudo apt-get install mercurial scons swig gcc m4 python python-dev libgoogle-perftools-dev g++

step 3: hg clone http://repo.gem5.org/gem5

step 4: cd gem5/

step5: scons build/ARM/gem5.opt -j2

step6: build/ARM/gem5.opt configs/example/se.py -c tests/test-progs/hello/bin/arm/linux/hel
­lo

[Technical Term] SPM - Scratch pad memory

SPM - Scratch Pad Memory
This is a high-speed internal memory which is on-chip memory. In CMP ( Chip Multi-core Processor), each core will have its own SPM.

Each core will use its own SPM to store temporary data for latter use in order to improve the performance in term of speed and power consumption. Moreover, the cores can access SPM of each other ( remote SPM ). Remote SPM and local SPM access time are usually less than main memory access time.

The SPMs on CMP can be simply schemed as below:

[Basic VHDL] Wait Statements

Wait statement is one of the useful statements in VHDL. we can use it for either synthesizable or non-synthesizable code. Below are 3 main syntax for wait statement:

+ wait until condition
 For example: wait until i_clk_sl'event and i_clk_sl = '1';

[Basic VHDL] Basic difference between signal and variable

There are some differences between signal and variable, but we just need to keep in mind the following basic differences:
+ Variables can only be used inside processes
+ Variables are assigned using the := assignment symbol; signals are assigned using the <= assignment symbol.
+ variables immediately take the value of their assignment; but, signal is going to take the value at the next clock cycle.

[Basic VHDL] Concatenation operator

Concatenation operator is very useful in VHDL when we want to do the shift logic.

Its syntax: A & B

Example:

[Basic VHDL] Type Conversion / Chuyển đổi kiểu dữ liệu

1- Automatic Type conversion:
Elements of signed, unsigned, and std_logic_vector can be converted automatically to std_ulogic or std_logic.

For example,

x1_std_logic <= y1_std_logic_vector(1);
x2_std_logic <= y2_unsigned(3);

[Basic VHDL] Fully Synchronous counter ( Bộ cộng đồng bộ 8 bít )

Here, we implement a 8-bit counter which has 4 controls input: clear, load, enable, and carry. All the states can be changed at the rising clock edge.

Specification:
if clear = 1 => the output is reset to 0;
if load = 1 => the input will be loaded to the output q;
if enable = 1 and carry = 1 => the output will be increased at every single clk.
      => if carry =1, then the carry out Cout will be calculated.

[Basic VHDL] arithmetic operation

One of the common errors that many beginners will experience at the first time when they use vhdl is:: ERROR:HDLCompiler:1731 which means that : found '0' definitions of operator "+", cannot determine exact overloaded matching definition for "+". Let see what the root cause of this error is and how to fix it:

In VHDL, we cannot use arithmetic operation on std_logic or std_logic_vector data type directly. Let consider below code snippet:

[Basic VHDL] Type Conversion Functions

VHDL is a very strong-type language, it means that we must supply the arguments of exactly right type to a function or operator. Otherwise, the compiler will give an error message.

Although many functions or operators are overloaded so that you can use the same functions for more than one type of data, in many cases it is a must to do a type conversion.

Many type conversions can be found in the package std_logic_arith in ieee library. Mostly we deal with std_logic_vector, unsigned and integer type.

Below are some common conversion functions, we should memorize because of its convenience:

std_logic_vector to  unsigned: unsigned(x)

std_logic_vector to integer: conv_integer(x)

unsigned to std_logic_vector: std_logic_vector(x)

unsigned to integer: conv_integer(x)

integer to unsigned: conv_unsigned(x,len)

integer to std_logic_vector: conv_std_logic_vector(x,leng)

std_logic_vector to integer: to_integer(unsigned(x));


vhdl, tutorial, type conversion functions, common vhdl conversion function
Related Posts Plugin for WordPress, Blogger...