题解 | #ROM的简单实现#

ROM的简单实现

https://www.nowcoder.com/practice/b76fdef7ffa747909b0ea46e0d13738a

单端口rom,同步rom,

存好数据在rom中,比如mif文件,通过地址读取rom中的数据

`timescale 1ns/1ns
module rom(
	input clk,
	input rst_n,
	input [7:0]addr,
	
	output [3:0]data
);

reg [3:0] rom_data [7:0];

always@(posedge clk or negedge rst_n)begin
	if(!rst_n)begin
		rom_data[0]<=4'd0;
		rom_data[1]<=4'd2;
		rom_data[2]<=4'd4;
		rom_data[3]<=4'd6;
		rom_data[4]<=4'd8;
		rom_data[5]<=4'd10;
		rom_data[6]<=4'd12;
		rom_data[7]<=4'd14;
	end
	else begin
		rom_data[0]<=rom_data[0];
		rom_data[1]<=rom_data[1];
		rom_data[2]<=rom_data[2];
		rom_data[3]<=rom_data[3];
		rom_data[4]<=rom_data[4];
		rom_data[5]<=rom_data[5];
		rom_data[6]<=rom_data[6];
		rom_data[7]<=rom_data[7];
	end
end
	assign data = rom_data[addr];
endmodule

全部评论

相关推荐

04-23 10:44
已编辑
门头沟学院 Java
pdd
爱吃鱼的肖恩求实习:pdd感觉池子太深了,hr面一周了没消息
点赞 评论 收藏
分享
learYuan:🐕看了都摇头
点赞 评论 收藏
分享
抱抱碍事梨a:三点建议,第一点是建议再做一个项目,把自我介绍部分顶了,第二点是中南大学加黑加粗,第三点是建议加v详细交流
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务