-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatapath.luc
68 lines (59 loc) · 1.41 KB
/
datapath.luc
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
module datapath (
input clk, // clock
input rst, // reset_conditioner
input random_value[16],
input ra_address[3],
input rb_address[3],
input write_address[3],
input we,
input asel[2],
input bsel[2],
input alufn[6],
input wdsel[2],
input current_button_press[16],
output rb_data[16],
output p1_score[16],
output p2_score[16],
output led_state[16]
) {
alu alu;
regfile regfile(.clk(clk), .rst(rst));
sig a[16];
sig b[16];
sig wdsel_out[16];
always {
regfile.ra_address = ra_address;
regfile.rb_address = rb_address;
regfile.write_address = write_address;
regfile.we = we;
rb_data = regfile.rb_data;
p1_score = regfile.p1_score;
p2_score = regfile.p2_score;
led_state = regfile.led_state;
a = 0;
b = 0;
wdsel_out = 0;
case (bsel){
b00: b = regfile.rb_data;
b01: b = b1;
b10: b = d7;
b11: b = d32; // max score, change to 99 later on if desired
}
case (asel){
b00: a = regfile.ra_data;
b01: a = b0;
b10: a = b1;
b11: a = random_value;
}
alu.a = a;
alu.b = b;
alu.alufn_signal = alufn;
case (wdsel){
b00: wdsel_out = alu.out;
b01: wdsel_out = 16hFFFF;
b10: wdsel_out = current_button_press;
b11: wdsel_out = 0;
}
regfile.write_data = wdsel_out;
}
}