OpenCores
URL https://opencores.org/ocsvn/sdr_ctrl/sdr_ctrl/trunk

Subversion Repositories sdr_ctrl

[/] [sdr_ctrl/] [trunk/] [rtl/] [core/] [sdrc_bs_convert.v] - Diff between revs 44 and 45

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 44 Rev 45
Line 55... Line 55...
        /* Control Signal from xfr ctrl */
        /* Control Signal from xfr ctrl */
                    x2a_rdstart,
                    x2a_rdstart,
                    x2a_wrstart,
                    x2a_wrstart,
                    x2a_rdlast,
                    x2a_rdlast,
                    x2a_wrlast,
                    x2a_wrlast,
                    app_rd_data_int,
                    x2a_rddt            ,
                    app_rd_valid_int,
                    x2a_rdok            ,
                    app_wr_data_int,
                    a2x_wrdt            ,
                    app_wr_en_n_int,
                    a2x_wren_n          ,
                    app_wr_next_int,
                    x2a_wrnext          ,
 
 
       /* Control Signal from request ctrl */
 
                    app_req_addr_int,
 
                    app_req_len_int,
 
                    app_req_ack_int,
 
                    app_sdr_req_int,
 
 
 
   /* Control Signal from Bank Ctrl  */
 
                    app_req_dma_last_int,
 
 
 
   /*  Control Signal from/to to application i/f  */
   /*  Control Signal from/to to application i/f  */
                    app_req_addr,
 
                    app_req_len,
 
                    app_sdr_req,
 
                    app_req_dma_last,
 
                    app_req_wr_n,
 
                    app_req_ack,
 
                    app_wr_data,
                    app_wr_data,
                    app_wr_en_n,
                    app_wr_en_n,
                    app_wr_next,
                    app_wr_next,
 
                    app_last_wr         ,
                    app_rd_data,
                    app_rd_data,
                    app_rd_valid
                    app_rd_valid        ,
 
                    app_last_rd
                );
                );
 
 
 
 
parameter  APP_AW   = 30;  // Application Address Width
parameter  APP_AW   = 30;  // Application Address Width
parameter  APP_DW   = 32;  // Application Data Width 
parameter  APP_DW   = 32;  // Application Data Width 
parameter  APP_BW   = 4;   // Application Byte Width
parameter  APP_BW   = 4;   // Application Byte Width
parameter  APP_RW   = 9;   // Application Request Width
parameter  APP_RW   = 9;   // Application Request Width
 
 
Line 95... Line 84...
 
 
input                    clk;
input                    clk;
input                    reset_n ;
input                    reset_n ;
input [1:0]             sdr_width           ; // 2'b00 - 32 Bit SDR, 2'b01 - 16 Bit SDR, 2'b1x - 8 Bit
input [1:0]             sdr_width           ; // 2'b00 - 32 Bit SDR, 2'b01 - 16 Bit SDR, 2'b1x - 8 Bit
 
 
/* Control Signal from xfr ctrl */
/* Control Signal from xfr ctrl Read Transaction*/
input                    x2a_rdstart; // read start indication
input                    x2a_rdstart; // read start indication
input                    x2a_wrstart; // writ start indication
 
input                    x2a_rdlast; //  read last burst access
input                    x2a_rdlast; //  read last burst access
input                    x2a_wrlast; // write last transfer
input [SDR_DW-1:0]       x2a_rddt         ;
input [SDR_DW-1:0]       app_rd_data_int;
input                    x2a_rdok         ;
input                    app_rd_valid_int;
 
output [SDR_DW-1:0]      app_wr_data_int;
 
output [SDR_BW-1:0]      app_wr_en_n_int;
 
input                    app_wr_next_int;
 
 
 
/* Control Signal from request ctrl */
 
output [APP_AW:0]        app_req_addr_int;
 
output [APP_RW-1:0]      app_req_len_int;
 
input                    app_req_ack_int;
 
output                   app_sdr_req_int;
 
 
 
/* Control Signal from Bank Ctrl  */
 
output                   app_req_dma_last_int;
 
 
 
 
/* Control Signal from xfr ctrl Write Transaction*/
 
input                    x2a_wrstart      ; // writ start indication
 
input                    x2a_wrlast       ; // write last transfer
 
input                    x2a_wrnext       ;
 
output [SDR_DW-1:0]      a2x_wrdt         ;
 
output [SDR_BW-1:0]      a2x_wren_n       ;
 
 
/*  Control Signal from/to to application i/f  */
// Application Write Transaction
input [APP_AW-1:0]       app_req_addr;
 
input  [APP_RW-1:0]      app_req_len ;
 
input                    app_req_wr_n;
 
input                    app_sdr_req;
 
input                    app_req_dma_last;
 
output                   app_req_dma_last_int;
 
output                   app_req_ack;
 
 
 
