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

Subversion Repositories sparc64soc

[/] [sparc64soc/] [trunk/] [WB2ALTDDR3/] [dram_wb.v] - Diff between revs 2 and 3

Show entire file | Details | Blame | View Log

Rev 2 Rev 3
Line 55... Line 55...
   output            ddr3_ce,
   output            ddr3_ce,
   output     [ 7:0] ddr3_dm,
   output     [ 7:0] ddr3_dm,
 
 
   output            phy_init_done,
   output            phy_init_done,
 
 
 
   output     [ 7:0] fifo_used,
 
 
   input             dcm_locked,
   input             dcm_locked,
   input             sysrst
   input             sysrst
);
);
 
 
wire [255:0] rd_data_fifo_out;
wire [255:0] rd_data_fifo_out;
reg  [255:0] rd_data_cache;
 
reg  [ 23:0] rd_addr_cache;
reg  [ 23:0] rd_addr_cache;
wire [ 71:0] wr_dout;
wire [ 71:0] wr_dout;
wire [ 31:0] cmd_out;
wire [ 31:0] cmd_out;
reg          wb_stb_i_d;
reg          wb_stb_i_d;
reg  [ 31:0] mask_data;
reg  [ 31:0] mask_data;
 
 
wire push_tran;
 
wire fifo_read;
 
wire fifo_empty;
wire fifo_empty;
reg  push_tran_d;
 
reg  fifo_read_d;
 
reg  fifo_empty_d;
 
 
 
 
 
