AX7A200教程(2): DDR3仿真平台搭建(二)

news2024/9/29 23:35:35

本章主要新建ddr3工程,然后将官方的ddr3仿真文件加入到工程里进行仿真,开发环境2020.1。

新建ddr3_test工程

新建ddr3工程顶层

新建的ddr3_top顶层文件,目前还是空白的

调用mig控制器,请参考我上一个章节,这里不在具体写调用过程

AX7A200教程(1):DDR3仿真平台搭建(一)

工程里调用mig控制器,如下图所示

将mig控制器例化到ddr3_top顶层

`timescale 1ns / 1ps
//
// Company: 
// Engineer: 
// 
// Create Date: 2023/01/20 20:24:41
// Design Name: 
// Module Name: ddr3_top
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//


module ddr3_top(
    //clock
    input               sys_clk_i,//200M
    //reset
    input               sys_rst,
   // Inouts
   inout [31:0]         ddr3_dq,
   inout [3:0]          ddr3_dqs_n,
   inout [3:0]          ddr3_dqs_p,
   // Outputs
   output [14:0]        ddr3_addr,
   output [2:0]         ddr3_ba,
   output               ddr3_ras_n,
   output               ddr3_cas_n,
   output               ddr3_we_n,
   output               ddr3_reset_n,
   output [0:0]         ddr3_ck_p,
   output [0:0]         ddr3_ck_n,
   output [0:0]         ddr3_cke,
   output [0:0]         ddr3_cs_n,   
   output [3:0]         ddr3_dm,
   output [0:0]         ddr3_odt
   
    );
    
  wire [28:0]                           app_addr;               //DDR3地址
  wire [2:0]                            app_cmd;                //MIG IP核操作命令,读或者写
  wire                                  app_en;                 //MIG IP发送命令使能
  wire                                  app_rdy;                //MIG 命令接收准备好标志
  wire [255:0]                          app_rd_data;            //用户读数据
  wire                                  app_rd_data_end;        //突发读当前时钟最后一个数据
  wire                                  app_rd_data_valid;      //读数据有效
  wire [255:0]                          app_wdf_data;           //用户写数据
  wire                                  app_wdf_end;            //突发写当前时钟最后一个数据
  wire [31:0]                           app_wdf_mask;
  wire                                  app_wdf_rdy;            //MIG数据接收准备好
  wire                                  app_sr_active;
  wire                                  app_ref_ack;
  wire                                  app_zq_ack;
  wire                                  app_wdf_wren;    
  wire                                  ui_clk;                //用户时钟
  wire                                  ui_clk_sync_rst;       //复位,高有效
    
  mig_7series_0 u_mig_7series_0 (


    // Memory interface ports
    .ddr3_addr                      (ddr3_addr),  // output [14:0]        ddr3_addr
    .ddr3_ba                        (ddr3_ba),  // output [2:0]        ddr3_ba
    .ddr3_cas_n                     (ddr3_cas_n),  // output            ddr3_cas_n
    .ddr3_ck_n                      (ddr3_ck_n),  // output [0:0]        ddr3_ck_n
    .ddr3_ck_p                      (ddr3_ck_p),  // output [0:0]        ddr3_ck_p
    .ddr3_cke                       (ddr3_cke),  // output [0:0]        ddr3_cke
    .ddr3_ras_n                     (ddr3_ras_n),  // output            ddr3_ras_n
    .ddr3_reset_n                   (ddr3_reset_n),  // output            ddr3_reset_n
    .ddr3_we_n                      (ddr3_we_n),  // output            ddr3_we_n
    .ddr3_dq                        (ddr3_dq),  // inout [31:0]        ddr3_dq
    .ddr3_dqs_n                     (ddr3_dqs_n),  // inout [3:0]        ddr3_dqs_n
    .ddr3_dqs_p                     (ddr3_dqs_p),  // inout [3:0]        ddr3_dqs_p
    .init_calib_complete            (init_calib_complete),  // output            init_calib_complete


    .ddr3_cs_n                      (ddr3_cs_n),  // output [0:0]        ddr3_cs_n
    .ddr3_dm                        (ddr3_dm),  // output [3:0]        ddr3_dm
    .ddr3_odt                       (ddr3_odt),  // output [0:0]        ddr3_odt
    // Application interface ports
    .app_addr                       (app_addr),  // input [28:0]        app_addr
    .app_cmd                        (app_cmd),  // input [2:0]        app_cmd
    .app_en                         (app_en),  // input                app_en
    .app_wdf_data                   (app_wdf_data),  // input [255:0]        app_wdf_data
    .app_wdf_end                    (app_wdf_end),  // input                app_wdf_end
    .app_wdf_wren                   (app_wdf_wren),  // input                app_wdf_wren
    .app_rd_data                    (app_rd_data),  // output [255:0]        app_rd_data
    .app_rd_data_end                (app_rd_data_end),  // output            app_rd_data_end
    .app_rd_data_valid              (app_rd_data_valid),  // output            app_rd_data_valid
    .app_rdy                        (app_rdy),  // output            app_rdy
    .app_wdf_rdy                    (app_wdf_rdy),  // output            app_wdf_rdy
    .app_sr_req                     (1'b0),  // input            app_sr_req
    .app_ref_req                    (1'b0),  // input            app_ref_req
    .app_zq_req                     (1'b0),  // input            app_zq_req
    .app_sr_active                  (app_sr_active),  // output            app_sr_active
    .app_ref_ack                    (app_ref_ack),  // output            app_ref_ack
    .app_zq_ack                     (app_zq_ack),  // output            app_zq_ack
    .ui_clk                         (ui_clk),  // output            ui_clk
    .ui_clk_sync_rst                (ui_clk_sync_rst),  // output            ui_clk_sync_rst
    .app_wdf_mask                   (32'd0),  // input [31:0]        app_wdf_mask
    // System Clock Ports
    .sys_clk_i                      (sys_clk_i),
    .sys_rst                        (sys_rst) // input sys_rst

    );    
endmodule

在这里往后都比较复杂,务必按照步骤来做,目前这种仿真ddr3的方法csdn上没有,但这种方式仿真不容易出错,但搭建起来比较麻烦

在我上篇博客中提到,xilinx官方提供了mig控制器的仿真脚本,那么现在我们就将上篇博客工程中的仿真文件,导入到这个新建的ddr3工程的仿真目录里面,上篇博客里的仿真文件如下图所示,但我们只需导入部分文件即可

找到xlinx官方的仿真路径下的文件,如下图所示

复制我选中的这五个文件,复制到我们现在新建的这个工程下面

复制到工程文件夹里面

点击“+”加入仿真文件

选择加入仿真文件

选择Add Files加入文件

选择这五个文件,点击OK加入进去

点击Finish,加入到仿真目录下

可以看到仿真目录sim也出现了官方提供的仿真文件

修改example_top文件,也就是红框选择的这个文件

修改后的example_top文件

//*****************************************************************************

// (c) Copyright 2009 - 2013 Xilinx, Inc. All rights reserved.

//

// This file contains confidential and proprietary information

// of Xilinx, Inc. and is protected under U.S. and

// international copyright and other intellectual property

// laws.

//

// DISCLAIMER

// This disclaimer is not a license and does not grant any

// rights to the materials distributed herewith. Except as

// otherwise provided in a valid license issued to you by

// Xilinx, and to the maximum extent permitted by applicable

// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND

// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES

// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING

// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-

// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and

// (2) Xilinx shall not be liable (whether in contract or tort,

// including negligence, or under any other theory of

// liability) for any loss or damage of any kind or nature

// related to, arising under or in connection with these

// materials, including for any direct, or any indirect,

// special, incidental, or consequential loss or damage

// (including loss of data, profits, goodwill, or any type of

// loss or damage suffered as a result of any action brought

// by a third party) even if such damage or loss was

// reasonably foreseeable or Xilinx had been advised of the

// possibility of the same.

//

// CRITICAL APPLICATIONS

// Xilinx products are not designed or intended to be fail-

// safe, or for use in any application requiring fail-safe

// performance, such as life-support or safety devices or

// systems, Class III medical devices, nuclear facilities,

// applications related to the deployment of airbags, or any

// other applications that could lead to death, personal

// injury, or severe property or environmental damage

// (individually and collectively, "Critical

// Applications"). Customer assumes the sole risk and

// liability of any use of Xilinx products in Critical

// Applications, subject only to applicable laws and

// regulations governing limitations on product liability.

//

// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS

// PART OF THIS FILE AT ALL TIMES.

//

//*****************************************************************************

//   ____  ____

//  /   /\/   /

// /___/  \  /    Vendor             : Xilinx

// \   \   \/     Version            : 4.2

//  \   \         Application        : MIG

//  /   /         Filename           : example_top.v

// /___/   /\     Date Last Modified : $Date: 2011/06/02 08:35:03 $

// \   \  /  \    Date Created       : Tue Sept 21 2010

//  \___\/\___\

//

// Device           : 7 Series

// Design Name      : DDR3 SDRAM

// Purpose          :

//   Top-level  module. This module serves as an example,

//   and allows the user to synthesize a self-contained design,

//   which they can be used to test their hardware.

//   In addition to the memory controller, the module instantiates:

//     1. Synthesizable testbench - used to model user's backend logic

//        and generate different traffic patterns

// Reference        :

// Revision History :

//*****************************************************************************



//`define SKIP_CALIB

