Archived
finish(maybe...)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
namespace VMdemo.Core
|
||||
{
|
||||
public enum AddressGenerationMode
|
||||
{
|
||||
RandomUniform = 0,
|
||||
SequentialArrayLoop = 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d91aaaf0f71455ba5f1707f02b3f7b7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -40,9 +40,21 @@ namespace VMdemo.Core
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config.vaBits != 32 && config.vaBits != 48 && config.vaBits != 64)
|
||||
if (config.machineBits <= 0 || config.machineBits > 64)
|
||||
{
|
||||
errorMessage = "vaBits 仅支持 32、48、64。";
|
||||
errorMessage = "machineBits 必须在 1 到 64 之间。";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config.vaBits != 8 && config.vaBits != 16 && config.vaBits != 24)
|
||||
{
|
||||
errorMessage = "vaBits 仅支持 8、16、24。";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config.vaBits > config.machineBits)
|
||||
{
|
||||
errorMessage = $"vaBits 不能大于 machineBits,当前 vaBits={config.vaBits}, machineBits={config.machineBits}。";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -82,6 +94,31 @@ namespace VMdemo.Core
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config.arrayLengthBytes <= 0)
|
||||
{
|
||||
errorMessage = "arrayLengthBytes 必须是正整数。";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config.arrayElementBytes <= 0)
|
||||
{
|
||||
errorMessage = "arrayElementBytes 必须是正整数。";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config.arrayBaseAddress < 0)
|
||||
{
|
||||
errorMessage = "arrayBaseAddress 不能为负数。";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config.addressGenerationMode == AddressGenerationMode.SequentialArrayLoop &&
|
||||
config.arrayLengthBytes < config.arrayElementBytes)
|
||||
{
|
||||
errorMessage = "SequentialArrayLoop 模式下 arrayLengthBytes 必须 >= arrayElementBytes。";
|
||||
return false;
|
||||
}
|
||||
|
||||
var pageSizeBytes = config.PageSizeBytes;
|
||||
if (!TryGetLog2(pageSizeBytes, out var offsetBits))
|
||||
{
|
||||
|
||||
@@ -5,12 +5,32 @@ namespace VMdemo.Core
|
||||
[Serializable]
|
||||
public class SimulationConfig
|
||||
{
|
||||
public int vaBits = 32;
|
||||
public int pageSizeKB = 4;
|
||||
public int physicalMemoryMB = 64;
|
||||
public int tlbEntries = 16;
|
||||
public const int FixedMachineBits = 32;
|
||||
public const int FixedVaBits = 24;
|
||||
public const int FixedPageSizeKB = 4;
|
||||
public const int FixedPhysicalMemoryMB = 1;
|
||||
public const int FixedTlbEntries = 8;
|
||||
|
||||
public int machineBits = FixedMachineBits;
|
||||
public int vaBits = FixedVaBits;
|
||||
public int pageSizeKB = FixedPageSizeKB;
|
||||
public int physicalMemoryMB = FixedPhysicalMemoryMB;
|
||||
public int tlbEntries = FixedTlbEntries;
|
||||
public int accessCount = 100;
|
||||
public int pageFaultPenalty = 100;
|
||||
public AddressGenerationMode addressGenerationMode = AddressGenerationMode.SequentialArrayLoop;
|
||||
public int arrayLengthBytes = 256;
|
||||
public int arrayElementBytes = 4;
|
||||
public int arrayBaseAddress = 0;
|
||||
|
||||
public void ApplyFixedCoreSpec()
|
||||
{
|
||||
machineBits = FixedMachineBits;
|
||||
vaBits = FixedVaBits;
|
||||
pageSizeKB = FixedPageSizeKB;
|
||||
physicalMemoryMB = FixedPhysicalMemoryMB;
|
||||
tlbEntries = FixedTlbEntries;
|
||||
}
|
||||
|
||||
public ulong PageSizeBytes => pageSizeKB > 0 ? (ulong)pageSizeKB * 1024UL : 0UL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user