forked from fan19-hub/ECE385-Dad-n-Me-on-FPGA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMe_ROM.sv
executable file
·164 lines (157 loc) · 4.27 KB
/
Me_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
module Me_ROM
(
input [7:0] state,
input [15:0] relative_address,
input Clk,frame_clk, Reset,
output logic [23:0] data_Out
);
// mem has width of 3 bits and a total of 400 addresses
logic [2:0] mem1 [0:10000];
logic [2:0] mem2 [0:10000];
logic [2:0] mem_a0 [0:12000];
logic [2:0] mem_a1 [0:12000];
logic [2:0] mem_a2 [0:12000];
logic [7:0] index;
initial
begin
$readmemb("sprite_bytes/1.txt", mem1);
$readmemb("sprite_bytes/2.txt", mem2);
$readmemb("sprite_bytes/a_0.txt", mem_a0);
$readmemb("sprite_bytes/a_1.txt", mem_a1);
$readmemb("sprite_bytes/a_2.txt", mem_a2);
end
logic [7:0] index_buffer;
always_ff @ (posedge Clk) begin
index<= index_buffer;
end
always_comb
begin
index_buffer=mem1[relative_address];
if(state===8'h02)
index_buffer=mem2[relative_address];
if(state===8'h06 || state===8'h08)
index_buffer=mem_a0[relative_address];
if(state===8'h07 || state===8'h05)
index_buffer=mem_a1[relative_address];
if(state===8'h09)
index_buffer=mem_a2[relative_address];
end
always_comb
begin
unique case (index)
3'h0: data_Out=24'ha664ff;
3'h1: data_Out=24'h9140ff;
3'h2: data_Out=24'hffffff;
3'h3: data_Out=24'h666666;
3'h4: data_Out=24'h000000;
3'h7: data_Out=24'h0000ff;
default : data_Out = 24'h000000; //by default, black
endcase
end
endmodule
//module Me_ROM
//(
// input [7:0] state,
// input [15:0] relative_address,
// input Clk,frame_clk, Reset,
// output logic [7:0] data_Out
//);
//
//// mem has width of 3 bits and a total of 400 addresses
//logic [7:0] mem1 [0:10000];
//logic [7:0] mem2 [0:10000];
//
//logic [7:0] mem_a0 [0:12000];
//logic [7:0] mem_a1 [0:12000];
//logic [7:0] mem_a2 [0:12000];
//
//initial
//begin
// $readmemh("sprite_bytes/1.txt", mem1);
// $readmemh("sprite_bytes/2.txt", mem2);
//// $readmemh("sprite_bytes/enemy.txt", mem3);
// $readmemh("sprite_bytes/a_0.txt", mem_a0);
// $readmemh("sprite_bytes/a_1.txt", mem_a1);
// $readmemh("sprite_bytes/a_2.txt", mem_a2);
//end
//logic [7:0] data_out_buffer;
//always_ff @ (posedge Clk) begin
// data_Out<= data_out_buffer;
//// Width<=Width_in;
//// Height<=Height_in;
//end
//always_comb
//begin
// data_out_buffer=mem1[relative_address];
// if(state===8'h02)
// data_out_buffer=mem2[relative_address];
// if(state===8'h06 || state===8'h08)
// data_out_buffer=mem_a0[relative_address];
// if(state===8'h07 || state===8'h05)
// data_out_buffer=mem_a1[relative_address];
// if(state===8'h09)
// data_out_buffer=mem_a2[relative_address];
//
//
//end
//
//endmodule
////
////module Me_ROM
////(
//// input [7:0] state,
//// input [15:0] relative_address,
//// input Clk,frame_clk, Reset,
//// output logic [23:0] data_Out
////);
////
////// mem has width of 3 bits and a total of 400 addresses
////logic [2:0] mem1 [0:10000];
////logic [2:0] mem2 [0:10000];
////logic [2:0] mem_a0 [0:12000];
////logic [2:0] mem_a1 [0:12000];
////logic [2:0] mem_a2 [0:12000];
////
////initial
////begin
//// $readmemb("sprite_bytes/1.txt", mem1);
//// $readmemb("sprite_bytes/2.txt", mem2);
//// $readmemb("sprite_bytes/a_0.txt", mem_a0);
//// $readmemb("sprite_bytes/a_1.txt", mem_a1);
//// $readmemb("sprite_bytes/a_2.txt", mem_a2);
////end
////logic [7:0] index_buffer;
////always_ff @ (posedge Clk) begin
//// index<= index_buffer;
////// Width<=Width_in;
////// Height<=Height_in;
////end
////always_comb
////begin
//// index_buffer=mem1[relative_address];
//// if(state===8'h02)
//// index_buffer=mem2[relative_address];
//// if(state===8'h06 || state===8'h08)
//// index_buffer=mem_a0[relative_address];
//// if(state===8'h07 || state===8'h05)
//// index_buffer=mem_a1[relative_address];
//// if(state===8'h09)
//// index_buffer=mem_a2[relative_address];
////end
////
////always_comb
//// begin
//// unique case (index)
//// 3'h0: data_Out=24'ha664ff;
//// 3'h1: data_Out=24'h9140ff;
//// 3'h2: data_Out=24'hffffff;
//// 3'h3: data_Out=24'h666666;
//// 3'h4: data_Out=24'h000000;
//// 3'h7: data_Out=24'h0000ff;
//// default : data_Out = 24'h000000; //by default, black
//// endcase
//// end
////
////
////
////endmodule