|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2023 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: // キャッシュ
8:
9: #pragma once
10:
11: #include "m68030.h"
1.1.1.2 ! root 12: #include <array>
! 13: #include <mutex>
! 14: #include "fixedqueue.h"
1.1 root 15:
16: // キャッシュライン
17: struct m68030CacheLine
18: {
19: // タグは命令キャッシュ/データキャッシュで共通だが、
1.1.1.2 ! root 20: // 命令キャッシュなら bit2 が S (FC2)、
! 21: // データキャッシュなら下位3ビットが FC (2,1,0 の順)。
1.1 root 22: // 3 2 1
23: // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
24: // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1.1.1.2 ! root 25: // |S|1|0|S| Tag Address (24bit) | | (Inst)
1.1 root 26: // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27: //
28: // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1.1.1.2 ! root 29: // |FC2-0|S| Tag Address (24bit) | | (Data)
1.1 root 30: // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31: uint32 tag {};
32: union {
33: uint32 valid_all {};
34: uint8 valid[4];
35: };
1.1.1.2 ! root 36: std::array<uint32, 4> data {};
1.1 root 37:
1.1.1.2 ! root 38: bool IsSuper() const { return (tag & 0x80000000); }
! 39: uint32 GetFC() const { return (tag >> 29); }
! 40: uint32 TagAddr() const { return (tag << 4); }
! 41: };
! 42:
! 43: // キャッシュの統計情報
! 44: struct m68030CacheStat
! 45: {
! 46: float hit; // ヒット率
1.1 root 47: };
48:
49: // キャッシュ (命令/データ共通)
50: class m68030Cache
51: {
52: public:
1.1.1.2 ! root 53: // キャッシュイネーブル。
! 54: bool enable {};
! 55:
! 56: // 凍結なら true。
! 57: bool freeze {};
! 58:
! 59: // バースト転送可能かつ許可なら true。
! 60: bool burst_enable {};
! 61:
! 62: // データキャッシュのライトアロケート。
! 63: bool wa {};
! 64:
! 65: // キャッシュ。
1.1 root 66: std::array<m68030CacheLine, 16> line {};
1.1.1.2 ! root 67:
! 68: // 統計情報。
! 69: uint32 stat_fasthit {}; // ファストパスでのヒット回数
! 70: uint32 stat_hit {}; // 通常パスでのヒット回数
! 71: uint32 stat_miss {}; // 通常パスでのミス回数
! 72:
! 73: // 移動平均用バッファ。
! 74: FixedQueue<m68030CacheStat, 3> hist {};
! 75: std::mutex hist_mtx {};
! 76:
! 77: public:
! 78: void CalcStat();
1.1 root 79: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.