Friday, August 26, 2016

An ethernet based FPGA emulation environment

After all the simulations and debugging efforts, we hope the design will work on FPGA. Isn't that promised by the beauty of synchronous design, and the magic of the EDA tools? Unfortunately the design may not work properly, so we need to debug.

One debugging approach is to do this on HW using logic analyzer. Connect the outputs that need to be observed to external pins, and connect these pins to logic analyzer. The logic analyzer will display the data on these pins, and the developer will compare these data with expected values and figure out where the problem is. This is usually an iterative process in order to narrow down exactly which logic causes the problem.


Make NFTS USB drive writable on Mac OS

A USB drive, like external HDD, with NTFS is read only on Mac. Different approaches are discussed on internet. One approach is to use commercial software. Another approach is to install open-source software osxfuse. Have not tried commercial software. osxfuse does not work, because a requirement component, ntfs-3g (dated 2010-5-22) is not compatible with Mac OS X El Capitan (10.11.6).

I found the approach suggested in the following page the easiest, it works on El Capitan (10.11.6) perfectly. 

http://macdrug.com/free-ntfs-read-and-write-solutions-in-mac-os-x-el-capitan-or-older/

In the blog, I shamelessly copy the information from that page. All credit goes to the original author.

1. Change the drive label, if it has space

I do not know how to do it on Mac OS. I did it on Ubuntu. On Ubuntu, it is pretty simple, if the USB drive has NTFS.

$ sudo ntfslabel /dev/sdb2 <new_label_name>

2. Add write permission

Plug in the drive to Mac. This time you should see the drive of new name under "Devices" in Finder.

Edit file /etc/fstab, and add the following line. If the file does not exist, create the file.

LABEL=<new_label_name> none ntfs rw,auto,nobrowse

After the file is saved, eject the drive and plug in the drive. This time the drive will not appear under "Devices" in Finder, but it can be found in folder "/Volumes".

If you think this is not convenient to access, you can create an alias to the drive using the following command. Now it will be listed under your home directory. However, if the drive is removed, the alias still exists, but it is invalid.

$ ln -s /Volumes/<new_label_name> ~/<new_label_name>

JPEG Encoder FPGA Implementation


I have been working as a system engineer on video coding for a long time. Here are what a video system engineer often does.

1. Read the standard specification MANY times,
2. Optimize the encoder and decoder implementation,
3. Develop system architecture,
4. Write C model, which is a software to model the system architecture.

Based on system architecture, HW engineer will develop micro-architecture of certain components and write HDL (verilog or VHDL) to implement them in ASIC or FPGA. Software or firmware engineer will write driver to utilize the HW modules, and provide high level API for application developers.

In the post, I will use a simple image coding standard, JPEG, as an example to show the complete design flow from specification to HW implementation in FPGA.

Verilog is the language of choice for HW implementation. The usage of verilog may seem to be unconventional to veteran ASIC designer. However, I think that's good enough for a system engineer.

1. JPEG encoder software


2. Architecture


3. HDL implementation


4. Simulation


5. FPGA implementation


6. Source code and copyright

Tuesday, May 3, 2011

Compile x264 on Windows

x264 is a popular open-source H.264 encoder. It comes with the build files for Linux environment. To build project on Windows, the easiest approach is to do this using MingW/MSYS.
All the information is from the link: http://doom10.org/index.php?topic=26.0. However, the procedure in that page can be much simplified as explained in this post.

1. Operating System

Windows 7 Home Premium (64-bit operating system)

2. Software and configuration


2.1. MingW/MSYS

Go to page: http://sourceforge.net/projects/mingw/files/
Simply click "Download mingw-get-inst-20110316.exe (576.1 KB)to download and install software.
When asked to select software features, check "C++ compiler", and "MingW Devloper Toolkit". These are good features, but may not be necessary to compile x264.
Add the path to MingW/bin to system path. For example, I install MingW under "c:\work", so I add "C:\work\MinGW\bin". This is needed in order to search for the libraries to run x264, especially libpthread-2.dll.

2.2. Download yasm


Download yasm of the latest version (version 1.1.0 currently, http://www.tortall.net/projects/yasm/releases/yasm-1.1.0-win32.exe). 
Copy this file to the MinGW\bin folder, and rename it to yasm.exe.


2.3. Download x264 source code

The latest x264 encoder can be downloaded from the following page:
http://www.videolan.org/developers/x264.html

3. Compile


3.1. Open "MingW shell"


3.2. Go to the top-level directory of x264 project

MingW shell will have a linux/unix like directory structure, and it will be at some unfamiliar directory by default. I downloaded x264 to "c:\work\x264", so go to the folder using the following command:
$ cd /c/work/x264
However, if you will not be able to see a folder "/c".

3.3. Run "make" to compile the code


$ make
It will run "./configure", followed by actual "make". If you forget to download yasm, "./configure" command will report such error.

Thursday, April 28, 2011

FFMPEG H.264 Decoder

FFMPEG is an open-source project on multimedia processing. Most people uses the applications it provides to perform multimedia processing tasks. It can also use it as a collection of libraries on top of which the developer can build multimedia applications.

This post will show how to write an H.264 decoder using functions in FFMPEG libraries.

1. Introduction to FFMPEG

2. Basic design

3. Source code