当前位置: 首页 > 工具软件 > ram > 使用案例 >

RAM设计

梁丘书
2023-12-01

数字IC设计学习笔记

序列检测

1.  RAM设计

RAM设计

  • 问题描述
    设计实现一个512*8的双端口RAM
    RAM宽度8bit,RAM深度512,ADDR位宽:2^9=512

  • Verilog代码

module ram_dual(
	clk_r,
	clk_w,
	en_r,
	en_w,
	addr_r,
	addr_w.
	data_r,
	data_w
);
	parameter DLY = 1;
	parameter RAM_WIDTH = 8;
	parameter RAM_DEPTH = 512;
	parameter ADDR_WIDTH = 9;
	input						clk_r;
	input       				clk_w;
	input [RAM_WIDTH-1:0] 		data_w;	
	input [ADDR_WIDTH-1:0] 		addr_w;		
	input [ADDR_WIDTH-1:0] 		addr_r;		
	input						en_r;
	input						en_w;	
	output reg [RAM_WIDTH-1:0]  data_r;
	reg [RAM_WIDTH-1:0] mem [RAM_DEPTH-1:0];
//write operation
	always@(posedge clk_w)begin
		if(en_w)
			mem [addr_w]<= #DLY data_w;
	end
//read operation
	always@(posedge clk_r)begin
		if(en_r)
			data_r<= #DLY mem [addr_r];
	end

endmodule


【注】:个人学习笔记,如有错误,望不吝赐教,这厢有礼了~~~


 类似资料: