0% found this document useful (0 votes)
42 views15 pages

Digital Camera

The document describes a CCD image processing system implemented using multiple modules. It discusses implementing the modules using both a microcontroller alone and a microcontroller with a separate custom processor for the CCD preprocessing module. The CCD preprocessing module implementation improves performance and reduces microcontroller cycles but increases costs. The overall system captures an image, compresses it using DCT, and transmits the encoded image serially.

Uploaded by

rintansari
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views15 pages

Digital Camera

The document describes a CCD image processing system implemented using multiple modules. It discusses implementing the modules using both a microcontroller alone and a microcontroller with a separate custom processor for the CCD preprocessing module. The CCD preprocessing module implementation improves performance and reduces microcontroller cycles but increases costs. The overall system captures an image, compresses it using DCT, and transmits the encoded image serially.

Uploaded by

rintansari
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

CCD module

Mensimulasikan real CCD CcdInitialize adalah inisialisasiuntuk file gambar CcdCapture membaca "image" dari file CcdPopPixel mengeluarkan piksel pada suatu waktu
void CcdInitialize(const char *imageFileName) { imageFileHandle = fopen(imageFileName, "r"); rowIndex = -1; colIndex = -1; }
void CcdCapture(void) { int pixel; rewind(imageFileHandle); for(rowIndex=0; rowIndex<SZ_ROW; rowIndex++) { for(colIndex=0; colIndex<SZ_COL; colIndex++) { if( fscanf(imageFileHandle, "%i", &pixel) == 1 ) { buffer[rowIndex][colIndex] = (char)pixel; } } } rowIndex = 0; colIndex = 0; }

#include <stdio.h> #define SZ_ROW 64 #define SZ_COL (64 + 2) static FILE *imageFileHandle; static char buffer[SZ_ROW][SZ_COL]; static unsigned rowIndex, colIndex;

char CcdPopPixel(void) { char pixel; pixel = buffer[rowIndex][colIndex]; if( ++colIndex == SZ_COL ) { colIndex = 0; if( ++rowIndex == SZ_ROW ) { colIndex = -1; rowIndex = -1; } } return pixel; }

CCDPP (CCD PreProcessing) module


Melakukan penyesuaian zero-bias CcdppCapture menggunakan CcdCapture dan CcdPopPixel untuk memperoleh citra Melakukan penyesuaian zero-bias setelah setiap baris dibaca
void CcdppCapture(void) { char bias; CcdCapture(); for(rowIndex=0; rowIndex<SZ_ROW; rowIndex++) { for(colIndex=0; colIndex<SZ_COL; colIndex++) { buffer[rowIndex][colIndex] = CcdPopPixel(); } bias = (CcdPopPixel() + CcdPopPixel()) / 2; for(colIndex=0; colIndex<SZ_COL; colIndex++) { buffer[rowIndex][colIndex] -= bias; } } rowIndex = 0; colIndex = 0; }
#define SZ_ROW

64 #define SZ_COL 64 static char buffer[SZ_ROW][SZ_COL]; static unsigned rowIndex, colIndex;

void CcdppInitialize() { rowIndex = -1; colIndex = -1; } char CcdppPopPixel(void) { char pixel; pixel = buffer[rowIndex][colIndex]; if( ++colIndex == SZ_COL ) { colIndex = 0; if( ++rowIndex == SZ_ROW ) { colIndex = -1; rowIndex = -1; } } return pixel; }

UART module
Sebenarnya setengah UART - Hanya mentransmisikan , tidak menerima UartInitialize adalah inisialisasi untuk file output

UartSend Mentransmisikan (menulis ke file output) byte pada suatu waktu


#include <stdio.h> static FILE *outputFileHandle; void UartInitialize(const char *outputFileName) { outputFileHandle = fopen(outputFileName, "w"); } void UartSend(char d) { fprintf(outputFileHandle, "%i\n", (int)d); }