`timescale 1ps/1ps



module example_top #

  (



   //***************************************************************************

   // Traffic Gen related parameters

   //***************************************************************************

   parameter PORT_MODE             = "BI_MODE",

   parameter DATA_MODE             = 4'b0010,

   parameter TST_MEM_INSTR_MODE    = "R_W_INSTR_MODE",

   parameter EYE_TEST              = "FALSE",

                                     // set EYE_TEST = "TRUE" to probe memory

                                     // signals. Traffic Generator will only

                                     // write to one single location and no

                                     // read transactions will be generated.

   parameter DATA_PATTERN          = "DGEN_ALL",

                                      // For small devices, choose one only.

                                      // For large device, choose "DGEN_ALL"

                                      // "DGEN_HAMMER", "DGEN_WALKING1",

                                      // "DGEN_WALKING0","DGEN_ADDR","

                                      // "DGEN_NEIGHBOR","DGEN_PRBS","DGEN_ALL"

   parameter CMD_PATTERN           = "CGEN_ALL",

                                      // "CGEN_PRBS","CGEN_FIXED","CGEN_BRAM",

                                      // "CGEN_SEQUENTIAL", "CGEN_ALL"

   parameter CMD_WDT               = 'h3FF,

   parameter WR_WDT                = 'h1FFF,

   parameter RD_WDT                = 'h3FF,

   parameter SEL_VICTIM_LINE       = 0,

   parameter BEGIN_ADDRESS         = 32'h00000000,

   parameter END_ADDRESS           = 32'h00ffffff,

   parameter PRBS_EADDR_MASK_POS   = 32'hff000000,



   //***************************************************************************

   // The following parameters refer to width of various ports

   //***************************************************************************

   parameter CK_WIDTH              = 1,

                                     // # of CK/CK# outputs to memory.

   parameter nCS_PER_RANK          = 1,

                                     // # of unique CS outputs per rank for phy

   parameter CKE_WIDTH             = 1,

                                     // # of CKE outputs to memory.

   parameter DM_WIDTH              = 4,

                                     // # of DM (data mask)

   parameter ODT_WIDTH             = 1,

                                     // # of ODT outputs to memory.

   parameter BANK_WIDTH            = 3,

                                     // # of memory Bank Address bits.

   parameter COL_WIDTH             = 10,

                                     // # of memory Column Address bits.

   parameter CS_WIDTH              = 1,

                                     // # of unique CS outputs to memory.

   parameter DQ_WIDTH              = 32,

                                     // # of DQ (data)

   parameter DQS_WIDTH             = 4,

   parameter DQS_CNT_WIDTH         = 2,

                                     // = ceil(log2(DQS_WIDTH))

   parameter DRAM_WIDTH            = 8,

                                     // # of DQ per DQS

   parameter ECC                   = "OFF",

   parameter ECC_TEST              = "OFF",

   //parameter nBANK_MACHS           = 4,

   parameter nBANK_MACHS           = 4,

   parameter RANKS                 = 1,

                                     // # of Ranks.

   parameter ROW_WIDTH             = 15,

                                     // # of memory Row Address bits.

   parameter ADDR_WIDTH            = 29,

                                     // # = RANK_WIDTH + BANK_WIDTH

                                     //     + ROW_WIDTH + COL_WIDTH;

                                     // Chip Select is always tied to low for

                                     // single rank devices



   //***************************************************************************

   // The following parameters are mode register settings

   //***************************************************************************

   parameter BURST_MODE            = "8",

                                     // DDR3 SDRAM:

                                     // Burst Length (Mode Register 0).

                                     // # = "8", "4", "OTF".

                                     // DDR2 SDRAM:

                                     // Burst Length (Mode Register).

                                     // # = "8", "4".



   

   //***************************************************************************

   // The following parameters are multiplier and divisor factors for PLLE2.

   // Based on the selected design frequency these parameters vary.

   //***************************************************************************

   parameter CLKIN_PERIOD          = 5000,

                                     // Input Clock Period

   parameter CLKFBOUT_MULT         = 4,

                                     // write PLL VCO multiplier

   parameter DIVCLK_DIVIDE         = 1,

                                     // write PLL VCO divisor

   parameter CLKOUT0_PHASE         = 0.0,

                                     // Phase for PLL output clock (CLKOUT0)

   parameter CLKOUT0_DIVIDE        = 1,

                                     // VCO output divisor for PLL output clock (CLKOUT0)

   parameter CLKOUT1_DIVIDE        = 2,

                                     // VCO output divisor for PLL output clock (CLKOUT1)

   parameter CLKOUT2_DIVIDE        = 32,

                                     // VCO output divisor for PLL output clock (CLKOUT2)

   parameter CLKOUT3_DIVIDE        = 8,

                                     // VCO output divisor for PLL output clock (CLKOUT3)

   parameter MMCM_VCO              = 800,

                                     // Max Freq (MHz) of MMCM VCO

   parameter MMCM_MULT_F           = 8,

                                     // write MMCM VCO multiplier

   parameter MMCM_DIVCLK_DIVIDE    = 1,

                                     // write MMCM VCO divisor



   //***************************************************************************

   // Simulation parameters

   //***************************************************************************

   parameter SIMULATION            = "FALSE",

                                     // Should be TRUE during design simulations and

                                     // FALSE during implementations



   //***************************************************************************

   // IODELAY and PHY related parameters

   //***************************************************************************

   parameter TCQ                   = 100,

   

   parameter DRAM_TYPE             = "DDR3",



   

   //***************************************************************************

   // System clock frequency parameters

   //***************************************************************************

   parameter nCK_PER_CLK           = 4,

                                     // # of memory CKs per fabric CLK



   



   //***************************************************************************

   // Debug parameters

   //***************************************************************************

   parameter DEBUG_PORT            = "OFF",

                                     // # = "ON" Enable debug signals/controls.

                                     //   = "OFF" Disable debug signals/controls.

      

   parameter RST_ACT_LOW           = 1

                                     // =1 for active low reset,

                                     // =0 for active high.

   )

  (



   // Inouts

   inout [31:0]                         ddr3_dq,

   inout [3:0]                        ddr3_dqs_n,

   inout [3:0]                        ddr3_dqs_p,



   // Outputs

   output [14:0]                       ddr3_addr,

   output [2:0]                      ddr3_ba,

   output                                       ddr3_ras_n,

   output                                       ddr3_cas_n,

   output                                       ddr3_we_n,

   output                                       ddr3_reset_n,

   output [0:0]                        ddr3_ck_p,

   output [0:0]                        ddr3_ck_n,

   output [0:0]                       ddr3_cke,

   

   output [0:0]           ddr3_cs_n,

   

   output [3:0]                        ddr3_dm,

   

   output [0:0]                       ddr3_odt,

   



   // Inputs

   

   // Single-ended system clock

   input                                        sys_clk_i,

   



   output                                       tg_compare_error,

   output                                       init_calib_complete,

   

      



   // System reset - Default polarity of sys_rst pin is Active Low.

   // System reset polarity will change based on the option 

   // selected in GUI.

   input                                        sys_rst

   );



function integer clogb2 (input integer size);

    begin

      size = size - 1;

      for (clogb2=1; size>1; clogb2=clogb2+1)

        size = size >> 1;

    end

  endfunction // clogb2



  function integer STR_TO_INT;

    input [7:0] in;

    begin

      if(in == "8")

        STR_TO_INT = 8;

      else if(in == "4")

        STR_TO_INT = 4;

      else

        STR_TO_INT = 0;

    end

  endfunction





  localparam DATA_WIDTH            = 32;

  localparam RANK_WIDTH = clogb2(RANKS);

  localparam PAYLOAD_WIDTH         = (ECC_TEST == "OFF") ? DATA_WIDTH : DQ_WIDTH;

  localparam BURST_LENGTH          = STR_TO_INT(BURST_MODE);

  localparam APP_DATA_WIDTH        = 2 * nCK_PER_CLK * PAYLOAD_WIDTH;

  localparam APP_MASK_WIDTH        = APP_DATA_WIDTH / 8;



  //***************************************************************************

  // Traffic Gen related parameters (derived)

  //***************************************************************************

  localparam  TG_ADDR_WIDTH = ((CS_WIDTH == 1) ? 0 : RANK_WIDTH)

                                 + BANK_WIDTH + ROW_WIDTH + COL_WIDTH;

  localparam MASK_SIZE             = DATA_WIDTH/8;

      



  // Wire declarations

      

  wire [(2*nCK_PER_CLK)-1:0]              app_ecc_multiple_err;

  wire [(2*nCK_PER_CLK)-1:0]              app_ecc_single_err;

  wire [ADDR_WIDTH-1:0]                 app_addr;

  wire [2:0]                            app_cmd;

  wire                                  app_en;

  wire                                  app_rdy;

  wire [APP_DATA_WIDTH-1:0]             app_rd_data;

  wire                                  app_rd_data_end;

  wire                                  app_rd_data_valid;

  wire [APP_DATA_WIDTH-1:0]             app_wdf_data;

  wire                                  app_wdf_end;

  wire [APP_MASK_WIDTH-1:0]             app_wdf_mask;

  wire                                  app_wdf_rdy;

  wire                                  app_sr_active;

  wire                                  app_ref_ack;

  wire                                  app_zq_ack;

  wire                                  app_wdf_wren;

  wire [(64+(2*APP_DATA_WIDTH))-1:0]      error_status;

  wire [(PAYLOAD_WIDTH/8)-1:0] cumlative_dq_lane_error;

  wire                                  mem_pattern_init_done;

  wire [47:0]                           tg_wr_data_counts;

  wire [47:0]                           tg_rd_data_counts;

  wire                                  modify_enable_sel;

  wire [2:0]                            data_mode_manual_sel;

  wire [2:0]                            addr_mode_manual_sel;

  wire [APP_DATA_WIDTH-1:0]             cmp_data;

  reg [63:0]                            cmp_data_r;

  wire                                  cmp_data_valid;

  reg                                   cmp_data_valid_r;

  wire                                  cmp_error;

  wire [(PAYLOAD_WIDTH/8)-1:0]            dq_error_bytelane_cmp;



  wire                                  clk;

  wire                                  rst;



  wire                                  dbg_sel_pi_incdec;

  wire                                  dbg_pi_f_inc;

  wire                                  dbg_pi_f_dec;

  wire                                  dbg_sel_po_incdec;

  wire                                  dbg_po_f_inc;

  wire                                  dbg_po_f_stg23_sel;

  wire                                  dbg_po_f_dec;

  

  

  wire                                  vio_modify_enable;

  wire [3:0]                            vio_data_mode_value;

  wire                                  vio_pause_traffic;

  wire [2:0]                            vio_addr_mode_value;

  wire [3:0]                            vio_instr_mode_value;

  wire [1:0]                            vio_bl_mode_value;

  wire [9:0]                            vio_fixed_bl_value;

  wire [2:0]                            vio_fixed_instr_value;

  wire                                  vio_data_mask_gen;

  wire                                  vio_tg_rst;

  wire                                  vio_dbg_sel_pi_incdec;

  wire                                  vio_dbg_pi_f_inc;

  wire                                  vio_dbg_pi_f_dec;

  wire                                  vio_dbg_sel_po_incdec;

  wire                                  vio_dbg_po_f_inc;

  wire                                  vio_dbg_po_f_stg23_sel;

  wire                                  vio_dbg_po_f_dec;

     

  wire [11:0]                           device_temp;

  

`ifdef SKIP_CALIB

  // skip calibration wires

  wire                          calib_tap_req;

  reg                           calib_tap_load;

  reg [6:0]                     calib_tap_addr;

  reg [7:0]                     calib_tap_val;

  reg                           calib_tap_load_done;

