FPGA——DDR3的IP核

FPGA——DDR3的ip核

  • IP核配置
  • 基于MIG核代码
  • 基于AXI接口的DDR3

IP核配置

1
在这里插入图片描述
在这里插入图片描述
2
在这里插入图片描述
3
在这里插入图片描述

4
在这里插入图片描述

5
在这里插入图片描述
6
在这里插入图片描述

基于MIG核代码

控制MIG核的信号进行读写

module MIG_APP_Drive(
    input               i_ui_clk            ,
    input               i_ui_rst            ,
    input			    init_calib_complete ,
    output [28:0]		app_addr            ,    
    output [2 :0]		app_cmd             ,                        
    output				app_en              ,                    
    output [255:0]		app_wdf_data        ,                    
    output				app_wdf_end         ,                    
    output				app_wdf_wren        ,                
    input  [255:0]		app_rd_data         ,                    
    input			    app_rd_data_end     ,                        
    input			    app_rd_data_valid   ,                    
    input			    app_rdy             ,                    
    input			    app_wdf_rdy         ,                
    output [31:0]		app_wdf_mask        ,    

    input  [1 :0]       i_operation_cmd     ,
    input  [15:0]       i_operation_len     ,
    input  [28:0]       i_operation_addr    ,
    input               i_operation_valid   ,
    output              o_operation_ready   ,
    input  [255:0]      i_write_data        ,
    input               i_write_last        ,
    input               i_write_valid       ,
    output [255:0]      o_read_data         ,
    output              o_read_valid                     
);

/***************function**************/

/***************parameter*************/
localparam              P_ST_INIT       =   0   ,
                        P_ST_IDLE       =   1   ,
                        P_ST_WAIT       =   2   ,
                        P_ST_WRITE      =   3   ,
                        P_ST_READ       =   4   ,
                        P_ST_READ_WAIT  =   5   ;

/***************port******************/             

/***************mechine***************/
(* mark_debug = "true" *)reg  [7 :0]             r_st_current        ;
reg  [7 :0]             r_st_next           ;
reg  [15:0]             r_st_cnt            ;

/***************reg*******************/
reg  [28:0]		        ro_app_addr         ;
reg  [2 :0]		        ro_app_cmd          ;
reg  				    ro_app_en           ;
reg  				    ro_app_wdf_wren     ;
reg  [31:0]             ro_app_wdf_mask     ;
reg                     ro_operation_ready  ;
reg  [255:0]            ro_read_data        ;
reg                     ro_read_valid       ;
reg  [1 :0]             ri_operation_cmd    ;
reg  [15:0]             ri_operation_len    ;
reg  [28:0]             ri_operation_addr   ;
reg                     r_op_act            ;
reg  [15:0]             r_write_cnt         ;
reg  [15:0]             r_read_cnt          ;
(* mark_debug = "true" *)reg  [15:0]             r_read_data_cnt     ;
reg  [7 :0]             r_init              ;

/***************wire******************/
wire                    w_op_act            ;
wire [255:0]            w_write_fifo_dout   ;
wire                    w_write_fifo_empty  ;
wire                    w_write_fifo_full   ;
wire                    w_mig_wvalid        ;
wire                    w_mig_rvalid        ;
wire                    w_write_fifo_rd_en  ;

/***************component*************/
FIFO_256X512 FIFO_256X512_U0 (
  .clk                  (i_ui_clk           ),      // input wire clk
  .din                  (i_write_data       ),      // input wire [63 : 0] din
  .wr_en                (i_write_valid      ),  // input wire wr_en
  .rd_en                (w_write_fifo_rd_en ),  // input wire rd_en
  .dout                 (w_write_fifo_dout  ),    // output wire [63 : 0] dout
  .full                 (w_write_fifo_full  ),    // output wire full
  .empty                (w_write_fifo_empty )  // output wire empty
);
/***************assign****************/
assign app_addr             = ro_app_addr           ;
assign app_cmd              = ro_app_cmd            ;
assign app_en               = ro_app_en & app_rdy   ;
assign app_wdf_data         = w_write_fifo_dout     ;
assign app_wdf_end          = app_wdf_wren          ; 
assign app_wdf_wren         = ro_app_wdf_wren & app_rdy & app_wdf_rdy;
assign app_wdf_mask         = ro_app_wdf_mask       ;
assign o_operation_ready    = ro_operation_ready    ;
assign o_read_data          = ro_read_data          ;
assign o_read_valid         = ro_read_valid         ;
assign w_op_act             = i_operation_valid & o_operation_ready;
assign w_mig_wvalid         = app_rdy & app_wdf_rdy & app_en & ro_app_wdf_wren & app_cmd == 0;
assign w_write_fifo_rd_en   = w_mig_wvalid          ;
assign w_mig_rvalid         = app_rdy & app_en & app_cmd == 1;


/***************always****************/
always@(posedge i_ui_clk,posedge i_ui_rst) 
begin
    if(i_ui_rst)
        r_st_current <= P_ST_INIT;
    else 
        r_st_current <= r_st_next;
end