CODEC module
Model FDCT encoding ibuffer memegang asli 8 x 8 blok obuffer memegang dikodekan 8 x 8 blok CodecPushPixel disebut 64 kali untuk mengisi ibuffer dengan blok asli CodecDoFdct dipanggil sekali untuk mengubah 8 x 8 blok Dijelaskan dalam slide berikutnya CodecPopPixel disebut 64 kali untuk mengambil blok dikodekan dari obuffer
static short ibuffer[8][8], obuffer[8][8], idx; void CodecInitialize(void) { idx = 0; } void CodecPushPixel(short p) { if( idx == 64 ) idx = 0; ibuffer[idx / 8][idx % 8] = p; idx++; }

void CodecDoFdct(void) { int x, y; for(x=0; x<8; x++) { for(y=0; y<8; y++) obuffer[x][y] = FDCT(x, y, ibuffer); } idx = 0; }

short CodecPopPixel(void) { short p; if( idx == 64 ) idx = 0; p = obuffer[idx / 8][idx % 8]; idx++; return p; }

CODEC (cont.)
Menerapkan rumus FDCT C(h) = if (h == 0) then 1/sqrt(2) else 1.0 F(u,v) = x C(u) x C(v) x=0..7 y=0..7 Dxy x cos((2u + 1)u/16) x cos((2y + 1)v/16) Hanya 64 masukan yang mungkin untuk COS, sehingga tabel dapat digunakan untuk menghemat waktu kinerja - Floating-point dikalikan dengan nilai 32.678 dan dibulatkan ke integer terdekat - 32.678 dipilih untuk menyimpan nilai masingmasing dalam 2 byte memori - representasi Fixed-point dijelaskan lagi nanti FDCT unrolls inner loop dari penjumlahan, mengimplementasikan penjumlahan luar sebagai dua beruntun untuk loop
static short ONE_OVER_SQRT_TWO = 23170; static double COS(int xy, int uv) { return COS_TABLE[xy][uv] / 32768.0; } static double C(int h) { return h ? 1.0 : ONE_OVER_SQRT_TWO / 32768.0; } static const { 32768, 6392 }, { 32768, 18204 }, { 32768, 27245 }, { 32768, 32138 }, { 32768, 32138 }, { 32768, 27245 }, { 32768, 18204 }, { 32768, 6392 } }; short COS_TABLE[8][8] = { 32138, 30273, 27245, 23170, 27245, 12539, 18204, 12539, -6392, -23170, -32138, -30273, -

18204, -12539, -32138, -23170,


6392, -30273, -18204, -6392, -30273, -18204, -12539, -27245, -32138, 12539, 18204, 23170,

6392,

30273,

27245, -12539, -

23170, -27245, -12539, -6392, 30273, -

32138, -23170, 6392, -23170,

32138, -30273, 12539, -

30273, -27245,

23170, -18204,

static int FDCT(int u, int v, short img[8][8]) { double s[8], r = 0; int x; for(x=0; x<8; x++) { s[x] = img[x][0] * COS(0, v) + img[x][1] * COS(1, img[x][2] * COS(2, v) + img[x][3] * COS(3, img[x][4] * COS(4, v) + img[x][5] * COS(5, img[x][6] * COS(6, v) + img[x][7] * COS(7, } for(x=0; x<8; x++) r += s[x] * COS(x, u); return (short)(r * .25 * C(u) * C(v)); }

v) + v) + v) + v);

CNTRL (controller) module


Inti dari sistem CntrlInitialize hanya untuk konsistensi dengan modul lain CntrlCaptureImage menggunakan modul CCDPP untuk input gambar dan tempat dalam buffer CntrlCompressImage membagi 64 x 64 buffer ke 8 x 8 blok dan melakukan FDCT pada setiap blok menggunakan modul CODEC - Juga melakukan kuantisasi pada setiap blok CntrlSendImage mentransmisikan gambar yang dikodekan secara serial menggunakan UART modul
void CntrlSendImage(void) { for(i=0; i<SZ_ROW; i++) for(j=0; j<SZ_COL; j++) { temp = buffer[i][j]; UartSend(((char*)&temp)[0]); byte */ UartSend(((char*)&temp)[1]); byte */ } } }

