blob: b53a205a49ac989c135e946e2bf9dec10c41105e (
plain) (
blame)
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
|
#pragma once
#include <array>
#include "infra/arbiter.h"
#include "infra/pipetrace.h"
#include "infra/port.h"
#include "io/model.h"
#include "isa/checker.h"
#include "isa/isa.h"
#include "memory/cache.h"
#include "memory/dram.h"
struct core;
struct restart {
infra::transaction tr;
unsigned int new_pc;
bool interrupt;
};
struct fetch_bundle {
infra::transaction tr;
unsigned int gen;
unsigned int pc;
memory::line data;
};
struct inst_bundle {
infra::transaction tr;
unsigned int gen;
unsigned int pc;
std::uint64_t icount;
instruction_context inst;
};
struct fetch_stage : public infra::sim {
core &c;
memory::inline_cache<8, 2> cache;
unsigned int pc;
bool didrestart = false;
bool outstandingfill = false;
fetch_stage(core &c);
void clock();
};
struct decode_stage : public infra::sim {
core &c;
bool interrupt = false;
unsigned int pc;
std::uint64_t icount;
decode_stage(core &c);
void clock();
};
struct indir_stage : public infra::sim {
core &c;
unsigned int gen = 0;
indir_stage(core &c);
void clock();
};
struct exec_stage : public infra::sim {
core &c;
unsigned int gen = 0;
unsigned int acc;
unsigned int link;
unsigned int mq;
unsigned int pc;
std::array<uint_fast32_t, NUM_CTLREGS> ctlregs;
exec_stage(core &c);
void clock();
};
struct core {
iomodel &system;
funcchecker checker;
std::optional<restart> restarto;
unsigned int gen = 0;
std::uint64_t icount;
memory::dram mem{0};
infra::port<memory::dram::command> mem_commandp;
infra::priority_arbiter<memory::dram::command, 5> mem_command_arb;
infra::port<memory::dram::command> fetch_mem_commandp;
infra::port<memory::dram::response> fetch_mem_responsep;
infra::port<fetch_bundle> fetch_bundlep;
infra::port<memory::dram::command> decode_mem_commandp;
infra::port<memory::dram::response> decode_mem_responsep;
infra::port<inst_bundle> decode_to_exec_instp;
infra::port<inst_bundle> indir_instp;
infra::port<memory::dram::command> indir_mem_load_commandp;
infra::port<memory::dram::command> indir_mem_store_commandp;
infra::port<memory::dram::response> indir_mem_responsep;
infra::port<inst_bundle> indir_to_exec_instp;
infra::port<memory::dram::command> exec_mem_commandp;
infra::port<memory::dram::response> exec_mem_responsep;
// Construction order is execution order within a cycle, so this list should be back-to-front (for zero-cycle restarts)
exec_stage exec{*this};
indir_stage indir{*this};
decode_stage decode{*this};
fetch_stage fetch{*this};
core(iomodel &model)
: system(model)
, checker(model)
, icount(checker.icount)
{
mem.commandp = &mem_commandp;
mem_command_arb.outp = &mem_commandp;
mem_command_arb.peerp[0] = &exec_mem_commandp;
mem_command_arb.peerp[1] = &indir_mem_store_commandp;
mem_command_arb.peerp[2] = &indir_mem_load_commandp;
mem_command_arb.peerp[3] = &decode_mem_commandp;
mem_command_arb.peerp[4] = &fetch_mem_commandp;
}
};
|