Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > NMI delay
2024-02-13 22:34
JackAsser

Registered: Jun 2002
Posts: 1990
NMI delay

How much is an NMI delayed if triggered during IRQ-setup?
2024-02-13 22:39
Fungus

Registered: Sep 2002
Posts: 626
1 cycle I think?

Was talking to groepaz a couple months ago about "eaten IRQs" which is a bug in the 6502. I supposed if the NMI came at the wrong time after an IRQ the IRQ can be lost, or a BRK.

There was some talk about it on the 6502 site he linked.
2024-02-13 22:43
chatGPZ

Registered: Dec 2001
Posts: 11141
what do you mean "during IRQ-setup"?
2024-02-13 22:44
JackAsser

Registered: Jun 2002
Posts: 1990
Quote: 1 cycle I think?

Was talking to groepaz a couple months ago about "eaten IRQs" which is a bug in the 6502. I supposed if the NMI came at the wrong time after an IRQ the IRQ can be lost, or a BRK.

There was some talk about it on the 6502 site he linked.


In VICE it's definetly more than 1 cycle, but hard to tell.
2024-02-13 22:44
JackAsser

Registered: Jun 2002
Posts: 1990
Quote: what do you mean "during IRQ-setup"?

When the CPU performs the 7-cycle IRQ-setup (i.e. push status etc on the stack). During that time NMIs won't interrupt and will be delayed. But it doesn't seem to be delayed the full 7 cycles (at least not in VICE, havn't tested on the real thing but this is surely emulated correctly anyways).
2024-02-13 22:47
chatGPZ

Registered: Dec 2001
Posts: 11141
ok. for that case, basically look at it like your NMI interrupts a BRK instruction (because it IS a BRK instruction!).

and then to see the details, simulate in visual6502 :) i am still struggling at explaining this properly, it should be added to NMS :)
2024-02-13 22:50
Oswald

Registered: Apr 2002
Posts: 5026
cool, this sounds like a yummy raster fx :)
2024-02-13 22:52
Fungus

Registered: Sep 2002
Posts: 626
Oh you mean the lockout time before another NMI can occur, isn't it the instruction length, but... if NMI is held low then another one shouldn't be able to strike unless you are doing something weird. Are you using the CIA where the code is executed the so the flag is cleared automatically? That would present a problem.
2024-02-13 22:52
JackAsser

Registered: Jun 2002
Posts: 1990
Quote: ok. for that case, basically look at it like your NMI interrupts a BRK instruction (because it IS a BRK instruction!).

and then to see the details, simulate in visual6502 :) i am still struggling at explaining this properly, it should be added to NMS :)


Struggling also (and already checked visual6502), hence I took the lazy path and just asked. :D
2024-02-13 22:53
JackAsser

Registered: Jun 2002
Posts: 1990
Quote: Oh you mean the lockout time before another NMI can occur, isn't it the instruction length, but... if NMI is held low then another one shouldn't be able to strike unless you are doing something weird. Are you using the CIA where the code is executed the so the flag is cleared automatically? That would present a problem.

No no no not at all. Imagine u have a raster IRQ, and when the CPU performs the IRQ-load (i.e. push status, return address, read IRQ vector and jump (7c) ) an NMI occurs. This NMI will get delayed by that IRQ process, but how much at most? In VICE it looks like around 3-4 cycles, but I don't understand why. Why not 7c?
2024-02-13 22:55
JackAsser

Registered: Jun 2002
Posts: 1990
Quote: cool, this sounds like a yummy raster fx :)

It depends on the max delay, hence my question. :D
2024-02-13 22:57
chatGPZ

Registered: Dec 2001
Posts: 11141
start here:

https://web.archive.org/web/20141224041136/http://visual6502.or..

You'll be more confused than before :o)
2024-02-13 22:59
JackAsser

Registered: Jun 2002
Posts: 1990
Quote: start here:

https://web.archive.org/web/20141224041136/http://visual6502.or..

You'll be more confused than before :o)


Haha, already did. Hence the question here. :D
2024-02-13 23:00
chatGPZ

Registered: Dec 2001
Posts: 11141
also
https://web.archive.org/web/20210405071346/http://visual6502.or..
https://web.archive.org/web/20210405071501/http://visual6502.or..
2024-02-13 23:44
Fungus

Registered: Sep 2002
Posts: 626
Ah I see what you mean now, I'm not entirely sure either.
2024-02-14 00:35
Krill