always@(*)
begin
    case(r_st_current)
        P_ST_INIT       : r_st_next = &r_init   ? P_ST_IDLE     : P_ST_INIT;
        P_ST_IDLE       : r_st_next = r_op_act  ?
                                      ri_operation_cmd == 0 ? P_ST_WAIT     : P_ST_READ
                                      : P_ST_IDLE ;
        P_ST_WAIT       : r_st_next = r_st_cnt    == 4                          ? P_ST_WRITE    : P_ST_WAIT         ;
        P_ST_WRITE      : r_st_next = r_write_cnt == ri_operation_len - 1 & w_mig_wvalid    ? P_ST_IDLE     : P_ST_WRITE        ;
        P_ST_READ       : r_st_next = r_read_cnt  == ri_operation_len - 2 & w_mig_rvalid    ? P_ST_READ_WAIT: P_ST_READ         ;
        P_ST_READ_WAIT  : r_st_next = r_read_data_cnt >= ri_operation_len - 2 & app_rd_data_valid ? P_ST_IDLE     : P_ST_READ_WAIT    ;
        default         : r_st_next = P_ST_INIT;
    endcase
end

always@(posedge i_ui_clk,posedge i_ui_rst) 
begin
    if(i_ui_rst)
        r_init <= 'd0;
    else
        r_init <= {r_init[6 :0],init_calib_complete};
end

always@(posedge i_ui_clk,posedge i_ui_rst) 
begin
    if(i_ui_rst)
        r_st_cnt <= 'd0;
    else if(r_st_current != r_st_next)
        r_st_cnt <= 'd0;
    else 
        r_st_cnt <= r_st_cnt  + 1;
end

always@(posedge i_ui_clk,posedge i_ui_rst) 
begin
    if(i_ui_rst) begin
        ri_operation_cmd  <= 'd0;
        ri_operation_len  <= 'd0;
        ri_operation_addr <= 'd0;
    end else if(w_op_act) begin
        ri_operation_cmd  <= i_operation_cmd ;
        ri_operation_len  <= i_operation_len ;
        ri_operation_addr <= i_operation_addr;
    end else begin
        ri_operation_cmd  <= ri_operation_cmd ;
        ri_operation_len  <= ri_operation_len ;
        ri_operation_addr <= ri_operation_addr;
    end

end

always@(posedge i_ui_clk,posedge i_ui_rst) 
begin
    if(i_ui_rst)
        r_op_act <= 'd0;
    else 
        r_op_act <= w_op_act;
end
 
always@(posedge i_ui_clk,posedge i_ui_rst) 
begin
    if(i_ui_rst) begin
        ro_app_cmd <= 'd0;
        ro_app_en  <= 'd0;
    end else if(r_st_current == P_ST_WRITE) begin
        ro_app_cmd <= 'd0;
        ro_app_en  <= 'd1;
    end else if(r_st_current == P_ST_READ) begin
        ro_app_cmd <= 'd1;
        ro_app_en  <= 'd1;
    end else begin
        ro_app_cmd <= 'd0;
        ro_app_en  <= 'd0;
    end
    
end

always@(posedge i_ui_clk,posedge i_ui_rst) 
begin
    if(i_ui_rst)
        ro_app_addr <= 'd0;
    else if(w_op_act)
        ro_app_addr <= i_operation_addr;
    else if(w_mig_wvalid)
        ro_app_addr <= ro_app_addr + 8 ;
    else if(w_mig_rvalid)
        ro_app_addr <= ro_app_addr + 8 ;
    else 
        ro_app_addr <= ro_app_addr;
end

always@(posedge i_ui_clk,posedge i_ui_rst) 
begin
    if(i_ui_rst)
        ro_app_wdf_mask <= 'd0;
    else 
        ro_app_wdf_mask <= 'd0;
end

always@(posedge i_ui_clk,posedge i_ui_rst) 
begin
    if(i_ui_rst)
        ro_app_wdf_wren <= 'd0;
    else if(r_st_current == P_ST_WRITE)
        ro_app_wdf_wren <= 'd1;
    else 
        ro_app_wdf_wren <= 'd0;
end

always@(posedge i_ui_clk,posedge i_ui_rst) 
begin
    if(i_ui_rst) begin
        ro_read_data  <= 'd0;
        ro_read_valid <= 'd0;
    end else  begin
        ro_read_data  <= app_rd_data;
        ro_read_valid <= app_rd_data_valid;
    end 
end

always@(posedge i_ui_clk,posedge i_ui_rst) 
begin
    if(i_ui_rst)
        ro_operation_ready <= 'd0;
    else if(w_op_act)
        ro_operation_ready <= 'd0;
    else if(r_st_next == P_ST_IDLE)
        ro_operation_ready <= 'd1;
    else 
        ro_operation_ready <= ro_operation_ready;
end
 
always@(posedge i_ui_clk,posedge i_ui_rst) 
begin
    if(i_ui_rst)
        r_write_cnt <= 'd0;
    else if(r_st_current == P_ST_IDLE)
        r_write_cnt <= 'd0;
    else if(w_mig_wvalid)
        r_write_cnt <= r_write_cnt + 1;
    else 
        r_write_cnt <= r_write_cnt;
end