input  [APP_DW-1:0]      app_wr_data;
input  [APP_DW-1:0]      app_wr_data;
input  [APP_BW-1:0]      app_wr_en_n;
input  [APP_BW-1:0]      app_wr_en_n;
output                   app_wr_next;
output                   app_wr_next;
 
output                   app_last_wr      ; // Indicate last Write Transfer for a given burst size
 
 
 
// Application Read Transaction
output [APP_DW-1:0]      app_rd_data;
output [APP_DW-1:0]      app_rd_data;
output                   app_rd_valid;
output                   app_rd_valid;
 
output                   app_last_rd      ; // Indicate last Read Transfer for a given burst size
 
 
reg [APP_AW:0]           app_req_addr_int;
//----------------------------------------------
reg [APP_RW-1:0]         app_req_len_int;
// Local Decleration
 
// ----------------------------------------
reg                      app_req_dma_last_int;
 
reg                      app_sdr_req_int;
 
reg                      app_req_ack;
 
 
 
reg [APP_DW-1:0]         app_rd_data;
reg [APP_DW-1:0]         app_rd_data;
reg                      app_rd_valid;
reg                      app_rd_valid;
reg [SDR_DW-1:0]         app_wr_data_int;
reg [SDR_DW-1:0]         a2x_wrdt         ;
reg [SDR_BW-1:0]         app_wr_en_n_int;
reg [SDR_BW-1:0]         a2x_wren_n       ;
reg                      app_wr_next;
reg                      app_wr_next;
 
 
reg [23:0]               saved_rd_data;
reg [23:0]               saved_rd_data;
reg [1:0]                rd_xfr_count;
reg [1:0]                rd_xfr_count;
reg [1:0]                wr_xfr_count;
reg [1:0]                wr_xfr_count;
 
 
 
 
wire                  ok_to_req;
assign  app_last_wr = x2a_wrlast;
 
assign  app_last_rd = x2a_rdlast;
assign ok_to_req = ((wr_xfr_count == 0) && (rd_xfr_count == 0));
 
 
 
