// display_cont.cpp
// 2015/06/03 by marsee
//
// 画面を4分割した第1象限は赤、第2象限は緑、第3象限は青、第4象限は白を表示する
//
#include <stdio.h>
#include <string.h>
#include <ap_int.h>
// SVGA 解像度
#define H_ACTIVE_VIDEO 800
#define H_FRONT_PORCH 40
#define H_SYNC_PULSE 128
#define H_BACK_PORCH 88
#define H_SUM (H_ACTIVE_VIDEO + H_FRONT_PORCH + H_SYNC_PULSE + H_BACK_PORCH)
#define V_ACTIVE_VIDEO 600
#define V_FRONT_PORCH 1
#define V_SYNC_PULSE 4
#define V_BACK_PORCH 23
#define V_SUM (V_ACTIVE_VIDEO + V_FRONT_PORCH + V_SYNC_PULSE + V_BACK_PORCH)
void display_cont(ap_uint<8> *red, ap_uint<8> *green, ap_uint<8> *blue, ap_uint<1> *display_enable, ap_uint<1> *hsyncx, ap_uint<1> *vsyncx){
#pragma HLS INTERFACE ap_none register port=red
#pragma HLS INTERFACE ap_none register port=green
#pragma HLS INTERFACE ap_none register port=blue
#pragma HLS INTERFACE ap_none register port=display_enable
#pragma HLS INTERFACE ap_none register port=hsyncx
#pragma HLS INTERFACE ap_none register port=vsyncx
#pragma HLS INTERFACE ap_ctrl_none port=return
ap_uint<16> h_count, v_count;
while(1){
for (v_count=0; v_count<V_SUM; v_count++){
for (h_count=0; h_count<H_SUM; h_count++){
#pragma HLS PIPELINE
#pragma HLS LATENCY min=1 max=1
if (h_count > (H_ACTIVE_VIDEO +H_FRONT_PORCH) && h_count < (H_ACTIVE_VIDEO + H_FRONT_PORCH + H_SYNC_PULSE))
*hsyncx = 0;
else
*hsyncx = 1;
if (v_count > (V_ACTIVE_VIDEO + V_FRONT_PORCH) && v_count < (V_ACTIVE_VIDEO + V_FRONT_PORCH + V_SYNC_PULSE))
*vsyncx = 0;
else
*vsyncx = 1;
if (h_count < H_ACTIVE_VIDEO && v_count < V_ACTIVE_VIDEO)
*display_enable = 1;
else
*display_enable = 0;
if (v_count < V_ACTIVE_VIDEO/2){
if (h_count < H_ACTIVE_VIDEO/2){
*red=0xff; *green=0; *blue=0;
} else if (h_count < H_ACTIVE_VIDEO){
*red=0; *green=0xff; *blue=0;
} else {
*red=0; *green=0; *blue=0;
}
} else if (v_count < V_ACTIVE_VIDEO){
if (h_count < H_ACTIVE_VIDEO/2){
*red=0; *green=0; *blue=0xff;
} else if (h_count < H_ACTIVE_VIDEO){
*red=0xff; *green=0xff; *blue=0xff;
} else {
*red=0; *green=0; *blue=0;
}
} else {
*red=0; *green=0; *blue=0;
}
}
}
}
}
void display_cont_sub(ap_uint<8> *red, ap_uint<8> *green, ap_uint<8> *blue, ap_uint<1> *display_enable, ap_uint<1> *hsyncx, ap_uint<1> *vsyncx){
#pragma HLS INTERFACE ap_none register port=red
#pragma HLS INTERFACE ap_none register port=green
#pragma HLS INTERFACE ap_none register port=blue
#pragma HLS INTERFACE ap_none register port=display_enable
#pragma HLS INTERFACE ap_none register port=hsyncx
#pragma HLS INTERFACE ap_none register port=vsyncx
#pragma HLS INTERFACE ap_ctrl_hs port=return
ap_uint<16> h_count, v_count;
for (v_count=0; v_count<V_SUM; v_count++){
for (h_count=0; h_count<H_SUM; h_count++){
#pragma HLS PIPELINE
#pragma HLS LATENCY min=1 max=1
if (h_count > (H_ACTIVE_VIDEO +H_FRONT_PORCH) && h_count < (H_ACTIVE_VIDEO + H_FRONT_PORCH + H_SYNC_PULSE))
*hsyncx = 0;
else
*hsyncx = 1;
if (v_count > (V_ACTIVE_VIDEO + V_FRONT_PORCH) && v_count < (V_ACTIVE_VIDEO + V_FRONT_PORCH + V_SYNC_PULSE))
*vsyncx = 0;
else
*vsyncx = 1;
if (h_count < H_ACTIVE_VIDEO && v_count < V_ACTIVE_VIDEO)
*display_enable = 1;
else
*display_enable = 0;
if (v_count < V_ACTIVE_VIDEO/2){
if (h_count < H_ACTIVE_VIDEO/2){
*red=0xff; *green=0; *blue=0;
} else if (h_count < H_ACTIVE_VIDEO){
*red=0; *green=0xff; *blue=0;
} else {
*red=0; *green=0; *blue=0;
}
} else if (v_count < V_ACTIVE_VIDEO){
if (h_count < H_ACTIVE_VIDEO/2){
*red=0; *green=0; *blue=0xff;
} else if (h_count < H_ACTIVE_VIDEO){
*red=0xff; *green=0xff; *blue=0xff;
} else {
*red=0; *green=0; *blue=0;
}
} else {
*red=0; *green=0; *blue=0;
}
}
}
}
cd C:/Users/Masaaki/Documents/Vivado_HLS/ZYBO/display_cont/solution1/sim/verilog
current_fileset
open_wave_database display_cont_sub.wdb
open_wave_config display_cont_sub.wcfg
//
// display_cont_tb.cpp
// 2015/06/03 by marsee
//
#include <stdio.h>
#include <string.h>
#include <ap_int.h>
void display_cont_sub(ap_uint<8> *red, ap_uint<8> *green, ap_uint<8> *blue, ap_uint<1> *display_enable, ap_uint<1> *hsyncx, ap_uint<1> *vsyncx);
int main(){
ap_uint<8> redb, *red;
ap_uint<8> greenb, *green;
ap_uint<8> blueb, *blue;
ap_uint<1> deb, *display_enable;
ap_uint<1> hb, *hsyncx;
ap_uint<1> vb, *vsyncx;
red = &redb;
green = &greenb;
blue = &blueb;
display_enable = &deb;
hsyncx = &hb;
vsyncx = &vb;
display_cont_sub(red, green, blue, display_enable, hsyncx, vsyncx);
return 0;
}
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
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 | 31 | - | - | - | - |