-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstruction_rom.sv
43 lines (35 loc) · 1.02 KB
/
instruction_rom.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* Quartus II Verilog Template
/ Single Port ROM
Use following format for init instructions:
Where: CorD: - is 1 if instruction is cmd
- is 0 if instruction is data
Instr: is 8 bit instruction
Delay: is 7 bit value to wait in uS
Address Bits
0 {1'bCorD , 8'hInstuction, 7'hDelay}
1 {1'bCorD , 8'hInstuction, 7'hDelay}
*/
module instruction_rom
#(parameter DATA_WIDTH=16, parameter ADDR_WIDTH=6)
(
input [(ADDR_WIDTH-1):0] addr,
input clk,
output reg [(DATA_WIDTH-1):0] q
);
// Declare the ROM variable
reg [DATA_WIDTH-1:0] rom[2**ADDR_WIDTH-1:0];
// Initialize the ROM with $readmemb. Put the memory contents
// in the file single_port_rom_init.txt. Without this file,
// this design will not compile.
// See Verilog LRM 1364-2001 Section 17.2.8 for details on the
// format of this file, or see the "Using $readmemb and $readmemh"
// template later in this section.
initial
begin
$readmemb("rom_instructions_wo_underscore.bin", rom);
end
always @ (addr)
begin
q <= rom[addr];
end
endmodule