always @(*) begin
always @(*) begin
        if(sdr_width == 2'b00) // 32 Bit SDR Mode
        if(sdr_width == 2'b00) // 32 Bit SDR Mode
          begin
          begin
            app_req_addr_int = {1'b0,app_req_addr};
            a2x_wrdt             = app_wr_data;
            app_req_len_int = app_req_len;
            a2x_wren_n           = app_wr_en_n;
            app_wr_data_int = app_wr_data;
            app_wr_next          = x2a_wrnext;
            app_wr_en_n_int = app_wr_en_n;
            app_rd_data          = x2a_rddt;
            app_req_dma_last_int = app_req_dma_last;
            app_rd_valid         = x2a_rdok;
            app_sdr_req_int = app_sdr_req;
 
            app_wr_next = app_wr_next_int;
 
            app_rd_data = app_rd_data_int;
 
            app_rd_valid = app_rd_valid_int;
 
            app_req_ack = app_req_ack_int;
 
          end
          end
        else if(sdr_width == 2'b01) // 16 Bit SDR Mode
        else if(sdr_width == 2'b01) // 16 Bit SDR Mode
        begin
        begin
           // Changed the address and length to match the 16 bit SDR Mode
           // Changed the address and length to match the 16 bit SDR Mode
            app_req_addr_int = {app_req_addr,1'b0};
            app_wr_next          = (x2a_wrnext & wr_xfr_count[0]);
            app_req_len_int = {app_req_len,1'b0};
 
            app_req_dma_last_int = app_req_dma_last;
 
            //app_sdr_req_int = app_sdr_req && ok_to_req;
 
            app_sdr_req_int = app_sdr_req ;
 
            app_req_ack = app_req_ack_int;
 
            app_wr_next = (app_wr_next_int & wr_xfr_count[0]);
 
            app_rd_valid = (rd_xfr_count & rd_xfr_count[0]);
            app_rd_valid = (rd_xfr_count & rd_xfr_count[0]);
            if(wr_xfr_count[0] == 1'b1)
            if(wr_xfr_count[0] == 1'b1)
              begin
              begin
                app_wr_en_n_int = app_wr_en_n[3:2];
                a2x_wren_n      = app_wr_en_n[3:2];
                app_wr_data_int = app_wr_data[31:16];
                a2x_wrdt        = app_wr_data[31:16];
              end
              end
            else
            else
              begin
              begin
                app_wr_en_n_int = app_wr_en_n[1:0];
                a2x_wren_n      = app_wr_en_n[1:0];
                app_wr_data_int = app_wr_data[15:0];
                a2x_wrdt        = app_wr_data[15:0];
              end
              end
 
 
            app_rd_data = {app_rd_data_int,saved_rd_data[15:0]};
            app_rd_data = {x2a_rddt,saved_rd_data[15:0]};
        end else  // 8 Bit SDR Mode
        end else  // 8 Bit SDR Mode
        begin
        begin
           // Changed the address and length to match the 16 bit SDR Mode
           // Changed the address and length to match the 16 bit SDR Mode
            app_req_addr_int = {app_req_addr,2'b0};
            app_wr_next         = (x2a_wrnext & (wr_xfr_count[1:0]== 2'b11));
            app_req_len_int = {app_req_len,2'b0};
 
            app_req_dma_last_int = app_req_dma_last;
 
            app_sdr_req_int = app_sdr_req && ok_to_req;
 
            app_req_ack = app_req_ack_int;
 
            app_wr_next = (app_wr_next_int & (wr_xfr_count[1:0]== 2'b11));
 
            app_rd_valid = (rd_xfr_count &   (rd_xfr_count[1:0]== 2'b11));
            app_rd_valid = (rd_xfr_count &   (rd_xfr_count[1:0]== 2'b11));
            if(wr_xfr_count[1:0] == 2'b11)
            if(wr_xfr_count[1:0] == 2'b11)
            begin
            begin
                app_wr_en_n_int = app_wr_en_n[3];
                a2x_wren_n      = app_wr_en_n[3];
                app_wr_data_int = app_wr_data[31:24];
                a2x_wrdt        = app_wr_data[31:24];
            end
            end
            else if(wr_xfr_count[1:0] == 2'b10)
            else if(wr_xfr_count[1:0] == 2'b10)
            begin
            begin
                app_wr_en_n_int = app_wr_en_n[2];
                a2x_wren_n      = app_wr_en_n[2];
                app_wr_data_int = app_wr_data[23:16];
                a2x_wrdt        = app_wr_data[23:16];
            end
            end
            else if(wr_xfr_count[1:0] == 2'b01)
            else if(wr_xfr_count[1:0] == 2'b01)
            begin
            begin
                app_wr_en_n_int = app_wr_en_n[1];
                a2x_wren_n      = app_wr_en_n[1];
                app_wr_data_int = app_wr_data[15:8];
                a2x_wrdt        = app_wr_data[15:8];
            end
            end
            else begin
            else begin
                app_wr_en_n_int = app_wr_en_n[0];
                a2x_wren_n      = app_wr_en_n[0];
                app_wr_data_int = app_wr_data[7:0];
                a2x_wrdt        = app_wr_data[7:0];
            end
            end
 
 
            app_rd_data = {app_rd_data_int,saved_rd_data[23:0]};
            app_rd_data         = {x2a_rddt,saved_rd_data[23:0]};
          end
          end
     end
     end
 
 
 
 
 
 
Line 241... Line 197...
 
 
        // During Write Phase
        // During Write Phase
        if(x2a_wrlast) begin
        if(x2a_wrlast) begin
           wr_xfr_count    <= 0;
           wr_xfr_count    <= 0;
        end
        end
        else if(app_wr_next_int) begin
        else if(x2a_wrnext) begin
           wr_xfr_count <= wr_xfr_count + 1'b1;
           wr_xfr_count <= wr_xfr_count + 1'b1;
        end
        end
 
 
        // During Read Phase
        // During Read Phase
        if(x2a_rdlast) begin
        if(x2a_rdlast) begin
           rd_xfr_count    <= 0;
           rd_xfr_count    <= 0;
        end
        end
        else if(app_rd_valid_int) begin
        else if(x2a_rdok) begin
           rd_xfr_count   <= rd_xfr_count + 1'b1;
           rd_xfr_count   <= rd_xfr_count + 1'b1;
        end
        end
 
 
        // Save Previous Data
        // Save Previous Data
        if(app_rd_valid_int) begin
        if(x2a_rdok) begin
           if(sdr_width == 2'b01) // 16 Bit SDR Mode
           if(sdr_width == 2'b01) // 16 Bit SDR Mode
              saved_rd_data[15:0]  <= app_rd_data_int;
              saved_rd_data[15:0]  <= x2a_rddt;
            else begin// 8 bit SDR Mode - 
            else begin// 8 bit SDR Mode - 
               if(rd_xfr_count[1:0] == 2'b00)      saved_rd_data[7:0]   <= app_rd_data_int[7:0];
               if(rd_xfr_count[1:0] == 2'b00)      saved_rd_data[7:0]   <= x2a_rddt[7:0];
               else if(rd_xfr_count[1:0] == 2'b01) saved_rd_data[15:8]  <= app_rd_data_int[7:0];
               else if(rd_xfr_count[1:0] == 2'b01) saved_rd_data[15:8]  <= x2a_rddt[7:0];
               else if(rd_xfr_count[1:0] == 2'b10) saved_rd_data[23:16] <= app_rd_data_int[7:0];
               else if(rd_xfr_count[1:0] == 2'b10) saved_rd_data[23:16] <= x2a_rddt[7:0];
            end
            end
        end
        end
    end
    end
end
end
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.