6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu May 09, 2024 4:12 pm

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Sun Nov 12, 2023 9:32 am 
Offline

Joined: Tue Oct 31, 2023 10:34 am
Posts: 15
Location: Germany
Hi All,

I have difficulty visualizing hex addresses especially coupled with the address decoding as set up by Ben Eater in his 6502 project. I set up an Excel spreadsheet which shows any address in the 6502 range, the pins addressed, and which device it is pointing to. I found it quite useful in getting a better understanding of the address logic. I hope these attachments work as I haven't tried this before.

Attachment:
Address_decoder.pdf [209.91 KiB]
Downloaded 75 times

Attachment:
Address decoder.xlsx [13.63 KiB]
Downloaded 54 times


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 12, 2023 11:15 am 
Offline
User avatar

Joined: Mon Aug 30, 2021 11:52 am
Posts: 261
Location: South Africa
Cookie13! wrote:
Attachment:
Address decoder.xlsx
I'm not familiar with Ben Eater's 6502 memory map but I must say the interactive spreadsheet is pretty sweet 8)


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 13, 2023 1:09 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8177
Location: Midwestern USA
Cookie13! wrote:
Hi All,

I have difficulty visualizing hex addresses especially coupled with the address decoding as set up by Ben Eater in his 6502 project. I set up an Excel spreadsheet which shows any address in the 6502 range, the pins addressed, and which device it is pointing to. I found it quite useful in getting a better understanding of the address logic. I hope these attachments work as I haven't tried this before.

Attachment:
Address_decoder.pdf

Attachment:
Address decoder.xlsx

Minor pedantic note: the 65C02 is not an “MCU.”

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 13, 2023 9:17 am 
Offline

Joined: Tue Oct 31, 2023 10:34 am
Posts: 15
Location: Germany
BigDumbDinosaur wrote:
Quote:
Minor pedantic note: the 65C02 is not an “MCU.”[/color]


Ah yes, thanks.


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 13, 2023 2:00 pm 
Offline

Joined: Wed Aug 21, 2019 6:10 pm
Posts: 217
AndrewP wrote:
Cookie13! wrote:
Attachment:
The attachment Address decoder.xlsx is no longer available
I'm not familiar with Ben Eater's 6502 memory map but I must say the interactive spreadsheet is pretty sweet 8)


His memory map is from Garth Wilson's single IC address decoder circuit: https://wilsonminesco.com/6502primer/addr_decoding.html

See below for the image from: https://wilsonminesco.com/6502primer/32 ... Mlogic.jpg

It inverts A15 with one NAND gate, and that is fed into /ROM_CS and /ROM_OE (using leading "/" to mean active low), so /ROM_CS and /ROM_OE are active low from $8000-$FFFF.
/ROM_CS := /ROM_OE := NAND(A15,A15)

It selects a 32K SRAM when A15 is low and Phi2 is high by taking that inverted A15 and combining it with Phi2 so that SRAM is only selected in the second half of the clock phase:

/RAM_CS := NAND(Phi2,NAND(A15,A15))

It feeds A14 into the /RAM_OE, so RAM only outputs in $0000-$3FFF, using 16KB of the 32KB RAM. Note that /RAM_OE is also active low in $8000-$BFFF, but in that range RAM is not selected.
/RAM_OE := A14