Registered: Apr 2002
Posts: 2854
Quoting JackAsser
Imagine u have a raster IRQ, and when the CPU performs the IRQ-load (i.e. push status, return address, read IRQ vector and jump (7c) ) an NMI occurs. This NMI will get delayed by that IRQ process, but how much at most? In VICE it looks like around 3-4 cycles, but I don't understand why. Why not 7c?
Hazarding a guess, this seems rather analogous to the BA/AEC-goes-low VIC-takes-over-the-bus case (or REU DMA, for that matter).

Up to 3 write cycles (6502/6510 never needs more in a row, with any kind of interrupt being the worst case), then interruption, because it's safe only now.

Wouldn't be surprised if the NMI-on-top-of-IRQ and BA/AEC-low cases share some considerable assumptions, logic and circuitry.
2024-02-14 05:50
Martin Piper

Registered: Nov 2007
Posts: 645
To really get an answer to this the PLA ROM needs to be understood.

http://www.visual6502.org/JSSim/expert.html
https://www.pagetable.com/?p=410
https://www.pagetable.com/?p=39
"At the end of each instruction, the PLA causes the T bitfield to reset, so that the next instruction starts with T1=1 again."
"All interrupt and NMI requests are always delayed until the current instruction is finished, i.e. until T gets reset."
2024-02-14 09:33
JackAsser

Registered: Jun 2002
Posts: 1990
Quote: To really get an answer to this the PLA ROM needs to be understood.

http://www.visual6502.org/JSSim/expert.html
https://www.pagetable.com/?p=410
https://www.pagetable.com/?p=39
"At the end of each instruction, the PLA causes the T bitfield to reset, so that the next instruction starts with T1=1 again."
"All interrupt and NMI requests are always delayed until the current instruction is finished, i.e. until T gets reset."


Given that and given that an IRQ really is a BRK-instruction under the hood we can assume the delay can be up to 7 cycles then?
2024-02-14 13:56
chatGPZ

Registered: Dec 2001
Posts: 11141
If only it was that simple :o)

It might be a good idea to simulate and iterate too all possible timings (ie trigger the nmi in every possible half cycle of that "BRK") and then see what happens. If i understood the wiki correctly, there are still special cases to consider.
2024-02-14 14:09
JackAsser

Registered: Jun 2002
Posts: 1990
Quote: If only it was that simple :o)

It might be a good idea to simulate and iterate too all possible timings (ie trigger the nmi in every possible half cycle of that "BRK") and then see what happens. If i understood the wiki correctly, there are still special cases to consider.


Yeah, someday. For now I simply made sure that my IRQs never collides with the NMIs. :)
2024-02-14 14:18
chatGPZ

Registered: Dec 2001
Posts: 11141
BAH! DO IT! :D
2024-02-14 17:01
Martin Piper

Registered: Nov 2007
Posts: 645
Quote: Yeah, someday. For now I simply made sure that my IRQs never collides with the NMIs. :)

There's no real problem as both will trigger eventually.
2024-02-14 17:10
chatGPZ

Registered: Dec 2001
Posts: 11141
The problem is having predictable timing in all cases. Of course they trigger (except when they don't - see the wiki pages).
2024-02-14 17:20
JackAsser

Registered: Jun 2002
Posts: 1990
Quote: The problem is having predictable timing in all cases. Of course they trigger (except when they don't - see the wiki pages).

Exactly. My NMIs must NOT be delayed or this card house will fall completly and ungraceful.
2024-02-14 17:28
Fungus

Registered: Sep 2002
Posts: 626
Quote: The problem is having predictable timing in all cases. Of course they trigger (except when they don't - see the wiki pages).

Yes this is what I was looking at too, to see in which instances the IRQ is "eaten". I need to do some simulations there too and see if this behavior can be documented so we know exactly when and how this can occur.

I was already aware of BRK can eat an IRQ and vice versa, but if NMI is also a BRK instruction then the same thing could happen. It's just a matter of under what circumstances...
2024-02-14 17:34
chatGPZ

Registered: Dec 2001
Posts: 11141
Yes. Those wiki pages are very confusing for that matter, because they also consider cases that can never happen - in a C64 anyway.
2024-02-14 17:38
Krill

Registered: Apr 2002
Posts: 2854
Quoting Martin Piper
To really get an answer to this the PLA ROM needs to be understood.
Please don't call it PLA. It's not programmable, it's just a ROM. =)
2024-02-14 18:17
JackAsser

Registered: Jun 2002
Posts: 1990
Quote: Quoting Martin Piper
To really get an answer to this the PLA ROM needs to be understood.
Please don't call it PLA. It's not programmable, it's just a ROM. =)


The LA. :)
2024-02-14 18:26
Krill

Registered: Apr 2002
Posts: 2854
Quoting JackAsser
The LA. :)
Lookup array. Basically table. =)
2024-02-15 00:18
Martin Piper