always@(posedge i_ui_clk,posedge i_ui_rst) 
begin
    if(i_ui_rst)
        r_read_cnt <= 'd0;
    else if(r_st_current == P_ST_IDLE)
        r_read_cnt <= 'd0;
    else if(w_mig_rvalid)
        r_read_cnt <= r_read_cnt + 1;
    else 
        r_read_cnt <= r_read_cnt;
end

always@(posedge i_ui_clk,posedge i_ui_rst)
begin
    if(i_ui_rst)
        r_read_data_cnt <= 'd0;
    else if(r_st_current == P_ST_IDLE)
        r_read_data_cnt <= 'd0;
    else if(app_rd_data_valid) 
        r_read_data_cnt <= r_read_data_cnt + 1;
    else 
        r_read_data_cnt <= r_read_data_cnt;
end

endmodule

示列

DDR3_MIG u_DDR3_MIG (
    // Memory interface ports
    .ddr3_addr                      (ddr3_addr                  ),
    .ddr3_ba                        (ddr3_ba                    ),
    .ddr3_cas_n                     (ddr3_cas_n                 ),
    .ddr3_ck_n                      (ddr3_ck_n                  ),
    .ddr3_ck_p                      (ddr3_ck_p                  ),
    .ddr3_cke                       (ddr3_cke                   ),
    .ddr3_ras_n                     (ddr3_ras_n                 ),
    .ddr3_reset_n                   (ddr3_reset_n               ),
    .ddr3_we_n                      (ddr3_we_n                  ),
    .ddr3_dq                        (ddr3_dq                    ),
    .ddr3_dqs_n                     (ddr3_dqs_n                 ),
    .ddr3_dqs_p                     (ddr3_dqs_p                 ),
	.ddr3_cs_n                      (ddr3_cs_n                  ),
    .ddr3_dm                        (ddr3_dm                    ),
    .ddr3_odt                       (ddr3_odt                   ),
    // Application interface ports
    .init_calib_complete            (w_init_calib_complete      ),
    .app_addr                       (w_app_addr                 ),
    .app_cmd                        (w_app_cmd                  ),
    .app_en                         (w_app_en                   ),
    .app_wdf_data                   (w_app_wdf_data             ),
    .app_wdf_end                    (w_app_wdf_end              ),
    .app_wdf_wren                   (w_app_wdf_wren             ),
    .app_rd_data                    (w_app_rd_data              ),
    .app_rd_data_end                (w_app_rd_data_end          ),
    .app_rd_data_valid              (w_app_rd_data_valid        ),
    .app_rdy                        (w_app_rdy                  ),
    .app_wdf_rdy                    (w_app_wdf_rdy              ),
    .app_wdf_mask                   (w_app_wdf_mask             ),
    .app_sr_req                     (0                          ),
    .app_ref_req                    (0                          ),
    .app_zq_req                     (0                          ),
    .app_sr_active                  (                           ),
    .app_ref_ack                    (                           ),
    .app_zq_ack                     (                           ),
    .ui_clk                         (ui_clk                     ),
    .ui_clk_sync_rst                (ui_clk_sync_rst            ),
    // System Clock Ports
    .sys_clk_p                      (i_clk_200m_p               ),
    .sys_clk_n                      (i_clk_200m_n               ),
    .sys_rst                        (0                          ) 
);

MIG_APP_Drive MIG_APP_Drive_u0(
    .i_ui_clk                       (ui_clk                     ),
    .i_ui_rst                       (ui_clk_sync_rst            ),
    .init_calib_complete            (w_init_calib_complete      ),
    .app_addr                       (w_app_addr                 ),    
    .app_cmd                        (w_app_cmd                  ),                        
    .app_en                         (w_app_en                   ),                    
    .app_wdf_data                   (w_app_wdf_data             ),                    
    .app_wdf_end                    (w_app_wdf_end              ),                    
    .app_wdf_wren                   (w_app_wdf_wren             ),                
    .app_rd_data                    (w_app_rd_data              ),                    
    .app_rd_data_end                (w_app_rd_data_end          ),                        
    .app_rd_data_valid              (w_app_rd_data_valid        ),                    
    .app_rdy                        (w_app_rdy                  ),                    
    .app_wdf_rdy                    (w_app_wdf_rdy              ),                
    .app_wdf_mask                   (w_app_wdf_mask             ),    

    .i_operation_cmd                (w_app_operation_cmd        ),
    .i_operation_len                (w_app_operation_len        ),
    .i_operation_addr               (w_app_operation_addr       ),
    .i_operation_valid              (w_app_operation_valid      ),
    .o_operation_ready              (w_app_operation_ready      ),           
    .i_write_data                   (w_app_write_data           ),
    .i_write_last                   (w_app_write_last           ),
    .i_write_valid                  (w_app_write_valid          ),
    .o_read_data                    (w_app_read_data            ),
    .o_read_valid                   (w_app_read_valid           )             
);

基于AXI接口的DDR3

