-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregfile.luc
More file actions
76 lines (66 loc) · 2.05 KB
/
regfile.luc
File metadata and controls
76 lines (66 loc) · 2.05 KB
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
module regfile (
input clk, // clock
input rst, // reset
input read_address_a[4], //address port a
input read_address_b[4], //address port b
input write_address[16],
input write_data[16],
input write_enable,
output read_data_a[16],
output read_data_b[16],
//debug
// output level_out[16],
// output row_out[16],
output position_out[16],
output last_row_out[16],
output player_level_out[16],
output player_row_out[16]
) {
.clk(clk){
.rst(rst){
dff player_level[16](#INIT(b00000001));
dff player_row[16](#INIT(0));
dff player_position[16](#INIT(b00010000));
dff mazeLastRow[16](#INIT(b00000000));
dff temp_var[16];
}
}
always {
// write port
if (write_enable){
case(write_address){
b0011 : player_level.d = write_data;
b0010 : player_row.d = write_data;
b0100 : player_position.d = write_data;
b0101 : mazeLastRow.d = write_data;
b1111 : temp_var.d = write_data;
}
}
//read port a
case(read_address_a){
b0011 : read_data_a = player_level.q;
b0010 : read_data_a = player_row.q;
b0100 : read_data_a = player_position.q;
b0101 : read_data_a = mazeLastRow.q;
b1111 : read_data_a = temp_var.q;
default : read_data_a = 0;
}
//read port b
case(read_address_b){
b0011 : read_data_b = player_level.q;
b0010 : read_data_b = player_row.q;
b0100 : read_data_b = player_position.q;
b0101 : read_data_b = mazeLastRow.q;
b1111 : read_data_b = temp_var.q;
default : read_data_b = 0;
}
//For debugging
// level_out = player_level.q;
// row_out = player_row.q;
// position_out = player_position.q;
last_row_out = mazeLastRow.q;
position_out = player_position.q;
player_level_out = player_level.q;
player_row_out = player_row.q;
}
}