Registered: Nov 2007
Posts: 645
Quote: Quoting Martin Piper
To really get an answer to this the PLA ROM needs to be understood.
Please don't call it PLA. It's not programmable, it's just a ROM. =)


"it's actually a PLA"
https://retrocomputing.stackexchange.com/questions/15227/why-di..
2024-02-15 00:30
Krill

Registered: Apr 2002
Posts: 2854
Quoting Martin Piper
"it's actually a PLA"
https://retrocomputing.stackexchange.com/questions/15227/why-di..
So, well, it's programmable (by whoever edits a mask and re-runs production), but not field programmable... essentially the same technology as ROM. Ooookay. :)

Easy counter: https://electronics.stackexchange.com/questions/5825/what-is-th.. =)
2024-02-15 00:35
Martin Piper

Registered: Nov 2007
Posts: 645
https://en.wikipedia.org/wiki/Programmable_logic_array

"the original 6502 chip contained a PLA"

It's obviously not a full ROM.
2024-02-15 00:45
chatGPZ

Registered: Dec 2001
Posts: 11141
That's simply wrong. It's a decode ROM, no more, no less. (And yes, what Krill said. Its not a traditional ROM, sure. Its a logic array. And that kind of thing is usually called decode ROM - not PLA. PLA is programmable, not mask edited.)
2024-02-15 00:57
Martin Piper

Registered: Nov 2007
Posts: 645
Quote: That's simply wrong. It's a decode ROM, no more, no less. (And yes, what Krill said. Its not a traditional ROM, sure. Its a logic array. And that kind of thing is usually called decode ROM - not PLA. PLA is programmable, not mask edited.)

Wrong. The PLA in the 6502 is sparse. A full ROM maps every single output. The 6502 PLA saves space compared to a full ROM.

It's why we have illegal opcodes.

https://www.pagetable.com/?p=39
2024-02-15 01:01
chatGPZ

Registered: Dec 2001
Posts: 11141
You don't have to copypaste me the ill informed stuff that you found on reddit.

FPLA is a synonym for the (modern) FPGA btw - and has zero to do with the oldschool "PLA".

(yes, please inform me about how illegal opcodes work, i always wanted to know)
2024-02-15 01:19
Martin Piper

Registered: Nov 2007
Posts: 645
Quote: You don't have to copypaste me the ill informed stuff that you found on reddit.

FPLA is a synonym for the (modern) FPGA btw - and has zero to do with the oldschool "PLA".

(yes, please inform me about how illegal opcodes work, i always wanted to know)


Wrong again.
Look at the chip layout, it's obviously a PLA, not a full ROM.

http://www.visual6502.org/JSSim/expert.html?nosim=t&panx=110.5&..
2024-02-15 01:39
Martin Piper

Registered: Nov 2007
Posts: 645
"approximately top fifth of the chip (with the regular rectangular pattern) is the **PLA** that decodes instructions."

https://www.righto.com/2013/01/a-small-part-of-6502-chip-explai..


Basically "paz" you're not considering the actual layout of the gates on the chip and instead applying your incorrect thinking from an incorrect understanding about some higher level context which isn't appropriate.
2024-02-15 01:42
Martin Piper

Registered: Nov 2007
Posts: 645
This explains why your PLA explanation is wrong "paz".

https://en.wikipedia.org/wiki/Programmable_logic_array

"In 1970, Texas Instruments developed a *mask-programmable IC*..." "...TI coined the term **Programmable Logic Array** for this device."
2024-02-15 02:01
chatGPZ

Registered: Dec 2001
Posts: 11141
If you'd spend as much time programming as googling up your "knowledge", perhaps your verlet integration code would even be ready by now :)
2024-02-15 02:08
Fungus

Registered: Sep 2002
Posts: 626
Martin, if you have nothing to add to this conversation, then kindly shut up. No one wants to argue with you about tangential subjects just so you can die on yet another hill about something you clearly misunderstand.

Good lord man...
2024-02-15 02:22
Martin Piper