module AXI_Master_Drive(
    input                   i_clk                   ,
    input                   i_rst                   ,

(* mark_debug = "true" *)    input                   i_init_calib_complete   ,

    output [3 :0]           m_axi_awid              ,
    output [29:0]			m_axi_awaddr            ,
    output [7 :0]			m_axi_awlen             ,
    output [2 :0]			m_axi_awsize            ,           
    output [1 :0]			m_axi_awburst           ,           
    output [0 :0]			m_axi_awlock            ,              
    output [3 :0]			m_axi_awcache           ,          
    output [2 :0]			m_axi_awprot            ,                  
    output [3 :0]			m_axi_awqos             ,         
    output 		            m_axi_awvalid           ,                 
(* mark_debug = "true" *)    input 			        m_axi_awready           ,   

    output [255:0]			m_axi_wdata             ,                 
    output [31:0]			m_axi_wstrb             ,             
    output			        m_axi_wlast             ,       
    output			        m_axi_wvalid            ,   
(* mark_debug = "true" *)    input			        m_axi_wready            ,  

    input [3 :0]			m_axi_bid               ,       
    input [1 :0]			m_axi_bresp             ,   
(* mark_debug = "true" *)    input			        m_axi_bvalid            ,       
    output			        m_axi_bready            ,  

    output  [3 :0]			m_axi_arid              ,       
    output  [29:0]			m_axi_araddr            ,   
    output  [7 :0]			m_axi_arlen             ,
    output  [2 :0]			m_axi_arsize            ,   
    output  [1 :0]			m_axi_arburst           ,       
    output  [0 :0]			m_axi_arlock            ,       
    output  [3 :0]			m_axi_arcache           ,       
    output  [2 :0]			m_axi_arprot            ,       
    output  [3 :0]			m_axi_arqos             ,   
    output			        m_axi_arvalid           ,   
(* mark_debug = "true" *)    input			        m_axi_arready           ,  

    input [3 :0]			m_axi_rid               ,       
    input [255:0]			m_axi_rdata             ,       
    input [1 :0]			m_axi_rresp             ,       
    input			        m_axi_rlast             ,       
    input			        m_axi_rvalid            ,       
    output			        m_axi_rready                       
);

/***************function**************/

/***************parameter*************/
localparam                  P_ST_INIT   =   0   ,
                            P_ST_IDLE   =   1   ,
                            P_ST_WRITE  =   2   ,
                            P_ST_READ   =   3   ;

localparam                  P_LEN       =   16  ;

/***************port******************/             

/***************mechine***************/
(* mark_debug = "true" *)reg  [7 :0]                 r_st_current        ;
reg  [7 :0]                 r_st_next           ;
reg  [15:0]                 r_st_cnt            ;

/***************reg*******************/
reg  [3 :0]                 ro_m_axi_awid       ;
(* mark_debug = "true" *)reg  [29:0]			        ro_m_axi_awaddr     ;
(* mark_debug = "true" *)reg  [7 :0]			        ro_m_axi_awlen      ;
reg  [2 :0]			        ro_m_axi_awsize     ;
reg  [1 :0]			        ro_m_axi_awburst    ;
reg  [0 :0]			        ro_m_axi_awlock     ;
reg  [3 :0]			        ro_m_axi_awcache    ;
reg  [2 :0]			        ro_m_axi_awprot     ;
reg  [3 :0]			        ro_m_axi_awqos      ;
(* mark_debug = "true" *)reg  		                ro_m_axi_awvalid    ;
(* mark_debug = "true" *)reg  [255:0]			    ro_m_axi_wdata      ;
reg  [31:0]			        ro_m_axi_wstrb      ;
(* mark_debug = "true" *)reg  			            ro_m_axi_wlast      ;
(* mark_debug = "true" *)reg  			            ro_m_axi_wvalid     ;
(* mark_debug = "true" *)reg                         ro_m_axi_bready     ;
reg  [3 :0]			        ro_m_axi_arid       ;
(* mark_debug = "true" *)reg  [29:0]			        ro_m_axi_araddr     ;
(* mark_debug = "true" *)reg  [7 :0]			        ro_m_axi_arlen      ;
reg  [2 :0]			        ro_m_axi_arsize     ;
reg  [1 :0]			        ro_m_axi_arburst    ;
reg  [0 :0]			        ro_m_axi_arlock     ;
reg  [3 :0]			        ro_m_axi_arcache    ;
reg  [2 :0]			        ro_m_axi_arprot     ;
reg  [3 :0]			        ro_m_axi_arqos      ;
(* mark_debug = "true" *)reg  		                ro_m_axi_arvalid    ;
(* mark_debug = "true" *)reg                         ro_m_axi_rready     ;
reg  [3 :0]			        ri_m_axi_rid        ;
(* mark_debug = "true" *)reg  [255:0]			    ri_m_axi_rdata      ;
reg  [1 :0]			        ri_m_axi_rresp      ;
(* mark_debug = "true" *)reg  			            ri_m_axi_rlast      ;
(* mark_debug = "true" *)reg  			            ri_m_axi_rvalid     ;
reg  [15:0]     r_read_cnt;

/***************wire******************/
wire                        w_aw_act            ;
wire                        w_w_act             ;
wire                        w_br_act            ;
wire                        w_ar_act            ;
wire                        w_r_act             ;

/***************component*************/

/***************assign****************/
assign m_axi_awid    = ro_m_axi_awid                    ;
assign m_axi_awaddr  = ro_m_axi_awaddr                  ;
assign m_axi_awlen   = ro_m_axi_awlen                   ;
assign m_axi_awsize  = ro_m_axi_awsize                  ;
assign m_axi_awburst = ro_m_axi_awburst                 ;
assign m_axi_awlock  = ro_m_axi_awlock                  ;
assign m_axi_awcache = ro_m_axi_awcache                 ;
assign m_axi_awprot  = ro_m_axi_awprot                  ;
assign m_axi_awqos   = ro_m_axi_awqos                   ;
assign m_axi_awvalid = ro_m_axi_awvalid                 ;
assign m_axi_wdata   = ro_m_axi_wdata                   ;
assign m_axi_wstrb   = ro_m_axi_wstrb                   ;
assign m_axi_wlast   = ro_m_axi_wlast                   ;
assign m_axi_wvalid  = ro_m_axi_wvalid                  ;
assign m_axi_bready  = ro_m_axi_bready                  ;
assign m_axi_arid    = ro_m_axi_arid                    ;
assign m_axi_araddr  = ro_m_axi_araddr                  ;
assign m_axi_arlen   = ro_m_axi_arlen                   ;
assign m_axi_arsize  = ro_m_axi_arsize                  ;
assign m_axi_arburst = ro_m_axi_arburst                 ;
assign m_axi_arlock  = ro_m_axi_arlock                  ;
assign m_axi_arcache = ro_m_axi_arcache                 ;
assign m_axi_arprot  = ro_m_axi_arprot                  ;
assign m_axi_arqos   = ro_m_axi_arqos                   ;
assign m_axi_arvalid = ro_m_axi_arvalid                 ;
assign m_axi_rready  = ro_m_axi_rready                  ;
assign w_aw_act      = m_axi_awvalid & m_axi_awready    ;//写地址激活信号
assign w_w_act       = m_axi_wvalid  & m_axi_wready     ;//写数据激活信号
assign w_br_act      = m_axi_bvalid  & m_axi_bready     ;//响应激活信号
assign w_ar_act      = m_axi_arvalid & m_axi_arready    ;//读地址激活信号
assign w_r_act       = m_axi_rvalid  & m_axi_rready     ;//读数据信号

/***************always****************/
//第一段状态机
always@(posedge i_clk,posedge i_rst)
begin
    if(i_rst)
        r_st_current <= P_ST_IDLE;
    else
        r_st_current <= r_st_next;    
end

//第二段
always@(*)
begin
    case(r_st_current)
        P_ST_INIT   : r_st_next <= i_init_calib_complete ? P_ST_IDLE : P_ST_INIT;
        P_ST_IDLE   : r_st_next <= P_ST_WRITE;
        P_ST_WRITE  : r_st_next <= w_br_act     ? P_ST_READ : P_ST_WRITE;
        P_ST_READ   : r_st_next <= r_read_cnt == P_LEN - 1 && w_r_act  ? P_ST_IDLE : P_ST_READ;
        default     : r_st_next <= P_ST_IDLE;
    endcase
end

always@(posedge i_clk,posedge i_rst)
begin
    if(i_rst)
        r_st_cnt <= 'd0;
    else if(r_st_current != r_st_next)
        r_st_cnt <= 'd0;
    else 
        r_st_cnt <= r_st_cnt + 1;
end

always@(posedge i_clk,posedge i_rst)
begin
    if(i_rst) begin
        ro_m_axi_awid    <= 'd0;
        ro_m_axi_awaddr  <= 'd0;
        ro_m_axi_awlen   <= 'd0;
        ro_m_axi_awsize  <= 'd0;
        ro_m_axi_awburst <= 'd0;
        ro_m_axi_awlock  <= 'd0;
        ro_m_axi_awcache <= 'd0;
        ro_m_axi_awprot  <= 'd0;
        ro_m_axi_awqos   <= 'd0;
        ro_m_axi_awvalid <= 'd0;
    end else if(w_aw_act) begin
        ro_m_axi_awid    <= 'd0;
        ro_m_axi_awaddr  <= 'd0;
        ro_m_axi_awlen   <= 'd0;
        ro_m_axi_awsize  <= 'd0;
        ro_m_axi_awburst <= 'd0;
        ro_m_axi_awlock  <= 'd0;
        ro_m_axi_awcache <= 'd0;
        ro_m_axi_awprot  <= 'd0;
        ro_m_axi_awqos   <= 'd0;
        ro_m_axi_awvalid <= 'd0;
    end else if(r_st_current == P_ST_WRITE && r_st_cnt == 0) begin
        ro_m_axi_awid    <= 'd0;
        ro_m_axi_awaddr  <= 'd0;
        ro_m_axi_awlen   <= P_LEN - 1;
        ro_m_axi_awsize  <= 3'b101;//32byte
        ro_m_axi_awburst <= 'd1;//突发模式
        ro_m_axi_awlock  <= 'd0;
        ro_m_axi_awcache <= 4'b0010;//无缓存
        ro_m_axi_awprot  <= 'd0;
        ro_m_axi_awqos   <= 'd0;
        ro_m_axi_awvalid <= 'd1;//有效拉高
    end else begin
        ro_m_axi_awid    <= ro_m_axi_awid   ;
        ro_m_axi_awaddr  <= ro_m_axi_awaddr ;
        ro_m_axi_awlen   <= ro_m_axi_awlen  ;
        ro_m_axi_awsize  <= ro_m_axi_awsize ;
        ro_m_axi_awburst <= ro_m_axi_awburst;
        ro_m_axi_awlock  <= ro_m_axi_awlock ;
        ro_m_axi_awcache <= ro_m_axi_awcache;
        ro_m_axi_awprot  <= ro_m_axi_awprot ;
        ro_m_axi_awqos   <= ro_m_axi_awqos  ;
        ro_m_axi_awvalid <= ro_m_axi_awvalid;
    end 
