题解 | #ROM的简单实现#
ROM的简单实现
https://www.nowcoder.com/practice/b76fdef7ffa747909b0ea46e0d13738a
不需要用时钟上升沿触发同步输出吗?
`timescale 1ns/1ns module rom( input clk, input rst_n, input [7:0]addr, output [3:0]data ); reg [3:0] mem[0:7]; integer i; always@(posedge clk or negedge rst_n) begin if(!rst_n) begin for(i=0;i<8;i=i+1) begin mem[i] <= (i<<1); end end else begin for(i=0;i<8;i=i+1) begin mem[i] <= mem[i]; end end end assign data = mem[addr]; endmodule