wire [13:0] parallelterminationcontrol;
wire [13:0] parallelterminationcontrol;
wire [13:0] seriesterminationcontrol;
wire [13:0] seriesterminationcontrol;
 
 
dram dram_ctrl(
dram dram_ctrl(
Line 169... Line 164...
assign trig0[237]=0;
assign trig0[237]=0;
assign trig0[238]=0;
assign trig0[238]=0;
assign trig0[254:239]=0;
assign trig0[254:239]=0;
 
 
reg fifo_full_d;
reg fifo_full_d;
 
reg written;
 
 
dram_fifo fifo(
dram_fifo fifo(
    .aclr(ddr_rst),
    .aclr(ddr_rst),
 
 
    .wrclk(wb_clk_i),
    .wrclk(wb_clk_i),
    .rdclk(ddr_clk),
    .rdclk(ddr_clk),
 
 
    .data({wb_sel_i,wb_dat_i,wb_we_i,wb_adr_i[33:3]}),
    .data({wb_sel_i,wb_dat_i,wb_we_i,wb_adr_i[33:3]}),
    .wrreq(wb_cyc_i && wb_stb_i && (!wb_stb_i_d || fifo_full_d) && !fifo_full && !(rd_addr_cache==wb_adr_i[28:5] && !wb_we_i)),
    .wrreq(wb_cyc_i && wb_stb_i && (!wb_stb_i_d || (fifo_full_d && !written)) && !fifo_full && !(rd_addr_cache==wb_adr_i[28:5] && !wb_we_i)),
    .wrfull(fifo_full),
    .wrfull(fifo_full),
 
 
    .rdreq(fifo_read),
    .rdreq(fifo_read),
    .q({wr_dout,cmd_out}),
    .q({wr_dout,cmd_out}),
 
    .wrusedw(fifo_used),
    .rdempty(fifo_empty)
    .rdempty(fifo_empty)
);
);
 
 
assign fifo_read=cmd_out[31] ? push_tran:rd_data_valid;
`define DDR_IDLE    3'b000
 
`define DDR_WRITE_1 3'b001
reg dram_ready_d;
`define DDR_WRITE_2 3'b010
 
`define DDR_READ_1  3'b011
 
`define DDR_READ_2  3'b100
 
 
 
reg [2:0] ddr_state;
 
reg       push_tran;
 
reg       fifo_read;
 
 
always @(posedge ddr_clk)
always @(posedge ddr_clk or posedge ddr_rst)
 
   if(ddr_rst)
   begin
   begin
      fifo_empty_d<=fifo_empty;
         ddr_state<=`DDR_IDLE;
      fifo_read_d<=fifo_read;
         fifo_read<=0;
      dram_ready_d<=dram_ready;
         push_tran<=0;
      fifo_full_d<=fifo_full;
         rd_data_valid_stb<=0;
   end
   end
 
   else
// Push transaction to controller FIFO
      case(ddr_state)
assign push_tran=!fifo_empty && dram_ready && (fifo_empty_d || fifo_read_d || !dram_ready_d);
         `DDR_IDLE:
 
            if(!fifo_empty && dram_ready)
 
               begin
 
                  push_tran<=1;
 
                  if(cmd_out[31])
 
                     begin
 
                        ddr_state<=`DDR_WRITE_1;
 
                        fifo_read<=1;
 
                     end
 
                  else
 
                     ddr_state<=`DDR_READ_1;
 
               end
 
         `DDR_WRITE_1:
 
            begin
 
               push_tran<=0;
 
               fifo_read<=0;
 
               ddr_state<=`DDR_WRITE_2; // Protect against FIFO empty signal latency
 
            end
 
         `DDR_WRITE_2:
 
            ddr_state<=`DDR_IDLE;
 
         `DDR_READ_1:
 
            begin
 
               push_tran<=0;
 
               if(rd_data_valid)
 
                  begin
 
                     rd_data_valid_stb<=1;
 
                     fifo_read<=1;
 
                     ddr_state<=`DDR_READ_2;
 
                  end
 
            end
 
         `DDR_READ_2:
 
            begin
 
               fifo_read<=0;
 
               if(wb_ack_d1) // Enought delay to protect against FIFO empty signal latency
 
                  begin
 
                     rd_data_valid_stb<=0;
 
                     ddr_state<=`DDR_IDLE;
 
                  end
 
            end
 
      endcase
 
 
reg rd_data_valid_stb;
reg rd_data_valid_stb;
reg rd_data_valid_stb_d1;
reg rd_data_valid_stb_d1;
reg rd_data_valid_stb_d2;
reg rd_data_valid_stb_d2;
reg rd_data_valid_stb_d3;
reg rd_data_valid_stb_d3;
Line 233... Line 276...
               rd_addr_cache<=24'hFFFFFF;
               rd_addr_cache<=24'hFFFFFF;
      rd_data_valid_stb_d1<=rd_data_valid_stb;
      rd_data_valid_stb_d1<=rd_data_valid_stb;
      rd_data_valid_stb_d2<=rd_data_valid_stb_d1;
      rd_data_valid_stb_d2<=rd_data_valid_stb_d1;
      rd_data_valid_stb_d3<=rd_data_valid_stb_d2;
      rd_data_valid_stb_d3<=rd_data_valid_stb_d2;
      rd_data_valid_stb_d4<=rd_data_valid_stb_d3;
      rd_data_valid_stb_d4<=rd_data_valid_stb_d3;
 
      fifo_full_d<=fifo_full;
 
      if(wb_ack_o)
 
         written<=0;
 
      else
 
         if(!fifo_full && fifo_full_d)
 
            written<=1;
   end
   end
 
 
assign wb_ack_o=wb_we_i ? (wb_cyc_i && wb_stb_i && !fifo_full):rd_data_valid_stb_d2 && !rd_data_valid_stb_d3 || (!wb_we_i && rd_addr_cache==wb_adr_i[28:5]);
assign wb_ack_o=wb_we_i ? (wb_cyc_i && wb_stb_i && !fifo_full):(rd_data_valid_stb_d2 && !rd_data_valid_stb_d3) || (rd_addr_cache==wb_adr_i[28:5]);
 
 
always @(posedge ddr_clk)
always @(posedge ddr_clk)
   begin
   begin
      wb_ack_d<=wb_ack_o;
      wb_ack_d<=wb_ack_o;
      wb_ack_d1<=wb_ack_d;
      wb_ack_d1<=wb_ack_d;
      if(rd_data_valid)
      if(rd_data_valid)
         begin
 
            rd_data_fifo_out_d<=rd_data_fifo_out;
            rd_data_fifo_out_d<=rd_data_fifo_out;
            rd_data_valid_stb<=1;
 
         end
 
      else
 
         if(wb_ack_d1)
 
            rd_data_valid_stb<=0;
 
   end
   end
 
 
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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