end

always@(posedge i_clk,posedge i_rst)
begin
    if(i_rst)
        ro_m_axi_wdata <= 'd0;
    else if(ro_m_axi_wdata == P_LEN - 1 && w_w_act)
        ro_m_axi_wdata <= 'd0;
    else if(w_w_act)
        ro_m_axi_wdata <= ro_m_axi_wdata + 1;
    else 
        ro_m_axi_wdata <= ro_m_axi_wdata;
end

always@(posedge i_clk,posedge i_rst)
begin
    if(i_rst)
        ro_m_axi_wvalid <= 'd0;
    else if(ro_m_axi_wdata == P_LEN - 1 && w_w_act)
        ro_m_axi_wvalid <= 'd0;
    else if(w_aw_act)       
        ro_m_axi_wvalid <= 'd1;
    else 
        ro_m_axi_wvalid <= ro_m_axi_wvalid;
end

always@(posedge i_clk,posedge i_rst)
begin
    if(i_rst)
        ro_m_axi_wlast <= 'd0;
    else if(ro_m_axi_wdata == P_LEN - 1 && w_w_act)
        ro_m_axi_wlast <= 'd0;
    else if(ro_m_axi_wdata == P_LEN - 2)   
        ro_m_axi_wlast <= 'd1;
    else 
        ro_m_axi_wlast <= ro_m_axi_wlast;
end

always@(posedge i_clk,posedge i_rst)
begin
    if(i_rst)
        ro_m_axi_wstrb <= 32'hffffffff;
    else 
        ro_m_axi_wstrb <= 32'hffffffff;
end

always@(posedge i_clk,posedge i_rst)
begin
    if(i_rst)
        ro_m_axi_bready <= 'd0;
    else if(w_br_act)
        ro_m_axi_bready <= 'd0;
    else if(ro_m_axi_wlast)
        ro_m_axi_bready <= 'd1;
    else 
        ro_m_axi_bready <= ro_m_axi_bready;
end

always@(posedge i_clk,posedge i_rst)
begin
    if(i_rst) begin
        ro_m_axi_arid    <= 'd0;
        ro_m_axi_araddr  <= 'd0;
        ro_m_axi_arlen   <= 'd0;
        ro_m_axi_arsize  <= 'd0;
        ro_m_axi_arburst <= 'd0;
        ro_m_axi_arlock  <= 'd0;
        ro_m_axi_arcache <= 'd0;
        ro_m_axi_arprot  <= 'd0;
        ro_m_axi_arqos   <= 'd0;
        ro_m_axi_arvalid <= 'd0;
    end else if(w_ar_act) begin
        ro_m_axi_arid    <= 'd0;
        ro_m_axi_araddr  <= 'd0;
        ro_m_axi_arlen   <= 'd0;
        ro_m_axi_arsize  <= 'd0;
        ro_m_axi_arburst <= 'd0;
        ro_m_axi_arlock  <= 'd0;
        ro_m_axi_arcache <= 'd0;
        ro_m_axi_arprot  <= 'd0;
        ro_m_axi_arqos   <= 'd0;
        ro_m_axi_arvalid <= 'd0;
    end else if(r_st_current == P_ST_READ && r_st_cnt == 0) begin
        ro_m_axi_arid    <= 'd0;
        ro_m_axi_araddr  <= 'd0;
        ro_m_axi_arlen   <= P_LEN - 1;
        ro_m_axi_arsize  <= 3'b101;
        ro_m_axi_arburst <= 'd1;
        ro_m_axi_arlock  <= 'd0;
        ro_m_axi_arcache <= 4'b0010;
        ro_m_axi_arprot  <= 'd0;
        ro_m_axi_arqos   <= 'd0;
        ro_m_axi_arvalid <= 'd1;
    end else begin
        ro_m_axi_arid    <= ro_m_axi_arid   ;
        ro_m_axi_araddr  <= ro_m_axi_araddr ;
        ro_m_axi_arlen   <= ro_m_axi_arlen  ;
        ro_m_axi_arsize  <= ro_m_axi_arsize ;
        ro_m_axi_arburst <= ro_m_axi_arburst;
        ro_m_axi_arlock  <= ro_m_axi_arlock ;
        ro_m_axi_arcache <= ro_m_axi_arcache;
        ro_m_axi_arprot  <= ro_m_axi_arprot ;
        ro_m_axi_arqos   <= ro_m_axi_arqos  ;
        ro_m_axi_arvalid <= ro_m_axi_arvalid;
    end 
