---function is called only once at the array initialize.
-function rom_fill return rom_array is
- type binary_file is file of character;
- FILE nes_file : binary_file OPEN read_mode IS "rom-file.nes" ;
- variable read_data : character;
- variable i : integer;
- variable out_line : line;
- variable ret : rom_array;
- begin
- --skip first 16 bit data(NES cardridge header part.)
- for i in 0 to 15 loop
- read(nes_file, read_data);
- end loop;
-
- for i in ret'range loop
- read(nes_file, read_data);
- ret(i) :=
- conv_std_logic_vector(character'pos(read_data), 8);
- end loop;
- write(out_line, string'("file load success."));
- writeline(output, out_line);
- return ret;
- end rom_fill;
+----function is called only once at the array initialize.
+--function rom_fill return rom_array is
+-- type binary_file is file of character;
+-- FILE nes_file : binary_file OPEN read_mode IS "rom-file.nes" ;
+-- variable read_data : character;
+-- variable i : integer;
+-- variable out_line : line;
+-- variable ret : rom_array;
+-- begin
+-- --skip first 16 bit data(NES cardridge header part.)
+-- for i in 0 to 15 loop
+-- read(nes_file, read_data);
+-- end loop;
+--
+-- for i in ret'range loop
+-- read(nes_file, read_data);
+-- ret(i) :=
+-- conv_std_logic_vector(character'pos(read_data), 8);
+-- end loop;
+-- write(out_line, string'("file load success."));
+-- writeline(output, out_line);
+-- return ret;
+-- end rom_fill;
+\r
+ function init_rom\r
+ return rom_array is \r
+ variable tmp : rom_array := (others => (others => '0'));\r
+ begin \r
+ for addr_pos in 0 to 2**abus_size - 1 loop \r
+ -- Initialize each address with the address itself\r
+ tmp(addr_pos) := std_logic_vector(to_unsigned(addr_pos, dbus_size));\r
+ end loop;\r
+ return tmp;\r
+ end init_rom; \r
+\r
+ -- Declare the ROM signal and specify a default value. Quartus II\r
+ -- will create a memory initialization file (.mif) based on the \r
+ -- default value.\r