blob: a6772f351de6101750177953e1044aecae458c52 (
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
|
#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 fetch_bundle {
infra::transaction tr;
unsigned int gen;
unsigned int pc;
memory::line data;
};
struct fetch_restart {
infra::transaction tr;
unsigned int new_gen;
unsigned int new_pc;
};
struct fetch_stage : public infra::sim {
core &c;
memory::inline_cache<8, 2> cache;
unsigned int gen = 0;
unsigned int pc;
bool didrestart = false;
bool outstandingfill = false;
fetch_stage(core &c);
void clock();
};
struct decode_stage : public infra::sim {
core &c;
unsigned int gen = 0;
bool interrupt = false;
unsigned int acc;
unsigned int link;
unsigned int mq;
unsigned int pc;
std::array<uint_fast32_t, NUM_CTLREGS> ctlregs;
std::uint64_t icount;
instruction_context inst;
bool outstandingfill = false;
decode_stage(core &c);
void clock();
};
struct core {
iomodel &system;
funcchecker checker;
memory::dram mem{12};
infra::port<memory::dram::command> mem_commandp;
infra::priority_arbiter<memory::dram::command, 2> 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;
std::optional<fetch_restart> fetch_restarto;
infra::port<memory::dram::command> decode_mem_commandp;
infra::port<memory::dram::response> decode_mem_responsep;
// Construction order is execution order within a cycle, so this list should be back-to-front (for zero-cycle restarts)
decode_stage decode{*this};
fetch_stage fetch{*this};
core(iomodel &model)
: system(model)
, checker(model)
{
mem.commandp = &mem_commandp;
mem_command_arb.outp = &mem_commandp;
mem_command_arb.peerp[0] = &decode_mem_commandp;
mem_command_arb.peerp[1] = &fetch_mem_commandp;
}
};
|