Registered: Nov 2007
Posts: 645
Quote: If you'd spend as much time programming as googling up your "knowledge", perhaps your verlet integration code would even be ready by now :)

We can see when you're wrong when you go into irrelevant topics.
2024-02-15 02:24
Martin Piper

Registered: Nov 2007
Posts: 645
Quote: Martin, if you have nothing to add to this conversation, then kindly shut up. No one wants to argue with you about tangential subjects just so you can die on yet another hill about something you clearly misunderstand.

Good lord man...


It's directly relevant since it details exactly how the instructions work.

Paz is just wrong and trying to go into tangents instead of sticking to the topic.
2024-02-15 02:26
chatGPZ

Registered: Dec 2001
Posts: 11141
It has been an irrelevant topic since post #28, so yes.

Everyone here knows already how illegal opcodes work and that incomplete decoding is involved. Really. If you want to call it PLA doesn't matter a single bit to the topic.
2024-02-15 02:30
Martin Piper

Registered: Nov 2007
Posts: 645
Quote: It has been an irrelevant topic since post #28, so yes.

Everyone here knows already how illegal opcodes work and that incomplete decoding is involved. Really. If you want to call it PLA doesn't matter a single bit to the topic.


It's not me calling it a PLA, it's all the technical sources demonstrating it's a PLA by the analysis of the gates on the chip. Meanwhile we have your lack of knowledge baseless claims.

The fact is "paz" you're just wrong on this topic as you are wrong on so many other topics.

It's relevant to the topic because it directly deals with how the instructions are decoded. It's why studying at things like visual 6502 are important.
2024-02-15 02:32
Martin Piper

Registered: Nov 2007
Posts: 645
Quote: Martin, if you have nothing to add to this conversation, then kindly shut up. No one wants to argue with you about tangential subjects just so you can die on yet another hill about something you clearly misunderstand.

Good lord man...


oh and "No one wants to argue with you" if that were true then "paz" wouldn't be trying to reply to my posts right? But here we he, "paz" is spewing rubbish again and again. If you have a problem with irrelevant posts then talk to "paz".
2024-02-15 02:34
chatGPZ

Registered: Dec 2001
Posts: 11141
Incomplete logic is not what defines a PLA. Removing "don't care" gates and logic from digital circuits is basically done everywhere, always (And the guys at MOS were really good at this, no doubt).

If you really want to pull the ancient TI terminology - even that doesn't apply. This refers to a standard component that can be customized by the customer. This is not the case for the 6502 either. The "custom chip" on the later AR5 hardware would be one for which this is the correct term, for example (iirc they coined yet another, different, term for this particular IC, because marketing reasons. Forgot what it was).

But what do i know. You are the expert.

(And yes, as soon as someone has to resort to calling names, you can be sure you have to take him serious. for real)
2024-02-15 03:24
Martin Piper

Registered: Nov 2007
Posts: 645
Quote: Incomplete logic is not what defines a PLA. Removing "don't care" gates and logic from digital circuits is basically done everywhere, always (And the guys at MOS were really good at this, no doubt).

If you really want to pull the ancient TI terminology - even that doesn't apply. This refers to a standard component that can be customized by the customer. This is not the case for the 6502 either. The "custom chip" on the later AR5 hardware would be one for which this is the correct term, for example (iirc they coined yet another, different, term for this particular IC, because marketing reasons. Forgot what it was).

But what do i know. You are the expert.

(And yes, as soon as someone has to resort to calling names, you can be sure you have to take him serious. for real)


Again incorrect.

https://en.wikipedia.org/wiki/Programmable_logic_array

"A programmable logic array (PLA) is a kind of programmable logic device used to implement combinational logic circuits. "

It does not have to be programmable or customisable by the customer either. A mask programmed part is still a PLA, just like the one in the 6502.


Your incorrect statements are not supported by anything.
2024-02-15 03:37
chatGPZ

Registered: Dec 2001
Posts: 11141
You are so right Martin. Thanks.
2024-02-15 03:54
ChristopherJam

Registered: Aug 2004
Posts: 1381
Martin, the very page you keep linking to opens by saying that "A programmable logic array (PLA) is a kind of programmable logic device," with the last three words linking to a page that states in the first paragraph that "the function of a PLD is undefined at the time of manufacture."

The incomplete address decoding is entirely tangential to post manufacture programmability. You're correct in saying that it's not a ROM, but you're wrong about saying it's programmable.
2024-02-15 04:02
Martin Piper

