当前位置: 首页 > news >正文

VESA DSC 基于FPGA DSC_Encoder IP仿真

VESA DSC 基于FPGA DSC_Encoder IP仿真

1:IP设置

2:仿真文件导入

3:仿真

                //
// Created by Microsemi SmartDesign Thu Oct 10 12:36:11 2019
// Testbench Template
// This is a basic testbench that instantiates your design with basic 
// clock and reset pins connected.  If your design has special
// clock/reset or testbench driver requirements then you should 
// copy this file and modify it. 
//

///
// Company: <Name>
//
// File: test_bench.v
// File history:
//      <Revision number>: <Date>: <Comments>
//      <Revision number>: <Date>: <Comments>
//      <Revision number>: <Date>: <Comments>
//
// Description: 
//
// <Description here>
//
// Targeted device: <Family::PolarFire> <Die::MPF300T> <Package::FCG1152>
// Author: <Name>
//
/// 


`timescale 1ns/100ps
 
module test_bench;

parameter SYSCLK_PERIOD = 10;// 100MHZ
parameter H_RES = 432;
parameter V_RES = 240;
parameter g_DATAWIDTH = 8;

reg SYSCLK;
reg NSYSRESET;
reg [15:0] h_resolution=H_RES,v_resolution=V_RES,h_blanking=280,v_blanking=20;
reg [15:0] h_counter,v_counter,h_total,v_total;
reg h_active,v_active,data_valid,data_valid_dly,eof,eof_dly;
reg[g_DATAWIDTH : 0] Y_array[0:(H_RES*V_RES)-1];
 reg[g_DATAWIDTH : 0] Cb_array[0:(H_RES*V_RES)-1];
reg[g_DATAWIDTH : 0] Cr_array[0:(H_RES*V_RES)-1]; 
reg[47 : 0] bitstream_quant_array[0:(H_RES*V_RES)-1];
reg[11 : 0] bitstream_array[0:(H_RES*V_RES)-1];
wire [g_DATAWIDTH - 1 : 0] Y_data,Cb_data,Cr_data;
wire [47  : 0] bitstream_quant;
wire bitstream_quant_valid;

reg [7 : 0] dsc_out_ref [0 : 262143];
reg [17 : 0] ref_addr;

reg [15 : 0] err;

reg pulse=0;
integer i; 


//
// Reset Pulse
//
initial
begin
    SYSCLK = 0;
    NSYSRESET = 0;
    #(SYSCLK_PERIOD * 10 )
        NSYSRESET = 1'b1;
end


//
// Clock Driver
//
always @(SYSCLK)
    #(SYSCLK_PERIOD / 2.0) SYSCLK <= !SYSCLK;

/


// initialize the hexadecimal reads from the file
initial $readmemh("img_in_luma.txt", Y_array); 
initial $readmemh("img_in_cb.txt", Cb_array); 
initial $readmemh("img_in_cr.txt", Cr_array);   
initial $readmemh("dsc_out_ref.txt", dsc_out_ref);   
assign Y_data     = Y_array[i][7:0];
assign Cb_data     = Cb_array[i][7:0];
assign Cr_data     = Cr_array[i][7:0];

initial
begin
    h_total = h_resolution + h_blanking;
    v_total = v_resolution + v_blanking;
end
always @(posedge SYSCLK or negedge NSYSRESET) begin
        if(~NSYSRESET)   begin
        pulse     <= 0;
    end
    if(data_valid==1 && data_valid_dly==0) begin
        pulse = 1;
    end
    else begin
        pulse = pulse;
    end
end
always@(h_counter,h_resolution) begin
    if(h_counter >= (h_blanking+1)) begin
        h_active = 1;
    end
    else begin
        h_active = 0;
    end
end

always@(v_counter,v_resolution) begin
    if(v_counter >= (v_blanking+1)) begin
        v_active = 1;
    end
    else begin
        v_active = 0;
    end
end

always@(h_active,v_active) begin
    data_valid = h_active && v_active;
end

always@(v_counter) begin
    if((v_counter == 15)&&(pulse==1)) begin
        eof = 1;
    end
    else begin
        eof = 0;
    end
end

// Horizontal counter
always @(posedge SYSCLK or negedge NSYSRESET) begin
    if(~NSYSRESET)   begin
        h_counter     <= 0;
        i <= 0;
        data_valid_dly <= 0;
        eof_dly <= 0;
    end
    else begin
        data_valid_dly <= data_valid;
        eof_dly <= eof;
        if(h_counter < h_total) begin 
            h_counter     <= h_counter + 1;
        end
        else  begin
            h_counter     <= 0;
        end
        if(eof == 1) begin
            i <= 0;
        end
        else begin
            if (data_valid == 1) begin
                i = i + 1;
            end
        end
    end
end

// Vertical counter
always @(posedge SYSCLK or negedge NSYSRESET) begin
    if(~NSYSRESET)   begin
        v_counter     <= 0;
    end
    else begin    
        if(h_counter == h_total) begin                
            if(v_counter < v_total) begin 
                v_counter     <= v_counter + 1;
            end
            else  begin
                v_counter     <= 0;
            end
        end
    end
end
//
// Instantiate Unit Under Test:  data_gather
//
DSC_Encoder #(.G_DATA_WIDTH(g_DATAWIDTH)) DSC_Encoder(
    // Inputs
    .RESETN_I(NSYSRESET),
    .PIX_CLK_I(SYSCLK),
    .DATA_Y_I(Y_data),
    .DATA_CB_I(Cb_data),
    .DATA_CR_I(Cr_data),
    .HRES_I(H_RES[15:0]),
    .VRES_I(V_RES[15:0]),
    .DATA_VALID_I(data_valid),
     .FRAME_END_I(eof), 
    // Outputs
    .DATA_O(bitstream_quant),
    .DATA_VALID_O(bitstream_quant_valid)
    
);

always @ (posedge SYSCLK, negedge NSYSRESET)begin
    if(~NSYSRESET) begin 
        err     <= 0;
        ref_addr<= 0;
    end
    else if(eof==0 && eof_dly==1) begin 
        err     <= 0;
        ref_addr<= 0;
    end
    else if (bitstream_quant_valid)begin
        ref_addr <= ref_addr + 6;
        if(bitstream_quant != {dsc_out_ref[ref_addr],dsc_out_ref[ref_addr+1],dsc_out_ref[ref_addr+2],dsc_out_ref[ref_addr+3],
                               dsc_out_ref[ref_addr+4],dsc_out_ref[ref_addr+5]}) begin 
            err <=  err + 1;                  
        end
    end
end

always @ (posedge SYSCLK, negedge NSYSRESET)begin
    if(eof==1 && eof_dly==0) begin 
        $display(" ***********************************");
        $display(" ***********************************");
        $display(" H_RES:%d  V_RES:%d",H_RES,V_RES);
        
        if(err == 0) begin 
            $display(" DSC Compression Test Passed");
            $display(" ***********************************");
            $display(" ***********************************");
        end
        else begin 
            $display(" DSC Compression Test Failed");
            $display(" ***********************************");
            $display(" ***********************************");
        end
        
        $stop;
        
    end

end

endmodule

4:仿真运行

5:欢迎讨论交流

微:moning_hello

相关文章:

  • ABP vNext + HBase:打造超高吞吐分布式列式数据库
  • [C#]基于winform部署PP-OCRv5的推理模型paddleocrv5模型部署
  • web端rtmp推拉流测试、抽帧识别计数,一键式生成巡检报告
  • 曲面的存在性定理
  • ServerTrust 并非唯一
  • Spring AI中使用ChatMemory实现会话记忆功能
  • Java【基础篇0】
  • 【时序预测】-Transformer系列
  • 【差分】详解二维前缀和和差分问题
  • F(x, y, z) = 0 隐函数微分 确定自变量
  • 【异常】极端事件的概率衰减方式(指数幂律衰减)
  • 【CUDA 】第5章 共享内存和常量内存——5.3减少全局内存访问(2)展开+动态共享内存
  • AI智能体|扣子(Coze)搭建【公众号对标文章采集拆解】工作流
  • 【量化】策略交易类型
  • 互联网协议IPv6
  • 解决Vscode JDK插件源码缺失问题
  • Opnelayers:封装Popup
  • HNSW - 分层可导航小世界
  • 使用idea开发工具创建javaweb项目工程
  • 《最短路(Bellman-ford)》题集
  • 购物网站成功案例/湖南今日新闻最新头条
  • 做任务的设计网站/企业网站推广注意事项
  • 武汉想做网站/百中搜优化软件靠谱吗
  • java web做网站/杭州seo博客
  • 怎样做聊天网站/长沙seo研究中心
  • 安徽省 政府网站建设的要求/宁波网络推广方式