From 15337f762451deabdabec873e7aa8a2a483ec75c Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Fri, 14 Apr 2023 11:43:43 +0300 Subject: Set up MMIO with keyboard, terminal emulator --- asm/bootstrap.atk16 | 25 +- asm/idle_loop.atk16 | 10 + digital/atk16.dig | 1034 +++++++++++++++++++++++++++++---------------- digital/atk16_mem.dig | 780 +++++++++++++++++++++++++++------- digital/atk16_mem_mux.dig | 276 ++++++++++++ 5 files changed, 1613 insertions(+), 512 deletions(-) create mode 100644 asm/idle_loop.atk16 create mode 100644 digital/atk16_mem_mux.dig diff --git a/asm/bootstrap.atk16 b/asm/bootstrap.atk16 index 73165b9..29ed0ea 100644 --- a/asm/bootstrap.atk16 +++ b/asm/bootstrap.atk16 @@ -1,16 +1,33 @@ @let stack_segment 0x8000 @let vector_table 0x10 +@let terminal_addr 0xE000 +@let keyboard_addr 0xE001 @address vector_table - hlt_isr ; 0x10 ISR0 - hlt_isr ; 0x11 ISR1 - hlt_isr ; 0x12 ISR2 - hlt_isr ; 0x13 ISR3 + hlt_isr ; 0x10 ISR0 + hlt_isr ; 0x11 ISR1 + hlt_isr ; 0x12 ISR2 + keyboard_isr ; 0x13 ISR3 (keyboard) stack_segment ; 0x14 Stack address 0x0 ; 0x15 Interrupt PC address (IPCA) + terminal_addr ; 0x16 Terminal peripheral address + keyboard_addr ; 0x17 Keyboard peripheral address @label hlt_isr ldi 0x55 RE + hlt + +@label keyboard_isr + spu RA ; use RA, RB + spu RB + ldi 0x17 RA ; RA := 0x17 Keyboard peripheral address pointer + ldr RA RA ; RA := 0xE001 Keyboard peripheral address deref + ldr RA RA ; RA := <16-bit keyboard character code> from MMIO register + ldi 0x16 RB ; RB := 0x16 Terminal peripheral address pointer + ldr RB RB ; RB := 0xE000 Terminal peripheral address deref + str RA RB ; terminal <- character code + spo RB ; restore RA, RB + spo RA rti @label program_segment diff --git a/asm/idle_loop.atk16 b/asm/idle_loop.atk16 new file mode 100644 index 0000000..442923c --- /dev/null +++ b/asm/idle_loop.atk16 @@ -0,0 +1,10 @@ +@opt stack_pointer RF +@opt csr_scratch RH +@use ext_std:* + +; bootstrap code (must be called to setup mandatory data) +; will jump to label main +@include bootstrap + +@label main + jpi main diff --git a/digital/atk16.dig b/digital/atk16.dig index d1787ab..c2b1cf3 100644 --- a/digital/atk16.dig +++ b/digital/atk16.dig @@ -119,36 +119,13 @@ atk16_mem.dig - - - - - Tunnel - - - rotation - - - - NetName - MEM_IE - - - - - - Tunnel - rotation - - - - NetName - MEM_OE + Label + MEMORY - + atk16_jump_unit.dig @@ -224,7 +201,7 @@ program(0x4051, 0x40a2, 0x029b) rotation - + @@ -242,7 +219,7 @@ program(0x4051, 0x40a2, 0x029b) Frequency - 15 + 100 @@ -1276,9 +1253,49 @@ program(0x4051, 0x40a2, 0x029b) - Keyboard + RS_FF_AS - + + + + Ground + + + rotation + + + + + + + Ground + + + rotation + + + + + + + Ground + + + rotation + + + + + + + LED + + + rotation + + + + Tunnel @@ -1292,22 +1309,135 @@ program(0x4051, 0x40a2, 0x029b) CLK - + - VDD + Tunnel rotation - + + + + NetName + MEM_IE - + - RS_FF_AS + Tunnel + + + rotation + + + + NetName + MEM_OE + + + + + + Tunnel + + + NetName + DBUS + + + + + + Comparator + + + Bits + 13 + + + + + + Const + + + Value + 0 + + + Bits + 13 + + + + + + And - + + + + Terminal + + + + + Tunnel + + + rotation + + + + NetName + CLK + + + + + + Tunnel + + + rotation + + + + NetName + DBUS + + + + + + Tunnel + + + rotation + + + + NetName + MMIO_IE + + + + + + Tunnel + + + rotation + + + + NetName + MMIO_S + + + Tunnel @@ -1321,85 +1451,179 @@ program(0x4051, 0x40a2, 0x029b) IM_DS - + - Ground + Tunnel rotation - + + + + NetName + IRQ0 - + - Ground + Keyboard + + + + + Tunnel + + + NetName + IRQ0 + + + + + + Tunnel + + + NetName + DBUS + + + + + + Tunnel rotation - + + + + NetName + CLK - + - Ground + Comparator + + + Bits + 13 + + + + + + Const + + + Bits + 13 + + + + + + And + + + + + Tunnel rotation - + + + + NetName + MMIO_OE - + - LED + Tunnel rotation - + + + + NetName + MMIO_S - + - - - - - - - - - - - - - - - - - - - - - + + Probe + + + Label + MMIO_S + + + + + + Tunnel + + + NetName + MMIO_IE + + + + + + Tunnel + + + NetName + MMIO_OE + + + + + + Tunnel + + + NetName + MMIO_S + + + + + + + + + - - + + - - + + - - + + - - + + + + + + @@ -1422,76 +1646,324 @@ program(0x4051, 0x40a2, 0x029b) - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1534,36 +2006,12 @@ program(0x4051, 0x40a2, 0x029b) - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -1577,10 +2025,6 @@ program(0x4051, 0x40a2, 0x029b) - - - - @@ -1590,24 +2034,8 @@ program(0x4051, 0x40a2, 0x029b) - - - - - - - - - - - - - - - - - - + + @@ -1626,8 +2054,16 @@ program(0x4051, 0x40a2, 0x029b) - - + + + + + + + + + + @@ -1649,34 +2085,10 @@ program(0x4051, 0x40a2, 0x029b) - - - - - - - - - - - - - - - - - - - - - - - - @@ -1718,32 +2130,8 @@ program(0x4051, 0x40a2, 0x029b) - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -1754,16 +2142,8 @@ program(0x4051, 0x40a2, 0x029b) - - - - - - - - - - + + @@ -1789,14 +2169,6 @@ program(0x4051, 0x40a2, 0x029b) - - - - - - - - @@ -1814,116 +2186,128 @@ program(0x4051, 0x40a2, 0x029b) - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + - - + + - - + + @@ -1942,12 +2326,8 @@ program(0x4051, 0x40a2, 0x029b) - - - - - - + + @@ -1961,22 +2341,6 @@ program(0x4051, 0x40a2, 0x029b) - - - - - - - - - - - - - - - - @@ -1985,30 +2349,10 @@ program(0x4051, 0x40a2, 0x029b) - - - - - - - - - - - - - - - - - - - - @@ -2019,40 +2363,16 @@ program(0x4051, 0x40a2, 0x029b) - - - - - - - - - - - - - + - - + + - - - - - - - - - - - - \ No newline at end of file diff --git a/digital/atk16_mem.dig b/digital/atk16_mem.dig index 540e64d..0c217b9 100644 --- a/digital/atk16_mem.dig +++ b/digital/atk16_mem.dig @@ -10,122 +10,194 @@ Width - 5 + 7 - RAMAsync + EEPROM AddrBits 15 + + isProgramMemory + true + Label - MEM_RAM + MEM_ROM Bits 16 + + Data + 4014,2a00,6026,13*8000,18,18,18,1a,8000,0,e000,e001,4855,f000 +,3140,1b48,3148,1b48,4017,2000,2000,4216,2240,3040,1b49,2340,1b49 +,2140,e000,61ff + - + - Tunnel + Ground rotation - + + + + + + VDD + - NetName - MEM_IE + rotation + - + - EEPROM + VDD - AddrBits - 15 + rotation + + + + + + In + - isProgramMemory - true + Description + Address Label - MEM_ROM + ADDR Bits 16 + + + + + Splitter + - Data - 4014,2a00,6015,13*8000,4*16,8010,0,4855,e000,400a,9e00,1fe0,3178 -,1b48,6001,f000,3148,1b48,3150,1b48,1011,860a,3158,1b48,4200,4401 -,650,1280,14c0,1009,8408,61fa,1b49,2540,1b49,2340,1b49,2f40,51c0 -,10c0,1b49,2740,1b49,2540,1b49,2340,1b49,2f40,51c0 + Input Splitting + 16 + + + Output Splitting + 13,1,1,1 - + + + + atk16_mem_mux.dig + + Splitter Input Splitting - 16 + 13,1,1 + + + Output Splitting + 15 + + + + + + Splitter + + + Input Splitting + 1,1 Output Splitting - 15,1 + 2 - + Demultiplexer + + Selector Bits + 2 + Bits 15 - + - Ground + Probe - rotation - + Label + ROM_OUT - + - In + Driver - Description - Address + Bits + 16 - Label - ADDR + flipSelPos + true + + + + + Demultiplexer + - Bits - 16 + Selector Bits + 2 + + + flipSelPos + true - + + + + Tunnel + + + NetName + RAM_IE + + + In @@ -147,83 +219,159 @@ true - + - Driver + Tunnel - rotation - + NetName + CLK + + + + + + RAMDualPort + + + AddrBits + 15 + + + Label + MEM_RAM Bits 16 - + + + + VDD + + + rotation + + + + Tunnel rotation - + NetName - MEM_OE + CLK + + + + + + Tunnel + + + rotation + + + + NetName + RAM_IE + + + + + + Tunnel + + + rotation + + + + NetName + DBUS + + + + + + Probe + + + Label + RAM_OUT + + + + + + Driver + + + Bits + 16 - + In Description - Memory input enable + Clock Label - MEM_IE + CLK - + - In + Out Description - Memory output enable + Memory-mapped I/O word input enable Label - MEM_OE + MMIO_IE - + - Tunnel + Out - NetName - MEM_OE + Description + Memory-mapped I/O word output enable + + + Label + MMIO_OE - + Tunnel NetName - MEM_IE + MMIO_S - + Testcase @@ -231,243 +379,573 @@ Testdata - ADDR MEM_IE MEM_OE DBUS DBUS_out + CLK ADDR MEM_IE MEM_OE DBUS DBUS_out # read ROM program(0xFF) -0x0 0 1 Z 0xFF +C 0x0 0 1 Z 0xFF # read RAM memory MEM_RAM(0x0)=0x55; -0 0 0 Z X -0x8000 0 1 Z 0x55 +C 0 0 0 Z X +C 0x8000 0 1 Z 0x55 # write to RAM -0x8000 1 0 0xAA 0xAA -0x8000 0 1 Z 0xAA +C 0x8000 1 0 0xAA 0xAA +C 0x8000 0 1 Z 0xAA - + - Driver + In - Bits - 16 + Description + Memory input enable + + + Label + MEM_IE - + - VDD + In - rotation - + Description + Memory output enable + + + Label + MEM_OE - + - VDD + And rotation - + - + + + + Tunnel + + + NetName + RAM_OE + + + + + + Tunnel + + + NetName + MEM_OE + + + + + + Tunnel + + + NetName + MEM_OE + + + + + + Tunnel + + + NetName + DBUS + + + - DriverInvSel + And rotation - + + + + + + Tunnel + - Bits - 16 + NetName + ROM_OE + + + + + + Tunnel + + + NetName + MEM_OE + + + + + + Tunnel + + + NetName + DBUS + + + + + + Tunnel + + + NetName + DBUS + + + + + + Decoder + + + Selector Bits + 2 flipSelPos true - + - Probe + Tunnel - Label - ROM_OUT + NetName + ROM_OE - + - Probe + Tunnel + + + NetName + RAM_OE + + + + + + Tunnel + + + NetName + MMIO_OE + + + + + + Tunnel + + + NetName + MMIO_IE + + + + + + And + + + + + Tunnel + + + rotation + + + + NetName + MEM_OE + + + + + + Tunnel + + + rotation + + + + NetName + MMIO_OE + + + + + + And + + + + + Tunnel + + + rotation + + + + NetName + MEM_IE + + + + + + Tunnel + + + rotation + + + + NetName + MMIO_IE + + + + + + Out + + Description + Memory-mapped I/O word selector + Label - RAM_OUT + MMIO_S + + + Bits + 13 - + + + + Tunnel + + + rotation + + + + NetName + MMIO_S + + + + + + Tunnel + + + NetName + MEM_IE + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + - + - - + + - - + + - - + + - - + + + + + + - - + + + + + + + + + + + + + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + diff --git a/digital/atk16_mem_mux.dig b/digital/atk16_mem_mux.dig new file mode 100644 index 0000000..d4be584 --- /dev/null +++ b/digital/atk16_mem_mux.dig @@ -0,0 +1,276 @@ + + + 2 + + + + Out + + + Label + X + + + Inputs + 1 + + + + + + And + + + wideShape + true + + + Inputs + 3 + + + + + + Out + + + Label + Y + + + Inputs + 1 + + + + + + Or + + + wideShape + true + + + + + + And + + + wideShape + true + + + + + + And + + + wideShape + true + + + + + + In + + + rotation + + + + Label + C + + + + + + In + + + rotation + + + + Label + B + + + + + + Not + + + rotation + + + + + + + In + + + rotation + + + + Label + A + + + + + + Not + + + rotation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.3