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
|
`include "core/uarch.sv"
module core_cycles
(
input logic clk,
dec_execute,
dec_branch,
dec_writeback,
dec_update_flags,
input ptr dec_branch_offset,
input alu_decode dec_alu,
input ptr fetch_insn_pc,
output logic stall,
branch,
writeback,
update_flags,
output reg_num rd,
output ptr branch_target,
pc,
pc_visible,
output psr_mode reg_mode,
output alu_control alu
);
enum
{
EXECUTE
} cycle, next_cycle;
assign stall = next_cycle != EXECUTE;
assign pc_visible = pc + 2;
assign next_cycle = EXECUTE; //TODO
assign reg_mode = `MODE_SVC; //TODO
always_ff @(posedge clk) begin
cycle <= next_cycle;
if(next_cycle == EXECUTE) begin
branch <= 0;
writeback <= 0;
update_flags <= 0;
branch_target <= 30'bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
if(dec_execute) begin
branch <= dec_branch;
writeback <= dec_writeback;
branch_target <= pc_visible + dec_branch_offset;
end
alu.op <= dec_alu.op;
alu.shl <= dec_alu.shl;
alu.shr <= dec_alu.shr;
alu.ror <= dec_alu.ror;
alu.put_carry <= dec_alu.put_carry;
alu.sign_extend <= dec_alu.sign_extend;
pc <= fetch_insn_pc;
rd <= dec_alu.rd;
update_flags <= dec_update_flags;
end
end
initial begin
cycle = EXECUTE;
branch = 1;
writeback = 0;
branch_target = 30'd0;
pc = 0;
end
endmodule
|