end

always@(posedge i_clk,posedge i_rst)
begin
    if(i_rst)
        ro_m_axi_rready <= 'd0;
    else if(r_read_cnt == P_LEN - 1 && w_r_act)
        ro_m_axi_rready <= 'd0;
    else if(w_ar_act)
        ro_m_axi_rready <= 'd1;
    else 
        ro_m_axi_rready <= ro_m_axi_rready;
end

always@(posedge i_clk,posedge i_rst)
begin
    if(i_rst) begin
        ri_m_axi_rid    <= 'd0;
        ri_m_axi_rdata  <= 'd0;
        ri_m_axi_rresp  <= 'd0;
        ri_m_axi_rlast  <= 'd0;
        ri_m_axi_rvalid <= 'd0;
    end else begin
        ri_m_axi_rid    <= m_axi_rid   ;
        ri_m_axi_rdata  <= m_axi_rdata ;
        ri_m_axi_rresp  <= m_axi_rresp ;
        ri_m_axi_rlast  <= m_axi_rlast ;
        ri_m_axi_rvalid <= m_axi_rvalid;
    end
end

always@(posedge i_clk,posedge i_rst)
begin
    if(i_rst)
        r_read_cnt <= 'd0;
    else if(r_read_cnt == P_LEN - 1 && w_r_act)
        r_read_cnt <= 'd0;
    else if(w_r_act)
        r_read_cnt <= r_read_cnt + 1;
    else 
        r_read_cnt <= r_read_cnt;
end
endmodule

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Django templates 存放html目录

模板 一概述 模板由两部分组成&#xff0c;一部分是HTML代码&#xff0c;一部分是逻辑控制代码&#xff08;变量&#xff0c;标签&#xff0c;过滤器&#xff09; 作用&#xff1a;可以通过一些逻辑控制代码减少一些重复的操作更快速的生成HTML代码&#xff0c;并且实现简单的…

VSCode下使用github初步

由于各种需要&#xff0c;现在需要统一将一些代码提交搞github&#xff0c;于是有了在VSCode下使用github的需求。之前只是简单的使用git clone&#xff0c;代码提交这些用的是其他源代码工具&#xff0c;于是得学习实操下&#xff0c;并做一记录以备后用。 安装 VSCode安装 …

K8S POD 启动探针 startupProbe 的使用

当我们启动一个POD 时&#xff0c; 当k8s detect 里面的容器启动成功时&#xff0c; 就会认为这个POD 启动完成了&#xff0c; 通常就会在状态里表示 ready 1/1 … 例如 rootk8s-master:~# kubectl get pods NAME READY STATUS RESTARTS AGE bq-api-demo 1…

部署Zabbix Agents添加使能监测服务器_Windows平台_MSI/Archive模式

Windows平台 一、从MSI安装Windows代理,添加Windows Servers/PC 概述 可以从Windows MSI安装包(32位或64位) 安装Zabbix agent 32位包不能安装在64位Windows中 所有软件包都支持TLS,配置TLS可选 支持UI和命令行的安装。 1、下载Agent代理程序,使用Agent2升级版,官网链接如…

首次突破1000量子比特!德国TU Darmstadt发布全新量子处理架构

内容来源&#xff1a;量子前哨&#xff08;ID&#xff1a;Qforepost&#xff09; 编辑丨慕一 编译/排版丨沛贤 深度好文&#xff1a;1200字丨8分钟阅读 量子计算机能否进一步发展&#xff0c;关键在于量子系统如何更具有可扩展性。随着量子系统规模的扩大&#xff0c;其算力优…

【接口防重复提交】⭐️基于RedisLockRegistry 分布式锁管理器实现

目录 前言 思路 实现方式 实践 1.引入相关依赖 2.aop注解 3.切面类代码 4.由于启动时报错找不到对应的RedisLockRegistry bean&#xff0c;选择通过配置类手动注入&#xff0c;配置类代码如下 测试 章末 前言 项目中有个用户根据二维码绑定身份的接口&#xff0c;由于用户在…

Python aiohttp 使用指南:快速入门教程

aiohttp 就是 Python 中一款优秀的异步 Web 框架&#xff0c;它能够帮助我们构建高效的异步 Web 应用和异步 HTTP 客户端。在本文中&#xff0c;我们将深入探讨 aiohttp 是什么以及如何使用它&#xff0c;通过简单易懂的案例带领你理解异步编程&#xff0c;以及如何处理异步请求…

基于C语言的“贪吃蛇”游戏设计理念

3.功能描述&#xff1a;本游戏主要实现以下几种功能 图1.游戏功能模块 3.1. 贪吃蛇的控制功能&#xff1a;通过各种条件的判断&#xff0c;实现对游戏蛇的左移、右移、下移、上移、自由移动&#xff0c;贪吃蛇的加长功能。 3.2. 游戏显示更新功能&#xff1a;当贪吃蛇左右移动、…

