📄 altmemddr_mem_model.v
字号:
//Legal Notice: (C)2007 Altera Corporation. All rights reserved. Your
//use of Altera Corporation's design tools, logic functions and other
//software and tools, and its AMPP partner logic functions, and any
//output files any of the foregoing (including device programming or
//simulation files), and any associated documentation or information are
//expressly subject to the terms and conditions of the Altera Program
//License Subscription Agreement or other applicable license agreement,
//including, without limitation, that your use is for the sole purpose
//of programming logic devices manufactured by Altera and sold by Altera
//or its authorized distributors. Please refer to the applicable
//agreement for further details.
// synthesis translate_off
`timescale 1ns / 1ps
// synthesis translate_on
// turn off superfluous verilog processor warnings
// altera message_level Level1
// altera message_off 10034 10035 10036 10037 10230 10240 10030
module altmemddr_mem_model_ram_module (
// inputs:
data,
rdaddress,
rdclken,
wraddress,
wrclock,
wren,
// outputs:
q
)
;
output [ 31: 0] q;
input [ 31: 0] data;
input [ 22: 0] rdaddress;
input rdclken;
input [ 22: 0] wraddress;
input wrclock;
input wren;
reg [ 31: 0] mem_array [8388607: 0];
wire [ 31: 0] q;
reg [ 22: 0] read_address;
//synthesis translate_off
//////////////// SIMULATION-ONLY CONTENTS
always @(rdaddress)
begin
if (1)
read_address <= rdaddress;
end
// Data read is asynchronous.
assign q = mem_array[read_address];
always @(posedge wrclock)
begin
// Write data
if (wren)
mem_array[wraddress] <= data;
end
//////////////// END SIMULATION-ONLY CONTENTS
//synthesis translate_on
//synthesis read_comments_as_HDL on
// always @(rdaddress)
// begin
// if (1)
// read_address <= rdaddress;
// end
//
//
// lpm_ram_dp lpm_ram_dp_component
// (
// .data (data),
// .q (q),
// .rdaddress (read_address),
// .rdclken (rdclken),
// .wraddress (wraddress),
// .wrclock (wrclock),
// .wren (wren)
// );
//
// defparam lpm_ram_dp_component.lpm_file = "UNUSED",
// lpm_ram_dp_component.lpm_hint = "USE_EAB=ON",
// lpm_ram_dp_component.lpm_indata = "REGISTERED",
// lpm_ram_dp_component.lpm_outdata = "UNREGISTERED",
// lpm_ram_dp_component.lpm_rdaddress_control = "UNREGISTERED",
// lpm_ram_dp_component.lpm_width = 32,
// lpm_ram_dp_component.lpm_widthad = 23,
// lpm_ram_dp_component.lpm_wraddress_control = "REGISTERED",
// lpm_ram_dp_component.suppress_memory_conversion_warnings = "ON";
//
//synthesis read_comments_as_HDL off
endmodule
// turn off superfluous verilog processor warnings
// altera message_level Level1
// altera message_off 10034 10035 10036 10037 10230 10240 10030
module altmemddr_mem_model (
// inputs:
mem_addr,
mem_ba,
mem_cas_n,
mem_cke,
mem_clk,
mem_clk_n,
mem_cs_n,
mem_dm,
mem_ras_n,
mem_we_n,
// outputs:
global_reset_n,
mem_dq,
mem_dqs
)
;
output global_reset_n;
inout [ 15: 0] mem_dq;
inout [ 1: 0] mem_dqs;
input [ 12: 0] mem_addr;
input [ 1: 0] mem_ba;
input mem_cas_n;
input mem_cke;
input mem_clk;
input mem_clk_n;
input mem_cs_n;
input [ 1: 0] mem_dm;
input mem_ras_n;
input mem_we_n;
wire [ 23: 0] CODE;
wire [ 12: 0] a;
wire [ 7: 0] addr_col;
wire [ 1: 0] ba;
reg [ 2: 0] burstlength;
reg burstmode;
wire cas_n;
wire cke;
wire clk;
wire [ 2: 0] cmd_code;
wire cs_n;
wire [ 1: 0] current_row;
wire [ 1: 0] dm;
reg [ 3: 0] dm_captured;
reg [ 31: 0] dq_captured;
wire [ 15: 0] dq_temp;
wire dq_valid;
wire [ 1: 0] dqs_temp;
wire dqs_valid;
reg dqs_valid_temp;
reg [ 15: 0] first_half_dq;
wire global_reset_n;
reg [ 3: 0] index;
wire [ 31: 0] mem_bytes;
wire [ 15: 0] mem_dq;
wire [ 1: 0] mem_dqs;
reg [ 12: 0] open_rows [ 3: 0];
wire ras_n;
reg [ 22: 0] rd_addr_pipe_0;
reg [ 22: 0] rd_addr_pipe_1;
reg [ 22: 0] rd_addr_pipe_10;
reg [ 22: 0] rd_addr_pipe_2;
reg [ 22: 0] rd_addr_pipe_3;
reg [ 22: 0] rd_addr_pipe_4;
reg [ 22: 0] rd_addr_pipe_5;
reg [ 22: 0] rd_addr_pipe_6;
reg [ 22: 0] rd_addr_pipe_7;
reg [ 22: 0] rd_addr_pipe_8;
reg [ 22: 0] rd_addr_pipe_9;
reg [ 10: 0] rd_valid_pipe;
wire [ 22: 0] read_addr_delayed;
reg read_cmd;
reg read_cmd_echo;
wire [ 31: 0] read_data;
wire [ 15: 0] read_dq;
wire read_valid;
reg read_valid_r;
reg read_valid_r2;
reg read_valid_r3;
reg read_valid_r4;
reg reset_n;
wire [ 22: 0] rmw_address;
reg [ 31: 0] rmw_temp;
reg [ 15: 0] second_half_dq;
wire [ 23: 0] txt_code;
wire we_n;
wire [ 22: 0] wr_addr_delayed;
reg [ 22: 0] wr_addr_delayed_r;
reg [ 22: 0] wr_addr_pipe_0;
reg [ 22: 0] wr_addr_pipe_1;
reg [ 22: 0] wr_addr_pipe_10;
reg [ 22: 0] wr_addr_pipe_2;
reg [ 22: 0] wr_addr_pipe_3;
reg [ 22: 0] wr_addr_pipe_4;
reg [ 22: 0] wr_addr_pipe_5;
reg [ 22: 0] wr_addr_pipe_6;
reg [ 22: 0] wr_addr_pipe_7;
reg [ 22: 0] wr_addr_pipe_8;
reg [ 22: 0] wr_addr_pipe_9;
reg [ 10: 0] wr_valid_pipe;
reg write_cmd;
reg write_cmd_echo;
wire write_to_ram;
reg write_to_ram_r;
reg write_valid;
reg write_valid_r;
reg write_valid_r2;
reg write_valid_r3;
initial
begin
$write("\n");
$write("**********************************************************************\n");
$write("This testbench includes a generated Altera memory model:\n");
$write("'altmemddr.v', to simulate accesses to the DDR SDRAM memory.\n");
$write(" \n");
$write("**********************************************************************\n");
end
//Synchronous write when (CODE == 24'h205752 (write))
altmemddr_mem_model_ram_module altmemddr_mem_model_ram
(
.data (rmw_temp),
.q (read_data),
.rdaddress (rmw_address),
.rdclken (1'b1),
.wraddress (wr_addr_delayed_r),
.wrclock (clk),
.wren (write_to_ram_r)
);
assign clk = mem_clk;
assign dm = mem_dm;
assign cke = mem_cke;
assign cs_n = mem_cs_n;
assign ras_n = mem_ras_n;
assign cas_n = mem_cas_n;
assign we_n = mem_we_n;
assign ba = mem_ba;
assign a = mem_addr;
//generate a fake reset inside the memory model
assign global_reset_n = reset_n;
initial
begin
reset_n <= 0;
#100 reset_n <= 1;
end
assign cmd_code = (&cs_n) ? 3'b111 : {ras_n, cas_n, we_n};
assign CODE = (&cs_n) ? 24'h494e48 : txt_code;
assign addr_col = a[8 : 1];
assign current_row = {ba};
// Decode commands into their actions
always @(posedge clk or negedge reset_n)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -