This repository has been archived on 2023-12-21. You can view files and clone it, but cannot push or open issues or pull requests.
cse141L-project/RTL/InstROM.sv
Arthur Lu 4b909d48dd add program machine code as parameter to ROM and top_level,
change output of example assembler scripts,
update testbenches for programs 1 2 3 to use overloadable parameter,
formatted program3_tb
2022-08-30 19:10:38 -07:00

20 lines
554 B
Systemverilog

// Module Name: InstFetch
// Project Name: CSE141L
// Description: instruction ROM module for use with InstFetch
module InstROM #(parameter A=10, W=9, machine_code_file = "machine_code.txt") (
input logic [A-1:0] InstAddress,
output logic[W-1:0] InstOut
);
// declare 2-dimensional array, W bits wide, 2**A words deep
logic[W-1:0] inst_rom[2**A];
assign InstOut = inst_rom[InstAddress];
// use readmemb to read ascii 0 and 1 representation of binary values from text file
initial begin
$readmemb(machine_code_file,inst_rom);
end
endmodule