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

Subversion Repositories ddr3_synthesizable_bfm

[/] [ddr3_synthesizable_bfm/] [trunk/] [rtl/] [ddr3_simple4.v] - Diff between revs 3 and 4

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

Rev 3 Rev 4
Line 27... Line 27...
*  cs#---|___|---------
*  cs#---|___|---------
*
*
*        |   |    |
*        |   |    |
*        t0  t1  t2 ....
*        t0  t1  t2 ....
*
*
 
*
*/
*/
 
 
`timescale 1ps / 1ps
`timescale 1ps / 1ps
 
 
module ddr3_simple4#(
module ddr3_simple4#(
parameter MEM_DQ_WIDTH          =8,
parameter MEM_DQ_WIDTH          =8,
parameter MEM_BA_WIDTH          =3,
parameter MEM_BA_WIDTH          =3,
parameter MEM_ROW_WIDTH         =13,
parameter MEM_ROW_WIDTH         =13,
parameter MEM_COL_WIDTH         =13,
parameter MEM_COL_WIDTH         =13,
parameter MEM_TRTP                      =6,
parameter MEM_AL                =0,
parameter MEM_TRCD                      =11,
parameter MEM_CWL               =8, //CWL
parameter MEM_TWL                               =8,
parameter MEM_CL                =6  //CL
parameter MEM_TRL                               =6,
 
parameter MEM_ACT_CMD           =7 //activates to command
 
)(
)(
input wire [MEM_ROW_WIDTH-1:0]   a,
input wire [MEM_ROW_WIDTH-1:0]   a,
input wire [ MEM_BA_WIDTH-1:0]   ba,
input wire [ MEM_BA_WIDTH-1:0]   ba,
input wire                                                              ck,
input wire                                                              ck,
input wire                                                              ck_n,
input wire                                                              ck_n,
Line 59... Line 58...
inout wire                                                              dqs,
inout wire                                                              dqs,
inout wire                                                              dqs_n,
inout wire                                                              dqs_n,
input wire                                                              odt
input wire                                                              odt
);
);
 
 
 
//convert actual CL and CWL parameter to 
 
 
//definitions
//definitions
localparam         OPCODE_PRECHARGE             = 4'b0010;
localparam         OPCODE_PRECHARGE             = 4'b0010;
localparam              OPCODE_ACTIVATE                 = 4'b0011;
localparam              OPCODE_ACTIVATE                 = 4'b0011;
localparam              OPCODE_WRITE                    = 4'b0100;
localparam              OPCODE_WRITE                    = 4'b0100;
Line 71... Line 71...
localparam              OPCODE_REFRESH          = 4'b0001;
localparam              OPCODE_REFRESH          = 4'b0001;
localparam              OPCODE_DES                         = 4'b1000;
localparam              OPCODE_DES                         = 4'b1000;
localparam              OPCODE_ZQC                         = 4'b0110;
localparam              OPCODE_ZQC                         = 4'b0110;
localparam              OPCODE_NOP                         = 4'b0111;
localparam              OPCODE_NOP                         = 4'b0111;
 
 
localparam  BL8 = 1'b1;
 
localparam  BC4 = 1'b0;
 
 
 
 
 
