summaryrefslogtreecommitdiff
path: root/cpu.h
blob: 5ef45a0d0219a2d84995d42e58f16e0410427c70 (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
#pragma once

#include <cstdint>
#include <cstring>
#include <optional>

#include "backend/exec.h"
#include "backend/regfile.h"
#include "frontend/decode.h"
#include "frontend/fetch.h"
#include "infra/arbiter.h"
#include "infra/pipetrace.h"
#include "infra/queue.h"
#include "infra/sim.h"
#include "inst.h"
#include "memory/dram.h"

struct cpu {
    backend::exec exec;
    backend::regfile regfile;
    frontend::decode decode;
    frontend::fetch fetch;
    infra::priority_arbiter<memory::dram::command, 3> dram_arbiter;
    infra::queue<inst, 4> decodeq;
    memory::dram dram;

    cpu() {
        decode.fetch_restartp = &fetch.restartp;
        decode.instp = &decodeq.input;
        decodeq.output = &regfile.instp;
        dram_arbiter.outp = &dram.commandp;
        exec.loadp = &dram_arbiter.peerp[1];
        exec.writebackp = &regfile.writebackp;
        fetch.bundlep = &decode.bundlep;
        fetch.commandp = &dram_arbiter.peerp[2];
        regfile.decode_restartp = &decode.restartp;
        regfile.execp = &exec.execp;
        regfile.storep = &dram_arbiter.peerp[0];
    }
};