如何使用Basys3板创建一个简单的示波器

该项目将大家一起使用basys3板创建一个简单的示波器,花费时间约4小时。
硬件组件
digilent basys 3
软件应用程序和在线服务
xilinx vivado 设计套件   
xilinx vitis 统一软件平台
项目介绍
digilent basys3 板是一款功能强大的板,可用于开始开发 fpga 项目。它为用户提供了一个 artix 35t 设备、usb-uart、四个 pmod——包括一个为 xadc 配置的 pmod、12 位 vga 和开关、led 和七段显示器。
该项目旨在演示 basys3 板的功能,为此我们将创建一个简单的示波器,它可以使用 xdac pmod 输入通道和 vga 显示器来显示波形。
为此,我们将使用 microblaze 控制器来运行应用程序并控制 xadc 的测量,并确定在 vga 屏幕上绘制数据的位置。
vga 显示器将是 640 x 480,12 位 rgb 在软件内存中渲染需要 3、686、400 位。这超过了 fpga 中可用的 1、800、000 位 bram。处理器也无法以能够达到所需帧速率所需的速度运行。
我们将通过使用处理器来确定数据点图来解决这个问题,同时逻辑渲染帧以实时显示。为此,我们将使用我们首先创建的高级综合核心。
高级综合核心
开始时要重新创建一个 hls 核心,它可以在 vga 显示器中绘制多达 10 个样本(当然,您可以稍后更改)。hls 内核将生成一个 640 像素 x 480 行的 axi 流。为了更新每一帧的显示,将有定义样本数据位置的 sample_x / _y 寄存器、定义数据点大小的寄存器和定义数据点颜色的最终寄存器。
创建 hls 流需要使用 ap_fixed.h 和 hls_video.h 库进行简单定义。
我们将有一个 32 位像素,其中包括每个 rgb 的 8 位,还有一个用于混合的 8 位 alpha 通道。
hud.h 文件包括以下几行
#include  hls_video.h
#include
#include string.h
#define width 32 //32 as alpha channel
typedef ap_uint pixel_type;
typedef hls::stream axis;
typedef ap_axiu video_stream;
void hud_gen(axis& op,
            int row,
            int column,
            int plot_x_1,
            int plot_y_1,
            int plot_x_2,
            int plot_y_2,
            int plot_x_3,
            int plot_y_3,
            int plot_x_4,
            int plot_y_4,
            int plot_x_5,
            int plot_y_5,
            int plot_x_6,
            int plot_y_6,
            int plot_x_7,
            int plot_y_7,
            int plot_x_8,
            int plot_y_8,
            int plot_x_9,
            int plot_y_9,
            int plot_x_10,
            int plot_y_10,
            int plot_x_11,
            int plot_y_11,
            int plot_x_12,
            int plot_y_12,
            int plot_x_13,
            int plot_y_13,
            int plot_x_14,
            int plot_y_14,
            int plot_x_15,
            int plot_y_15,
            int plot_x_16,
            int plot_y_16,
            int plot_x_17,
            int plot_y_17,
            int plot_x_18,
            int plot_y_18,
            int plot_x_19,
            int plot_y_19,
            int plot_x_20,
            int plot_y_20,
int plot_size,
            uint32_t plot_colour  ) ;
