Line 34... |
Line 34... |
module wb_single_port_ram #(
|
module wb_single_port_ram #(
|
parameter Dw=32, //RAM data_width in bits
|
parameter Dw=32, //RAM data_width in bits
|
parameter Aw=10, //RAM address width
|
parameter Aw=10, //RAM address width
|
parameter BYTE_WR_EN= "YES",//"YES","NO"
|
parameter BYTE_WR_EN= "YES",//"YES","NO"
|
parameter FPGA_VENDOR= "ALTERA",//"ALTERA","GENERIC"
|
parameter FPGA_VENDOR= "ALTERA",//"ALTERA","GENERIC"
|
parameter JTAG_CONNECT= "JTAG_WB",//"DISABLED", "JTAG_WB" , "ALTERA_IMCE", if not disabled then the actual memory implements as a dual port RAM with the second port is connected either to In-System Memory Content Editor or Jtag_to_wb
|
parameter JTAG_CONNECT= "ALTERA_JTAG_WB",//"DISABLED", "ALTERA_JTAG_WB" , "ALTERA_IMCE", if not disabled then the actual memory implements as a dual port RAM with the second port is connected either to In-System Memory Content Editor or Jtag_to_wb
|
parameter JTAG_INDEX= 0,
|
parameter JTAG_INDEX= 0,
|
parameter INITIAL_EN= "NO",
|
parameter INITIAL_EN= "NO",
|
parameter MEM_CONTENT_FILE_NAME= "ram0",// ram initial file name
|
parameter MEM_CONTENT_FILE_NAME= "ram0",// ram initial file name
|
parameter INIT_FILE_PATH = "path_to/sw", // The sw folder path. It will be used for finding initial file. The path will be rewriten by the top module.
|
parameter INIT_FILE_PATH = "path_to/sw", // The sw folder path. It will be used for finding initial file. The path will be rewriten by the top module.
|
// wishbon bus param
|
// wishbon bus param
|
Line 190... |
Line 190... |
module single_port_ram_top #(
|
module single_port_ram_top #(
|
parameter Dw=32, //RAM data_width in bits
|
parameter Dw=32, //RAM data_width in bits
|
parameter Aw=10, //RAM address width
|
parameter Aw=10, //RAM address width
|
parameter BYTE_WR_EN= "YES",//"YES","NO"
|
parameter BYTE_WR_EN= "YES",//"YES","NO"
|
parameter FPGA_VENDOR= "ALTERA",//"ALTERA","GENERIC"
|
parameter FPGA_VENDOR= "ALTERA",//"ALTERA","GENERIC"
|
parameter JTAG_CONNECT= "JTAG_WB",//"DISABLED", "JTAG_WB" , "ALTERA_IMCE", if not disabled then the actual memory implements as a dual port RAM with the second port is connected either to In-System Memory Content Editor or Jtag_to_wb
|
parameter JTAG_CONNECT= "ALTERA_JTAG_WB",//"DISABLED", "ALTERA_JTAG_WB" , "ALTERA_IMCE", if not disabled then the actual memory implements as a dual port RAM with the second port is connected either to In-System Memory Content Editor or Jtag_to_wb
|
parameter JTAG_INDEX= 0,
|
parameter JTAG_INDEX= 0,
|
parameter INITIAL_EN= "NO",
|
parameter INITIAL_EN= "NO",
|
parameter INIT_FILE= "sw/ram/ram0.txt"// ram initial file
|
parameter INIT_FILE= "sw/ram/ram0.txt"// ram initial file
|
|
|
)
|
)
|
Line 205... |
Line 205... |
addr_a,
|
addr_a,
|
byteena_a,
|
byteena_a,
|
we_a,
|
we_a,
|
q_a
|
q_a
|
);
|
);
|
|
/* verilator lint_off WIDTH */
|
localparam BYTE_ENw= ( BYTE_WR_EN == "YES")? Dw/8 : 1;
|
localparam BYTE_ENw= ( BYTE_WR_EN == "YES")? Dw/8 : 1;
|
|
/* verilator lint_on WIDTH */
|
|
|
input clk,reset;
|
input clk,reset;
|
input [Dw-1 : 0] data_a;
|
input [Dw-1 : 0] data_a;
|
input [Aw-1 : 0] addr_a;
|
input [Aw-1 : 0] addr_a;
|
input we_a;
|
input we_a;
|
Line 250... |
Line 252... |
|
|
|
|
|
|
|
|
generate
|
generate
|
|
/* verilator lint_off WIDTH */
|
if(FPGA_VENDOR=="ALTERA")begin:altera_fpga
|
if(FPGA_VENDOR=="ALTERA")begin:altera_fpga
|
|
/* verilator lint_on WIDTH */
|
localparam RAM_TAG_STRING=i2s(JTAG_INDEX);
|
localparam RAM_TAG_STRING=i2s(JTAG_INDEX);
|
localparam RAM_ID =(JTAG_CONNECT== "ALTERA_IMCE") ? {"ENABLE_RUNTIME_MOD=YES,INSTANCE_NAME=",RAM_TAG_STRING}
|
localparam RAM_ID =(JTAG_CONNECT== "ALTERA_IMCE") ? {"ENABLE_RUNTIME_MOD=YES,INSTANCE_NAME=",RAM_TAG_STRING}
|
: {"ENABLE_RUNTIME_MOD=NO"};
|
: {"ENABLE_RUNTIME_MOD=NO"};
|
|
/* verilator lint_off WIDTH */
|
if(JTAG_CONNECT== "JTAG_WB")begin:dual_ram
|
if(JTAG_CONNECT== "ALTERA_JTAG_WB")begin:dual_ram
|
|
/* verilator lint_on WIDTH */
|
// aletra dual port ram
|
// aletra dual port ram
|
altsyncram #(
|
altsyncram #(
|
.operation_mode("BIDIR_DUAL_PORT"),
|
.operation_mode("BIDIR_DUAL_PORT"),
|
.address_reg_b("CLOCK0"),
|
.address_reg_b("CLOCK0"),
|
.wrcontrol_wraddress_reg_b("CLOCK0"),
|
.wrcontrol_wraddress_reg_b("CLOCK0"),
|
Line 349... |
Line 354... |
.eccstatus ( )
|
.eccstatus ( )
|
);
|
);
|
|
|
end
|
end
|
end
|
end
|
|
/* verilator lint_off WIDTH */
|
else if(FPGA_VENDOR=="GENERIC")begin:generic_ram
|
else if(FPGA_VENDOR=="GENERIC")begin:generic_ram
|
if(JTAG_CONNECT== "JTAG_WB")begin:dual_ram
|
if(JTAG_CONNECT== "ALTERA_JTAG_WB")begin:dual_ram
|
|
/* verilator lint_on WIDTH */
|
|
|
generic_dual_port_ram #(
|
generic_dual_port_ram #(
|
.Dw(Dw),
|
.Dw(Dw),
|
.Aw(Aw),
|
.Aw(Aw),
|
.BYTE_WR_EN(BYTE_WR_EN),
|
.BYTE_WR_EN(BYTE_WR_EN),
|
Line 403... |
Line 408... |
);
|
);
|
|
|
end//jtag_wb
|
end//jtag_wb
|
end //Generic
|
end //Generic
|
|
|
|
/* verilator lint_off WIDTH */
|
if(JTAG_CONNECT == "JTAG_WB")begin:jtag_wb
|
if(JTAG_CONNECT == "ALTERA_JTAG_WB")begin:jtag_wb
|
|
/* verilator lint_on WIDTH */
|
reg jtag_ack;
|
reg jtag_ack;
|
wire jtag_we_o, jtag_stb_o;
|
wire jtag_we_o, jtag_stb_o;
|
|
|
localparam Sw= log2(Aw+1);
|
localparam Sw= log2(Aw+1);
|
localparam [Sw-1 : 0] ST = Aw;
|
localparam [Sw-1 : 0] ST = Aw;
|