`endif

      

  



//***************************************************************************




endmodule




修改example_top文件后,sim目录如下图所示

将我们新建的ddr3_top顶层例化到example_top文件里面,如下所示

//*****************************************************************************

// (c) Copyright 2009 - 2013 Xilinx, Inc. All rights reserved.

//

// This file contains confidential and proprietary information

// of Xilinx, Inc. and is protected under U.S. and

// international copyright and other intellectual property

// laws.

//

// DISCLAIMER

// This disclaimer is not a license and does not grant any

// rights to the materials distributed herewith. Except as

// otherwise provided in a valid license issued to you by

// Xilinx, and to the maximum extent permitted by applicable

// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND

// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES

// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING

// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-

// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and

// (2) Xilinx shall not be liable (whether in contract or tort,

// including negligence, or under any other theory of

// liability) for any loss or damage of any kind or nature

// related to, arising under or in connection with these

// materials, including for any direct, or any indirect,

// special, incidental, or consequential loss or damage

// (including loss of data, profits, goodwill, or any type of

// loss or damage suffered as a result of any action brought

// by a third party) even if such damage or loss was

// reasonably foreseeable or Xilinx had been advised of the

// possibility of the same.

//

// CRITICAL APPLICATIONS

// Xilinx products are not designed or intended to be fail-

// safe, or for use in any application requiring fail-safe

// performance, such as life-support or safety devices or

// systems, Class III medical devices, nuclear facilities,

// applications related to the deployment of airbags, or any

// other applications that could lead to death, personal

// injury, or severe property or environmental damage

// (individually and collectively, "Critical

// Applications"). Customer assumes the sole risk and

// liability of any use of Xilinx products in Critical

// Applications, subject only to applicable laws and

// regulations governing limitations on product liability.

//

// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS

// PART OF THIS FILE AT ALL TIMES.

//

//*****************************************************************************

//   ____  ____

//  /   /\/   /

// /___/  \  /    Vendor             : Xilinx

// \   \   \/     Version            : 4.2

//  \   \         Application        : MIG

//  /   /         Filename           : example_top.v

// /___/   /\     Date Last Modified : $Date: 2011/06/02 08:35:03 $

// \   \  /  \    Date Created       : Tue Sept 21 2010

//  \___\/\___\

//

// Device           : 7 Series

// Design Name      : DDR3 SDRAM

// Purpose          :

//   Top-level  module. This module serves as an example,

//   and allows the user to synthesize a self-contained design,

//   which they can be used to test their hardware.

//   In addition to the memory controller, the module instantiates:

//     1. Synthesizable testbench - used to model user's backend logic

//        and generate different traffic patterns

// Reference        :

// Revision History :

//*****************************************************************************



//`define SKIP_CALIB

`timescale 1ps/1ps



module example_top #

  (



   //***************************************************************************

   // Traffic Gen related parameters

   //***************************************************************************

   parameter PORT_MODE             = "BI_MODE",

   parameter DATA_MODE             = 4'b0010,

   parameter TST_MEM_INSTR_MODE    = "R_W_INSTR_MODE",

   parameter EYE_TEST              = "FALSE",

                                     // set EYE_TEST = "TRUE" to probe memory

                                     // signals. Traffic Generator will only

                                     // write to one single location and no

                                     // read transactions will be generated.

   parameter DATA_PATTERN          = "DGEN_ALL",

                                      // For small devices, choose one only.

                                      // For large device, choose "DGEN_ALL"

                                      // "DGEN_HAMMER", "DGEN_WALKING1",

                                      // "DGEN_WALKING0","DGEN_ADDR","

                                      // "DGEN_NEIGHBOR","DGEN_PRBS","DGEN_ALL"

   parameter CMD_PATTERN           = "CGEN_ALL",

                                      // "CGEN_PRBS","CGEN_FIXED","CGEN_BRAM",

                                      // "CGEN_SEQUENTIAL", "CGEN_ALL"

   parameter CMD_WDT               = 'h3FF,

   parameter WR_WDT                = 'h1FFF,

   parameter RD_WDT                = 'h3FF,

   parameter SEL_VICTIM_LINE       = 0,

   parameter BEGIN_ADDRESS         = 32'h00000000,

   parameter END_ADDRESS           = 32'h00ffffff,

   parameter PRBS_EADDR_MASK_POS   = 32'hff000000,



   //***************************************************************************

   // The following parameters refer to width of various ports

   //***************************************************************************

   parameter CK_WIDTH              = 1,

                                     // # of CK/CK# outputs to memory.

   parameter nCS_PER_RANK          = 1,

                                     // # of unique CS outputs per rank for phy

   parameter CKE_WIDTH             = 1,

                                     // # of CKE outputs to memory.

   parameter DM_WIDTH              = 4,

                                     // # of DM (data mask)

   parameter ODT_WIDTH             = 1,

                                     // # of ODT outputs to memory.

   parameter BANK_WIDTH            = 3,

                                     // # of memory Bank Address bits.

   parameter COL_WIDTH             = 10,

                                     // # of memory Column Address bits.

   parameter CS_WIDTH              = 1,

                                     // # of unique CS outputs to memory.

   parameter DQ_WIDTH              = 32,

                                     // # of DQ (data)

   parameter DQS_WIDTH             = 4,

   parameter DQS_CNT_WIDTH         = 2,

                                     // = ceil(log2(DQS_WIDTH))

   parameter DRAM_WIDTH            = 8,

                                     // # of DQ per DQS

   parameter ECC                   = "OFF",

   parameter ECC_TEST              = "OFF",

   //parameter nBANK_MACHS           = 4,

   parameter nBANK_MACHS           = 4,

   parameter RANKS                 = 1,

                                     // # of Ranks.

   parameter ROW_WIDTH             = 15,

                                     // # of memory Row Address bits.

   parameter ADDR_WIDTH            = 29,

                                     // # = RANK_WIDTH + BANK_WIDTH

                                     //     + ROW_WIDTH + COL_WIDTH;

                                     // Chip Select is always tied to low for

                                     // single rank devices



   //***************************************************************************

   // The following parameters are mode register settings

   //***************************************************************************

   parameter BURST_MODE            = "8",

                                     // DDR3 SDRAM:

                                     // Burst Length (Mode Register 0).

                                     // # = "8", "4", "OTF".

                                     // DDR2 SDRAM:

                                     // Burst Length (Mode Register).

                                     // # = "8", "4".



   

   //***************************************************************************

   // The following parameters are multiplier and divisor factors for PLLE2.

   // Based on the selected design frequency these parameters vary.

   //***************************************************************************

   parameter CLKIN_PERIOD          = 5000,

                                     // Input Clock Period

   parameter CLKFBOUT_MULT         = 4,

                                     // write PLL VCO multiplier

   parameter DIVCLK_DIVIDE         = 1,

                                     // write PLL VCO divisor

   parameter CLKOUT0_PHASE         = 0.0,

                                     // Phase for PLL output clock (CLKOUT0)

   parameter CLKOUT0_DIVIDE        = 1,

                                     // VCO output divisor for PLL output clock (CLKOUT0)

   parameter CLKOUT1_DIVIDE        = 2,

                                     // VCO output divisor for PLL output clock (CLKOUT1)

   parameter CLKOUT2_DIVIDE        = 32,

                                     // VCO output divisor for PLL output clock (CLKOUT2)

   parameter CLKOUT3_DIVIDE        = 8,

                                     // VCO output divisor for PLL output clock (CLKOUT3)

   parameter MMCM_VCO              = 800,

                                     // Max Freq (MHz) of MMCM VCO

   parameter MMCM_MULT_F           = 8,

                                     // write MMCM VCO multiplier

   parameter MMCM_DIVCLK_DIVIDE    = 1,

                                     // write MMCM VCO divisor



   //***************************************************************************

   // Simulation parameters

   //***************************************************************************

   parameter SIMULATION            = "FALSE",

                                     // Should be TRUE during design simulations and

                                     // FALSE during implementations



   //***************************************************************************

   // IODELAY and PHY related parameters

   //***************************************************************************

   parameter TCQ                   = 100,

   

   parameter DRAM_TYPE             = "DDR3",



   

   //***************************************************************************

   // System clock frequency parameters

   //***************************************************************************

   parameter nCK_PER_CLK           = 4,

                                     // # of memory CKs per fabric CLK



   



   //***************************************************************************

   // Debug parameters

   //***************************************************************************

   parameter DEBUG_PORT            = "OFF",

                                     // # = "ON" Enable debug signals/controls.

                                     //   = "OFF" Disable debug signals/controls.

      

   parameter RST_ACT_LOW           = 1

                                     // =1 for active low reset,

                                     // =0 for active high.

   )

  (



   // Inouts

   inout [31:0]                         ddr3_dq,

   inout [3:0]                        ddr3_dqs_n,

   inout [3:0]                        ddr3_dqs_p,



   // Outputs

   output [14:0]                       ddr3_addr,

   output [2:0]                      ddr3_ba,

   output                                       ddr3_ras_n,

   output                                       ddr3_cas_n,

   output                                       ddr3_we_n,

   output                                       ddr3_reset_n,

   output [0:0]                        ddr3_ck_p,

   output [0:0]                        ddr3_ck_n,

   output [0:0]                       ddr3_cke,

   

   output [0:0]           ddr3_cs_n,

   

   output [3:0]                        ddr3_dm,

   

   output [0:0]                       ddr3_odt,

   



   // Inputs

   

   // Single-ended system clock

   input                                        sys_clk_i,

   



   output                                       tg_compare_error,

   output                                       init_calib_complete,

   

      



   // System reset - Default polarity of sys_rst pin is Active Low.

   // System reset polarity will change based on the option 

   // selected in GUI.

   input                                        sys_rst

   );



function integer clogb2 (input integer size);

    begin

      size = size - 1;

      for (clogb2=1; size>1; clogb2=clogb2+1)

        size = size >> 1;

    end

  endfunction // clogb2



  function integer STR_TO_INT;

    input [7:0] in;

    begin

      if(in == "8")

        STR_TO_INT = 8;

      else if(in == "4")

        STR_TO_INT = 4;

      else

        STR_TO_INT = 0;

    end

  endfunction





  localparam DATA_WIDTH            = 32;

  localparam RANK_WIDTH = clogb2(RANKS);

  localparam PAYLOAD_WIDTH         = (ECC_TEST == "OFF") ? DATA_WIDTH : DQ_WIDTH;

  localparam BURST_LENGTH          = STR_TO_INT(BURST_MODE);

  localparam APP_DATA_WIDTH        = 2 * nCK_PER_CLK * PAYLOAD_WIDTH;

  localparam APP_MASK_WIDTH        = APP_DATA_WIDTH / 8;



  //***************************************************************************

  // Traffic Gen related parameters (derived)

  //***************************************************************************

  localparam  TG_ADDR_WIDTH = ((CS_WIDTH == 1) ? 0 : RANK_WIDTH)

                                 + BANK_WIDTH + ROW_WIDTH + COL_WIDTH;

  localparam MASK_SIZE             = DATA_WIDTH/8;

      



  // Wire declarations

      

  wire [(2*nCK_PER_CLK)-1:0]              app_ecc_multiple_err;

  wire [(2*nCK_PER_CLK)-1:0]              app_ecc_single_err;

  wire [ADDR_WIDTH-1:0]                 app_addr;

  wire [2:0]                            app_cmd;

  wire                                  app_en;

  wire                                  app_rdy;

  wire [APP_DATA_WIDTH-1:0]             app_rd_data;

  wire                                  app_rd_data_end;

  wire                                  app_rd_data_valid;

  wire [APP_DATA_WIDTH-1:0]             app_wdf_data;

  wire                                  app_wdf_end;

  wire [APP_MASK_WIDTH-1:0]             app_wdf_mask;

  wire                                  app_wdf_rdy;

  wire                                  app_sr_active;

  wire                                  app_ref_ack;

  wire                                  app_zq_ack;

  wire                                  app_wdf_wren;

  wire [(64+(2*APP_DATA_WIDTH))-1:0]      error_status;

  wire [(PAYLOAD_WIDTH/8)-1:0] cumlative_dq_lane_error;

  wire                                  mem_pattern_init_done;

  wire [47:0]                           tg_wr_data_counts;

  wire [47:0]                           tg_rd_data_counts;

  wire                                  modify_enable_sel;

  wire [2:0]                            data_mode_manual_sel;

  wire [2:0]                            addr_mode_manual_sel;

  wire [APP_DATA_WIDTH-1:0]             cmp_data;

  reg [63:0]                            cmp_data_r;

  wire                                  cmp_data_valid;

  reg                                   cmp_data_valid_r;

  wire                                  cmp_error;

  wire [(PAYLOAD_WIDTH/8)-1:0]            dq_error_bytelane_cmp;



  wire                                  clk;

  wire                                  rst;



  wire                                  dbg_sel_pi_incdec;

  wire                                  dbg_pi_f_inc;

  wire                                  dbg_pi_f_dec;

  wire                                  dbg_sel_po_incdec;

  wire                                  dbg_po_f_inc;

  wire                                  dbg_po_f_stg23_sel;

  wire                                  dbg_po_f_dec;

  

  

  wire                                  vio_modify_enable;

  wire [3:0]                            vio_data_mode_value;

  wire                                  vio_pause_traffic;

  wire [2:0]                            vio_addr_mode_value;

  wire [3:0]                            vio_instr_mode_value;

  wire [1:0]                            vio_bl_mode_value;

  wire [9:0]                            vio_fixed_bl_value;

  wire [2:0]                            vio_fixed_instr_value;

  wire                                  vio_data_mask_gen;

  wire                                  vio_tg_rst;

  wire                                  vio_dbg_sel_pi_incdec;

  wire                                  vio_dbg_pi_f_inc;

  wire                                  vio_dbg_pi_f_dec;

  wire                                  vio_dbg_sel_po_incdec;

  wire                                  vio_dbg_po_f_inc;

  wire                                  vio_dbg_po_f_stg23_sel;

  wire                                  vio_dbg_po_f_dec;

     

  wire [11:0]                           device_temp;

  

`ifdef SKIP_CALIB

  // skip calibration wires

  wire                          calib_tap_req;

  reg                           calib_tap_load;

  reg [6:0]                     calib_tap_addr;

  reg [7:0]                     calib_tap_val;

  reg                           calib_tap_load_done;

