mirror of
https://github.com/livingcomputermuseum/sImlac.git
synced 2026-01-11 23:53:24 +00:00
Made memory size configurable. Defaults to 8KW.
This commit is contained in:
parent
d54292d346
commit
18bb3eb9bd
@ -45,8 +45,8 @@ namespace imlac
|
||||
{
|
||||
_system = system;
|
||||
_mem = _system.Memory;
|
||||
_instructionCache = new DisplayInstruction[Memory.Size];
|
||||
_dtStack = new Stack<ushort>(8);
|
||||
InitializeCache();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
@ -156,6 +156,11 @@ namespace imlac
|
||||
get { return _dpcEntry; }
|
||||
}
|
||||
|
||||
public void InitializeCache()
|
||||
{
|
||||
_instructionCache = new DisplayInstruction[Memory.Size];
|
||||
}
|
||||
|
||||
public void InvalidateCache(ushort address)
|
||||
{
|
||||
_instructionCache[address & Memory.SizeMask] = null;
|
||||
|
||||
@ -166,7 +166,7 @@ namespace imlac.IO
|
||||
private byte _txData;
|
||||
|
||||
private int _clocks;
|
||||
private readonly int _dataClocks = 100;
|
||||
private readonly int _dataClocks = 250;
|
||||
|
||||
private ISerialDataChannel _dataChannel;
|
||||
|
||||
|
||||
@ -15,15 +15,39 @@
|
||||
along with sImlac. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace imlac
|
||||
{
|
||||
// TODO: make memory size configurable.
|
||||
public class Memory
|
||||
{
|
||||
public Memory(ImlacSystem system)
|
||||
{
|
||||
_mem = new ushort[Size];
|
||||
{
|
||||
_system = system;
|
||||
SetMemorySize(0x2000);
|
||||
}
|
||||
|
||||
public void SetMemorySize(ushort size)
|
||||
{
|
||||
if (size != 0x1000 && size != 0x2000 && size != 0x4000)
|
||||
{
|
||||
throw new InvalidOperationException("Size must be 4k, 8k, or 16k.");
|
||||
}
|
||||
|
||||
_size = size;
|
||||
_sizeMask = (ushort)(size - 1);
|
||||
|
||||
_mem = new ushort[Size];
|
||||
|
||||
if (_system.Processor != null)
|
||||
{
|
||||
_system.Processor.InitializeCache();
|
||||
}
|
||||
|
||||
if (_system.DisplayProcessor != null)
|
||||
{
|
||||
_system.DisplayProcessor.InitializeCache();
|
||||
}
|
||||
}
|
||||
|
||||
public ushort Fetch(ushort address)
|
||||
@ -44,13 +68,16 @@ namespace imlac
|
||||
|
||||
public static ushort Size
|
||||
{
|
||||
get { return 0x4000; }
|
||||
get { return _size; }
|
||||
}
|
||||
|
||||
public static ushort SizeMask
|
||||
{
|
||||
get { return 0x3fff; }
|
||||
}
|
||||
get { return _sizeMask; }
|
||||
}
|
||||
|
||||
private static ushort _size;
|
||||
private static ushort _sizeMask;
|
||||
|
||||
private ushort[] _mem;
|
||||
private ImlacSystem _system;
|
||||
|
||||
@ -43,11 +43,11 @@ namespace imlac
|
||||
{
|
||||
_system = system;
|
||||
_mem = _system.Memory;
|
||||
_instructionCache = new Instruction[Memory.Size];
|
||||
|
||||
_iotDispatch = new IIOTDevice[0x200]; // 9 bits of IOT instructions
|
||||
|
||||
Reset();
|
||||
InitializeCache();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
@ -119,6 +119,11 @@ namespace imlac
|
||||
return GetCachedInstruction(address).Disassemble(address);
|
||||
}
|
||||
|
||||
public void InitializeCache()
|
||||
{
|
||||
_instructionCache = new Instruction[Memory.Size];
|
||||
}
|
||||
|
||||
public void InvalidateCache(ushort address)
|
||||
{
|
||||
_instructionCache[address & Memory.SizeMask] = null;
|
||||
@ -578,7 +583,7 @@ namespace imlac
|
||||
}
|
||||
|
||||
private ushort GetEffectiveAddress(ushort baseAddress)
|
||||
{
|
||||
{
|
||||
return (ushort)((_pc & (Memory.SizeMask & 0xf800)) | (baseAddress & 0x07ff));
|
||||
}
|
||||
|
||||
|
||||
@ -254,6 +254,29 @@ namespace imlac
|
||||
return SystemExecutionState.Debugging;
|
||||
}
|
||||
|
||||
[DebuggerFunction("set memory size 4kw", "Sets memory size to 4KW")]
|
||||
private SystemExecutionState SetMemorySize4kw()
|
||||
{
|
||||
_memory.SetMemorySize(0x1000);
|
||||
return SystemExecutionState.Debugging;
|
||||
}
|
||||
|
||||
|
||||
[DebuggerFunction("set memory size 8kw", "Sets memory size to 8KW")]
|
||||
private SystemExecutionState SetMemorySize8kw()
|
||||
{
|
||||
_memory.SetMemorySize(0x2000);
|
||||
return SystemExecutionState.Debugging;
|
||||
}
|
||||
|
||||
|
||||
[DebuggerFunction("set memory size 16kw", "Sets memory size to 16KW")]
|
||||
private SystemExecutionState SetMemorySize16kw()
|
||||
{
|
||||
_memory.SetMemorySize(0x4000);
|
||||
return SystemExecutionState.Debugging;
|
||||
}
|
||||
|
||||
[DebuggerFunction("set logging", "Sets the logging configuration", "<loglevel>")]
|
||||
private SystemExecutionState SetLogging(LogType value)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user