[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] Sainsmart Hall Effect Sensor board

[ref from: http://bobselectronics.blogspot.com/2014/07/sainsmart-hall-effect-sensor-board.html]

 Sainsmart Hall Effect Sensor board

This is a very simple description of how this board works. I was unable to find this info on the internet nor was the company I bought the board from any help.
This is a very inexpensive pre-assembled hall effect sensor available on EBAY that provides both a digital and analog output that is easily incorporated into the Arduino as a RPM measurement tool.
There are 4 connections:  + is +5V, - is ground, AO is analog out and DO is digital out.
A 10K pull up resistor is needed between which ever output is used and +5V. This will keep the DO at high when no magnetic influence is detected. When a magnetic field is detected the DO pin will go low and this can be inputted  to one of the Arduino digital input pins. There are two red LEDs on the board. The lower left one is on when power is supplied to the board and the lower right is on when DO goes low. If the lower right is on with no magnetic field then the variable pot must be adjusted until it goes out.
The analog output varies from 0 to +2.5V.
There are several Arduino sketches for using a hall effect sensor available on the internet but they have poor low RPM accuracy and I made a few modifications that I will post when I have a little time. I use a Sainsmart LCD keypad shield on the Arduino and it displays the RPM as a self contained unit. 

Here is a link to a diagram of the Eagle layout:
https://drive.google.com/file/d/0BxCQZLsb0vTKQndodjFrUVJqRFU/edit?usp=sharing

[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);

}

[CPS] Cyber Physical System

A new trend of embedded system, Cyber Physical System, will dominate the embedded system field in new future.

[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

[Gem5] Important Folders/Files in Gem5 source

From users perspective, it is not necessary to know all of source files in gem5. We just need to know some important folders/files which we will modify to fit our CPU architecture.

To me, the folder "configs" is important, we should dig into it first to see some examples of sample configurations and you can create a configurations for your own.

Below are some important folders/files which I think that we should know before we modify it to make our own CPU:

[Python] Inheritance

Python is an object-oriented programming language, so it also has inheritance, overloading, overriding, etc. Below is one of the simple examples of how inheritance is implemented in Python.

By looking at below example, it is easy to learn how a class inherits from other classes and how a class is declared, defined and used in Python.

--------------------------------
Python là một ngôn ngữ lập trình hướng đối tượng! bên dưới là một ví dụ đơn giản về tính thừa kế trong Python.

[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:

[OOP] Function Poniters/ con trỏ hàm

Below is a note which demonstrates how to declare and use function pointers.
 (VN version: Ví dụ đơn giản về con trỏ hàm: cách khai báo, cách gọi con trỏ hàm)


[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.

Related Posts Plugin for WordPress, Blogger...