`endif

      

  



//***************************************************************************

ddr3_top  ddr3_top_inst(
    //clock
    .               sys_clk_i       (sys_clk_i),//200M
    //reset
    .               sys_rst         (sys_rst),
   // Inouts
   .                ddr3_dq         (ddr3_dq),
   .                ddr3_dqs_n      (ddr3_dqs_n),
   .                ddr3_dqs_p      (ddr3_dqs_p),
   // Outputs
   .                ddr3_addr       (ddr3_addr),
   .                ddr3_ba         (ddr3_ba),
   .                ddr3_ras_n      (ddr3_ras_n),
   .                ddr3_cas_n      (ddr3_cas_n),
   .                ddr3_we_n       (ddr3_we_n),
   .                ddr3_reset_n    (ddr3_reset_n),
   .                ddr3_ck_p       (ddr3_ck_p),
   .                ddr3_ck_n       (ddr3_ck_n),
   .                ddr3_cke        (ddr3_cke),
   .                ddr3_cs_n       (ddr3_cs_n),   
   .                ddr3_dm         (ddr3_dm),
   .                ddr3_odt        (ddr3_odt)
   
    );


endmodule




example_top文件例化ddr3_top顶层后,sim目录如下图所示,可以看到ddr3_top和mig控制器都例化进去了

点击run simulation运行ddr3仿真

仿真界面如下图所示

选择clk_ref_i的下面所有文件

右击选择Delete删除

删除后,如下图所示

在仿真目录找到我们的顶层文件,右击选择Add to Wave Window,加入到仿真界面

加入顶层后,仿真界面如下图所示

点击复位图标将仿真数据都清零

点击复位后,仿真界面如下图所示

点击Run图标开始进行仿真

仿真进行中,初始化时间有点长,继续等待

可以看到,仿真运行到107us后init_calib_complete信号拉高,说明ddr3初始化成功,同时也说明ddr3仿真环境搭建成功

大家可以对比一下在vivado中和modelsim中仿真速度,很明显modelsim中要快很多,那是因为vivado中是直径对mig控制器进行仿真,而modelsim中有点类似对ddr3的仿真模型进行仿真,所以modelsim中仿真较快,而且vivado仿真环境是占用内存的,所以不能仿真太长时间,modelsim中这些方面比vivado要好很多。

vivado中ddr3仿真平台搭建目前已经完成,下一步就是进行一个突发长度的读写。

如若转载,请注明出处

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/174397.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

搜索引擎——Elasticsearch

文章目录1.ElasticSearch简介2.基本概念3.Elasticsearch概念-倒排索引4.Elasticsearch和Kibana的安装5.Elasticsearch入门操作5.1_cat5.2PUT&POST新增数据5.3PUT&POST修改数据5.4GET查询数据5.5DELETE删除数据5.7bulk批量操作5.6乐观锁字段6.Elasticsearch进阶操作6.1批…

蓝桥杯重点(C/C++)(随时更新)

目录 1 重点 1.1 取消同步(节约时间,甚至能多骗点分,最好每个程序都写上) 1.2 万能库(可能会耽误编译时间,但是省脑子) 1.3 蓝桥杯return 0千万别忘了写!! 1.4 …

【nginx】Windows下的常见问题踩坑

▒ 目录 ▒🛫 导读需求1️⃣ 安装2️⃣ 中文路径3️⃣ alias指定目录错误及原因正确示例📖 参考资料🛫 导读 需求 最近写了一个前端应用,需要部署后,让别人能访问,想来想去,还是选择了目前最强…

TeeChart Pro VCL FMX 2022.36.220929 Crack

TeeChart Pro VCL FMX图表组件库提供数百种用于数据可视化的 2D 和 3D 图形样式、56 种数学、统计和财务函数供您选择,还有无限数量的轴和 30 个调色板组件。 快速浏览 跨平台的一个来源 针对 Windows、Web 和移动应用程序 Delphi VCL 图表组件 使用 Embarcadero 的…

elasticsearch搜索功能(二)

一、DSL查询文档(P100) 1. DSL查询分类 Elasticsearch提供了基于JSON的DSL(Domain Specific Language)来定义查询。常见的查询类型包括: (1)查询所有:查询出所有数据,一…

《Python程序设计(第3版)》[美] 约翰·策勒(John Zelle) 第 9 章 答案

《Python程序设计(第3版)》[美] 约翰策勒(John Zelle) 第 9 章 答案 答案仅供参考,若有错误欢迎指正 判断对错 计算机可以生成真正的随机数。Python 的 random 函数返回伪随机整数。自顶向下的设计也称为逐步求精。…

Redis优惠券秒杀 | 黑马点评

目录 一、全局唯一ID 1、全局ID生成器 二、实现秒杀下单 1、基本的下单功能 2、超卖问题 3、乐观锁解决并发问题 三、实现一人一单 1、思路分析 2、代码初步实现 3、关于锁的范围 4、关于事务失效 5、集群下线程并发问题 一、全局唯一ID 订单如果用自增长会存在…

QT动画实例代码QPropertyAnimation的应用

用QT实现动画,我们必定用到QPropertyAnimation,这里我们介绍几种情形的动画实现。如直线动画,曲线动画,路径动画。 一、基础知识 1、QPropertyAnimation的初始化 我们首先必须在包涵QPropertyAnimation的头文件或者模块&#x…

Android之WorkManager处理后台定时任务

WorkManager和Service并不相同,也没有直接的联系。Service是Android系统四大组件之一,它没有被销毁的情况下是一直保持在后台运行的。而WorkManager只是一个处理定时任务的工具,它可以保证即使在应用退出甚至手机重启的情况下,之前…

动手深度学习-pytorch数据操作

N维数组是机器学习和神经网络的主要数据结构创建数组需要形状:如3*4的矩阵每个元素的类型:例如32位浮点数每个元素的值:例如全是0.或者随机数数据操作首先,导入torch张量表示一个数值组成的数组,这个数组可能有多个维度…

acwing基础课——欧拉函数

由数据范围反推算法复杂度以及算法内容 - AcWing 常用代码模板4——数学知识 - AcWing 基本思想: 这里我们了解一下欧拉函数是什么以及用筛法求欧拉函数,我们先给出欧拉函数的定义: 然后我们了解一下互质的概念,只要两数的公因…

连你女朋友都能看懂的分布式架构原理!

目录 从一个新闻门户网站案例引入推算一下你需要分析多少条数据?黄金搭档:分布式存储分布式计算 这篇文章聊一个话题:什么是分布式计算系统? 一、从一个新闻门户网站案例引入 现在很多同学经常会看到一些名词,比如分…

CSDN官方模板

这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注…

数据结构(栈)

目录 栈的定义 形象比喻 栈的相关术语 栈的抽象数据类型(栈Stack的ADT) 顺序栈 顺序栈类的声明 顺序栈类成员函数的实现 基本效率分析 顺序栈的应用(小测试) main.cpp 共享栈 双共享栈 链式栈 链式栈基本操作分析 链…

cf Educational Codeforces Round 134 E. Prefix Function Queries

原题: You are given a string s, consisting of lowercase Latin letters. You are asked q queries about it: given another string t, consisting of lowercase Latin letters, perform the following steps: concatenate s and t; calculate the prefix func…

实战打靶集锦-001-Funbox2

**写在前面:**这应该是本人第一次自主成功完成的打靶,纪念一下下。 目录1. 主机发现2. 端口扫描3. 服务枚举4. 服务探查4.1 Apache探查4.1.1 浏览器访问4.1.2 站点地图查看4.1.3 目录枚举4.1.4 公共EXP搜索4.2 FTP探查4.2.1 手工登录FTP4.2.2 公共EXP搜索…

基于决策树模型和支持向量机模型的手写数字识别

目录 1、导入库和手写数字数据集 2、 把数据可视化 3、把数据分成训练数据集和测试数据集 4、训练SVM模型 5、训练决策树模型 6、对所使用的模型进行评估 7、对手写数字图像进行预测 本项目实现了 第一个功能:可以通过导入库和数据集、通过对数据集的预处理…

JavaScript基础(17)_Function方法(call、apply)、arguments

概念 call,apply都属于Function.prototype的一个方法,它是JavaScript引擎内在实现的,因为属于Function.prototype,所以每个Function对象实例(就是每个方法)都有call,apply属性,可以通过函数对象来调用。 a…

2023牛客寒假算法基础集训营3 赛时思路+正解

这场数学和思维偏多,特别是数学,五个小时过于充实了,而且更加考验你的心态。 这场不乏码量大的毒瘤题,也不乏人类智慧妙妙题。 A 不断减损的时间 题意 给定一个数组aaa,我们可以执行任意次操作,该操作定义…

Rethinking Performance Gains in Image Dehazing Networks

论文源码:https://download.csdn.net/download/zhouaho2010/87393184 Abstract 图像去雾是低层视觉中的一个活跃话题,随着深度学习的快速发展,许多图像去雾网络被提出。尽管这些网络的工作良好,但提高图像去雾性能的关键机制仍不…