//mode registers
//mode registers
reg [31:0] mr0;
reg [31:0] mr0;
reg [31:0] mr2;
reg [31:0] mr2;
reg [31:0] mr3;
reg [31:0] mr3;
 
 
Line 186... Line 182...
 
 
 
 
//cmd
//cmd
//read
//read
ddr3_sr4 #(
ddr3_sr4 #(
.PIPE_LEN(MEM_TRL)
.PIPE_LEN(MEM_CL)
)ddr3_read_cmd_sr(
)ddr3_read_cmd_sr(
        .clk(ck),
        .clk(ck),
        .shift_in(last_read_cmd),
        .shift_in(last_read_cmd),
        .shift_out(read_cmd)
        .shift_out(read_cmd)
);
);
//bank, row, col
//bank, row, col
ddr3_sr36 #(
ddr3_sr36 #(
.PIPE_LEN(MEM_TRL+1)
.PIPE_LEN(MEM_CL+1)
)ddr3_read_add_sr(
)ddr3_read_add_sr(
        .clk(ck),
        .clk(ck),
        .shift_in(last_read_add),
        .shift_in(last_read_add),
        .shift_out(read_add)
        .shift_out(read_add)
);
);
 
 
//cmd
//cmd
//write
//write
ddr3_sr4#(
ddr3_sr4#(
.PIPE_LEN(MEM_TWL)
.PIPE_LEN(MEM_CWL)
)ddr3_write_cmd_sr(
)ddr3_write_cmd_sr(
        .clk(ck),
        .clk(ck),
        .shift_in(last_write_cmd),
        .shift_in(last_write_cmd),
        .shift_out(write_cmd)
        .shift_out(write_cmd)
);
);
 
 
//bank, row, col
//bank, row, col
ddr3_sr36#(
ddr3_sr36#(
.PIPE_LEN(MEM_TWL+1) //have to be a cycle late to wait for IDDR latency
.PIPE_LEN(MEM_CWL+1) //have to be a cycle late to wait for IDDR latency
) ddr3_write_add_sr(
) ddr3_write_add_sr(
        .clk(ck),
        .clk(ck),
        .shift_in(last_write_add),
        .shift_in(last_write_add),
        .shift_out(write_add)
        .shift_out(write_add)
);
);
Line 416... Line 412...
send_dqs0<=send_dqs1;
send_dqs0<=send_dqs1;
end//end always
end//end always
 
 
//ram here
//ram here
dport_ram  #(
dport_ram  #(
        .DATA_WIDTH(8), //data_hi,data_lo
        .DATA_WIDTH(MEM_DQ_WIDTH), //data_hi,data_lo
        .ADDR_WIDTH(36)
        .ADDR_WIDTH(36)
)dport_ram_hi(
)dport_ram_hi(
        .clk                    (ck),
        .clk                    (ck),
        .di                     (data_hi),
        .di                     (data_hi),
        .read_addr      (read_add+read_col),
        .read_addr      (read_add+read_col),
Line 428... Line 424...
        .we                     (mem_we & data_hi_dm),
        .we                     (mem_we & data_hi_dm),
        .do                     (read_data[15:8])
        .do                     (read_data[15:8])
);
);
 
 
dport_ram  #(
dport_ram  #(
        .DATA_WIDTH(8), //data_hi,data_lo
        .DATA_WIDTH(MEM_DQ_WIDTH), //data_hi,data_lo
        .ADDR_WIDTH(36)
        .ADDR_WIDTH(36)
)dport_ram_lo(
)dport_ram_lo(
        .clk                    (ck),
        .clk                    (ck),
        .di                     (data_lo),
        .di                     (data_lo),
        .read_addr      (read_add+read_col),
        .read_addr      (read_add+read_col),
Line 444... Line 440...
assign dqs_n=((send_dqs0==1'b1) || (send_dq==1'b1))?ck_n:1'bz;
assign dqs_n=((send_dqs0==1'b1) || (send_dq==1'b1))?ck_n:1'bz;
assign dq   = (send_dq==1'b1)?dq_out:8'hZZ;
assign dq   = (send_dq==1'b1)?dq_out:8'hZZ;
 
 
/* utility functions to display information
/* utility functions to display information
*/
*/
 
 
initial begin
initial begin
        $timeformat (-9, 1, " ns", 1);
        $timeformat (-9, 1, " ns", 1);
      end
      end
 
 
always @(posedge ck )
always @(posedge ck )
Line 464... Line 461...
 
 
        OPCODE_DES                      :begin
        OPCODE_DES                      :begin
                                                                $display("%m: at time %t DES ",$time);
                                                                $display("%m: at time %t DES ",$time);
                                                        end
                                                        end
        OPCODE_MRS              :begin
        OPCODE_MRS              :begin
                                                                $display("%m: at time %t MRS ",$time);
                                                        $display("%m: at time %t MRS - MR[%d]",$time,ba[1:0]);
                                                        end
                                                        case(ba[1:0])
 
                                                                2'b00:begin //MR0
 
                                                                        case(a[1:0]) // burst length
 
                                                                                2'b00:$display("%m\tBL = BL8 \(Fixed\)");
 
                                                                                2'b01:$display("%m\tBL = BC4/BL8 OTF");
 
                                                                                2'b10:$display("%m\tBL = BC4 (Fixed)");
 
                                                                                2'b11:$display("%m\tBL = Reserved");
 
                                                                        endcase
 
 
 
                                                                        case({a[6:4],a[2]}) //CAS Latency
 
                                                                                4'b0000:$display("%m\tCL = Reserved");
 
                                                                                4'b0010:$display("%m\tCL = 5");
 
                                                                                4'b0100:$display("%m\tCL = 6");
 
                                                                                4'b0110:$display("%m\tCL = 7");
 
                                                                                4'b1000:$display("%m\tCL = 8");
 
                                                                                4'b1010:$display("%m\tCL = 9");
 
                                                                                4'b1100:$display("%m\tCL = 10");
 
                                                                                4'b1111:$display("%m\tCL = 11(Optional for DD3-1600)");
 
                                                                                4'b0001:$display("%m\tCL = 12");
 
                                                                                4'b0011:$display("%m\tCL = 13");
 
                                                                                4'b0101:$display("%m\tCL = 14");
 
                                                                                4'b0111:$display("%m\tCL = Reserved for 15");
 
                                                                                4'b1001:$display("%m\tCL = Reserved for 16");
 
                                                                                4'b1011:$display("%m\tCL = Reserved");
 
                                                                                4'b1101:$display("%m\tCL = Reserved");
 
                                                                                4'b1111:$display("%m\tCL = Reserved");
 
                                                                        endcase
 
 
 
                                                                        case(a[11:9]) //Write Recover
 
                                                                                3'b000:$display("%m\tWR = 16^2(256 cycles)");
 
                                                                                3'b001:$display("%m\tWR =  5^2( 25 cycles)");
 
                                                                                3'b010:$display("%m\tWR =  6^2( 36 cycles)");
 
                                                                                3'b011:$display("%m\tWR =  7^2( 49 cycles)");
 
                                                                                3'b100:$display("%m\tWR =  8^2( 64 cycles)");
 
                                                                                3'b101:$display("%m\tWR = 10^2(100 cycles)");
 
                                                                                3'b110:$display("%m\tWR = 12^2(144 cycles)");
 
                                                                                3'b111:$display("%m\tWR = 14^2(196 cycles)");
 
                                                                        endcase
 
                                                                end//end MR0
 
                                                                2'b01:begin //MR1
 
                                                                end//end MR1
 
                                                                2'b10:begin //MR2
 
                                                                end//end MR2
 
                                                                2'b11:begin //MR3
 
                                                                end//end MR3
 
                                                        endcase //end which MRS
 
 
 
 
 
                                                end //end MRS
        /*OPCODE_NOP            :begin
        /*OPCODE_NOP            :begin
                                                                /$display("%m: at time %t WRITE ",$time);
                                                                /$display("%m: at time %t WRITE ",$time);
                                                        end
                                                        end
        */
        */
        /*
        /*

powered by: WebSVN 2.1.0

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