It derives the /IO_SELECT by taking the NAND of A14 and the inverted 15 line, so /IO_SELECT is active low in $4000-$7FFF:
/IO_SELECT := NAND(A14,NAND(A15,A15)

Then it can take advantage of 6502 bus I/O chips like the VIA that have two selects, one active low and one active high, by tying one of the address lines from A8-A13 to the active high select and /IO_SELECT to the active low select.

You are free to extend that down to up to 10 "slots" with A0-A3 for register addressing, but with such a massive I/O memory mapped space available, using A8-A13 means that the device is the first two digits of a hexadecimal address and the register address in the device is the second two digits.

You avoid the problem that an address like $7F04 (%01.111111.00000100) would select all of the I/O device by "don't do that" ... you only use addresses with one of the address lines A8-A13 high:
%01.000001 = $41 ... Device0 = $40+2^0
%01.000010 = $42 ... Device1 = $40+2^1
%01.000100 = $44 ... Device2 = $40+2^2
%01.001000 = $48 ... Device3 = $40+2^3
%01.010000 = $50 ... Device4 = $40+2^4
%01.100000 = $60 ... Device5 = $40+2^5

If you want to put an active low shift register or a latch in that I/O address you can use a couple of NAND gates for active low:
/IO5 := NAND(A13,NAND(/IOSELECT,VCC))

A single quad NAND could put three single active low select parts on Device3-Device5 that way. Or you can also fit a single active low select part as Device5 and a single active high part as Device4:
/IO4 := NAND(A12,NAND(/IOSELECT,VCC))
IO4 := NAND(/IO4,VCC)

Garth also has a version of a single chip Address Decode for 32KB of RAM from $0000-$7FFF, IO in $8000-$BFFF, and 16KB of ROM in $C000-$FFFF. With that one, if you have a 32KB ROM, you can put the ROM A14 line on a jumper between VCC and GND and have two different ROM banks ... you could even dedicate a VIA GPIO to ROM A14 and have software selectable ROM banks. IMHO, that one is more interesting for a Forth system, since I would like to have a Kernel jump table to load and save RAM images and common I/O routines and core primitives I am not going to monkey around with in the ROM and a (separated header) Forth dictionary in RAM, so I would have more code in RAM than is common with Ben Eater's "reprogram the ROM and see what happens" approach.


Attachments:
32kROM16kRAMlogic.jpg
32kROM16kRAMlogic.jpg [ 42.15 KiB | Viewed 3004 times ]
Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 14, 2023 5:29 am 
Offline
User avatar

Joined: Mon Aug 30, 2021 11:52 am
Posts: 261
Location: South Africa
BruceRMcF wrote:
His memory map is from Garth Wilson's single IC address decoder circuit: https://wilsonminesco.com/6502primer/addr_decoding.html
Thanks for that. I know I've skimmed through Garth's primer several times but unless I'm in the right context I don't really remember what I'm reading.

I did wonder how Garth managed to decode six 65xx support ICs given both the ACIA and the VIA only have two chip selects. And, of course, I was questioning that before I read the rest of your message :oops: .
Attachment:
Address Decoding.png
Address Decoding.png [ 129.32 KiB | Viewed 2961 times ]

I'd started drawing how it worked before I read or thought about your answer. It's very clever! Just use restraint when programming to make sure that two support ICs aren't selected at the same time.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 14, 2023 7:35 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8432
Location: Southern California
AndrewP wrote:
Just use restraint when programming to make sure that two support ICs aren't selected at the same time.

There is a possible advantage to being able to select more than one at a time, like if you want to start the timers of two VIAs simultaneously.  (I can't say I've ever done that though, as far as I can remember).  In using this for nearly 32 years now, I've never had any problems relating to accidentally addressing more than one thing at a time.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 15, 2023 4:36 am 
Offline

Joined: Wed Aug 21, 2019 6:10 pm
Posts: 217
AndrewP wrote:
... I'd started drawing how it worked before I read or thought about your answer. It's very clever! Just use restraint when programming to make sure that two support ICs aren't selected at the same time.


And, after all, when you have an assembly language source, you define the device address in the definitions section at the top. So while it might "feel like" tightrope walking when looking at the holes in the I/O address space, it's not really an issue ... as Garth says on the back of far more experience than I.

Indeed, if for some reason I was using the trick that you can access parallel registers at the same time, I expect I would let the assembler do the logic for me, and do it with an OR: "STA (VIA1 | VIA2)+DDRA"

I would be inclined to reserve A0-A4 for register addresses, so if I was selecting individual IC's (shift register or latches), I would be inclined to use the A5, A6 and A7 selects for individual IC selects, making those $4020, $4040, and $4080 (or $8020, $8040 and $8080 in the $32KB usable RAM version).


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 15, 2023 7:24 pm 
Offline
User avatar

Joined: Mon Aug 30, 2021 11:52 am
Posts: 261
Location: South Africa
I was also vaguely wondering about malicious code. But not likely I suppose. The chance of someone getting to sneakily run code on someone else's board without access to the board (and a hammer) seems ... small.

Cookie13! wrote:
I have difficulty visualizing hex addresses especially coupled with the address decoding as set up by Ben Eater in his 6502 project. I set up an Excel spreadsheet which shows any address in the 6502 range, the pins addressed, and which device it is pointing to. I found it quite useful in getting a better understanding of the address logic. I hope these attachments work as I haven't tried this before.
Looks like you're not the first to struggle to visualise the address layout. Adrian and Michael have both drawn up aids too.


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 27, 2023 12:37 am 
Offline
User avatar

Joined: Fri Feb 17, 2023 11:59 pm
Posts: 163
Location: Lviv, Ukraine
AndrewP wrote:
Looks like you're not the first to struggle to visualise the address layout. Adrian and Michael have both drawn up aids too.

Same. Would be so much easier if only humans had 8 fingers... :D

_________________
/Andrew

deck65 - 6502 slab with screen and keyboard | ПК-88 - SBC based on KM1810VM88 (Ukrainian i8088 clone) | leo80 - simple Z80 SBC
nice65 - 6502 assembly linter | My parts, footprints & 3D models for KiCad/FreeCAD


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 27, 2023 3:44 am 
Offline

Joined: Sun Sep 24, 2023 3:45 pm
Posts: 45
Here is the memory map file I use.

I have various areas colored like Zero Page, the Stack, VIA, ACIA, visible and offscreen areas of the Display as well as the mapping of the ROM in my version of EhBasic.

Since I'm spending so much time working with the display and images I find it better to visualize the memory mapped out like the screen is at 128 byte alignment.

I like being able to scroll around and see what fits where. It was helpful when EhBasic started to grow because of the functions I was adding and I was also storing sprite data.

https://github.com/Fifty1Ford/BeEhBasic
(Edit.. Removed PNG... Too big. Slow to load.)


Attachments:
File comment: Excel Ben Eater Memory Mapping
NormalLuserMemMap6502.xlsx [484.17 KiB]
Downloaded 28 times
File comment: LibreOffice Ben Eater Memory Mapping
NormalLuserMemMap6502.ods [595.04 KiB]
Downloaded 29 times
Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 27, 2023 10:56 am 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 683
Location: Potsdam, DE
and3rson wrote:
Would be so much easier if only humans had 8 fingers... :D


Last time I looked I *did* have eight fingers... different in the big city, I guess :D

Neil


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 27, 2023 4:41 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8177
Location: Midwestern USA
NormalLuser wrote:
Here is the memory map file I use...

Stuff like that should be posted in a neutral format.  I can’t speak for the others, but I don’t have any software that recognizes those files you posted.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 27, 2023 5:15 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
no idea what kind of software you tried, but Libre Office (or really any modern Excel compatible software) works fine with .xlsx files.
Now i'm interested in what format would you suggest considering that Libre Office is already a very common piece of software (IIRC it comes bundled with Ubuntu).
i guess .ods would've been an alternative


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 29, 2023 1:52 am 
Offline

Joined: Sun Sep 24, 2023 3:45 pm
Posts: 45
BigDumbDinosaur wrote:
NormalLuser wrote:
Here is the memory map file I use...

Stuff like that should be posted in a neutral format.  I can’t speak for the others, but I don’t have any software that recognizes those files you posted.


Here is that PNG I removed.

I think this is a logical way to view the memory layout of the 6502 in this system.


Attachments:
File comment: PNG of large Spreadsheet. 10,500KB
NormalLuserMemMap6502.png
NormalLuserMemMap6502.png [ 10.58 MiB | Viewed 2659 times ]
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: BigEd, Hermes and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron