4.2.4 The Microcode Memory
The Display Controller contains a microprogrammed sequencer for controlling the screen format. The sequencer has an IterationCounter for setting the number of cycles each microinstruction will take and a LoopCounter which permits one level of programmed loop. Each microinstruction has a NextAddr field that specifies the next microinstruction; this field can be modified by various conditional jump mechanisms to be described below. Each microinstruction also contains a CountData field, used to load either the IterationCounter or the LoopCounter; two internal control bits; and eight control bits that control things outside the sequencer itself.
The microprogrammed sequencer operates at a rate which is 1/4th the pixel rate. For this reason, there are certain limits placed on the screen format. For example, the number of pixels in a scan line must be divisible by four. The width of the border in pixels must also be divisible by four.
The microcode memory consists of 64 words that are 28 bits wide. It occupies address range 240-27F. One IOWRqst instruction can download one word of microcode memory to the Display Controller. Figure 3 gives the format for the 28-bit microcode word
.
[Artwork node; type 'Artwork on' to command tool]
Figure 3: The format of the 28-bit microcode word.
The following table lists the fields of the microcode word and their meanings:
Field Meaning
NextAddr first 6 bits. Points to the next microcode word.
CounterData next 12 bits. CounterData is used to load either the IterationCounter or the LoopCounter, depending on the value of LoadLoop in the previous microcode instruction. The value is a negative number, represented in two's complement. Subsequently the counter is incremented until it reaches a value of FFF.
LoadLoop bit 18. If LoadLoop = 1, then on the next microde instruction LoopCounter ← CountData and IterationCounter ← FFF. If LoadLoop = 0, then on the next microcode instruction IterationCounter ← CountData.
CondJump bit 19. Normally the address of the next microinstruction is specified by the NextAddr field of the current microinstruction. However, under certain conditions to be discussed in detail below, this address can be forced to be odd. This feature provides a kind of conditional jump capability. Here are the conditions that will force the address to be odd:
CondJump = 1 AND LoopCounter = FFF
CondJump=0 AND T0=1 AND (NextAddr=38 OR NextAddr = 3A)
CondJump=0 AND T1=1 AND (NextAddr=3C OR NextAddr = 3E)
nHSync bit 20. Holds value of the nHSync bit.
nBlank bit 21. Holds value of the nBlank bit.
VideoData bit 22. If VideoData = 1, pixels are fetched from the FIFO and sent to the PixOut outputs.
CursorData bit 23. If CursorData = 1, the logic that controls the cursor display is instructed to provide cursor pixels, which are sent to the COut outputs.
Border bit 24. If Border = 1, the COut outputs are forced to 3's, regardless of the cursor. If desired, this feature can be used to display a border around the portion of the screen that contains ``real'' data.
NewLine bit 25. If NewLine = 1, LoopCounter is incremented (unless it is loaded with the contents of CountData, as specified by LoadLoop bit of the previous microinstruction). Typically, this corresponds to starting a new scan line.
nVSync bit 26. Holds value of the vHSync bit.
ProgInt bit 27. If ProgInt = 1, an interrupt request bit will be set and an interrupt will occur on the DynaBus as soon as the corresponding interrupt mask bit is set. There are 2 microcode interrupts:
Interrupt 0:
If NextAddr < 20H, then bit 0 of the InterruptStatus register is set. Also, as a side effect, FramePtr, the internal register that points to the next block of image data to be fetched from main memory, is initialized to the contents of FramePtrBase.
Interrupt 1:
If NextAddr e 20H, then bit 1 of the InterruptStatus register is set.
4.2.4.1 An Example of Microcode
The following microcode demonstrates all the functionality that would be required for a toy display with 20 visible scan lines containing pixel data and 8 scan lines during vertical retrace. Each scan line takes 16 cycles. Each visible scan line contains 32 data pixels and 8 border pixels on each side.
Adr NextAddr Assert Ctrl Bits Counters/Timers
00 Start: Jump ScnE1
IT←-1
Vertical Retrace Interval:
02 VR1S1: Jump VR1S2 nHSync nBlank IT←-2
34 VR1S2: CJmp VR1S1,VR1E1 nBlank NewLine IT←-14
03 VR1E1: Jump VR1E2 nHSync nBlank LoadLoop IT←-1
05 VR1E2: Jump VSyI1 nHSync nBlank V.Timer←-2
06 VSyI1: Jump VSyI2 nBlank IT←-8
07 VSyI2: Jump VSyS1 nBlank nVSync IT←-6
08 VSyS1: Jump VSyS2 nHSync nBlank nVSync IT←-2
0A VSyS2: CJmp VSyS1,VSyE1 nBlank nVSync NewLine IT←-14
09 VSyE1: Jump VSyE2 nHSync nBlank nVSync LoadLoop IT←-1
0B VSyE2: Jump VSyO1 nHSync nBlank nVSync V.Timer←-2
0C VSyO1: Jump VSyO2 nBlank nVSync IT←-7
0D VSyO2: Jump VR2S1 nBlank IT←-7
0E VR2S1: Jump VR2S2 nHSync nBlank IT←-2
10 VR2S2: CJmp VR2S1,VR2E1 nBlank NewLine IT←-14
0F VR2E1: Jump VR2E2 nHSync nBlank LoadLoop IT←-1
11 VR2E2: Jump ScnS1 nHSync nBlank V.Timer←-20
Scan Line:
20 ScnS1: Jump ScnS2 nHSync nBlank IT←-2
22 ScnS2: Jump ScnS3 nBlank IT←-1
23 ScnS3: Jump ScnS4 nBlank CursorData Border IT←-1
24 ScnS4: Jump ScnS5 VideoData CursorData Border IT←-1
25 ScnS5: Jump ScnS6 VideoData CursorData IT←-6
26 ScnS6: Jump ScnS7 VideoData IT←-1
27 ScnS7: Jump ScnS8 IT←-1
28 ScnS8: Jump ScnS9 Border IT←-2
29 ScnS9: CJmp ScnS1,ScnE1 Border NewLine IT←-1
21 ScnE1: Jump ScnE2 nHSync nBlank LoadLoop IT←-1
1A ScnE2: Jump VR1S2 nHSync nBlank ProgInt V.Timer←-2
Here is the binary encoding of the above microcode:
Hex Binary Equivalent divided into fields
Next Addr Counter Booleans
87FFC00 100001 111111111111 0000000000
13FF8C0 000100 111111111110 0011000000
0BFC944 000010 111111110010 0101000100
17FFEC0 000101 111111111111 1011000000
1BFF8C0 000110 111111111110 0011000000
1FFE040 000111 111111111000 0000100000
23FE842 001000 111111111010 0001000010
2BFF8C2 001010 111111111110 0011000010
23FC946 001000 111111110010 0101000110
2FFFEC2 001011 111111111111 1011000010
33FF8C2 001100 111111111110 0011000010
37FE442 001101 111111111001 0000100010
3BFE440 001110 111111111001 0001000000
43FF8C0 001000 111111111110 0011000000
3BFC944 001110 111111110010 0101000100
47FFEC0 001001 111111111111 1011000000
8BFB0C0 100010 111111101100 0011000000
8BFF8C0 100010 111111111110 0011000000
8FFFC40 100011 111111111111 0001000000
93FFC58 100100 111111111111 0001011000
97FFC38 100101 111111111111 0000111000
9BFE830 100110 111111111010 0000110000
9FFFC20 100111 111111111111 0000100000
A3FFC00 101000 111111111111 0000000000
A7FF808 101001 111111111110 0000001000
83FFD0C 100000 111111111111 0100001100
6BFFEC0 011010 111111111111 1011000000
13FF8C1 000100 111111111110 0011000001