|
发表于 2014-9-10 02:23:20
|
显示全部楼层
下面是我自己建的generic sram module,使用多年,
altera, xilinx, lattice 相關的 tool 都可以 compile 成 memory。
給你參考
//============================================================================//
// Filename: ramsp.v //
// Module: ramsp //
// Function: //
// Sync single-port simulation and FPGA-synthesizable model //
// //
// Author: Jarod //
// Date: 2005/11/25, //
// //
//============================================================================//
module ramsp_1024x18
(
CLK,
WE,
RD,
AD,
DI,
DO
);
parameter ADDR_BITS = 10;
parameter MEM_SIZE = 1024;
parameter DATA_BITS = 18;
input CLK; // clock
input WE; // write
input RD; // read
input [ADDR_BITS-1:0] AD; // address
input [DATA_BITS-1:0] DI; // data input
output [DATA_BITS-1:0] DO; // data output
// behavior model of ram
reg [DATA_BITS-1:0] mem[0:MEM_SIZE-1];
reg [DATA_BITS-1:0] DO;
always @(posedge CLK)
begin
if(WE)
mem[AD] <= #1 DI;
DO <= #1 mem[AD];
end
endmodule
|
|