Skip to content

Commit

Permalink
Emulator now correctly supports 'stacked' PHROMs allowing multiple PH…
Browse files Browse the repository at this point in the history
…ROMs to be used at once
  • Loading branch information
Simon Inns committed Jun 28, 2018
1 parent c6f6635 commit 5c4531c
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 53 deletions.
69 changes: 53 additions & 16 deletions Firmware/tms6100/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ uint8_t m0ReadyReceived;
uint8_t outputBuffer;
uint8_t outputBufferPointer;

uint8_t outputEnabled;

// Initialise the AVR hardware
void initialiseHardware(void)
{
Expand Down Expand Up @@ -109,6 +111,7 @@ void initialiseHardware(void)
// Initialise the output buffer
outputBuffer = 0xFF;
outputBufferPointer = 0;
outputEnabled = FALSE;

// Initialise the SPI pins (no longer used in this firmware)
// (MISO configured by ADD8)
Expand Down Expand Up @@ -138,29 +141,42 @@ void m0SignalHandler(void) //ISR(TMS6100_M0_INT_VECT)
// This is the first M0 pulse after a M1 pulse (the 'ready' pulse)
m0ReadyReceived = TRUE;

// Load the byte to be transmitted
//uint32_t currentBank = (currentAddress & 0x3C000) >> 14; // 0b 0011 1100 0000 0000 0000 = 0x03C000
// Get the current bank and local address
uint32_t currentBank = (currentAddress & 0x3C000) >> 14; // 0b 0011 1100 0000 0000 0000 = 0x03C000
uint32_t localAddress = (currentAddress & 0x3FFF); // 0b 0000 0011 1111 1111 1111 = 0x03FFF
outputBuffer = pgm_read_byte(&(phromData[localAddress]));

// Reset the buffer pointer
outputBufferPointer = 0; // LSB to MSB
// Load the byte to be transmitted (if this is our bank)
if (currentBank == PHROM_BANK) {
// Load the output buffer
outputBuffer = pgm_read_byte(&(phromData[localAddress]));

// Set the ADD8 bus pin to output mode and set the pin high
// (as this is what the original TMS6100 does)
TMS6100_ADD8_DDR |= TMS6100_ADD8;
TMS6100_ADD8_PORT |= TMS6100_ADD8;
outputEnabled = TRUE;
} else outputBuffer = 0x00;

// Set the ADD8 bus pin to output mode and set the pin high
// (as this is what the original TMS6100 does)
TMS6100_ADD8_DDR |= TMS6100_ADD8;
TMS6100_ADD8_PORT |= TMS6100_ADD8;
// Reset the buffer pointer
outputBufferPointer = 0;

// Show M0 handler inactive in debug
DEBUG0_PORT &= ~DEBUG0;
} else {
// Show M0 handler active in debug
DEBUG1_PORT |= DEBUG1;

// This is a data read M0 pulse

// Set the data on the output pin (so it is valid when the falling edge of M0 occurs)
if (outputBuffer & (1 << outputBufferPointer)) TMS6100_ADD8_PORT |= TMS6100_ADD8;
else TMS6100_ADD8_PORT &= ~TMS6100_ADD8;
// Get the current bank and local address
uint32_t currentBank = (currentAddress & 0x3C000) >> 14; // 0b 0011 1100 0000 0000 0000 = 0x03C000

// Load the byte to be transmitted (if this is our bank)
if (currentBank == PHROM_BANK) {
// Set the data on the output pin (so it is valid when the falling edge of M0 occurs)
if (outputBuffer & (1 << outputBufferPointer)) TMS6100_ADD8_PORT |= TMS6100_ADD8;
else TMS6100_ADD8_PORT &= ~TMS6100_ADD8;
}

// Increment the bit pointer
outputBufferPointer += 1;
Expand All @@ -174,11 +190,30 @@ void m0SignalHandler(void) //ISR(TMS6100_M0_INT_VECT)
// Get the next byte to transmit
currentAddress++;

//uint32_t currentBank = (currentAddress & 0x3C000) >> 14; // 0b 0011 1100 0000 0000 0000 = 0x03C000
// Get the current bank and local address
uint32_t currentBank = (currentAddress & 0x3C000) >> 14; // 0b 0011 1100 0000 0000 0000 = 0x03C000
uint32_t localAddress = (currentAddress & 0x3FFF); // 0b 0000 0011 1111 1111 1111 = 0x03FFF

outputBuffer = pgm_read_byte(&(phromData[localAddress]));
outputBufferPointer = 0;

// Load the byte to be transmitted (if this is our bank)
if (currentBank == PHROM_BANK) {
// Load the output buffer
outputBuffer = pgm_read_byte(&(phromData[localAddress]));

// Reset the buffer pointer
outputBufferPointer = 0;

// If the output is disabled, enable it now
// Note: this is for the edge case where a sequence of reads
// cross a PHROM bank boundary
if (outputEnabled == FALSE) {
TMS6100_ADD8_DDR |= TMS6100_ADD8;
TMS6100_ADD8_PORT |= TMS6100_ADD8;
outputEnabled = TRUE;
}
} else {
outputBuffer = 0x00;
outputBufferPointer = 0;
}
}
}

Expand All @@ -193,6 +228,8 @@ void m1SignalHandler(void)

// Set the ADD8 bus pin to input mode
TMS6100_ADD8_DDR &= ~TMS6100_ADD8;
TMS6100_ADD8_PORT &= ~TMS6100_ADD8;
outputEnabled = FALSE;

// Read the nibble from the address bus
if ((TMS6100_ADD1_PIN & TMS6100_ADD1)) addressNibble += 1;
Expand Down
74 changes: 37 additions & 37 deletions Firmware/tms6100/tms6100.cproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,43 +83,43 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>-mmcu=atmega32u2 -B "%24(PackRepoDir)\Atmel\ATmega_DFP\1.0.106\gcc\dev\atmega32u2"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
<Value>PHROM_ACORN</Value>
<Value>F_CPU=16000000UL</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\Atmel\ATmega_DFP\1.0.106\include</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\Atmel\ATmega_DFP\1.0.106\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc>
<avrgcc.common.Device>-mmcu=atmega32u2 -B "%24(PackRepoDir)\Atmel\ATmega_DFP\1.0.106\gcc\dev\atmega32u2"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
<Value>PHROM_ACORN</Value>
<Value>F_CPU=16000000UL</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\Atmel\ATmega_DFP\1.0.106\include</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\Atmel\ATmega_DFP\1.0.106\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
Expand Down

0 comments on commit 5c4531c

Please sign in to comment.