Vivado HLSのExampleを試してみる1(axi_lite の生成)
Vivado HLSのExampleを試してみる2(シミュレーションと合成)
Vivado HLSのExampleを試してみる3(インターフェイス)
Vivado HLSのExampleを試してみる4(C/RTL Cosimulation)
Vivado HLSのExampleを試してみる5(IPにした)
Vivado HLSで作ったaxi_lite IPをテストした
エラーの内容を下に示す。
@E [SYNCHK-41] image_lap_fil.c:61: unsupported pointer reinterpretation from type 'int' to type 'i32*' on variable 'r_addr'.
@I [SYNCHK-10] 1 error(s), 0 warning(s).
// laplacian_filter.c
// RGBをYに変換後にラプラシアンフィルタを掛ける。
// ピクセルのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 2013/09/16
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
#include <fcntl.h>
#include <assert.h>
#include <ctype.h>
#include <sys/stat.h>
#include <unistd.h>
#define HORIZONTAL_PIXEL_WIDTH 800
#define VERTICAL_PIXEL_WIDTH 600
#define ALL_PIXEL_VALUE (HORIZONTAL_PIXEL_WIDTH*VERTICAL_PIXEL_WIDTH)
#define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024)
#define BUFSIZE 1024
#define MEASURE_COUNT 5000
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2);
int conv_rgb2y(int rgb);
int chkhex(char *str);
int image_lap_fil(unsigned int fb_addr, unsigned int bitmap_dc_reg_addr)
{
int xy[3][3];
char buf[BUFSIZE], *token;
unsigned int read_num;
unsigned int next_frame_addr;
unsigned int val;
int lap_fil_val;
int x, y;
unsigned int r_addr, w_addr;
unsigned int r_buf, w_buf, bitmap_buf;
unsigned int line_buf[3][HORIZONTAL_PIXEL_WIDTH];
int a, b;
int fl, sl, tl;
// ラプラシアンフィルタの結果を入れておくフレーム・バッファ
next_frame_addr = ((fb_addr + (ALL_PIXEL_VALUE*4)) & (~(int)(PAGE_SIZE-1))) + PAGE_SIZE;
// RGB値をY(輝度成分)のみに変換し、ラプラシアンフィルタを掛けた。
for (y=0; y<VERTICAL_PIXEL_WIDTH; y++){
for (x=0; x<HORIZONTAL_PIXEL_WIDTH; x++){
if (y==0 || y==VERTICAL_PIXEL_WIDTH-1){ // 縦の境界の時の値は0とする
lap_fil_val = 0;
}else if (x==0 || x==HORIZONTAL_PIXEL_WIDTH-1){ // 横の境界の時も値は0とする
lap_fil_val = 0;
}else{
if (y == 1 && x == 1){ // 最初のラインの最初のピクセルでは2ライン分の画素を読み出す
for (a=0; a<2; a++){ // 2ライン分
for (b=0; b<HORIZONTAL_PIXEL_WIDTH; b++){ // ライン
r_addr = fb_addr+((y+(a-1))*HORIZONTAL_PIXEL_WIDTH+b)*4;
line_buf[a][b] = *(volatile unsigned int *)r_addr;
line_buf[a][b] = conv_rgb2y(line_buf[a][b]);
}
}
}
if (x == 1) { // ラインの最初なので、2つのピクセルを読み込む
for (b=0; b<2; b++){ // ライン
r_addr = fb_addr+((y+1)*HORIZONTAL_PIXEL_WIDTH+b)*4;
line_buf[(y+1)%3][b] = *(volatile unsigned int *)r_addr;
// (y+1)%3 は、使用済みのラインがに読み込む、y=2 の時 line[0], y=3の時 line[1], y=4の時 line[2]
line_buf[(y+1)%3][b] = conv_rgb2y(line_buf[(y+1)%3][b]);
}
}
// 1つのピクセルを読み込みながらラプラシアン・フィルタを実行する
r_addr = fb_addr+((y+1)*HORIZONTAL_PIXEL_WIDTH+(x+1))*4; // ラプラシアン・フィルタに必要な最後のピクセルを読み込む
line_buf[(y+1)%3][x+1] = *(volatile unsigned int *)r_addr;
// (y+1)%3 は、使用済みのラインがに読み込む、y=2 の時 line[0], y=3の時 line[1], y=4の時 line[2]
line_buf[(y+1)%3][x+1] = conv_rgb2y(line_buf[(y+1)%3][x+1]);
fl = (y-1)%3; // 最初のライン, y=1 012, y=2 120, y=3 201, y=4 012
sl = y%3; // 2番めのライン
tl = (y+1)%3; // 3番目のライン
lap_fil_val = laplacian_fil(line_buf[fl][x-1], line_buf[fl][x], line_buf[fl][x+1], line_buf[sl][x-1], line_buf[sl][x], line_buf[sl][x+1], line_buf[tl][x-1], line_buf[tl][x], line_buf[tl][x+1]);
}
w_addr = next_frame_addr+(y*HORIZONTAL_PIXEL_WIDTH + x)*4;
*(volatile unsigned int *)w_addr = (lap_fil_val<<16)+(lap_fil_val<<8)+lap_fil_val ;
// printf("x = %d y = %d", x, y);
}
a++;
}
// ラプラシアンフィルタの掛かった画像のスタートアドレスを bitmap-disp-cntrler-axi-master にセット
*(volatile unsigned int *)bitmap_dc_reg_addr = next_frame_addr;
return(0);
}
// RGBからYへの変換
// RGBのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 輝度信号Yのみに変換する。変換式は、Y = 0.299R + 0.587G + 0.114B
// "YUVフォーマット及び YUV<->RGB変換"を参考にした。http://vision.kuee.kyoto-u.ac.jp/~hiroaki/firewire/yuv.html
// 2013/09/27 : float を止めて、すべてint にした
int conv_rgb2y(int rgb){
int r, g, b, y_f;
int y;
b = rgb & 0xff;
g = (rgb>>8) & 0xff;
r = (rgb>>16) & 0xff;
y_f = 77*r + 150*g + 29*b; //y_f = 0.299*r + 0.587*g + 0.114*b;の係数に256倍した
y = y_f >> 8; // 256で割る
return(y);
}
// ラプラシアンフィルタ
// x0y0 x1y0 x2y0 -1 -1 -1
// x0y1 x1y1 x2y1 -1 8 -1
// x0y2 x1y2 x2y2 -1 -1 -1
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2)
{
return(abs(-x0y0 -x1y0 -x2y0 -x0y1 +8*x1y1 -x2y1 -x0y2 -x1y2 -x2y2));
}
// 文字列が16進数かを調べる
int chkhex(char *str){
while (*str != '\0'){
if (!isxdigit(*str))
return 0;
str++;
}
return 1;
}
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = 434225 usec
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = 433856 usec
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = 433856 usec
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = -565756 usec
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = 433745 usec
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = 0.391241 sec
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = 0.391315 sec
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = 0.392016 sec
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = 0.391776 sec
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = 0.391168 sec
// laplacian_filter.c
// RGBをYに変換後にラプラシアンフィルタを掛ける。
// ピクセルのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 2013/09/16
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
#include <fcntl.h>
#include <assert.h>
#include <ctype.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <linux/kernel.h>
#define HORIZONTAL_PIXEL_WIDTH 800
#define VERTICAL_PIXEL_WIDTH 600
#define ALL_PIXEL_VALUE (HORIZONTAL_PIXEL_WIDTH*VERTICAL_PIXEL_WIDTH)
#define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024)
#define BUFSIZE 1024
#define MEASURE_COUNT 5000
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2);
int conv_rgb2y(int rgb);
int chkhex(char *str);
volatile unsigned *setup_io(off_t mapped_addr, unsigned int *buf_addr);
void Xil_DCacheInvalidateLine(unsigned int adr);
void Xil_DCacheFlushLine(unsigned int adr);
int main()
{
FILE *fd;
int xy[3][3];
char buf[BUFSIZE], *token;
unsigned int read_num;
unsigned int bitmap_dc_reg_addr;
volatile unsigned *bm_disp_cnt_reg;
unsigned int fb_addr, next_frame_addr;
unsigned int val;
int lap_fil_val;
int x, y;
int *r_pixel, *w_pixel;
unsigned int r_addr, w_addr;
unsigned int r_addr_page, w_addr_page;
unsigned int r_addr_page_pre=0, w_addr_page_pre=0;
unsigned int r_addr_offset, w_addr_offset;
unsigned int r_buf, w_buf, bitmap_buf;
struct timeval start_time, temp1, temp2, end_time;
unsigned int rmmap_cnt=0, wmmap_cnt=0;
unsigned int line_buf[3][HORIZONTAL_PIXEL_WIDTH];
int a, b;
int fl, sl, tl;
gettimeofday(&start_time, NULL); // プログラム起動時の時刻を記録
// fb_start_addr.txt の内容をパイプに入れる
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// fb_start_addr.txt を開く
fd = popen("cat /Apps/fb_start_addr.txt", "r");
if (fd != NULL){
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
sscanf(buf, "%x\n", &fb_addr);
}
}
pclose(fd);
// ラプラシアンフィルタの結果を入れておくフレーム・バッファ
next_frame_addr = ((fb_addr + (ALL_PIXEL_VALUE*4)) & (~(int)(PAGE_SIZE-1))) + PAGE_SIZE;
// RGB値をY(輝度成分)のみに変換し、ラプラシアンフィルタを掛けた。
for (y=0; y<VERTICAL_PIXEL_WIDTH; y++){
for (x=0; x<HORIZONTAL_PIXEL_WIDTH; x++){
if (y==0 || y==VERTICAL_PIXEL_WIDTH-1){ // 縦の境界の時の値は0とする
lap_fil_val = 0;
}else if (x==0 || x==HORIZONTAL_PIXEL_WIDTH-1){ // 横の境界の時も値は0とする
lap_fil_val = 0;
}else{
if (y == 1 && x == 1){ // 最初のラインの最初のピクセルでは2ライン分の画素を読み出す
for (a=0; a<2; a++){ // 2ライン分
for (b=0; b<HORIZONTAL_PIXEL_WIDTH; b++){ // ライン
r_addr = fb_addr+((y+(a-1))*HORIZONTAL_PIXEL_WIDTH+b)*4;
r_addr_page = r_addr & (~(int)(PAGE_SIZE-1));
r_addr_offset = r_addr & ((int)(PAGE_SIZE-1));
if (r_addr_page != r_addr_page_pre){ // 以前のページと違うのでunmmap してページの物理アドレスを取り直す
if (r_addr_page_pre != 0){ // 初めの場合はmmap()していないので、munmap()しない
munmap(r_pixel, BLOCK_SIZE);
free((unsigned int *)r_buf);
}
r_pixel = setup_io((off_t)r_addr_page, &r_buf);
rmmap_cnt++;
r_addr_page_pre = r_addr_page;
}
line_buf[a][b] = *(volatile int *)((unsigned int)r_pixel + r_addr_offset);
line_buf[a][b] = conv_rgb2y(line_buf[a][b]);
}
}
}
if (x == 1) { // ラインの最初なので、2つのピクセルを読み込む
for (b=0; b<2; b++){ // ライン
r_addr = fb_addr+((y+1)*HORIZONTAL_PIXEL_WIDTH+b)*4;
r_addr_page = r_addr & (~(int)(PAGE_SIZE-1));
r_addr_offset = r_addr & ((int)(PAGE_SIZE-1));
if (r_addr_page != r_addr_page_pre){ // 以前のページと違うのでunmmap してページの物理アドレスを取り直す
if (r_addr_page_pre != 0){ // 初めの場合はmmap()していないので、munmap()しない
munmap(r_pixel, BLOCK_SIZE);
free((unsigned int *)r_buf);
}
r_pixel = setup_io((off_t)r_addr_page, &r_buf);
rmmap_cnt++;
r_addr_page_pre = r_addr_page;
}
line_buf[(y+1)%3][b] = *(volatile int *)((unsigned int)r_pixel + r_addr_offset);
// (y+1)%3 は、使用済みのラインがに読み込む、y=2 の時 line[0], y=3の時 line[1], y=4の時 line[2]
line_buf[(y+1)%3][b] = conv_rgb2y(line_buf[(y+1)%3][b]);
}
}
// 1つのピクセルを読み込みながらラプラシアン・フィルタを実行する
r_addr = fb_addr+((y+1)*HORIZONTAL_PIXEL_WIDTH+(x+1))*4; // ラプラシアン・フィルタに必要な最後のピクセルを読み込む
r_addr_page = r_addr & (~(int)(PAGE_SIZE-1));
r_addr_offset = r_addr & ((int)(PAGE_SIZE-1));
if (r_addr_page != r_addr_page_pre){ // 以前のページと違うのでunmmap してページの物理アドレスを取り直す
if (r_addr_page_pre != 0){ // 初めの場合はmmap()していないので、munmap()しない
munmap(r_pixel, BLOCK_SIZE);
free((unsigned int *)r_buf);
}
r_pixel = setup_io((off_t)r_addr_page, &r_buf);
rmmap_cnt++;
r_addr_page_pre = r_addr_page;
}
line_buf[(y+1)%3][x+1] = *(volatile int *)((unsigned int)r_pixel + r_addr_offset);
// (y+1)%3 は、使用済みのラインがに読み込む、y=2 の時 line[0], y=3の時 line[1], y=4の時 line[2]
line_buf[(y+1)%3][x+1] = conv_rgb2y(line_buf[(y+1)%3][x+1]);
fl = (y-1)%3; // 最初のライン, y=1 012, y=2 120, y=3 201, y=4 012
sl = y%3; // 2番めのライン
tl = (y+1)%3; // 3番目のライン
lap_fil_val = laplacian_fil(line_buf[fl][x-1], line_buf[fl][x], line_buf[fl][x+1], line_buf[sl][x-1], line_buf[sl][x], line_buf[sl][x+1], line_buf[tl][x-1], line_buf[tl][x], line_buf[tl][x+1]);
}
w_addr = next_frame_addr+(y*HORIZONTAL_PIXEL_WIDTH + x)*4;
w_addr_page = w_addr & (~(int)(PAGE_SIZE-1));
w_addr_offset = w_addr & ((int)(PAGE_SIZE-1));
if (w_addr_page != w_addr_page_pre){ // 以前のページと違うのでunmmap してページの物理アドレスを取り直す
if (w_addr_page_pre != 0){ // 初めの場合はmmap()していないので、munmap()しない
munmap(w_pixel, BLOCK_SIZE);
free((unsigned int *)w_buf);
}
w_pixel = setup_io((off_t)w_addr_page, &w_buf);
wmmap_cnt++;
w_addr_page_pre = w_addr_page;
}
*(volatile int *)((unsigned int)w_pixel + w_addr_offset) = (lap_fil_val<<16)+(lap_fil_val<<8)+lap_fil_val ;
// printf("x = %d y = %d", x, y);
}
a++;
}
munmap((unsigned int *)r_addr_page, BLOCK_SIZE);
free((unsigned int *)r_buf);
munmap((unsigned int *)w_addr_page, BLOCK_SIZE);
free((unsigned int *)w_buf);
// bitmap-disp-cntrler-axi-master のアドレスを取得
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// ls /sys/devices/axi.0 の内容をパイプに入れる
fd = popen("ls /sys/devices/axi.0", "r");
if (fd != NULL){
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
token = buf;
if ((token=strtok(token, ".\n")) != NULL){
do {
if (chkhex(token)){ // 16進数
sscanf(token, "%x", &val);
} else {
if (strcmp(token, "bitmap-disp-cntrler-axi-master") == 0)
bitmap_dc_reg_addr = val;
}
}while((token=strtok(NULL, ".\n")) != NULL);
}
}
}
pclose(fd);
// ラプラシアンフィルタの掛かった画像のスタートアドレスを bitmap-disp-cntrler-axi-master にセット
bm_disp_cnt_reg = setup_io((off_t)bitmap_dc_reg_addr, &bitmap_buf);
*bm_disp_cnt_reg = next_frame_addr;
munmap((unsigned int *)bm_disp_cnt_reg, BLOCK_SIZE);
free((unsigned int *)bitmap_buf);
gettimeofday(&end_time, NULL);
printf("rmmap_cnt = %d\n", rmmap_cnt);
printf("wmmap_cnt = %d\n", wmmap_cnt);
if (end_time.tv_usec < start_time.tv_usec) {
printf("total time = %d.%d sec\n", end_time.tv_sec - start_time.tv_sec - 1, 1000000 + end_time.tv_usec - start_time.tv_usec);
}
else {
printf("total time = %d.%d sec\n", end_time.tv_sec - start_time.tv_sec, end_time.tv_usec - start_time.tv_usec);
}
return(0);
}
// RGBからYへの変換
// RGBのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 輝度信号Yのみに変換する。変換式は、Y = 0.299R + 0.587G + 0.114B
// "YUVフォーマット及び YUV<->RGB変換"を参考にした。http://vision.kuee.kyoto-u.ac.jp/~hiroaki/firewire/yuv.html
// 2013/09/27 : float を止めて、すべてint にした
int conv_rgb2y(int rgb){
int r, g, b, y_f;
int y;
b = rgb & 0xff;
g = (rgb>>8) & 0xff;
r = (rgb>>16) & 0xff;
y_f = 77*r + 150*g + 29*b; //y_f = 0.299*r + 0.587*g + 0.114*b;の係数に256倍した
y = y_f >> 8; // 256で割る
return(y);
}
// ラプラシアンフィルタ
// x0y0 x1y0 x2y0 -1 -1 -1
// x0y1 x1y1 x2y1 -1 8 -1
// x0y2 x1y2 x2y2 -1 -1 -1
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2)
{
return(abs(-x0y0 -x1y0 -x2y0 -x0y1 +8*x1y1 -x2y1 -x0y2 -x1y2 -x2y2));
}
//
// Set up a memory regions to access GPIO
//
volatile unsigned *setup_io(off_t mapped_addr, unsigned int *buf_addr)
// void setup_io()
{
int mem_fd;
char *gpio_mem, *gpio_map;
/* open /dev/mem */
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
printf("can't open /dev/mem \n");
printf("mapped_addr = %x\n", mapped_addr);
exit (-1);
}
/* mmap GPIO */
// Allocate MAP block
if ((gpio_mem = malloc(BLOCK_SIZE + (PAGE_SIZE-1))) == NULL) {
printf("allocation error \n");
exit (-1);
}
*buf_addr = gpio_mem; // mallocしたアドレスをコピー
// Make sure pointer is on 4K boundary
if ((unsigned long)gpio_mem % PAGE_SIZE)
gpio_mem += PAGE_SIZE - ((unsigned long)gpio_mem % PAGE_SIZE);
// Now map it
gpio_map = (unsigned char *)mmap(
(caddr_t)gpio_mem,
BLOCK_SIZE,
PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED,
mem_fd,
mapped_addr
);
if ((long)gpio_map < 0) {
printf("mmap error %d\n", (int)gpio_map);
printf("mapped_addr = %x\n", mapped_addr);
exit (-1);
}
close(mem_fd); // /dev/mem のクローズ
// Always use volatile pointer!
// gpio = (volatile unsigned *)gpio_map;
return((volatile unsigned *)gpio_map);
} // setup_io
// 文字列が16進数かを調べる
int chkhex(char *str){
while (*str != '\0'){
if (!isxdigit(*str))
return 0;
str++;
}
return 1;
}
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = 439478 usec
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = 439385 usec
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = -560927 usec
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = -560688 usec
zynq> ./laplacian_filter.elf
rmmap_cnt = 469
wmmap_cnt = 469
total time = 438869 usec
// laplacian_filter.c
// RGBをYに変換後にラプラシアンフィルタを掛ける。
// ピクセルのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 2013/09/16
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
#include <fcntl.h>
#include <assert.h>
#include <ctype.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <linux/kernel.h>
#define HORIZONTAL_PIXEL_WIDTH 800
#define VERTICAL_PIXEL_WIDTH 600
#define ALL_PIXEL_VALUE (HORIZONTAL_PIXEL_WIDTH*VERTICAL_PIXEL_WIDTH)
#define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024)
#define BUFSIZE 1024
#define MEASURE_COUNT 5000
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2);
int conv_rgb2y(int rgb);
int chkhex(char *str);
volatile unsigned *setup_io(off_t mapped_addr, unsigned int *buf_addr);
void Xil_DCacheInvalidateLine(unsigned int adr);
void Xil_DCacheFlushLine(unsigned int adr);
int main()
{
FILE *fd;
int xy[3][3];
char buf[BUFSIZE], *token;
unsigned int read_num;
unsigned int bitmap_dc_reg_addr;
volatile unsigned *bm_disp_cnt_reg;
unsigned int fb_addr, next_frame_addr;
unsigned int val;
int lap_fil_val;
int x, y;
int *r_pixel, *w_pixel;
unsigned int r_addr, w_addr;
unsigned int r_addr_page, w_addr_page;
unsigned int r_addr_page_pre=0, w_addr_page_pre=0;
unsigned int r_addr_offset, w_addr_offset;
unsigned int r_buf, w_buf, bitmap_buf;
struct timeval start_time, temp1, temp2, end_time;
unsigned int rmmap_cnt=0, wmmap_cnt=0;
unsigned int line_buf[3][HORIZONTAL_PIXEL_WIDTH];
int a, b;
int fl, sl, tl;
gettimeofday(&start_time, NULL); // プログラム起動時の時刻を記録
// fb_start_addr.txt の内容をパイプに入れる
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// fb_start_addr.txt を開く
fd = popen("cat /Apps/fb_start_addr.txt", "r");
if (fd != NULL){
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
sscanf(buf, "%x\n", &fb_addr);
}
}
pclose(fd);
// ラプラシアンフィルタの結果を入れておくフレーム・バッファ
next_frame_addr = ((fb_addr + (ALL_PIXEL_VALUE*4)) & (~(int)(PAGE_SIZE-1))) + PAGE_SIZE;
// RGB値をY(輝度成分)のみに変換し、ラプラシアンフィルタを掛けた。
for (y=0; y<VERTICAL_PIXEL_WIDTH; y++){
for (x=0; x<HORIZONTAL_PIXEL_WIDTH; x++){
if (y==0 || y==VERTICAL_PIXEL_WIDTH-1){ // 縦の境界の時の値は0とする
lap_fil_val = 0;
}else if (x==0 || x==HORIZONTAL_PIXEL_WIDTH-1){ // 横の境界の時も値は0とする
lap_fil_val = 0;
}else{
if (x == 1){ // ラインの最初でラインの画素を読み出す
if (y == 1){ // 最初のラインでは3ライン分の画素を読み出す
for (a=0; a<3; a++){ // 3ライン分
for (b=0; b<HORIZONTAL_PIXEL_WIDTH; b++){ // ライン
r_addr = fb_addr+((y+(a-1))*HORIZONTAL_PIXEL_WIDTH+b)*4;
r_addr_page = r_addr & (~(int)(PAGE_SIZE-1));
r_addr_offset = r_addr & ((int)(PAGE_SIZE-1));
if (r_addr_page != r_addr_page_pre){ // 以前のページと違うのでunmmap してページの物理アドレスを取り直す
if (r_addr_page_pre != 0){ // 初めの場合はmmap()していないので、munmap()しない
munmap(r_pixel, BLOCK_SIZE);
free((unsigned int *)r_buf);
}
r_pixel = setup_io((off_t)r_addr_page, &r_buf);
rmmap_cnt++;
r_addr_page_pre = r_addr_page;
}
line_buf[a][b] = *(volatile int *)((unsigned int)r_pixel + r_addr_offset);
line_buf[a][b] = conv_rgb2y(line_buf[a][b]);
}
}
} else { // 最初のラインではないので、1ラインだけ読み込む。すでに他の2ラインは読み込まれている
for (b=0; b<HORIZONTAL_PIXEL_WIDTH; b++){ // ライン
r_addr = fb_addr+((y+1)*HORIZONTAL_PIXEL_WIDTH+b)*4;
r_addr_page = r_addr & (~(int)(PAGE_SIZE-1));
r_addr_offset = r_addr & ((int)(PAGE_SIZE-1));
if (r_addr_page != r_addr_page_pre){ // 以前のページと違うのでunmmap してページの物理アドレスを取り直す
if (r_addr_page_pre != 0){ // 初めの場合はmmap()していないので、munmap()しない
munmap(r_pixel, BLOCK_SIZE);
free((unsigned int *)r_buf);
}
r_pixel = setup_io((off_t)r_addr_page, &r_buf);
rmmap_cnt++;
r_addr_page_pre = r_addr_page;
}
line_buf[(y+1)%3][b] = *(volatile int *)((unsigned int)r_pixel + r_addr_offset);
// (y+1)%3 は、使用済みのラインがに読み込む、y=2 の時 line[0], y=3の時 line[1], y=4の時 line[2]
line_buf[(y+1)%3][b] = conv_rgb2y(line_buf[(y+1)%3][b]);
}
}
}
fl = (y-1)%3; // 最初のライン, y=1 012, y=2 120, y=3 201, y=4 012
sl = y%3; // 2番めのライン
tl = (y+1)%3; // 3番目のライン
lap_fil_val = laplacian_fil(line_buf[fl][x-1], line_buf[fl][x], line_buf[fl][x+1], line_buf[sl][x-1], line_buf[sl][x], line_buf[sl][x+1], line_buf[tl][x-1], line_buf[tl][x], line_buf[tl][x+1]);
}
w_addr = next_frame_addr+(y*HORIZONTAL_PIXEL_WIDTH + x)*4;
w_addr_page = w_addr & (~(int)(PAGE_SIZE-1));
w_addr_offset = w_addr & ((int)(PAGE_SIZE-1));
if (w_addr_page != w_addr_page_pre){ // 以前のページと違うのでunmmap してページの物理アドレスを取り直す
if (w_addr_page_pre != 0){ // 初めの場合はmmap()していないので、munmap()しない
munmap(w_pixel, BLOCK_SIZE);
free((unsigned int *)w_buf);
}
w_pixel = setup_io((off_t)w_addr_page, &w_buf);
wmmap_cnt++;
w_addr_page_pre = w_addr_page;
}
*(volatile int *)((unsigned int)w_pixel + w_addr_offset) = (lap_fil_val<<16)+(lap_fil_val<<8)+lap_fil_val ;
// printf("x = %d y = %d", x, y);
}
}
munmap((unsigned int *)r_addr_page, BLOCK_SIZE);
free((unsigned int *)r_buf);
munmap((unsigned int *)w_addr_page, BLOCK_SIZE);
free((unsigned int *)w_buf);
// bitmap-disp-cntrler-axi-master のアドレスを取得
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// ls /sys/devices/axi.0 の内容をパイプに入れる
fd = popen("ls /sys/devices/axi.0", "r");
if (fd != NULL){
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
token = buf;
if ((token=strtok(token, ".\n")) != NULL){
do {
if (chkhex(token)){ // 16進数
sscanf(token, "%x", &val);
} else {
if (strcmp(token, "bitmap-disp-cntrler-axi-master") == 0)
bitmap_dc_reg_addr = val;
}
}while((token=strtok(NULL, ".\n")) != NULL);
}
}
}
pclose(fd);
// ラプラシアンフィルタの掛かった画像のスタートアドレスを bitmap-disp-cntrler-axi-master にセット
bm_disp_cnt_reg = setup_io((off_t)bitmap_dc_reg_addr, &bitmap_buf);
*bm_disp_cnt_reg = next_frame_addr;
munmap((unsigned int *)bm_disp_cnt_reg, BLOCK_SIZE);
free((unsigned int *)bitmap_buf);
gettimeofday(&end_time, NULL);
printf("rmmap_cnt = %d\n", rmmap_cnt);
printf("wmmap_cnt = %d\n", wmmap_cnt);
printf("total time = %d usec\n", end_time.tv_usec - start_time.tv_usec);
return(0);
}
// RGBからYへの変換
// RGBのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 輝度信号Yのみに変換する。変換式は、Y = 0.299R + 0.587G + 0.114B
// "YUVフォーマット及び YUV<->RGB変換"を参考にした。http://vision.kuee.kyoto-u.ac.jp/~hiroaki/firewire/yuv.html
//
int conv_rgb2y(int rgb){
float r, g, b, y_f;
int y;
b = (float)(rgb & 0xff);
g = (float)((rgb>>8) & 0xff);
r = (float)((rgb>>16) & 0xff);
y_f = 0.299*r + 0.587*g + 0.114*b;
y = (int)y_f;
return(y);
}
// ラプラシアンフィルタ
// x0y0 x1y0 x2y0 -1 -1 -1
// x0y1 x1y1 x2y1 -1 8 -1
// x0y2 x1y2 x2y2 -1 -1 -1
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2)
{
return(abs(-x0y0 -x1y0 -x2y0 -x0y1 +8*x1y1 -x2y1 -x0y2 -x1y2 -x2y2));
}
//
// Set up a memory regions to access GPIO
//
volatile unsigned *setup_io(off_t mapped_addr, unsigned int *buf_addr)
// void setup_io()
{
int mem_fd;
char *gpio_mem, *gpio_map;
/* open /dev/mem */
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
printf("can't open /dev/mem \n");
printf("mapped_addr = %x\n", mapped_addr);
exit (-1);
}
/* mmap GPIO */
// Allocate MAP block
if ((gpio_mem = malloc(BLOCK_SIZE + (PAGE_SIZE-1))) == NULL) {
printf("allocation error \n");
exit (-1);
}
*buf_addr = gpio_mem; // mallocしたアドレスをコピー
// Make sure pointer is on 4K boundary
if ((unsigned long)gpio_mem % PAGE_SIZE)
gpio_mem += PAGE_SIZE - ((unsigned long)gpio_mem % PAGE_SIZE);
// Now map it
gpio_map = (unsigned char *)mmap(
(caddr_t)gpio_mem,
BLOCK_SIZE,
PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED,
mem_fd,
mapped_addr
);
if ((long)gpio_map < 0) {
printf("mmap error %d\n", (int)gpio_map);
printf("mapped_addr = %x\n", mapped_addr);
exit (-1);
}
close(mem_fd); // /dev/mem のクローズ
// Always use volatile pointer!
// gpio = (volatile unsigned *)gpio_map;
return((volatile unsigned *)gpio_map);
} // setup_io
// 文字列が16進数かを調べる
int chkhex(char *str){
while (*str != '\0'){
if (!isxdigit(*str))
return 0;
str++;
}
return 1;
}
printf("rmmap_cnt = %d\n", rmmap_cnt);
printf("wmmap_cnt = %d\n", wmmap_cnt);
rmmap_cnt = 4294836
wmmap_cnt = 480000
total time = 138 sec
rmmap_cnt = 1223626
wmmap_cnt = 469
munmap() time = 36 usec
total time = 37 sec
4774836x + y = 138 ----- 式1
1224095x + y = 37 -----式2
flag = 1, map_time = 626895
flag = 2, map_time = 55
flag = 3, map_time = 37
flag = 4, map_time = 37
flag = 5, map_time = 37
flag = 6, map_time = 37
flag = 7, map_time = 18
flag = 8, map_time = 37
flag = 9, map_time = 37
flag = 10, map_time = 37
map time = 29 usec
// laplacian_filter.c
// RGBをYに変換後にラプラシアンフィルタを掛ける。
// ピクセルのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 2013/09/16
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
#include <fcntl.h>
#include <assert.h>
#include <ctype.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <linux/kernel.h>
#define HORIZONTAL_PIXEL_WIDTH 800
#define VERTICAL_PIXEL_WIDTH 600
#define ALL_PIXEL_VALUE (HORIZONTAL_PIXEL_WIDTH*VERTICAL_PIXEL_WIDTH)
#define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024)
#define BUFSIZE 1024
#define MEASURE_COUNT 5000
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2);
int conv_rgb2y(int rgb);
int chkhex(char *str);
volatile unsigned *setup_io(off_t mapped_addr, unsigned int *buf_addr);
void Xil_DCacheInvalidateLine(unsigned int adr);
void Xil_DCacheFlushLine(unsigned int adr);
int main()
{
FILE *fd;
int xy[3][3];
char buf[BUFSIZE], *token;
unsigned int read_num;
unsigned int bitmap_dc_reg_addr;
volatile unsigned *bm_disp_cnt_reg;
unsigned int fb_addr, next_frame_addr;
int x, y;
unsigned int val;
int i, j;
int lap_fil_val;
int *r_pixel, *w_pixel;
unsigned int r_addr, w_addr;
unsigned int r_addr_page, w_addr_page;
unsigned int r_addr_page_pre=0, w_addr_page_pre=0;
unsigned int r_addr_offset, w_addr_offset;
unsigned int r_buf, w_buf, bitmap_buf;
struct timeval start_time, temp1, temp2, end_time;
unsigned int rmmap_cnt=0, wmmap_cnt=0;
int flag=0;
long map_time=0L;
gettimeofday(&start_time, NULL); // プログラム起動時の時刻を記録
// fb_start_addr.txt の内容をパイプに入れる
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// fb_start_addr.txt を開く
fd = popen("cat /Apps/fb_start_addr.txt", "r");
if (fd != NULL){
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
sscanf(buf, "%x\n", &fb_addr);
}
}
pclose(fd);
// ラプラシアンフィルタの結果を入れておくフレーム・バッファ
next_frame_addr = ((fb_addr + (ALL_PIXEL_VALUE*4)) & (~(int)(PAGE_SIZE-1))) + PAGE_SIZE;
// RGB値をY(輝度成分)のみに変換し、ラプラシアンフィルタを掛けた。
for (y=0; y<VERTICAL_PIXEL_WIDTH; y++){
for (x=0; x<HORIZONTAL_PIXEL_WIDTH; x++){
if (y==0 || y==VERTICAL_PIXEL_WIDTH-1){ // 縦の境界の時の値は0とする
lap_fil_val = 0;
}else if (x==0 || x==HORIZONTAL_PIXEL_WIDTH-1){ // 横の境界の時も値は0とする
lap_fil_val = 0;
}else{
for (j=-1; j<2; j++){
for (i=-1; i<2; i++){
r_addr = fb_addr+((y+j)*HORIZONTAL_PIXEL_WIDTH+(x+i))*4;
r_addr_page = r_addr & (~(int)(PAGE_SIZE-1));
r_addr_offset = r_addr & ((int)(PAGE_SIZE-1));
if (r_addr_page != r_addr_page_pre){ // 以前のページと違うのでunmmap してページの物理アドレスを取り直す
if (flag>1 && flag <= MEASURE_COUNT+1)
gettimeofday(&temp1, NULL);
if (r_addr_page_pre != 0){ // 初めの場合はmmap()していないので、munmap()しない
munmap(r_pixel, BLOCK_SIZE);
free((unsigned int *)r_buf);
}else{
flag++;
}
r_pixel = setup_io((off_t)r_addr_page, &r_buf);
if (flag>1 && flag <= MEASURE_COUNT+1){
gettimeofday(&temp2, NULL);
map_time = map_time + (temp2.tv_usec - temp1.tv_usec);
//printf("flag = %d, map_time = %d\n", flag, (temp2.tv_usec - temp1.tv_usec));
flag++;
}else{
flag++;
}
rmmap_cnt++;
r_addr_page_pre = r_addr_page;
}
xy[i+1][j+1] = *(volatile int *)((unsigned int)r_pixel + r_addr_offset);
xy[i+1][j+1] = conv_rgb2y(xy[i+1][j+1]);
}
}
lap_fil_val = laplacian_fil(xy[0][0], xy[1][0], xy[2][0], xy[0][1], xy[1][1], xy[2][1], xy[0][2], xy[1][2], xy[2][2]);
}
w_addr = next_frame_addr+(y*HORIZONTAL_PIXEL_WIDTH + x)*4;
w_addr_page = w_addr & (~(int)(PAGE_SIZE-1));
w_addr_offset = w_addr & ((int)(PAGE_SIZE-1));
if (w_addr_page != w_addr_page_pre){ // 以前のページと違うのでunmmap してページの物理アドレスを取り直す
if (w_addr_page_pre != 0){ // 初めの場合はmmap()していないので、munmap()しない
munmap(w_pixel, BLOCK_SIZE);
free((unsigned int *)w_buf);
}
w_pixel = setup_io((off_t)w_addr_page, &w_buf);
wmmap_cnt++;
w_addr_page_pre = w_addr_page;
}
*(volatile int *)((unsigned int)w_pixel + w_addr_offset) = (lap_fil_val<<16)+(lap_fil_val<<8)+lap_fil_val ;
// printf("x = %d y = %d", x, y);
}
}
munmap((unsigned int *)r_addr_page, BLOCK_SIZE);
free((unsigned int *)r_buf);
munmap((unsigned int *)w_addr_page, BLOCK_SIZE);
free((unsigned int *)w_buf);
// bitmap-disp-cntrler-axi-master のアドレスを取得
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// ls /sys/devices/axi.0 の内容をパイプに入れる
fd = popen("ls /sys/devices/axi.0", "r");
if (fd != NULL){
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
token = buf;
if ((token=strtok(token, ".\n")) != NULL){
do {
if (chkhex(token)){ // 16進数
sscanf(token, "%x", &val);
} else {
if (strcmp(token, "bitmap-disp-cntrler-axi-master") == 0)
bitmap_dc_reg_addr = val;
}
}while((token=strtok(NULL, ".\n")) != NULL);
}
}
}
pclose(fd);
// ラプラシアンフィルタの掛かった画像のスタートアドレスを bitmap-disp-cntrler-axi-master にセット
bm_disp_cnt_reg = setup_io((off_t)bitmap_dc_reg_addr, &bitmap_buf);
*bm_disp_cnt_reg = next_frame_addr;
munmap((unsigned int *)bm_disp_cnt_reg, BLOCK_SIZE);
free((unsigned int *)bitmap_buf);
gettimeofday(&end_time, NULL);
printf("rmmap_cnt = %d\n", rmmap_cnt);
printf("wmmap_cnt = %d\n", wmmap_cnt);
printf("map time = %d usec\n", map_time/MEASURE_COUNT);
printf("total time = %d sec\n", end_time.tv_sec - start_time.tv_sec);
return(0);
}
// RGBからYへの変換
// RGBのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 輝度信号Yのみに変換する。変換式は、Y = 0.299R + 0.587G + 0.114B
// "YUVフォーマット及び YUV<->RGB変換"を参考にした。http://vision.kuee.kyoto-u.ac.jp/~hiroaki/firewire/yuv.html
//
int conv_rgb2y(int rgb){
float r, g, b, y_f;
int y;
b = (float)(rgb & 0xff);
g = (float)((rgb>>8) & 0xff);
r = (float)((rgb>>16) & 0xff);
y_f = 0.299*r + 0.587*g + 0.114*b;
y = (int)y_f;
return(y);
}
// ラプラシアンフィルタ
// x0y0 x1y0 x2y0 -1 -1 -1
// x0y1 x1y1 x2y1 -1 8 -1
// x0y2 x1y2 x2y2 -1 -1 -1
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2)
{
return(abs(-x0y0 -x1y0 -x2y0 -x0y1 +8*x1y1 -x2y1 -x0y2 -x1y2 -x2y2));
}
//
// Set up a memory regions to access GPIO
//
volatile unsigned *setup_io(off_t mapped_addr, unsigned int *buf_addr)
// void setup_io()
{
int mem_fd;
char *gpio_mem, *gpio_map;
/* open /dev/mem */
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
printf("can't open /dev/mem \n");
printf("mapped_addr = %x\n", mapped_addr);
exit (-1);
}
/* mmap GPIO */
// Allocate MAP block
if ((gpio_mem = malloc(BLOCK_SIZE + (PAGE_SIZE-1))) == NULL) {
printf("allocation error \n");
exit (-1);
}
*buf_addr = gpio_mem; // mallocしたアドレスをコピー
// Make sure pointer is on 4K boundary
if ((unsigned long)gpio_mem % PAGE_SIZE)
gpio_mem += PAGE_SIZE - ((unsigned long)gpio_mem % PAGE_SIZE);
// Now map it
gpio_map = (unsigned char *)mmap(
(caddr_t)gpio_mem,
BLOCK_SIZE,
PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED,
mem_fd,
mapped_addr
);
if ((long)gpio_map < 0) {
printf("mmap error %d\n", (int)gpio_map);
printf("mapped_addr = %x\n", mapped_addr);
exit (-1);
}
close(mem_fd); // /dev/mem のクローズ
// Always use volatile pointer!
// gpio = (volatile unsigned *)gpio_map;
return((volatile unsigned *)gpio_map);
} // setup_io
// 文字列が16進数かを調べる
int chkhex(char *str){
while (*str != '\0'){
if (!isxdigit(*str))
return 0;
str++;
}
return 1;
}
gettimeofday(&start_time, NULL); // プログラム起動時の時刻を記録
gettimeofday(&end_time, NULL);
printf("mmap() time = %d usec\n", temp2.tv_usec - temp1.tv_usec);
printf("total time = %d sec\n", end_time.tv_sec - start_time.tv_sec);
return(0);
}
if (x==1 && y==1 && j==-1 && i==-1)
gettimeofday(&temp1, NULL);
r_pixel = setup_io((off_t)r_addr_page, &r_buf);
if (x==1 && y==1 && j==-1 && i==-1)
gettimeofday(&temp2, NULL);
mmap() time = 18 usec
total time = 139 sec
// laplacian_filter.c
// RGBをYに変換後にラプラシアンフィルタを掛ける。
// ピクセルのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 2013/09/16
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
#include <fcntl.h>
#include <assert.h>
#include <ctype.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <linux/kernel.h>
#define HORIZONTAL_PIXEL_WIDTH 800
#define VERTICAL_PIXEL_WIDTH 600
#define ALL_PIXEL_VALUE (HORIZONTAL_PIXEL_WIDTH*VERTICAL_PIXEL_WIDTH)
#define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024)
#define ALLC_SIZE (PAGE_SIZE * 469) // 800*600*4 を超えるPAGE_SIZEの倍数
#define BUFSIZE 1024
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2);
int conv_rgb2y(int rgb);
int chkhex(char *str);
volatile unsigned int *setup_io(off_t mapped_addr, unsigned int *buf_addr);
void Xil_DCacheInvalidateLine(unsigned int adr);
void Xil_DCacheFlushLine(unsigned int adr);
int main()
{
FILE *fd;
int xy[3][3];
char buf[BUFSIZE], *token;
unsigned int read_num;
unsigned int bitmap_dc_reg_addr;
volatile unsigned *bm_disp_cnt_reg;
unsigned int fb_addr, next_frame_addr;
int x, y;
unsigned int val;
int i, j;
int lap_fil_val;
int *r_pixel, *w_pixel;
unsigned int r_addr, w_addr;
unsigned int r_addr_page, w_addr_page;
unsigned int r_addr_page_pre=0, w_addr_page_pre=0;
unsigned int r_addr_offset, w_addr_offset;
unsigned int r_buf, w_buf, bitmap_buf;
// fb_start_addr.txt の内容をパイプに入れる
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// fb_start_addr.txt を開く
fd = popen("cat /Apps/fb_start_addr.txt", "r");
if (fd != NULL){
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
sscanf(buf, "%x\n", &fb_addr);
}
}
pclose(fd);
// ラプラシアンフィルタの結果を入れておくフレーム・バッファ
next_frame_addr = ((fb_addr + (ALL_PIXEL_VALUE*4)) & (~(int)(PAGE_SIZE-1))) + PAGE_SIZE;
// RGB値をY(輝度成分)のみに変換し、ラプラシアンフィルタを掛けた。
for (y=0; y<VERTICAL_PIXEL_WIDTH; y++){
for (x=0; x<HORIZONTAL_PIXEL_WIDTH; x++){
if (y==0 || y==VERTICAL_PIXEL_WIDTH-1){ // 縦の境界の時の値は0とする
lap_fil_val = 0;
}else if (x==0 || x==HORIZONTAL_PIXEL_WIDTH-1){ // 横の境界の時も値は0とする
lap_fil_val = 0;
}else{
for (j=-1; j<2; j++){
for (i=-1; i<2; i++){
r_addr = fb_addr+((y+j)*HORIZONTAL_PIXEL_WIDTH+(x+i))*4;
r_addr_page = r_addr & (~(int)(PAGE_SIZE-1));
r_addr_offset = r_addr & ((int)(PAGE_SIZE-1));
r_pixel = setup_io((off_t)r_addr_page, &r_buf);
xy[i+1][j+1] = *(volatile int *)((unsigned int)r_pixel + r_addr_offset);
munmap(r_pixel, BLOCK_SIZE);
free((char *)r_buf);
xy[i+1][j+1] = conv_rgb2y(xy[i+1][j+1]);
}
}
lap_fil_val = laplacian_fil(xy[0][0], xy[1][0], xy[2][0], xy[0][1], xy[1][1], xy[2][1], xy[0][2], xy[1][2], xy[2][2]);
}
w_addr = next_frame_addr+(y*HORIZONTAL_PIXEL_WIDTH + x)*4;
w_addr_page = w_addr & (~(int)(PAGE_SIZE-1));
w_addr_offset = w_addr & ((int)(PAGE_SIZE-1));
w_pixel = setup_io((off_t)w_addr_page, &w_buf);
*(volatile int *)((unsigned int)w_pixel + w_addr_offset) = (lap_fil_val<<16)+(lap_fil_val<<8)+lap_fil_val ;
munmap(w_pixel, BLOCK_SIZE);
free((char *)w_buf);
// printf("x = %d y = %d", x, y);
}
}
// bitmap-disp-cntrler-axi-master のアドレスを取得
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// ls /sys/devices/axi.0 の内容をパイプに入れる
fd = popen("ls /sys/devices/axi.0", "r");
if (fd != NULL){
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
token = buf;
if ((token=strtok(token, ".\n")) != NULL){
do {
if (chkhex(token)){ // 16進数
sscanf(token, "%x", &val);
} else {
if (strcmp(token, "bitmap-disp-cntrler-axi-master") == 0)
bitmap_dc_reg_addr = val;
}
}while((token=strtok(NULL, ".\n")) != NULL);
}
}
}
pclose(fd);
// ラプラシアンフィルタの掛かった画像のスタートアドレスを bitmap-disp-cntrler-axi-master にセット
bm_disp_cnt_reg = setup_io((off_t)bitmap_dc_reg_addr, &bitmap_buf);
*bm_disp_cnt_reg = next_frame_addr;
munmap((unsigned int *)bm_disp_cnt_reg, BLOCK_SIZE);
free((char *)bitmap_buf);
return(0);
}
// RGBからYへの変換
// RGBのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 輝度信号Yのみに変換する。変換式は、Y = 0.299R + 0.587G + 0.114B
// "YUVフォーマット及び YUV<->RGB変換"を参考にした。http://vision.kuee.kyoto-u.ac.jp/~hiroaki/firewire/yuv.html
//
int conv_rgb2y(int rgb){
float r, g, b, y_f;
int y;
b = (float)(rgb & 0xff);
g = (float)((rgb>>8) & 0xff);
r = (float)((rgb>>16) & 0xff);
y_f = 0.299*r + 0.587*g + 0.114*b;
y = (int)y_f;
return(y);
}
// ラプラシアンフィルタ
// x0y0 x1y0 x2y0 -1 -1 -1
// x0y1 x1y1 x2y1 -1 8 -1
// x0y2 x1y2 x2y2 -1 -1 -1
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2)
{
return(abs(-x0y0 -x1y0 -x2y0 -x0y1 +8*x1y1 -x2y1 -x0y2 -x1y2 -x2y2));
}
//
// Set up a memory regions to access GPIO
//
volatile unsigned int *setup_io(off_t mapped_addr, unsigned int *buf_addr)
// void setup_io()
{
int mem_fd;
char *gpio_mem, *gpio_map;
/* open /dev/mem */
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
printf("can't open /dev/mem \n");
printf("mapped_addr = %x\n", (unsigned int)mapped_addr);
exit (-1);
}
/* mmap GPIO */
// Allocate MAP block
if ((gpio_mem = malloc(BLOCK_SIZE + (PAGE_SIZE-1))) == NULL) {
printf("allocation error \n");
exit (-1);
}
*buf_addr = (unsigned int)gpio_mem; // mallocしたアドレスをコピー
// Make sure pointer is on 4K boundary
if ((unsigned long)gpio_mem % PAGE_SIZE)
gpio_mem += PAGE_SIZE - ((unsigned long)gpio_mem % PAGE_SIZE);
// Now map it
gpio_map = (unsigned char *)mmap(
(caddr_t)gpio_mem,
BLOCK_SIZE,
PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED,
mem_fd,
mapped_addr
);
if ((long)gpio_map < 0) {
printf("mmap error %d\n", (int)gpio_map);
printf("mapped_addr = %x\n", (unsigned int)mapped_addr);
exit (-1);
}
close(mem_fd); // /dev/mem のクローズ
// Always use volatile pointer!
// gpio = (volatile unsigned *)gpio_map;
return((volatile unsigned *)gpio_map);
} // setup_io
// 文字列が16進数かを調べる
int chkhex(char *str){
while (*str != '\0'){
if (!isxdigit(*str))
return 0;
str++;
}
return 1;
}
// laplacian_filter.c
// RGBをYに変換後にラプラシアンフィルタを掛ける。
// ピクセルのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 2013/09/16
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
#include <fcntl.h>
#include <assert.h>
#include <ctype.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <linux/kernel.h>
#define HORIZONTAL_PIXEL_WIDTH 800
#define VERTICAL_PIXEL_WIDTH 600
#define ALL_PIXEL_VALUE (HORIZONTAL_PIXEL_WIDTH*VERTICAL_PIXEL_WIDTH)
#define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024)
#define BUFSIZE 1024
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2);
int conv_rgb2y(int rgb);
int chkhex(char *str);
volatile unsigned *setup_io(off_t mapped_addr, unsigned int *buf_addr);
void Xil_DCacheInvalidateLine(unsigned int adr);
void Xil_DCacheFlushLine(unsigned int adr);
int main()
{
FILE *fd;
int xy[3][3];
char buf[BUFSIZE], *token;
unsigned int read_num;
unsigned int bitmap_dc_reg_addr;
volatile unsigned *bm_disp_cnt_reg;
unsigned int fb_addr, next_frame_addr;
int x, y;
unsigned int val;
int i, j;
int lap_fil_val;
int *r_pixel, *w_pixel;
unsigned int r_addr, w_addr;
unsigned int r_addr_page, w_addr_page;
unsigned int r_addr_page_pre=0, w_addr_page_pre=0;
unsigned int r_addr_offset, w_addr_offset;
unsigned int r_buf, w_buf, bitmap_buf;
// fb_start_addr.txt の内容をパイプに入れる
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// fb_start_addr.txt を開く
fd = popen("cat /Apps/fb_start_addr.txt", "r");
if (fd != NULL){
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
sscanf(buf, "%x\n", &fb_addr);
}
}
pclose(fd);
// ラプラシアンフィルタの結果を入れておくフレーム・バッファ
next_frame_addr = ((fb_addr + (ALL_PIXEL_VALUE*4)) & (~(int)(PAGE_SIZE-1))) + PAGE_SIZE;
// RGB値をY(輝度成分)のみに変換し、ラプラシアンフィルタを掛けた。
for (y=0; y<VERTICAL_PIXEL_WIDTH; y++){
for (x=0; x<HORIZONTAL_PIXEL_WIDTH; x++){
if (y==0 || y==VERTICAL_PIXEL_WIDTH-1){ // 縦の境界の時の値は0とする
lap_fil_val = 0;
}else if (x==0 || x==HORIZONTAL_PIXEL_WIDTH-1){ // 横の境界の時も値は0とする
lap_fil_val = 0;
}else{
for (j=-1; j<2; j++){
for (i=-1; i<2; i++){
r_addr = fb_addr+((y+j)*HORIZONTAL_PIXEL_WIDTH+(x+i))*4;
r_addr_page = r_addr & (~(int)(PAGE_SIZE-1));
r_addr_offset = r_addr & ((int)(PAGE_SIZE-1));
if (r_addr_page != r_addr_page_pre){ // 以前のページと違うのでunmmap してページの物理アドレスを取り直す
if (r_addr_page_pre != 0){ // 初めの場合はmmap()していないので、munmap()しない
munmap(r_pixel, BLOCK_SIZE);
free((unsigned int *)r_buf);
}
r_pixel = setup_io((off_t)r_addr_page, &r_buf);
r_addr_page_pre = r_addr_page;
}
xy[i+1][j+1] = *(volatile int *)((unsigned int)r_pixel + r_addr_offset);
xy[i+1][j+1] = conv_rgb2y(xy[i+1][j+1]);
}
}
lap_fil_val = laplacian_fil(xy[0][0], xy[1][0], xy[2][0], xy[0][1], xy[1][1], xy[2][1], xy[0][2], xy[1][2], xy[2][2]);
}
w_addr = next_frame_addr+(y*HORIZONTAL_PIXEL_WIDTH + x)*4;
w_addr_page = w_addr & (~(int)(PAGE_SIZE-1));
w_addr_offset = w_addr & ((int)(PAGE_SIZE-1));
if (w_addr_page != w_addr_page_pre){ // 以前のページと違うのでunmmap してページの物理アドレスを取り直す
if (w_addr_page_pre != 0){ // 初めの場合はmmap()していないので、munmap()しない
munmap(w_pixel, BLOCK_SIZE);
free((unsigned int *)w_buf);
}
w_pixel = setup_io((off_t)w_addr_page, &w_buf);
w_addr_page_pre = w_addr_page;
}
*(volatile int *)((unsigned int)w_pixel + w_addr_offset) = (lap_fil_val<<16)+(lap_fil_val<<8)+lap_fil_val ;
// printf("x = %d y = %d", x, y);
}
}
munmap((unsigned int *)r_addr_page, BLOCK_SIZE);
free((unsigned int *)r_buf);
munmap((unsigned int *)w_addr_page, BLOCK_SIZE);
free((unsigned int *)w_buf);
// bitmap-disp-cntrler-axi-master のアドレスを取得
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// ls /sys/devices/axi.0 の内容をパイプに入れる
fd = popen("ls /sys/devices/axi.0", "r");
if (fd != NULL){
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
token = buf;
if ((token=strtok(token, ".\n")) != NULL){
do {
if (chkhex(token)){ // 16進数
sscanf(token, "%x", &val);
} else {
if (strcmp(token, "bitmap-disp-cntrler-axi-master") == 0)
bitmap_dc_reg_addr = val;
}
}while((token=strtok(NULL, ".\n")) != NULL);
}
}
}
pclose(fd);
// ラプラシアンフィルタの掛かった画像のスタートアドレスを bitmap-disp-cntrler-axi-master にセット
bm_disp_cnt_reg = setup_io((off_t)bitmap_dc_reg_addr, &bitmap_buf);
*bm_disp_cnt_reg = next_frame_addr;
munmap((unsigned int *)bm_disp_cnt_reg, BLOCK_SIZE);
free((unsigned int *)bitmap_buf);
return(0);
}
// RGBからYへの変換
// RGBのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 輝度信号Yのみに変換する。変換式は、Y = 0.299R + 0.587G + 0.114B
// "YUVフォーマット及び YUV<->RGB変換"を参考にした。http://vision.kuee.kyoto-u.ac.jp/~hiroaki/firewire/yuv.html
//
int conv_rgb2y(int rgb){
float r, g, b, y_f;
int y;
b = (float)(rgb & 0xff);
g = (float)((rgb>>8) & 0xff);
r = (float)((rgb>>16) & 0xff);
y_f = 0.299*r + 0.587*g + 0.114*b;
y = (int)y_f;
return(y);
}
// ラプラシアンフィルタ
// x0y0 x1y0 x2y0 -1 -1 -1
// x0y1 x1y1 x2y1 -1 8 -1
// x0y2 x1y2 x2y2 -1 -1 -1
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2)
{
return(abs(-x0y0 -x1y0 -x2y0 -x0y1 +8*x1y1 -x2y1 -x0y2 -x1y2 -x2y2));
}
//
// Set up a memory regions to access GPIO
//
volatile unsigned *setup_io(off_t mapped_addr, unsigned int *buf_addr)
// void setup_io()
{
int mem_fd;
char *gpio_mem, *gpio_map;
/* open /dev/mem */
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
printf("can't open /dev/mem \n");
printf("mapped_addr = %x\n", mapped_addr);
exit (-1);
}
/* mmap GPIO */
// Allocate MAP block
if ((gpio_mem = malloc(BLOCK_SIZE + (PAGE_SIZE-1))) == NULL) {
printf("allocation error \n");
exit (-1);
}
*buf_addr = gpio_mem; // mallocしたアドレスをコピー
// Make sure pointer is on 4K boundary
if ((unsigned long)gpio_mem % PAGE_SIZE)
gpio_mem += PAGE_SIZE - ((unsigned long)gpio_mem % PAGE_SIZE);
// Now map it
gpio_map = (unsigned char *)mmap(
(caddr_t)gpio_mem,
BLOCK_SIZE,
PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED,
mem_fd,
mapped_addr
);
if ((long)gpio_map < 0) {
printf("mmap error %d\n", (int)gpio_map);
printf("mapped_addr = %x\n", mapped_addr);
exit (-1);
}
close(mem_fd); // /dev/mem のクローズ
// Always use volatile pointer!
// gpio = (volatile unsigned *)gpio_map;
return((volatile unsigned *)gpio_map);
} // setup_io
// 文字列が16進数かを調べる
int chkhex(char *str){
while (*str != '\0'){
if (!isxdigit(*str))
return 0;
str++;
}
return 1;
}
// laplacian_filter.c
// RGBをYに変換後にラプラシアンフィルタを掛ける。
// ピクセルのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 2013/09/16
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
#include <fcntl.h>
#include <assert.h>
#include <ctype.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <linux/kernel.h>
#define HORIZONTAL_PIXEL_WIDTH 800
#define VERTICAL_PIXEL_WIDTH 600
#define ALL_PIXEL_VALUE (HORIZONTAL_PIXEL_WIDTH*VERTICAL_PIXEL_WIDTH)
#define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024)
#define BUFSIZE 1024
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2);
int conv_rgb2y(int rgb);
int chkhex(char *str);
volatile unsigned *setup_io(off_t mapped_addr);
void Xil_DCacheInvalidateLine(unsigned int adr);
void Xil_DCacheFlushLine(unsigned int adr);
int main()
{
FILE *fd;
int xy[3][3];
char buf[BUFSIZE], *token;
unsigned int read_num;
unsigned int bitmap_dc_reg_addr;
volatile unsigned *bm_disp_cnt_reg;
unsigned int fb_addr, next_frame_addr;
int x, y;
unsigned int val;
int i, j;
int lap_fil_val;
int *r_pixel, *w_pixel;
unsigned int r_addr, w_addr;
unsigned int r_addr_page, w_addr_page;
unsigned int r_addr_page_pre=0, w_addr_page_pre=0;
unsigned int r_addr_offset, w_addr_offset;
// fb_start_addr.txt の内容をパイプに入れる
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// fb_start_addr.txt を開く
fd = popen("cat /Apps/fb_start_addr.txt", "r");
if (fd != NULL){
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
sscanf(buf, "%x\n", &fb_addr);
}
}
pclose(fd);
// ラプラシアンフィルタの結果を入れておくフレーム・バッファ
next_frame_addr = fb_addr + (ALL_PIXEL_VALUE*4);
// RGB値をY(輝度成分)のみに変換し、ラプラシアンフィルタを掛けた。
for (y=0; y<VERTICAL_PIXEL_WIDTH; y++){
for (x=0; x<HORIZONTAL_PIXEL_WIDTH; x++){
if (y==0 || y==VERTICAL_PIXEL_WIDTH-1){ // 縦の境界の時の値は0とする
lap_fil_val = 0;
}else if (x==0 || x==HORIZONTAL_PIXEL_WIDTH-1){ // 横の境界の時も値は0とする
lap_fil_val = 0;
}else{
for (j=-1; j<2; j++){
for (i=-1; i<2; i++){
r_addr = fb_addr+((y+j)*HORIZONTAL_PIXEL_WIDTH+(x+i))*4;
r_addr_page = r_addr & (~(int)(BLOCK_SIZE-1));
r_addr_offset = r_addr & ((int)(BLOCK_SIZE-1));
if (r_addr_page != r_addr_page_pre){ // 以前のページと違うのでunmmap してページの物理アドレスを取り直す
if (r_addr_page_pre != 0){ // 初めの場合はmmap()していないので、munmap()しない
munmap((unsigned int *)r_addr_page_pre, BLOCK_SIZE);
}
r_pixel = setup_io((off_t)r_addr_page);
r_addr_page_pre = r_addr_page;
}
xy[i+1][j+1] = *(volatile int *)((unsigned int)r_pixel + r_addr_offset);
xy[i+1][j+1] = conv_rgb2y(xy[i+1][j+1]);
}
}
lap_fil_val = laplacian_fil(xy[0][0], xy[1][0], xy[2][0], xy[0][1], xy[1][1], xy[2][1], xy[0][2], xy[1][2], xy[2][2]);
}
w_addr = next_frame_addr+(y*HORIZONTAL_PIXEL_WIDTH + x)*4;
w_addr_page = w_addr & (~(int)(BLOCK_SIZE-1));
w_addr_offset = w_addr & ((int)(BLOCK_SIZE-1));
if (w_addr_page != w_addr_page_pre){ // 以前のページと違うのでunmmap してページの物理アドレスを取り直す
if (w_addr_page_pre != 0){ // 初めの場合はmmap()していないので、munmap()しない
munmap((unsigned int *)w_addr_page_pre, BLOCK_SIZE);
}
w_pixel = setup_io((off_t)w_addr_page);
w_addr_page_pre = w_addr_page;
}
*(volatile int *)((unsigned int)w_pixel + w_addr_offset) = (lap_fil_val<<16)+(lap_fil_val<<8)+lap_fil_val ;
// printf("x = %d y = %d", x, y);
}
}
// bitmap-disp-cntrler-axi-master のアドレスを取得
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// ls /sys/devices/axi.0 の内容をパイプに入れる
fd = popen("ls /sys/devices/axi.0", "r");
if (fd != NULL){
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
token = buf;
if ((token=strtok(token, ".\n")) != NULL){
do {
if (chkhex(token)){ // 16進数
sscanf(token, "%x", &val);
} else {
if (strcmp(token, "bitmap-disp-cntrler-axi-master") == 0)
bitmap_dc_reg_addr = val;
}
}while((token=strtok(NULL, ".\n")) != NULL);
}
}
}
pclose(fd);
// ラプラシアンフィルタの掛かった画像のスタートアドレスを bitmap-disp-cntrler-axi-master にセット
bm_disp_cnt_reg = setup_io((off_t)bitmap_dc_reg_addr);
*bm_disp_cnt_reg = next_frame_addr;
return(0);
}
// RGBからYへの変換
// RGBのフォーマットは、{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bits
// 輝度信号Yのみに変換する。変換式は、Y = 0.299R + 0.587G + 0.114B
// "YUVフォーマット及び YUV<->RGB変換"を参考にした。http://vision.kuee.kyoto-u.ac.jp/~hiroaki/firewire/yuv.html
//
int conv_rgb2y(int rgb){
float r, g, b, y_f;
int y;
b = (float)(rgb & 0xff);
g = (float)((rgb>>8) & 0xff);
r = (float)((rgb>>16) & 0xff);
y_f = 0.299*r + 0.587*g + 0.114*b;
y = (int)y_f;
return(y);
}
// ラプラシアンフィルタ
// x0y0 x1y0 x2y0 -1 -1 -1
// x0y1 x1y1 x2y1 -1 8 -1
// x0y2 x1y2 x2y2 -1 -1 -1
int laplacian_fil(int x0y0, int x1y0, int x2y0, int x0y1, int x1y1, int x2y1, int x0y2, int x1y2, int x2y2)
{
return(abs(-x0y0 -x1y0 -x2y0 -x0y1 +8*x1y1 -x2y1 -x0y2 -x1y2 -x2y2));
}
//
// Set up a memory regions to access GPIO
//
volatile unsigned *setup_io(off_t mapped_addr)
// void setup_io()
{
int mem_fd;
char *gpio_mem, *gpio_map;
/* open /dev/mem */
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
printf("can't open /dev/mem \n");
printf("mapped_addr = %x\n", mapped_addr);
exit (-1);
}
/* mmap GPIO */
// Allocate MAP block
if ((gpio_mem = malloc(BLOCK_SIZE + (PAGE_SIZE-1))) == NULL) {
printf("allocation error \n");
exit (-1);
}
// Make sure pointer is on 4K boundary
if ((unsigned long)gpio_mem % PAGE_SIZE)
gpio_mem += PAGE_SIZE - ((unsigned long)gpio_mem % PAGE_SIZE);
// Now map it
gpio_map = (unsigned char *)mmap(
(caddr_t)gpio_mem,
BLOCK_SIZE,
PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED,
mem_fd,
mapped_addr
);
if ((long)gpio_map < 0) {
printf("mmap error %d\n", (int)gpio_map);
printf("mapped_addr = %x\n", mapped_addr);
exit (-1);
}
close(mem_fd); // /dev/mem のクローズ
// Always use volatile pointer!
// gpio = (volatile unsigned *)gpio_map;
return((volatile unsigned *)gpio_map);
} // setup_io
// 文字列が16進数かを調べる
int chkhex(char *str){
while (*str != '\0'){
if (!isxdigit(*str))
return 0;
str++;
}
return 1;
}
1.カメラの画像データを書き込んでいるフレーム・バッファからピクセルデータを読み込む。
2.ピクセルデータは上位ビットから{8'd0, R(8bits), G(8bits), B(8bits)}, 1pixel = 32bitsとなっている。
3.輝度成分をラプラシアンフィルタに掛けるためにRGBからY(輝度成分)を計算する。(int conv_rgb2y(int rgb))
4.9個のデータを集めて、ラプラシアンフィルタに通す。(laplacian_fil())
5.次のフレーム・バッファに当該位置に書き込む。
6.1フレーム分のラプラシアン・フィルタリングが終了したら、フレーム・バッファを次のバッファ領域に移してラプラシアンフィルタが掛かったデータを表示する。
// fb_start_addr.txt を開く
if ((fd = fopen("/Apps/fb_start_addr.txt", "rt")) == NULL){
fprintf(stderr, "Can't Open /Apps/fb_start_addr.txt\n");
exit(1);
}
fscanf(fd, "%x", fb_addr);
fclose(fd);
// fb_start_addr.txt を開く
if ((rfile = open("fb_start_addr.txt", O_RDONLY)) == -1){
fprintf(stderr, "Can't Open /Apps/fb_start_addr.txt\n");
exit(1);
}
read_bytes = read(rfile, buf, 8);
*(buf+read_bytes) = NULL;
close(rfile);
// fb_start_addr.txt を開く
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// fb_start_addr.txt の内容をパイプに入れる
fd = popen("cat /Apps/fb_start_addr.txt", "r");
sscanf(buf, "%x", &fb_addr);
pclose(fd);
// cam_disp3_linux.c
//
// GPIOを1にして、カメラ表示回路を生かし、MT9D111の設定レジスタにRGB565を設定する
//
// 2013/02/11
// 2013/04/20 : カメラ・インターフェイスIPとビットマップ・ディスプレイ・コントローラIPのフレームバッファ・スタート・レジスタに
// Linuxの既存のフレームバッファのアドレスをWrite するように変更。
//
#define XPAR_AXI_GPIO_0_BASEADDR 0x44000000
#define XPAR_AXI_IIC_MT9D111_BASEADDR 0x45000000
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
#include <fcntl.h>
#include <assert.h>
#include <ctype.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024)
#define BUFSIZE 1024
// I/O access
volatile unsigned *setup_io(off_t addr);
int chkhex(char *str);
volatile unsigned *cam_i2c_control_reg;
volatile unsigned *cam_i2c_status_reg;
volatile unsigned *cam_i2c_tx_fifo;
volatile unsigned *cam_i2c_rx_fifo;
void cam_i2c_init(void) {
*cam_i2c_control_reg = 0x2; // reset tx fifo
*cam_i2c_control_reg = 0x1; // enable i2c
}
void cam_i2x_write_sync(void) {
// unsigned c;
// c = *cam_i2c_rx_fifo;
// while ((c & 0x84) != 0x80)
// c = *cam_i2c_rx_fifo; // No Bus Busy and TX_FIFO_Empty = 1
usleep(1000);
}
void cam_i2c_write(unsigned int device_addr, unsigned int write_addr, unsigned int write_data){
*cam_i2c_tx_fifo = 0x100 | (device_addr & 0xfe); // Slave IIC Write Address
*cam_i2c_tx_fifo = write_addr;
*cam_i2c_tx_fifo = (write_data >> 8)|0xff; // first data
*cam_i2c_tx_fifo = 0x200 | (write_data & 0xff); // second data
cam_i2x_write_sync();
}
int main()
{
volatile unsigned *cam_i2c, *axi_gpio;
volatile unsigned *axi_gpio_tri;
FILE *fd;
char buf[BUFSIZE], *token;
char *str0x;
unsigned int read_num;
unsigned int mt9d111_reg_addr, bitmap_dc_reg_addr;
volatile unsigned *mt9d111_inf_reg;
volatile unsigned *bm_disp_cnt_reg;
unsigned int fb_addr;
unsigned int val;
cam_i2c = setup_io((off_t)XPAR_AXI_IIC_MT9D111_BASEADDR);
axi_gpio = setup_io((off_t)XPAR_AXI_GPIO_0_BASEADDR);
cam_i2c_control_reg = cam_i2c + 0x40; // 0x100番地
cam_i2c_status_reg = cam_i2c + 0x41; // 0x104番地
cam_i2c_tx_fifo = cam_i2c + 0x42; // 0x108番地
cam_i2c_rx_fifo = cam_i2c + 0x43; // 0x10C番地
axi_gpio_tri = axi_gpio + 0x1; // 0x4番地
// フレームバッファのアドレスを取得
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// dmesg で、fbi->fix.smem_start の書いてある行をパイプに入れる
fd = popen("dmesg | grep \"fbi->fix.smem_start\"", "r");
if (fd != NULL){ // fbi->fix.smem_start の値を抽出
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
if ((str0x = strstr(buf, "0x")) != NULL){
str0x += 2;
sscanf(str0x, "%x\n", &fb_addr);
}
}
}
pclose(fd);
// mt9d111-inf-axi-master と bitmap-disp-cntrler-axi-master のアドレスを取得
memset(buf, '\0', sizeof(buf)); // buf すべてに\0 を入れる
// ls /sys/devices/axi.0 の内容をパイプに入れる
fd = popen("ls /sys/devices/axi.0", "r");
if (fd != NULL){
read_num = fread(buf, sizeof(unsigned char), BUFSIZE, fd);
if (read_num > 0){
token = buf;
if ((token=strtok(token, ".\n")) != NULL){
do {
if (chkhex(token)){ // 16進数
sscanf(token, "%x", &val);
} else {
if (strcmp(token, "mt9d111-inf-axi-master") == 0)
mt9d111_reg_addr = val;
else if (strcmp(token, "bitmap-disp-cntrler-axi-master") == 0)
bitmap_dc_reg_addr = val;
}
}while((token=strtok(NULL, ".\n")) != NULL);
}
}
}
pclose(fd);
mt9d111_inf_reg = setup_io((off_t)mt9d111_reg_addr);
bm_disp_cnt_reg = setup_io((off_t)bitmap_dc_reg_addr);
// フレームバッファのアドレスをAXI4 Lite Slave 経由でレジスタにWrite
fb_addr = ((fb_addr + (140 * 1920 * 4)) & (~(int)(PAGE_SIZE-1))) + PAGE_SIZE;
// 2頭のペンギンが表示されるようにペンギンの描画領域を外す。140ライン飛ばす、更にページ境界に合わせる
*bm_disp_cnt_reg = fb_addr;
*mt9d111_inf_reg = fb_addr;
// fb_start_addr.txt に fb_addr を書き込む
sprintf(buf, "echo %x > /Apps/fb_start_addr.txt", fb_addr);
system(buf);
// GPIOに1を書いて、カメラ表示回路を動作させる
*axi_gpio_tri = 0; // set output
*axi_gpio = 0x1; // output '1'
// CMOS Camera initialize, MT9D111
cam_i2c_init();
cam_i2c_write(0xba, 0xf0, 0x1); // IFP page 1 へレジスタ・マップを切り替える
cam_i2c_write(0xba, 0x97, 0x20); // RGB Mode, RGB565
return(0);
}
//
// Set up a memory regions to access GPIO
//
volatile unsigned *setup_io(off_t mapped_addr)
// void setup_io()
{
int mem_fd;
char *gpio_mem, *gpio_map;
/* open /dev/mem */
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
printf("can't open /dev/mem \n");
exit (-1);
}
/* mmap GPIO */
// Allocate MAP block
if ((gpio_mem = malloc(BLOCK_SIZE + (PAGE_SIZE-1))) == NULL) {
printf("allocation error \n");
exit (-1);
}
// Make sure pointer is on 4K boundary
if ((unsigned long)gpio_mem % PAGE_SIZE)
gpio_mem += PAGE_SIZE - ((unsigned long)gpio_mem % PAGE_SIZE);
// Now map it
gpio_map = (unsigned char *)mmap(
(caddr_t)gpio_mem,
BLOCK_SIZE,
PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED,
mem_fd,
mapped_addr
);
if ((long)gpio_map < 0) {
printf("mmap error %d\n", (int)gpio_map);
exit (-1);
}
close(mem_fd);
// Always use volatile pointer!
// gpio = (volatile unsigned *)gpio_map;
return((volatile unsigned *)gpio_map);
} // setup_io
// 文字列が16進数かを調べる
int chkhex(char *str){
while (*str != '\0'){
if (!isxdigit(*str))
return 0;
str++;
}
return 1;
}
create_project project_bft_batch C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Tutorial_Created_Data/project_bft_batch -part xc7k70tfbg484-2
add_files {C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/FifoBuffer.v C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bft.vhdl C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/async_fifo.v}
add_files -fileset sim_1 C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bft_tb.v
add_files C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib
set_property library bftLib [get_files {C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib/round_4.vhdl C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib/round_3.vhdl C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib/round_2.vhdl C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib/round_1.vhdl C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib/core_transform.vhdl C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib/bft_package.vhdl}]
import_files -force
import_files -fileset constrs_1 -force -norecurse C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/bft_full.xdc
update_compile_order -fileset sources_1
update_compile_order -fileset sources_1
update_compile_order -fileset sim_1
synth_design -rtl -name rtl_1
launch_xsim -simset sim_1 -mode behavioral
close_sim
launch_runs synth_1
wait_on_run synth_1
launch_runs impl_1
wait_on_run impl_1
open_run impl_1
close_design
open_run synth_1 -name netlist_1
set_delay_model -interconnect estimated
report_timing_summary -delay_type max -report_unconstrained -check_timing_verbose -max_paths 10 -input_pins -name timing_1
report_power -results {power_1}
close_design
open_run impl_1
report_timing -delay_type min_max -max_paths 10 -sort_by group -input_pins -name timing_1
close_design
launch_runs impl_1 -to_step write_bitstream
wait_on_run impl_1
cd C:\Users\Masaaki\Documents\Vivado\Vivado_Tutorial
vivado -mode batch -source run_bft.tcl
#-----------------------------------------------------------
# Vivado v2013.2 (64-bit)
# Build 272601 by xbuild on Sat Jun 15 11:27:26 MDT 2013
# Start of session at: Tue Sep 10 04:56:44 2013
# Process ID: 2412
# Log file: C:/Users/Masaaki/AppData/Roaming/Xilinx/Vivado/vivado.log
# Journal file: C:/Users/Masaaki/AppData/Roaming/Xilinx/Vivado\vivado.jou
#-----------------------------------------------------------
start_gui
create_project project_bft C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Tutorial_Created_Data/project_bft -part xc7k70tfbg484-2
add_files {C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/FifoBuffer.v C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bft.vhdl C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/async_fifo.v}
add_files -fileset sim_1 C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bft_tb.v
add_files C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib
set_property library bftLib [get_files {C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib/round_4.vhdl C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib/round_3.vhdl C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib/round_2.vhdl C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib/round_1.vhdl C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib/core_transform.vhdl C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/hdl/bftLib/bft_package.vhdl}]
import_files -force
import_files -fileset constrs_1 -force -norecurse C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial/Sources/bft_full.xdc
update_compile_order -fileset sources_1
update_compile_order -fileset sources_1
update_compile_order -fileset sim_1
synth_design -rtl -name rtl_1
launch_xsim -simset sim_1 -mode behavioral
close_sim
launch_runs synth_1
wait_on_run synth_1
launch_runs impl_1
wait_on_run impl_1
open_run impl_1
close_design
open_run synth_1 -name netlist_1
set_delay_model -interconnect estimated
report_timing_summary -delay_type max -report_unconstrained -check_timing_verbose -max_paths 10 -input_pins -name timing_1
report_power -results {power_1}
close_design
open_run impl_1
report_timing -delay_type min_max -max_paths 10 -sort_by group -input_pins -name timing_1
close_design
launch_runs impl_1 -to_step write_bitstream
wait_on_run impl_1
・黒-クロックドメイン間のクロックパスがない
・緑-クロックドメイン間のクロックパスが制約されている。
・赤-クロックドメイン間のパスすべてにユーザー定義のfalse_path またはクロック・グループ制約が適用されている
・黄-クロックドメイン間のパスの一部にユーザー定義のfalse_path またはクロック・グループ制約が適用されている
stop_gui
現在のネットリストを最適化します。デフォルトでは、リターゲット、定数伝搬、スイープ、およびブロック RAM の消費電力最適化が実行されます。
デザイン ネットリストをターゲット パーツ用に最適化します。最適化では、サードパーティ ツールからの合成済
みネットリストや合成中に最適化されなかったネットリストを向上できます。
このコマンドをインプリメンテーションでデザインを配置配線する前に実行し、デザインを最適化してネットリスト
を簡略化します。
高度なクロック ゲーティングを使用して、ダイナミック消費電力を最適化します。
フリップフロップのクロック イネーブルを利用してクロック ゲーティングを変更することにより、デザインのダイナミック消費電力を最適化します。クロック ゲーティング最適化はデザイン全体に対して自動的に実行され、デザインの動作が変化する可能性のある既存のロジックやクロックを変更せずに消費電力を削減します。
ポートと最下位インスタンスを自動配置します。
現在の配置済みネットリストを最適化します。
デザインの負のスラック パスに対してタイミング ドリブンの最適化を実行します。最適化が実行されるためには、パスの負のスラックがワースト ネガティブ スラック (WNS) に近いことが必要です。このコマンドは、place_design コマンドの後、route_design コマンドの前に実行してください。
現在のデザインのチェックポイントを書き出します。
デザインをデザイン プロセスの任意の段階で保存し、必要に応じてツールにすばやくインポートし直せるように
します。デザイン チェックポイント (DCP) には、ネットリスト、制約、およびインプリメント済みデザインの配置配線情報が含まれます。
チェックポイント ファイルをインポートするには、read_checkpoint コマンドを使用します。
現在のデザインを配線します。
opt_design
place_design
write_checkpoint -force $outputDir/post_place
report_timing_summary -file $outputDir/post_place_timing_summary.rpt
route_design
write_checkpoint -force $outputDir/post_route
report_timing_summary -file $outputDir/post_route_timing_summary.rpt
report_timing -sort_by group -max_paths 100 -path_type summary -file
$outputDir/post_route_timing.rpt
report_clock_utilization -file $outputDir/clock_util.rpt
report_utilization -file $outputDir/post_route_util.rpt
report_power -file $outputDir/post_route_power.rpt
report_drc -file $outputDir/post_imp_drc.rpt
write_verilog -force $outputDir/bft_impl_netlist.v
write_xdc -no_fixed_only -force $outputDir/bft_impl.xdc
write_bitstream -force $outputDir/bft.bit
+------------+------+-------+-----------+-------+
| Site Type | Used | Loced | Available | Util% |
+------------+------+-------+-----------+-------+
| BUFGCTRL | 2 | 0 | 32 | 6.25 |
| BUFIO | 0 | 0 | 24 | 0.00 |
| MMCME2_ADV | 0 | 0 | 6 | 0.00 |
| PLLE2_ADV | 0 | 0 | 6 | 0.00 |
| BUFMRCE | 0 | 0 | 12 | 0.00 |
| BUFHCE | 0 | 0 | 96 | 0.00 |
| BUFR | 0 | 0 | 24 | 0.00 |
+------------+------+-------+-----------+-------+
module memory_8bit #(
parameter integer C_S_AXI_ADDR_WIDTH = 32,
parameter integer C_MEMORY_SIZE = 512 // Word (not byte)
)(
input wire clk,
input wire [C_S_AXI_ADDR_WIDTH-1:0] waddr,
input wire [7:0] write_data,
input wire write_enable,
input wire byte_enable,
input wire [C_S_AXI_ADDR_WIDTH-1:0] raddr,
output wire [7:0] read_data
);
set outputDir ./Tutorial_Created_Data/bft_output
file mkdir $outputDir
read_vhdl -library bftLib [ glob ./Sources/hdl/bftLib/*.vhdl ]
read_vhdl ./Sources/hdl/bft.vhdl
read_verilog [ glob ./Sources/hdl/*.v ]
read_xdc ./Sources/bft_full.xdc
synth_design -top bft -part xc7k70tfbg484-2 -flatten rebuilt
write_checkpoint -force $outputDir/post_synth
report_timing_summary -file $outputDir/post_synth_timing_summary.rpt
report_power -file $outputDir/post_synth_power.rpt
report_utilization -file $outputDir/post_synth_util.rpt
Copyright 1986-1999, 2001-2013 Xilinx, Inc. All Rights Reserved.
-------------------------------------------------------------------------------------------------
| Tool Version : Vivado v.2013.2 (win64) Build 272601 Sat Jun 15 11:27:26 MDT 2013
| Date : Thu Sep 05 05:27:58 2013
| Host : running 64-bit Service Pack 1 (build 7601)
| Command : report_utilization -file ./Tutorial_Created_Data/bft_output/post_synth_util.rpt
| Design : bft
| Device : xc7k70t
| Design State : Synthesized
-------------------------------------------------------------------------------------------------
Utilization Design Information
Table of Contents
-----------------
1. Slice Logic
2. Memory
3. DSP
4. IO and GTX Specific
5. Clocking
6. Specific Feature
7. Primitives
8. Black Boxes
9. Instantiated Netlists
1. Slice Logic
--------------
+-------------------------+------+-------+-----------+-------+
| Site Type | Used | Loced | Available | Util% |
+-------------------------+------+-------+-----------+-------+
| Slice LUTs* | 1965 | 0 | 41000 | 4.79 |
| LUT as Logic | 1965 | 0 | 41000 | 4.79 |
| LUT as Memory | 0 | 0 | 13400 | 0.00 |
| Slice Registers | 1370 | 0 | 82000 | 1.67 |
| Register as Flip Flop | 1370 | 0 | 82000 | 1.67 |
| Register as Latch | 0 | 0 | 82000 | 0.00 |
| F7 Muxes | 32 | 0 | 20500 | 0.15 |
| F8 Muxes | 0 | 0 | 10250 | 0.00 |
+-------------------------+------+-------+-----------+-------+
* Warning! The Final LUT count, after physical optimizations and full implementation, is typically lower. Run opt_design after synthesis for a more realistic count.
2. Memory
---------
+-------------------+------+-------+-----------+-------+
| Site Type | Used | Loced | Available | Util% |
+-------------------+------+-------+-----------+-------+
| Block RAM Tile | 16 | 0 | 135 | 11.85 |
| RAMB36/FIFO* | 16 | 0 | 135 | 11.85 |
| RAMB36E1 only | 16 | | | |
| RAMB18 | 0 | 0 | 270 | 0.00 |
+-------------------+------+-------+-----------+-------+
* Note: Each Block RAM Tile only has one FIFO logic available and therefore can accommodate only one FIFO36E1 or one FIFO18E1. However, if a FIFO18E1 occupies a Block RAM Tile, that tile can still accommodate a RAMB18E1
3. DSP
------
+----------------+------+-------+-----------+-------+
| Site Type | Used | Loced | Available | Util% |
+----------------+------+-------+-----------+-------+
| DSPs | 64 | 0 | 240 | 26.66 |
| DSP48E1 only | 64 | | | |
+----------------+------+-------+-----------+-------+
4. IO and GTX Specific
----------------------
+-----------------------------+------+-------+-----------+-------+
| Site Type | Used | Loced | Available | Util% |
+-----------------------------+------+-------+-----------+-------+
| Bonded IOB | 71 | 71 | 285 | 24.91 |
| IOB Master Pads | 35 | | | |
| IOB Slave Pads | 33 | | | |
| Bonded IPADs | 0 | 0 | 14 | 0.00 |
| Bonded OPADs | 0 | 0 | 8 | 0.00 |
| GTXE2_CHANNEL | 0 | 0 | 4 | 0.00 |
| GTXE2_COMMON | 0 | 0 | 1 | 0.00 |
| IBUFGDS | 0 | 0 | 275 | 0.00 |
| IDELAYCTRL | 0 | 0 | 6 | 0.00 |
| IN_FIFO | 0 | 0 | 24 | 0.00 |
| OUT_FIFO | 0 | 0 | 24 | 0.00 |
| PHASER_REF | 0 | 0 | 6 | 0.00 |
| PHY_CONTROL | 0 | 0 | 6 | 0.00 |
| PHASER_OUT/PHASER_OUT_PHY | 0 | 0 | 24 | 0.00 |
| PHASER_IN/PHASER_IN_PHY | 0 | 0 | 24 | 0.00 |
| IDELAYE2/IDELAYE2_FINEDELAY | 0 | 0 | 300 | 0.00 |
| ODELAYE2/ODELAYE2_FINEDELAY | 0 | 0 | 100 | 0.00 |
| IBUFDS_GTE2 | 0 | 0 | 4 | 0.00 |
| ILOGIC | 0 | 0 | 285 | 0.00 |
| OLOGIC | 0 | 0 | 285 | 0.00 |
+-----------------------------+------+-------+-----------+-------+
5. Clocking
-----------
+------------+------+-------+-----------+-------+
| Site Type | Used | Loced | Available | Util% |
+------------+------+-------+-----------+-------+
| BUFGCTRL | 2 | 0 | 32 | 6.25 |
| BUFIO | 0 | 0 | 24 | 0.00 |
| MMCME2_ADV | 0 | 0 | 6 | 0.00 |
| PLLE2_ADV | 0 | 0 | 6 | 0.00 |
| BUFMRCE | 0 | 0 | 12 | 0.00 |
| BUFHCE | 0 | 0 | 96 | 0.00 |
| BUFR | 0 | 0 | 24 | 0.00 |
+------------+------+-------+-----------+-------+
6. Specific Feature
-------------------
+-------------+------+-------+-----------+-------+
| Site Type | Used | Loced | Available | Util% |
+-------------+------+-------+-----------+-------+
| BSCANE2 | 0 | 0 | 4 | 0.00 |
| CAPTUREE2 | 0 | 0 | 1 | 0.00 |
| DNA_PORT | 0 | 0 | 1 | 0.00 |
| EFUSE_USR | 0 | 0 | 1 | 0.00 |
| FRAME_ECCE2 | 0 | 0 | 1 | 0.00 |
| ICAPE2 | 0 | 0 | 2 | 0.00 |
| PCIE_2_1 | 0 | 0 | 1 | 0.00 |
| STARTUPE2 | 0 | 0 | 1 | 0.00 |
| XADC | 0 | 0 | 1 | 0.00 |
+-------------+------+-------+-----------+-------+
7. Primitives
-------------
+----------+------+
| Ref Name | Used |
+----------+------+
| LUT2 | 1427 |
| FDCE | 1152 |
| LUT6 | 370 |
| FDPE | 160 |
| LUT4 | 147 |
| LUT5 | 114 |
| LUT3 | 84 |
| CARRY4 | 80 |
| DSP48E1 | 64 |
| FDRE | 58 |
| LUT1 | 55 |
| IBUF | 37 |
| OBUF | 34 |
| MUXF7 | 32 |
| RAMB36E1 | 16 |
| BUFG | 2 |
+----------+------+
8. Black Boxes
--------------
+----------+------+
| Ref Name | Used |
+----------+------+
9. Instantiated Netlists
------------------------
+----------+------+
| Ref Name | Used |
+----------+------+
cd C:/Users/Masaaki/Documents/Vivado/Vivado_Tutorial
source run_bft_batch.tcl
create_clock -period 10.000 -name wbClk [get_ports wbClk]
create_clock -period 5.000 -name bftClk [get_ports bftClk]
set_property PACKAGE_PIN P20 [get_ports {wbOutputData[23]}]
set_property PACKAGE_PIN V22 [get_ports {wbOutputData[9]}]
set_property PACKAGE_PIN E21 [get_ports {wbInputData[18]}]
set_property BEL AFF [get_cells error_reg]
set_property BEL B6LUT [get_cells {egressLoop[4].egressFifo/buffer_fifo/xlnx_opt_LUT_infer_fifo.wr_addr_tmp_reg[2]_CE_cooolgate_en_gate_15_1}]
set_property BEL A5LUT [get_cells {egressLoop[4].egressFifo/buffer_fifo/infer_fifo.wr_addr_tmp_reg[9]_i_2__11}]
set_property BEL D6LUT [get_cells {egressLoop[4].egressFifo/buffer_fifo/infer_fifo.wr_addr_tmp_reg[9]_i_1__11}]
set_property BEL DFF [get_cells {egressLoop[4].egressFifo/buffer_fifo/infer_fifo.wr_addr_tmp_reg[9]}]
配置が固定されているかどうかに関わらず、すべての配置をエクスポートします。デフォルトでは、固定された配置のみがエクスポートされます。
write_verilog C:/Data/my_verilog.net -mode timesim -sdf_anno true
Vivado HLSのAXI Master Exampleを試す1
Vivado HLSのAXI Master Exampleを試す2
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | - | - | - | - | - |