sim0004.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <HTML>
  2. <HEAD>
  3. <META NAME="Generator" CONTENT="Corel WordPerfect 8">
  4. <TITLE>68HC12 Simulator Implementation Notes</TITLE>
  5. </HEAD>
  6. <BODY TEXT="#000000" LINK="#0000ff" VLINK="#551a8b" ALINK="#ff0000" BGCOLOR="#ffffff">
  7. <H1><A NAME="0top"></A>68HC12 Simulator Implementation Notes</H1>
  8. <P>The 68HC12 Simulator is written in Java in a modular fashion so it can be modified for specific needs. Here is the status of the
  9. various modules. "NYI" means Not Yet Implemented. "UI" means User Interface.</P>
  10. <P>Index</P>
  11. <UL>
  12. <LI><A HREF="#CPU12">CPU12</A></LI>
  13. <LI><A HREF="#Memory">Memory</A></LI>
  14. <LI><A HREF="#UI Execution control">User Interface Execution Control</A></LI>
  15. <LI>68HC12 Technical Summary</LI>
  16. <UL>
  17. <LI><A HREF="#Reference to 68HC12 Technical Summary">4 Register Block</A></LI>
  18. <LI><A HREF="#5 Bus Control and Input/Output">5 Bus Control and Input/Output</A></LI>
  19. <LI><A HREF="#6 Operating Modes and Resource Mapping">6 Operating Modes and Resource Mapping</A></LI>
  20. <LI><A HREF="#7 EEPROM">7 EEPROM</A></LI>
  21. <LI><A HREF="#8 Memory Expansion and Chip Select">8 Memory Expansion and Chip Select</A></LI>
  22. <LI><A HREF="#9 Resets and Interrupts">9 Resets and Interrupts</A></LI>
  23. <LI><A HREF="#10 Key wakeups">10 Key Wakeups</A></LI>
  24. <LI><A HREF="#11 Clock functions">11 Clock Functions</A></LI>
  25. <LI><A HREF="#12 PLL">12 Phase-Locked Loop</A></LI>
  26. <LI><A HREF="#13 Standard Timer Module">13 Standard Timer Module</A></LI>
  27. <LI><A HREF="#14 Multiple Serial Interface">14 Multiple Serial Interface</A></LI>
  28. <LI><A HREF="#15 Analog to Digital Converter">15 Analog to Digital Converter</A></LI>
  29. </UL>
  30. </UL>
  31. <H2><A NAME="CPU12"></A>CPU12</H2>
  32. <P>All instructions are simulated. Invalid operand bytes will cause an exception (which doesn't happen in a real 68HC12). The
  33. BGND instruction is simulated by causing an exception. This allow stopping a simulation programatically.</P>
  34. <P>Instruction timing is intended to match the real processor, however the order of memory accesses might vary in ways which
  35. should not affect any results. Also, all time is considered to be taken at the end of instruction execution, which, for example,
  36. will mean that reading TCNT will give a different (and larger) value than would be obtained in a real 68HC12.</P>
  37. <P>CPU registers are observable via the RegisterView display panel. Current state ("Running", "Waiting", "Stopped") is also
  38. observable. In the register view, changing the PC value (and hitting "Enter" in the edit control or stepping the simulator) will
  39. reload the CPU's instruction queue without consuming clock ticks. Changing the PC value will also change the current state to
  40. Running.</P>
  41. <P><A HREF="#0top">(Return to top of page)</A></P>
  42. <H2><A NAME="Memory"></A>Memory</H2>
  43. <P>A "plug-able" interface handles the memory simulation. The default provided memory module mimics the 68HC11EVB
  44. evaluation board environment:</P>
  45. <UL>
  46. <LI>Register block -- $0-$1FF (except $0-$7 and $20-$21)</LI>
  47. </UL>
  48. <UL>
  49. <LI>Onboard RAM -- $800-$BFF</LI>
  50. </UL>
  51. <UL>
  52. <LI>EEPROM -- $1000-$1FFF</LI>
  53. </UL>
  54. <UL>
  55. <LI>External RAM -- $4000-7FFF, mirrored at $0000-$3FFF where there are holes</LI>
  56. </UL>
  57. <UL>
  58. <LI>External ROM -- $8000-$FFFF (monitor simulator and vectors)</LI>
  59. </UL>
  60. <P>When operated in Single Chip Mode, the external RAM and ROM are not available, and the internal EEPROM is mapped from
  61. $F000 to $FFFF. When simulating a 68HC912B32 (in single chip mode) the memory map is:</P>
  62. <UL>
  63. <LI>Register block - $0- $1FF</LI>
  64. <LI>RAM - $800-$BFF</LI>
  65. <LI>EEPROM - $D00-$FFF</LI>
  66. <LI>Flash ROM - $8000-$FFFF</LI>
  67. </UL>
  68. <P>The 68HC12EVB D-BUG12 debugger uses $A00 to $BFF, however these locations are available in the simulation. For
  69. compatibility, however, only locations $800-$9FF should be used, and the stack pointer should be initialized to $A00.</P>
  70. <P>The EEPROM can be written via a program (following the required procedure) or from the UI. </P>
  71. <P>The external RAM and ROM should be configured to have a one ECLK stretch (set location $3E to $35) rather than the
  72. default 3 clock stretch for accurate timing measurements. Accessing the external RAM or EEPROM 16 bit non-aligned causes
  73. additional cycle(s) as described in the Motorola documentation. </P>
  74. <P>An additional ROM space is provided at $8000-$FFFF for reset/interrupt vectors, or loading a monitor simulator, to allow
  75. programs to be developed on the simulator and run without change on the EVB. Note that this should be configured for one
  76. ECLK stretch just like the external RAM.</P>
  77. <P>The registers INITRM, INITRG, and INITEE (and also MISC for the 68HC912B32) can be changed to alter the memory map.</P>
  78. <P>Memory is observable and alterable via the Memory View display panel. Observing register locations via the Memory View is
  79. considered to be secretly peeking at the values, and does not count as a "read" in those cases where reading the register
  80. modifies the processor state. This is normally a good thing, but it also means that some things, such as the SCI, can not be
  81. operated manually through the Memory View.</P>
  82. <P>Although not part of the 68HC12 design, the simulator can report invalid memory accessing (writing to ROM, or accessing
  83. unassigned address space) either to the console/log, or by generating an exception condition that stops the execution and
  84. reports the problem to the user. Accessing locations in the register block that are not simulated is also considered to be an
  85. error.</P>
  86. <P><A HREF="#0top">(Return to top of page)</A></P>
  87. <H2><A NAME="UI Execution control"></A>UI Execution control</H2>
  88. <P>Execution can be "single stepped". A step consists of executing an instruction followed by stacking for a pending interrupt (if
  89. any). In the case of WAI instructions, a step can represent one time unit of waiting. In the case of STOP instructions, no time
  90. passes in a step because the clocks are stopped. Number of steps can be set, however execution will stop immediately on
  91. memory error (when "trap" is selected) or an unimplemented instruction is reached.</P>
  92. <P>For "Go" type operation, execution can be started, and will halt if one of the following occurs:</P>
  93. <UL>
  94. <LI>Breakpoint is reached</LI>
  95. </UL>
  96. <UL>
  97. <LI>Stop button pressed</LI>
  98. </UL>
  99. <UL>
  100. <LI>Stop instruction is executed</LI>
  101. </UL>
  102. <UL>
  103. <LI>Memory error ("trap" selected) or the BGND instruction is executed.</LI>
  104. </UL>
  105. <P>Note that when the processor is in STOPPED state, the only way to proceed is to cause an external interrupt -- IRQ, XIRQ,
  106. RESET. However changing the PC value will switch the state to RUNNING. When running (either by stepping or by "Go")
  107. the display will not be updated (exception -- the serial terminal interface). When running via "Go" all inputs are active (IRQ,
  108. XIRQ, RESET, port T, port J, port H).</P>
  109. <P>The "Step Over" operation is a combination of "Step" and "Go" in that a JSR, BSR or CALL will cause a "Go" with a special,
  110. additional breakpoint set at the instruction following the JSR, BSR, or CALL. "Step Over" will cause a WAI instruction to
  111. finish its wait. If the instruction is not a JSR, BSR, or CALL, then only that instruction is executed ("step" mode).</P>
  112. <P><A HREF="#0top">(Return to top of page)</A></P>
  113. <H2><A NAME="Reference to 68HC12 Technical Summary"></A>Reference to 68HC12 Technical Summary</H2>
  114. <H3>4 Register Block</H3>
  115. <P>Unimplemented register access is considered to be an error, to aid in debugging.</P>
  116. <P><A HREF="#0top">(Return to top of page)</A></P>
  117. <H3><A NAME="5 Bus Control and Input/Output"></A>5 Bus Control and Input/Output</H3>
  118. <P>PORTA, DDRA, PORTB, DDRB, PORTC, DDRC, PORTD, and DDRD are not in the register map in the simulated Normal
  119. Expanded Wide mode. PORTD and DDRD are added in the Narrow Memory Model mode,</P>
  120. <P>while PORTA, DDRA, PORTB, DDRB, PORTD, and DDRD are added in Single Chip Memory Model mode. For the
  121. 68HC912B32 mode, ports A and B (PORTA, DDRA, PORTB, and DDRB registers) are available.</P>
  122. <P>Port E can be programmed as output pins (using DDRE and PEAR), however the simulator views these output pins as simply
  123. latched data. The IRQ and XIRQ inputs in PORTE are implemented. Other "Alternate" functions are not implemented and
  124. there is no test for invalid settings (such as disabling the alternate function for a pin that is probably needed.</P>
  125. <P>PUCR and RDRIV are implemented, but have no effect.</P>
  126. <P><A HREF="#0top">(Return to top of page)</A></P>
  127. <H3><A NAME="6 Operating Modes and Resource Mapping"></A>6 Operating Modes and Resource Mapping</H3>
  128. <P>Register bits that are documented to be "write once" are "read only" in the simulator, with exceptions noted. </P>
  129. <P><EM>MODE Register always reads $F0 (in Normal Expanded Wide Mode), $B0 (Normal Expanded Narrow Mode), $90 (Single
  130. Chip Mode or 68HC912B32 mode).</EM></P>
  131. <P><EM>MISC always reads 0</EM> <EM>(except for 68HC912B32 mode for which MISC is implemented)</EM></P>
  132. <P><A HREF="#0top">(Return to top of page)</A></P>
  133. <H3><A NAME="7 EEPROM"></A>7 EEPROM</H3>
  134. <P>EEPROM programming implemented. PROTLOC bit forced to 0, EESWAI ignored. A warning is given if less than 10 msec
  135. allowed for programming.</P>
  136. <P>The Simulator user interface cannot be used to program the EEPROM by accessing the programming registers since time does
  137. not pass. Instead, store directly into the locations.</P>
  138. <P><A HREF="#0top">(Return to top of page)</A></P>
  139. <H3><A NAME="8 Memory Expansion and Chip Select"></A>8 Memory Expansion and Chip Select</H3>
  140. <P>No plans to implement memory expansion, however PPAGE is implemented but paging is forced to disabled. This also means
  141. that ports F and G are not implemented or available for I/O, even though a few pins are available in the EVB.</P>
  142. <P>CS0, CS1, CS2, and CS3 are implemented (CSCTL0), and when in use behave like separate RAM memory regions (i.e. they
  143. can be read and written). Writing these locations can be reported to the log. </P>
  144. <P>CSP1, CSP2, and CSD are implemented (CSCTL1) but settings are ignored.</P>
  145. <P>CSSTR0 and CSSTR1 are implemented. To get performance matching that of the EVB, CSSTR0 needs to be set to $35
  146. instead of the default $3F.</P>
  147. <P><A HREF="#0top">(Return to top of page)</A></P>
  148. <H3><A NAME="9 Resets and Interrupts"></A>9 Resets and Interrupts</H3>
  149. <P>/RESET, /XIRQ, and /IRQ pins are simulated with UI check boxes. These are automatically reset when the interrupt is taken
  150. to aid in simulation. A UI menu item simulates a Power On Reset, and resets the internal RAM memory to $BEADFACE,
  151. repeated, to represent uninitialized memory.</P>
  152. <P>If an interrupt occurs, and the interrupt vector has a value of 0, it is assumed to be an error and the simulation stops.</P>
  153. <P>INTCR, IRQEN bit implemented.</P>
  154. <P>HPRIO implemented.</P>
  155. <P><A HREF="#0top">(Return to top of page)</A></P>
  156. <H3><A NAME="10 Key wakeups"></A>10 Key wakeups</H3>
  157. <P>Ports H and J implemented. Port D is not available for expanded mode, in which the simulator runs. PUPSJ and PULEJ
  158. ignored. Changes to the output may be reported to the log. Changes in Port H and J input via the UI are only seen when the
  159. CPU is then stepped.</P>
  160. <P><A HREF="#0top">(Return to top of page)</A></P>
  161. <H3><A NAME="11 Clock functions"></A>11 Clock functions</H3>
  162. <P>Sections 11, 12, 13 implemented in Clock module.</P>
  163. <P>COP Watchdog Implemented. COPCTL can be written once, typically to turn off the COP Watchdog. RTI is implemented.</P>
  164. <P>Clock Monitor- no plans to implement.</P>
  165. <P><A HREF="#0top">(Return to top of page)</A></P>
  166. <H3><A NAME="12 PLL"></A>12 PLL</H3>
  167. <P>This functionality does not apply to the 68HC912B32 part.</P>
  168. <P>Sections 11, 12, 13 implemented in Clock module.</P>
  169. <P>Of course, there is no real clock generator! </P>
  170. <P>PLL registers: LDV, RDV ignored, CLKCTL LCKF follows PLLON, MCS implemented. No plans to implement BCS.
  171. Indicated execution time assumes 8 Mhz E&amp;P clocks.</P>
  172. <P><A HREF="#0top">(Return to top of page)</A></P>
  173. <H3><A NAME="13 Standard Timer Module"></A>13 Standard Timer Module</H3>
  174. <P>Sections 11, 12, 13 implemented in Clock module.</P>
  175. <P>The CLK0 and CLK1 bits of PACTL are not implemented, and are assumed to be zero. PA input cannot be driven from OC7.
  176. Port T has a UI, but needs to be able to be overridden by algorithm or file. Changing Port T inputs via the UI while execution
  177. is stopped will not cause a capture to occur until the CPU is stepped (time is consumed).</P>
  178. <P><A HREF="#0top">(Return to top of page)</A></P>
  179. <H3><A NAME="14 Multiple Serial Interface"></A>14 Multiple Serial Interface</H3>
  180. <P>One SCI, SCI 0, is implemented, and has a terminal emulator interface. The terminal emulator will display printable ASCII
  181. characters, and responds to control characters: Control-H (backspace), Control-M (carriage return), Control-J (line feed),
  182. Control-G (bell), and Control-Z to erase the "screen".</P>
  183. <P>Nobody really wants serial communication rates to scale, so communication will be close to instantaneous if "Turbo" mode is
  184. selected. </P>
  185. <P>Since there is no actual serial communication, it is easy to overrun the receiver by typing too fast, especially when not in turbo
  186. mode.</P>
  187. <P>SC0CR1 is ignored. SC0CR2: RWU, ILIE and SBK are ignored. SC0SC2: IDLE NF FE and PF bits are not implemented.
  188. SC0SR2 is ignored.</P>
  189. <P>No plan to implement SPI.</P>
  190. <P><A HREF="#0top">(Return to top of page)</A></P>
  191. <H3><A NAME="15 Analog to Digital Converter"></A>15 Analog to Digital Converter</H3>
  192. <P>AWAI bit not implemented. ATDCTL3 ignored. PORTAD assumes values of $80 to $FF are "1" while those less than $80 are
  193. "0". Sampling is performed at time ADRnH is loaded, which isn't realistic. </P>
  194. <P>In the case of the 68HC912B32, the ADC only operates in 8 bit conversion mode.</P>
  195. <P>Programable interface planned.</P>
  196. <P><A HREF="#0top">(Return to top of page)</A></P>
  197. <BR WP="BR1"><BR WP="BR2">
  198. </BODY>
  199. </HTML>