-
Notifications
You must be signed in to change notification settings - Fork 0
/
rom16_8bit.v
47 lines (43 loc) · 1.44 KB
/
rom16_8bit.v
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
44
45
46
47
module rom16_8bit(
input [3:0] addr,
input low_o_en,
output reg [7:0] data_out
);
always @(addr or low_o_en)
begin
if(low_o_en)
begin
data_out = 8'bzzzzzzzz;
end
else
begin
// Change the RHS values in the assignments below to change the program that the simulation runs.
// The computer will subtract the value at address 0x9 from the value present in address 0x8 and display the output.
// 1 - 8 = -7
// The instructions are:
// LDA 0x8
// SUB 0x9
// OUT
// HLT
// Output: 0x11111001 (-7 as 2's complement)
case(addr)
4'h0: data_out = 8'h08; // Program memory starts here.
4'h1: data_out = 8'h29;
4'h2: data_out = 8'hee;
4'h3: data_out = 8'hff;
4'h4: data_out = 8'h00;
4'h5: data_out = 8'h00;
4'h6: data_out = 8'h00;
4'h7: data_out = 8'h00;
4'h8: data_out = 8'h01; // Data memory starts from here.
4'h9: data_out = 8'h08;
4'ha: data_out = 8'h00;
4'hb: data_out = 8'h00;
4'hc: data_out = 8'h00;
4'hd: data_out = 8'h00;
4'he: data_out = 8'h00;
4'hf: data_out = 8'h00;
endcase
end
end
endmodule