`timescale 1 ns / 1 ps module core_tb(); initial $timeformat(-9, 2, " ns", 20); localparam MEM_INST_LENGTH = 256; localparam MEM_DATA_LENGTH = 256; localparam INST_NOP = 32'h00000013; // nop reg clk, reset; reg [31:0] mem_inst [0:MEM_INST_LENGTH-1]; wire [31:0] mem_inst_addr; wire [31:0] mem_inst_idx = mem_inst_addr >> 2; wire [31:0] mem_inst_data = mem_inst_idx < MEM_INST_LENGTH ? mem_inst[mem_inst_idx] : INST_NOP; wire dummy_out; initial begin: mem_inst_init integer i; for (i=0; i> 2; always @(posedge clk) begin if (mem_data_we) begin if (mem_data_widx < MEM_DATA_LENGTH) begin mem_inst[mem_data_widx] <= (mem_inst[mem_data_widx] & ~{{8{mem_data_wmask[3]}}, {8{mem_data_wmask[2]}}, {8{mem_data_wmask[1]}}, {8{mem_data_wmask[0]}}}) | (mem_data_wdata & {{8{mem_data_wmask[3]}}, {8{mem_data_wmask[2]}}, {8{mem_data_wmask[1]}}, {8{mem_data_wmask[0]}}}); end // ignore illegal writes end end wire [31:0] mem_data_ridx = mem_data_raddr >> 2; always @(*) begin if (mem_data_ridx < MEM_DATA_LENGTH) begin mem_data_rdata = mem_inst[mem_data_ridx] & {{8{mem_data_rmask[3]}}, {8{mem_data_rmask[2]}}, {8{mem_data_rmask[1]}}, {8{mem_data_rmask[0]}}}; end else begin mem_data_rdata = 32'h00000000; end end endmodule