虽然代码的主体看起来像
#include hud.h
//#include char.h
void hud_gen(axis& op,
            int row,
            int column,
            int plot_x_1,
            int plot_y_1,
            int plot_x_2,
            int plot_y_2,
            int plot_x_3,
            int plot_y_3,
            int plot_x_4,
            int plot_y_4,
            int plot_x_5,
            int plot_y_5,
            int plot_x_6,
            int plot_y_6,
            int plot_x_7,
            int plot_y_7,
            int plot_x_8,
            int plot_y_8,
            int plot_x_9,
            int plot_y_9,
            int plot_x_10,
            int plot_y_10,
            int plot_x_11,
            int plot_y_11,
            int plot_x_12,
            int plot_y_12,
            int plot_x_13,
            int plot_y_13,
            int plot_x_14,
            int plot_y_14,
            int plot_x_15,
            int plot_y_15,
            int plot_x_16,
            int plot_y_16,
            int plot_x_17,
            int plot_y_17,
            int plot_x_18,
            int plot_y_18,
            int plot_x_19,
            int plot_y_19,
            int plot_x_20,
            int plot_y_20,
            int plot_size,
            uint32_t plot_colour  ) {
#pragma hls interface s_axilite port=return
#pragma hls interface s_axilite port=plot_y_1
#pragma hls interface s_axilite port=plot_x_1
#pragma hls interface s_axilite port=plot_y_2
#pragma hls interface s_axilite port=plot_x_2
#pragma hls interface s_axilite port=plot_y_3
#pragma hls interface s_axilite port=plot_x_3
#pragma hls interface s_axilite port=plot_y_4
#pragma hls interface s_axilite port=plot_x_4
#pragma hls interface s_axilite port=plot_y_5
#pragma hls interface s_axilite port=plot_x_5
#pragma hls interface s_axilite port=plot_y_6
#pragma hls interface s_axilite port=plot_x_6
#pragma hls interface s_axilite port=plot_y_7
#pragma hls interface s_axilite port=plot_x_7
#pragma hls interface s_axilite port=plot_y_8
#pragma hls interface s_axilite port=plot_x_8
#pragma hls interface s_axilite port=plot_y_9
#pragma hls interface s_axilite port=plot_x_9
#pragma hls interface s_axilite port=plot_y_10
#pragma hls interface s_axilite port=plot_x_10
#pragma hls interface s_axilite port=plot_y_11
#pragma hls interface s_axilite port=plot_x_11
#pragma hls interface s_axilite port=plot_y_12
#pragma hls interface s_axilite port=plot_x_12
#pragma hls interface s_axilite port=plot_y_13
#pragma hls interface s_axilite port=plot_x_13
#pragma hls interface s_axilite port=plot_y_14
#pragma hls interface s_axilite port=plot_x_14
#pragma hls interface s_axilite port=plot_y_15
#pragma hls interface s_axilite port=plot_x_15
#pragma hls interface s_axilite port=plot_y_16
#pragma hls interface s_axilite port=plot_x_16
#pragma hls interface s_axilite port=plot_y_17
#pragma hls interface s_axilite port=plot_x_17
#pragma hls interface s_axilite port=plot_y_18
#pragma hls interface s_axilite port=plot_x_18
#pragma hls interface s_axilite port=plot_y_19
#pragma hls interface s_axilite port=plot_x_19
#pragma hls interface s_axilite port=plot_y_20
#pragma hls interface s_axilite port=plot_x_20
#pragma hls interface s_axilite port=column
#pragma hls interface s_axilite port=row
#pragma hls interface s_axilite port=plot_size
#pragma hls interface s_axilite port=plot_colour
#pragma hls interface axis register both port=op
int i = 0;
int y = 0;
int x = 0;
//int bar_pos_x = 10;
//int bar_width = 30;
video_stream hud_int;
row_loop:for (y =0; y  column_loop:for (x =0; x = (plot_x_1 - plot_size)) & (x = (plot_y_1 - plot_size)) & (y = (plot_x_2 - plot_size)) & (x = (plot_y_2 - plot_size)) & (y = (plot_x_3 - plot_size)) & (x = (plot_y_3 - plot_size)) & (y = (plot_x_4 - plot_size)) & (x = (plot_y_4 - plot_size)) & (y = (plot_x_5 - plot_size)) & (x = (plot_y_5 - plot_size)) & (y = (plot_x_6 - plot_size)) & (x = (plot_y_6 - plot_size)) & (y = (plot_x_7 - plot_size)) & (x = (plot_y_7 - plot_size)) & (y = (plot_x_8 - plot_size)) & (x = (plot_y_8 - plot_size)) & (y = (plot_x_9 - plot_size)) & (x = (plot_y_9 - plot_size)) & (y = (plot_x_10 - plot_size)) & (x = (plot_y_10 - plot_size)) & (y = (plot_x_11 - plot_size)) & (x = (plot_y_11 - plot_size)) & (y = (plot_x_12 - plot_size)) & (x = (plot_y_12 - plot_size)) & (y = (plot_x_13 - plot_size)) & (x = (plot_y_13 - plot_size)) & (y = (plot_x_14 - plot_size)) & (x = (plot_y_14 - plot_size)) & (y = (plot_x_15 - plot_size)) & (x = (plot_y_15 - plot_size)) & (y = (plot_x_16 - plot_size)) & (x = (plot_y_16 - plot_size)) & (y = (plot_x_17 - plot_size)) & (x = (plot_y_17 - plot_size)) & (y = (plot_x_18 - plot_size)) & (x = (plot_y_18 - plot_size)) & (y = (plot_x_19 - plot_size)) & (x = (plot_y_19 - plot_size)) & (y = (plot_x_20 - plot_size)) & (x = (plot_y_20 - plot_size)) & (y = 0 & y = column-3 & y = 0 & x baseaddress);
    xgpio_setdatadirection(&gpio,1,0xffffffff);
    xgpio_setdatadirection(&gpio,2,0x00000000);
    vtc_config = xvtc_lookupconfig(xpar_vtc_0_device_id);
    xvtc_cfginitialize(&vtcinst, vtc_config, vtc_config->baseaddress);
video = vmode_640x480;
    vtctiming.hactivevideo = video.width;    /**< horizontal active video size */
    vtctiming.hfrontporch = video.hps - video.width;    /**< horizontal front porch size */
    vtctiming.hsyncwidth = video.hpe - video.hps;        /**< horizontal sync width */
    vtctiming.hbackporch = video.hmax - video.hpe + 1;        /**< horizontal back porch size */
    vtctiming.hsyncpolarity = video.hpol;    /**< horizontal sync polarity */
    vtctiming.vactivevideo = video.height;    /**< vertical active video size */
    vtctiming.v0frontporch = video.vps - video.height;    /**< vertical front porch size */
    vtctiming.v0syncwidth = video.vpe - video.vps;    /**< vertical sync width */
    vtctiming.v0backporch = video.vmax - video.vpe + 1;;    /**< horizontal back porch size */
    vtctiming.v1frontporch = video.vps - video.height;    /**< vertical front porch size */
    vtctiming.v1syncwidth = video.vpe - video.vps;    /**< vertical sync width */
    vtctiming.v1backporch = video.vmax - video.vpe + 1;;    /**baseaddress);
status = xv_tpg_isready(&tpg);
    printf(tpg status %u \n\r, (unsigned int) status);
    xv_tpg_set_height(&tpg, (u32) video.height);
    xv_tpg_set_width(&tpg, (u32) video.width);
    height = xv_tpg_get_height(&tpg);
    width = xv_tpg_get_width(&tpg);
    xv_tpg_set_colorformat(&tpg,xvidc_csf_rgb);
    xv_tpg_set_maskid(&tpg, 0x0);
    xv_tpg_set_motionspeed(&tpg, 0x4);
    printf(info from tpg %u %u \n\r, (unsigned int)height, (unsigned int)width);
    xv_tpg_set_bckgndid(&tpg,xtpg_bkgnd_solid_blue);//xtpg_bkgnd_color_bars); //);
    status = xv_tpg_get_bckgndid(&tpg);
    printf(status %x \n\r, (unsigned int) status);
    xv_tpg_enableautorestart(&tpg);
    xv_tpg_start(&tpg);
    status = xv_tpg_isidle(&tpg);
printf(status %u \n\r, (unsigned int) status);
    xhud_gen_set_plot_x_1(&xv_hud, 64);
    xhud_gen_set_plot_y_1(&xv_hud, 441);
    xhud_gen_set_plot_x_2(&xv_hud, 128);
    xhud_gen_set_plot_y_2(&xv_hud, 458);
    xhud_gen_set_plot_x_3(&xv_hud, 192);
    xhud_gen_set_plot_y_3(&xv_hud, 273);
    xhud_gen_set_plot_x_4(&xv_hud, 256);
    xhud_gen_set_plot_y_4(&xv_hud, 58);
    xhud_gen_set_plot_x_5(&xv_hud, 320);
    xhud_gen_set_plot_y_5(&xv_hud, 9);
    xhud_gen_set_plot_x_6(&xv_hud, 384);
    xhud_gen_set_plot_y_6(&xv_hud, 172);
    xhud_gen_set_plot_x_7(&xv_hud, 448);
    xhud_gen_set_plot_y_7(&xv_hud, 397);
    xhud_gen_set_plot_x_8(&xv_hud, 512);
    xhud_gen_set_plot_y_8(&xv_hud, 477);
    xhud_gen_set_plot_x_9(&xv_hud, 576);
    xhud_gen_set_plot_y_9(&xv_hud, 338);
    xhud_gen_set_plot_x_10(&xv_hud, 640);
    xhud_gen_set_plot_y_10(&xv_hud, 109);
    cleanup_platform();
    return 0;
}
当输出时,这会提供一个漂亮的彩色显示,作为 vga 显示的基本范围。
另外,我们可以创建一个简单的项目来展示如何在vga输出上绘制点。
未来的改进方向可能如下:
添加标签和标记
添加光标以在屏幕上报告样本值
点之间的线绘制
当然,我们需要注意所需的逻辑资源,因为这个项目对设备资源的要求很高。

设计建模系统流量并验证系统的性能
埃斯顿自动化与三一机器人战略合作
美国派克Parker电动缸ETH系列技术参数及其应用
TE荣获2022全球电子成就奖之年度创新产品
步步高无绳电话子机充电器简析与维修,Battery Charger Repair
如何使用Basys3板创建一个简单的示波器
公牛插座质量怎么样
SpaceX 2021年首次猎鹰9号火箭发射成功
洞悉 Omniverse: Adobe Substance 3D 与 Omniverse 提高 3D 工作流的创作自由度
直线电机模组在激光加工技术的应用
以后会不会有6G、7G、8G
进线柜与出线柜的区别及作用_进线柜与出线柜的停电操作程序
脑机接口新进展!用意念控制电脑还有多远
超低成本get一项新技能:在阿里云上进行IoT系统开发
NI宣布针对5G实验室和现场试验推出了Test UE产品
LC1智能墙壁开关来啦!
HBJ钮扣测试仪简介
通用软件无线电外设(USRP)设备升级方案
PCB设计的规则及抗干扰设计的要求解析
助力全球5G技术突破!新思科技ASIP Designer加速Viettel首款5G SoC面世