Registered: Nov 2007
Posts: 645
Quote: Martin, the very page you keep linking to opens by saying that "A programmable logic array (PLA) is a kind of programmable logic device," with the last three words linking to a page that states in the first paragraph that "the function of a PLD is undefined at the time of manufacture."

The incomplete address decoding is entirely tangential to post manufacture programmability. You're correct in saying that it's not a ROM, but you're wrong about saying it's programmable.


And can be mask programmable... "MOS Technology / Commodore Semiconductor Group began producing a **mask-programmed PLA**"


That's the important bit along with how the actual gates are on the chip. The gates for that part of the 6502 are very clearly documented in multiple sources as a PLA. "the original **6502 chip contained a PLA** to direct various operations of the processor"
2024-02-15 04:46
Martin Piper

Registered: Nov 2007
Posts: 645
"MOS 906114-01. This was a **mask programmable** NMOS clone of the 82S100."


"PLA pinout
The PLAs used in the C64 ... not connected internally **for mask programmable parts**."

https://skoe.de/docs/c64-dissected/pla/c64_pla_dissected_a4ds.p..
2024-02-15 05:04
Martin Piper

Registered: Nov 2007
Posts: 645
"the PLA may also be **mask-programmable** or field programmable. For a mask-programmable PLA, the user must submit a PLA program table to the manufacturer to produce a custom made PLA that has the required internal paths between inputs and outputs."

https://www.globalspec.com/reference/4274/348308/section-6-4-pr..


This rather proves the point that a PLA can be mask or field programmed.
2024-02-15 07:04
JackAsser

Registered: Jun 2002
Posts: 1990
Guys. Start a new thread about that and please stay on topic.
2024-02-15 08:33
Martin Piper

Registered: Nov 2007
Posts: 645
So specifically relevant to the timing of NMI in the instruction cycle. You can trace each cycle and see how the PLA decoding is affected. For example:

Click here: http://www.visual6502.org/JSSim/expert.html?nosim=t&panx=111.6&..

It will zoom into the top left portion of the 6502, the top left pad is NMI and just underneath and to the right is the PLA. The regular grid arrangement.

You can click the "Trace more" button a few times until "nmi" is displayed in the trace, or add "nmi" to the "Trace these too:" box.

Each click of the "forward" button will advance half a cycle.

Once the demo code is running, or your own edited code, you can open the javascript debugger and execute:

setLow('nmi');


This click "forward" a few frames, then use:

setHigh('nmi');


This will let you see how the NMI signal is intercepted and processed at the PLA level and precisely test this for every half cycle in any instruction you choose to do this for.

The debugger should show: Exec: BRK(T0) around the time it is reading fffa/fffb etc


You can also trigger IRQs with: setLow('irq'); setHigh('irq'); and test what happens with NMI timing when processing an IRQ.
2024-02-15 08:46
Martin Piper

Registered: Nov 2007
Posts: 645
And this help doc: https://www.nesdev.org/wiki/Visual6502wiki/JssimUserHelp

Has a nice useful section: set up some input pin transitions (Reset, IRQ, NMI, RDY)

Has this example URL which configures a NMI transition and updates the memory to allow for easily reproduced test cases with NMI and instruction timings, single stepping will show the same deterministic results each time and avoid having to do manual setup.

http://visual6502.org/JSSim/expert.html?graphics=f&loglevel=2&s..
2024-02-15 13:22
chatGPZ

Registered: Dec 2001
Posts: 11141
Quote:
the user must submit a PLA program table to the manufacturer to produce a custom made PLA

hear hear >_<
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
El Jefe/Slackers^sidD
blitzed
Janee/Breeze
Acidchild/Padua
wysiwtf
Total Chaos
McMeatLoaf
syntaxerror
Mibri/ATL^MSL^PRX
Flex/Artline Designs
Dr.j/Delysid
Jammer
algorithm
hedning/G★P
Guests online: 118
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 13:37  (9.6)
5 Edge of Disgrace  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 No Bounds  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 Layers  (9.7)
2 It's More Fun to Com..  (9.6)
3 Party Elk 2  (9.6)
4 Cubic Dream  (9.6)
5 Copper Booze  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Rainbow Connection  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Fullscreen Graphicians
1 Carrion  (9.8)
2 Joe  (9.8)
3 Duce  (9.8)
4 Mirage  (9.7)
5 Facet  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.12 sec.