/* send upper /* send lower

void CntrlCaptureImage(void) { CcdppCapture(); for(i=0; i<SZ_ROW; i++) for(j=0; j<SZ_COL; j++) buffer[i][j] = CcdppPopPixel(); }

#define SZ_ROW 64 #define SZ_COL 64 #define NUM_ROW_BLOCKS (SZ_ROW / 8) #define NUM_COL_BLOCKS (SZ_COL / 8) static short buffer[SZ_ROW][SZ_COL], i, j, k, l, temp; void CntrlInitialize(void) {}

void CntrlCompressImage(void) { for(i=0; i<NUM_ROW_BLOCKS; i++) for(j=0; j<NUM_COL_BLOCKS; j++) { for(k=0; k<8; k++) for(l=0; l<8; l++) CodecPushPixel( (char)buffer[i * 8 + k][j * 8 + l]); CodecDoFdct();/* part 1 - FDCT */ for(k=0; k<8; k++) for(l=0; l<8; l++) { buffer[i * 8 + k][j * 8 + l] = CodecPopPixel(); /* part 2 - quantization */ buffer[i*8+k][j*8+l] >>= 6; } } }

Menyatukan Semua
Pertama-tama menginisialisasi semua modul, kemudian menggunakan modul CNTRL untuk menangkap, mengompres, dan mengirimkan satu gambar Model sistem tingkat dapat digunakan untuk eksperimen yang luas - Bug lebih mudah untuk diperbaiki di sini daripada di model selanjutnya
int main(int argc, char *argv[]) { char *uartOutputFileName = argc > 1 ? argv[1] : "uart_out.txt"; char *imageFileName = argc > 2 ? argv[2] : "image.txt"; /* initialize the modules */ UartInitialize(uartOutputFileName); CcdInitialize(imageFileName); CcdppInitialize(); CodecInitialize(); CntrlInitialize(); /* simulate functionality */ CntrlCaptureImage(); CntrlCompressImage(); CntrlSendImage(); }

Design
Menentukan arsitektur sistem - Prosesor > Kombinasi prosesor single-purpose (custom atau standar) atau prosesor general-purpose - Memory, bus Fungsionalitas Peta untuk arsitektur itu - Beberapa fungsi pada satu prosesor - Satu fungsi pada satu atau lebih prosesor Implementasi - Sebuah arsitektur tertentu dan pemetaan - Ruang solusi diatur untuk semua implementasi Starting Point - Low-end general-purpose prosesor yang terhubung ke memori flash > Semua fungsi dipetakan ke perangkat lunak yang berjalan pada prosesor > Biasanya memenuhi daya, ukuran, dan kendala time-to-market >Jika kendala waktu tidak memuaskan maka implementasi selanjutnya dapat: # menggunakan prosesor single-purpose untuk time-critical functions # menulis ulang spesifikasi fungsional

Implementation 1: Microcontroller alone


Low-end prosesor bisa berupa Intel 8051 mikrokontroler Jumlah biaya IC termasuk NRE sekitar $ 5 Bekerja dengan baik di bawah daya 200 mW Time-to-market sekitar 3 bulan Namun, tidak mungkin memproses satu gambar per detik - 12 MHz, 12 siklus per instruksi # Melaksanakan satu juta instruksi per detik - CcdppCapture mempunyai nested loop yang menghasilkan 4096 (64 x 64) iterasi # ~ 100 Instruksi perakitan setiap iterasi # 409.000 (4096 x 100) petunjuk per gambar #Setengah dari anggaran untuk membaca gambar saja - Akan melampaui anggaran setelah menambahkan compute-intensive DCT dan pengkodean Huffman

Implementation 2: Microcontroller and CCDPP