信息系统项目管理师018:计算机网络(2信息技术发展—2.1信息技术及其发展—2.1.2计算机网络)

文章目录 2.1.2 计算机网络1.网络标准协议2.软件定义网络3.第五代移动通信技术 记忆要点总结 2.1.2 计算机网络 在计算机领域中&#xff0c;网络就是用物理链路将各个孤立的工作站或主机相连在一起&#xff0c;组成数据链路&#xff0c;从而达到资源共享和通信的目的。凡将地理…

DEYOv2: Rank Feature with Greedy Matchingfor End-to-End Object Detection

摘要 与前代类似&#xff0c; DEYOv2 采用渐进式推理方法 来加速模型训练并提高性能。该研究深入探讨了一对一匹配在优化器中的局限性&#xff0c;并提出了有效解决该问题的解决方案&#xff0c;如Rank 特征和贪婪匹配 。这种方法使DEYOv2的第三阶段能够最大限度地从第一和第二…

Day68:WEB攻防-Java安全原生反序列化SpringBoot攻防heapdump提取CVE

目录 Java安全-反序列化-原生序列化类函数 原生序列化类函数 SnakeYaml XMLDecoder ObjectInputStream.readObject 工具利用 ysoserial Yakit SerializedPayloadGenerator Java安全-SpringBoot框架-泄漏&CVE SpringBoot Actuator-黑白盒发现 人工识别 BurpSui…

华为配置WAPI-PSK安全策略实验

配置WAPI-PSK安全策略示例 组网图形 图1 配置WAPI-PSK安全策略组网图 配置流程组网需求配置思路配置注意事项操作步骤配置文件 配置流程 WLAN不同的特性和功能需要在不同类型的模板下进行配置和维护&#xff0c;这些模板统称为WLAN模板&#xff0c;如域管理模板、射频模板、VAP…

MATLAB的使用(二)

一&#xff0c;算法需求 算法五特性(1)有穷性。有穷性是指算法需在有穷步骤、有穷时间内结束。 (2)确定性。确定性是指每个步骤都有确切的意义&#xff0c;相同的输入有相同的输出。 (3)有效性。有效性是指可通过已实现的运算在有限次完成&#xff0c;或叫可行性。 (4)输入。…

信息学奥赛一本通之MAC端VSCode C++环境配置

前提 安装 Visual Studio CodeVSCode 中安装 C/C扩展确保 Clang 已经安装&#xff08;在终端中输入命令&#xff1a;clang --version 来确认是否安装&#xff09;未安装&#xff0c;在命令行执行xcode-select --install 命令&#xff0c;会自行安装&#xff0c;安装文件有点大…

超越传统的极限:解密B树与B+树的数据结构之美!

超越传统的极限&#xff1a;解密B树与B树的数据结构之美&#xff01; B树和B树是在计算机科学中常用的平衡查找树数据结构&#xff0c;它们在处理大规模数据和磁盘存储方面具有重要的优势。本文将深入介绍B树和B树的基本概念、特点以及它们在数据库和文件系统中的应用&#xff…

AR/MR产品设计(二):如何用一双手完成与虚拟对象的自然交互

AR/MR产品设计&#xff08;二&#xff09;&#xff1a;如何用一双手完成与虚拟对象的自然交互 - 知乎 手是我们与现实世界交互最重要的方式&#xff0c;同样在虚实混合的世界中是最重要的交互方式 在AR/MR/VR的交互中&#xff0c;手势交互会作为XR的重要交互动作&#xff0c;因…

强缓存和协商缓存

前言 计算机网络模型从底到上&#xff1a;物理层&#xff08;光纤、网线&#xff09;、链路层&#xff08;MAC地址&#xff09;、网络层&#xff08;IP协议&#xff09;、传输层&#xff08;TCP\UDP&#xff09;、应用层&#xff08;HTTP\FTP\DNS&#xff09;。HTTP协议是作用…

数据结构:栈「详解」

目录 一&#xff0c;栈的定义 二&#xff0c;栈的基本操作 1&#xff0c;顺序栈 1.1顺序栈的基本概念 1.2顺序栈的基本操作 2&#xff0c;链栈 2.1链栈的基本概念 2.2链栈的种类 2.3链栈的基本操作 三&#xff0c;栈的应用 1&#xff0c;函数递归调用 2&#xff0c;…

【论文阅读笔记】Split frequency attention network for single image deraining

1.论文介绍 Split frequency attention network for single image deraining 用于单幅图像去噪的分频注意力网络 Paper Code 2023年 SIVP 2.摘要 雨纹对图像质量的影响极大&#xff0c;基于数据驱动的单图像去噪方法不断发展并取得了巨大的成功。然而&#xff0c;传统的卷积…

Go语言gin框架中加载html/css/js等静态资源

Gin框架没有内置静态文件服务&#xff0c;但可以使用gin.Static或gin.StaticFS中间件来提供静态文件服务。 效果图如下&#xff1a; 一、gin 框架加载 Html 模板文件的方法 方式1&#xff1a;加载单个或多个html文件&#xff0c;需要指明具体文件名 r.LoadHTMLFiles("vie…