题解 | #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] ROM [7:0]; always@(posedge clk or negedge rst_n) begin if(!rst_n) begin // data <= 4'b0; ROM[0] <= 0; ROM[1] <= 2; ROM[2] <= 4; ROM[3] <= 6; ROM[4] <= 8; ROM[5] <= 10; ROM[6] <= 12; ROM[7] <= 14; end end assign data = ROM[addr]; endmodule
这里的data是wire,ROM的取值不看时钟?