psx.wiki

KSEG0 and KSEG1 Code Fetch

Measures how long the same short code bodies take when called through KSEG0 with the instruction cache and through KSEG1 without it.

KSEG0 and KSEG1 Code Fetch
MachineSCPH-5501
Programkseg1

Overview

The program writes six code bodies to RAM and calls each one eight times through KSEG0 at 8011xxxxh and eight times through KSEG1 at A011xxxxh. The cache is emptied with FlushCache before each set of eight, so the first KSEG0 call fetches from RAM and the later ones run from the cache. Each body sits between two loads of timer 2's count, and each output entry gives the two counts in hexadecimal and the cycles between them in decimal.1

Table 1: Bodies
Body Contents
empty Nothing between the two timer reads
nop64 64 NOPs
lw/4 64 words with a load from RAM through KSEG1 every 4th word, 16 loads
lw/2 64 words with a RAM load every 2nd word, 32 loads
sw/4 64 words with a RAM store every 4th word, 16 stores
loop32 A loop of addiu, bne and NOP run 32 times

See also:

Results

From KSEG1, 64 NOPs took 394 to 398 cycles, about 6 cycles an instruction ((396 - 8) / 64 = 6.1). From the warm cache they took 67 cycles, about 1 cycle an instruction, and the first call through KSEG0, which filled the cache, took 145 cycles.1

Table 2: Cycles for one call
Body KSEG0, first call KSEG0, later calls KSEG1
empty 4 4 8
nop64 145 67 394 to 398
lw/4 216 147 to 148 463 to 466
lw/2 398 262 to 265 587 to 597
sw/4 228 69 to 77 478 to 481
loop32 107 100 596 to 601

From the warm cache, 16 RAM loads added 80 cycles to the 64-word body, which is 5 cycles a load, and 32 loads added 195 cycles, which is about 6 a load. The 16 stores added 2 to 10 cycles. From KSEG1 the 16 loads added about 68 cycles and the 16 stores about 83. The loop of 32 turns took 100 cycles from the cache and about 6 times as long from KSEG1.1

Runs

9 October 2026

kseg1/KSEG1.txt

KSEG1 start
KSEG1 empty  kseg0 0010-0014=4 0033-0037=4 0049-004D=4 005F-0063=4 0075-0079=4 008B-008F=4 00A1-00A5=4 00B7-00BB=4
KSEG1 empty  kseg1 0019-0021=8 0054-005C=8 0086-008E=8 00B8-00C0=8 00EA-00F2=8 011C-0124=8 0152-015A=8 0184-018C=8
KSEG1 nop64  kseg0 0010-00A1=145 00C2-0105=67 0117-015A=67 016C-01AF=67 01C1-0204=67 0216-0259=67 026B-02AE=67 02C0-0303=67
KSEG1 nop64  kseg1 0019-01A3=394 01D3-035F=396 0389-0517=398 0541-06CF=398 06F9-0883=394 08B1-0A3B=394 0A65-0BF3=398 0C1D-0DAB=398
KSEG1 lw/4   kseg0 0010-00E8=216 0107-019A=147 01AC-0240=148 0252-02E6=148 02F8-038B=147 039D-0431=148 0443-04D6=147 04E8-057B=147
KSEG1 lw/4   kseg1 0019-01E8=463 0217-03E6=463 0410-05E0=464 060A-07DC=466 0806-09D7=465 0A01-0BD0=463 0BFA-0DCA=464 0DF4-0FC4=464
KSEG1 lw/2   kseg0 0010-019E=398 01BD-02C6=265 02D8-03DE=262 03F0-04F6=262 0508-060E=262 0620-0726=262 0738-083E=262 0850-0956=262
KSEG1 lw/2   kseg1 0019-026A=593 0299-04E7=590 0511-0766=597 0790-09DB=587 0A05-0C57=594 0C81-0ED1=592 0EFB-114B=592 1175-13C3=590
KSEG1 sw/4   kseg0 0010-00F4=228 0113-0160=77 0172-01B9=71 01CB-0212=71 0224-0269=69 027B-02C2=71 02D4-031B=71 032D-0375=72
KSEG1 sw/4   kseg1 0019-01F8=479 0227-0405=478 042F-060E=479 0638-0819=481 0843-0A22=479 0A4C-0C2B=479 0C55-0E36=481 0E60-103F=479
KSEG1 loop32 kseg0 0010-007B=107 009A-00FE=100 0110-0174=100 0186-01EA=100 01FC-0260=100 0272-02D6=100 02E8-034C=100 035E-03C2=100
KSEG1 loop32 kseg1 0019-026D=596 029C-04F5=601 051F-0773=596 079D-09F5=600 0A1F-0C73=596 0C9D-0EF5=600 0F1F-1173=596 119D-13F5=600
KSEG1 done

References


  1. ^ a b c SCPH-5501 output: kseg1/KSEG1.txt

Categories: Hardware tests