EEPROM 8051 RAM

SOC

UART

CCDPP

Fungsi CCDPP diimplementasikan pada custom single-purpose prosesor - Meningkatkan kinerja lebih sedikit siklus mikrokontroler - Meningkatkan biaya NRE dan time-to-market - Mudah untuk mengimplementasikan # Datapath yang sederhana # Beberapa state di kontroler UART sederhana mudah diimplementasikan sebagai single-purpose prosesor EEPROM untuk memori program dan RAM untuk memori data ditambahkan juga

Microcontroller
Versi Synthesizable dari Intel 8051 - Ditulis dalam VHDL - Ditangkap di register transfer level (RTL) Mengambil instruksi dari ROM Decode menggunakan Instruksi Decoder ALU mengeksekusi operasi aritmatika -Sumber dan tujuan register berada dalam RAM Khusus instruksi pergerakan data yang digunakan untuk memuat dan menyimpan secara eksternal Program khusus menghasilkan deskripsi VHDL dari ROM dari output C compiler / linker
Block diagram of Intel 8051 processor core
Instruction Decoder

4K ROM

ALU

Controller

128 RAM

To External Memory Bus

UART
UART dalam modus siaga sampai dipanggil - UART dipanggil saat 8051 mengeksekusi instruksi dengan UART enable register sebagai alamat target > Komunikasi pemetaan Memori antara 8051 dan semua single-purpose processors > 8-bit paling bawah pada alamat memori untuk RAM > 8-bit paling atas pada alamat memori untuk pemetaan memori I / O device Kondisi Start mentransmisikan 0 mulai menunjukkan transmisi byte kemudian transisi ke status Data Kondisi Data mengirimkan 8 bit serial kemudian transisi ke kondisi Stop Kondisi Stop mentransmisikan 1 indikasi transmisi yang telah selesai kemudian transisi kembali ke modus siaga
FSMD description of UART
invoked

Idle:
I=0 I<8

Star t:
Transmi t LOW

Sto p:
Transmi t HIGH

Data
I=8

: Transmit data(I), then I++

CCDPP
Pengimplementasian hardware dari operasi zero-bias Berinteraksi dengan chip CCD eksternal Buffer internal, B, memori-dipetakan ke 8051 Variabel R, C adalah baris buffer, kolom indeks GetRow, membaca dalam satu baris dari CCD ke B ComputeBias, Menghitung bias untuk baris itu dan menaruhnya di variabel Bias FixBias, mengiterasi baris yang sama mengurangi Bias dari setiap elemen Transisi NextRow untuk GetRow untuk mengulangi proses pada baris berikutnya atau ke bentuk Idle ketika semua 64 baris diselesaikan
FSMD description of CCDPP

Idle:
R=0 C=0 R = 64

invoked

GetRow:
B[R][C]=Pxl C=C+1

C < 66

C = 66 R < 64

NextRo w:
R++ C=0 C = 64

C < 64

ComputeB ias:
Bias=(B[R][11] + B[R][10]) / 2 C=0

FixBias:
B[R][C]=B[R][C]-Bias

Menghubungkan Komponen SOC


Memetakan Memori - Semua prosesor single-purpose dan RAM terhubung ke bus memori 8.051 Membaca - Prosesor menempatkan alamat pada 16-bit alamat bus - Menegaskan membaca sinyal kontrol untuk 1 siklus - Membaca data dari 8-bit data bus 1 siklus kemudian - Perangkat (RAM atau SPP) mendeteksi untuk membaca sinyal kontrol - Cek alamat - Menempat dan memegang data yang diminta pada bus data untuk 1 siklus Menulis - Processor menempatkan alamat dan data pada alamat dan data bus - Menegaskan menulis sinyal kontrol untuk siklus 1 clock - Perangkat (RAM atau SPP) mendeteksi menegaskan menulis sinyal kontrol - Cek alamat bus - Membaca dan menyimpan data dari bus data

Software

You might also like