######## POST p27124 | Sauraen | 2015-10-05 | t386-720.html [QUOTE] Stef wrote:Definitely very precious informations you're revealing here Sauraen !! The 9th bit of the DAC which is actually present in the test register, wonderful finding [IMG ./images/smilies/icon_smile.gif] [/QUOTE] Thanks! I'm having a lot of fun with this too. [IMG ./images/smilies/icon_smile.gif] [QUOTE] Something i'm really wondering, you said it would be pretty difficult to predict the behavior of the BUSY flag, but from what i understood it seems that only registers linked to OPN / FM states requires sort of processing time. Does it mean that writing to port 0 and port 2 (register index value) can be done at any time ? or at least that we can immediately write to port 1 or port 3 just after writing them ? [/QUOTE] I took a look at the BUSY signal and associated stuff, and this is what I've found so far. -- The signal that appears in bit 7 of the default read register is NOT the same as the signal that appears on the Test pin when it's configured as an output (by $2C:7 = 0). -- Neither signal affects any logic between the external I/O bus and the chip-level registers. This includes all the $2X registers, and also the address register and data register that all other addresses use. (I.e. when you write $78 to $52, it immediately stores $52 in the address register and $78 in the data register, and then when that operator--determined by the current address register--comes around in the circular buffers, it actually changes the value to whatever's in the data register.) This has the following results: The only limit on how fast you can write to the $2X registers is the YM2612's internal clock. Certainly it would need to have one cycle (6x 68000 clock cycles) for it to catch anything; I'd give it at least 2 (12) or maybe 3 (18), but hardware testing on this point would be great. Writing the address and writing the data should take the same amount of time. Writing data doesn't unlatch the address, you can keep writing data over and over to the last address. (I'm assuming this might be useful for the DAC.) Of course writing to the DAC faster than the YM2612's sample rate (external clock / (6*24)) will be useless. You can write to a $2X register while you're waiting for the channel/operator register write to complete. (EDIT: this is unfortunately not true) If you write to another channel/operator register while the last one is still pending, the previous write will be lost--it won't block the new write. The one exception is that if you write one address and data, and then you write a new address and data, but between writing the new address and writing the new data the new address's register comes along, it will write the old data in the new address (and then 24 cycles later the new data at that address, assuming the address didn't change before this). I'm just being specific here because someone might think "for any write, EITHER the chip misses it completely OR it gets it"--but this is a circumstance in which it gets the write wrong. -- The signal that appears on the Test pin originates from a "master sequencer" control unit (other outputs of which, for example, are the control signals for the algorithm in the operator unit, and a bunch more which I haven't traced yet). This control unit is located at the upper right of the PG and has a sizable decoder "table" and a couple smaller tables. (Sorry, Nemesis--this is a table you're not going to have worked out every bit of in your source code already! [IMG ./images/smilies/icon_wink.gif] ) Some of the outputs go directly into the interconnect, others go into push-pull buffers and then are routed throughout the chip. The Test pin output signal is one of these--it also ends up going to the PG, one of the timers, the channel register file, and probably a couple other places. I haven't traced the rest yet--hopefully more info coming soon. -- I hope I'm wrong about this, but this is what it looks like as best I can tell: the signal that appears on the default read register bit 7 (i.e. "BUSY") comes from a small timer/counter whose only inputs are the two clocks [the chip has clocks of both polarities throughout], system reset, and the "please read data off bus into registers" signal. The counter has 5 or 6 stages and is probably an asynchronous counter rather than a shift register, meaning it counts 32 or 64 cycles (of the internal clock, which is divided by 6 from the external clock). Since there's no other inputs, this means the timer starts when you write data and BUSY goes high, counts a certain number of cycles, and then clears BUSY. I'm guessing it's 5-bit and 32 cycles, because 24 cycles would be enough to ensure that all the operator registers have been updated. (Of course these are internal clock cycles, which is the external [68000] clock divided by 6.) I say I hope I'm wrong because if this is true, it means: The BUSY bit doesn't actually tell you any useful information about the chip's internal state, it's just a dumb timer for a fixed interval after a write. You might as well do timing in software. It implies that "the chip is busy", but in fact there's a lot you can do with the chip during that time (most importantly DAC writes). It overestimates the amount of time needed by 33% (32 instead of 24 cycles). 32x6=192 68000 cycles (about 90 Z80 cycles) is a lot of wasted time! I really hope it's not 64 internal cycles for some dumb reason! It makes the sound driver wait more than one sample between writes (assuming the sound driver does wait for it). This means the sound driver could never play a sample at the full YM2612 sampling rate, let alone do that and play other music at the same time. Can someone please test writing to various registers and counting Z80 cycles until the BUSY bit (bit 7 of the read register) goes low? Your counting doesn't have to be very accurate, one count every few Z80 cycles is plenty. Just check and see whether it's the same for a chip register, a channel register, and an operator register; and do the test a few times each, to make sure it's constant in each case. ######## POST p27127 | TmEE co.(TM) | 2015-10-05 | t386-720.html From my tests if you write to DAC faster than half the YM sample rate you get missed writes, sound gets noticably worse at that point. When you wait for busy you get roughly 22KHz sample rate when waiting for the DAC on some chips and roughly 32KHz on others (that is what i recall someone saying, I no longer remember results from my own tests). Some writes such as TLs seem to take longer to process than other stuff, I do full software timing in my old sound driver and I always had to have longer delays on TL writes or the data got mangled and I got wrong output. Same deal with the LR flags register. Others seemed to work faster. It doesn't make too much sense on hardware level though, at least if I designed the thing it wouldn't work like that [IMG ./images/smilies/icon_razz.gif] From what I have observed if you write too fast to the chip the new write will overwrite the old data messing up previous operation. Your research seems to confirm it. The busy flag SHOULD tell you when the chip is ready to grab new data. I would have thought the busy flag is cleared every sample or so. I guess it isn't the case... ######## POST p27133 | Stef | 2015-10-05 | t386-720.html Strangely in my case i never test the BUSY flag for DAC write and writing above 22 Khz does seems possible. Actually i logged output between 22 Khz DAC output and 32 Khz DAC output and i observed a real difference. Still it's quite difficult to say how much was actually played by the YM2612 DAC as my notebook microphone jack is pure shit but i can definitely saw the 32 Khz signal was better and more defined than the 22 Khz. You can easily do the test by yourself by using the "sound" sample given in SGDK, the first driver test allow you to play the same sample at different output rate (from 8Khz to 32Khz). About the BUSY flag itself, well in my case i never measured how much time it stay up but if it counts one sample for each write (even after address register write ?) then that is a pure waste of time :-/ What i can say is that the effective process time by the YM2612 is dependent from the register you are actually writing (as TmEE said). I observed than some registers requires no more than ~25 Z80 cycles to be processed but others can take a long than ~70-80 Z80 cycles... so now to be safe i am always testing the busy flag. I would say that a good practice to write YM register is to always check BUSY flag to be 0 first. Then if you need to write severals 2x registers you can write them really quickly with maybe 2 NOP to be safe between each write. When you write a specific register you write its address then you can immediately write its value, no need to check the BUSY flag between the address and value write... If that work then that is already a good thing to know [IMG ./images/smilies/icon_smile.gif] You said that : <> But if you do that, you can change the address register before the write to channel/operator occurred so the value is lost (or happen in the 2X register) ? Oh and by the way, internal clock of YM is not Z80 clock but 68000 clock (i just said that in regard of the Z80 cycle informations i gave) =) ######## POST p27138 | Sauraen | 2015-10-05 | t386-720.html [QUOTE] TmEE co.(TM) wrote:Some writes such as TLs seem to take longer to process than other stuff, I do full software timing in my old sound driver and I always had to have longer delays on TL writes or the data got mangled and I got wrong output. Same deal with the LR flags register. Others seemed to work faster. It doesn't make too much sense on hardware level though, at least if I designed the thing it wouldn't work like that [/QUOTE] [QUOTE] The busy flag SHOULD tell you when the chip is ready to grab new data. I would have thought the busy flag is cleared every sample or so. I guess it isn't the case... [/QUOTE] Haven't checked yet, but this is how I think it is: - All $2X registers will update within one internal clock. - All operator registers update once every 24 internal clocks. But you never know where in the cycle you're going to be, so you have to wait at least 24 clocks in all cases to be sure. - Some channel registers are like the operator registers and only update once every 24 clocks. Others update every 6 clocks. Hopefully I'll figure this out soon. The BUSY flag/bit does indeed tell you that the chip is ready--it just waits longer than the maximum necessary, so if you wait for it you're guaranteed to not mess anything up. [QUOTE] Stef wrote:About the BUSY flag itself, well in my case i never measured how much time it stay up but if it counts one sample for each write (even after address register write ?) then that is a pure waste of time :-/ [/QUOTE] No, it's triggered by data write, you can write addresses all day and the BUSY flag won't be affected. But yes, it waits more than one sample, since one sample is 24 clocks and it waits 32. One other thing to mention: it's possible they might have changed the BUSY flag in the YM3438 to actually only wait 24 clocks--I took a quick look at the die of that chip, and it's completely different, almost unrecognizable. The YM2612 is not only similar to the YM2203, they actually copied-and-pasted blocks from the YM2203 to the YM2612--in fact the position of some of the control units in the operator unit of the YM2612 matches where they were in the YM2203, even though this positioning doesn't make sense anymore in the YM2612. But anyway, both of these chips are built in NMOS, not CMOS (there's no P-channel FETs, and they vary transistor lengths rather than widths to control current and timing--breaking all the rules I'm learning in VLSI class!), so when the chip was redesigned in CMOS, it had to be completely redone from the ground up, they couldn't keep a single register. If they indeed changed the BUSY flag timing, this might explain how that one track in that one game plays faster on one system than another. [QUOTE] I would say that a good practice to write YM register is to always check BUSY flag to be 0 first. Then if you need to write severals 2x registers you can write them really quickly with maybe 2 NOP to be safe between each write. When you write a specific register you write its address then you can immediately write its value, no need to check the BUSY flag between the address and value write... If that work then that is already a good thing to know [/QUOTE] I would say this: Always give at least 1 YM2612 internal cycle (about 4 Z80 cycles) between any writes to the chip. Don't ever check the BUSY flag between writing address and data, it'll never be set anyway (unless it was already set before you wrote the address). Don't check the BUSY flag if the last address written was a $2X register. For all other writes, do software timing of just over 24 YM2612 internal cycles (about 70 Z80 cycles); this will save you about 25% from waiting for BUSY (about 90 Z80 cycles). Could someone please check this on hardware? I especially want to see what the minimum timing is for $2X writes and between address and data for all writes. [QUOTE] You said that : <> But if you do that, you can change the address register before the write to channel/operator occurred so the value is lost (or happen in the 2X register) ? [/QUOTE] I did mean that, but after thinking about it I take it back. The address register and data register for all other chip writes are at the same "level" as the $2X registers. So the access time for any of them is the same, and there ordinarily would be no reason you couldn't put an address and data in the operator/channel address register and data register, and then write to another $2X register immediately afterward. However, unfortunately, the operator/channel address register is enabled by any address which is not $0X. If I was designing it, I would have made it enabled by any address not $0X or $2X (would have taken slightly less logic than they actually have)--but the way it is, if you write another $2X register the operator/channel address register will get overwritten with that value as well. Sorry! [QUOTE] Oh and by the way, internal clock of YM is not Z80 clock but 68000 clock (i just said that in regard of the Z80 cycle informations i gave) =) [/QUOTE] Fixed, thanks! Dumb mistake, I've been playing with hardware clock circuits for these chips for the past few days, I know their frequencies. [IMG ./images/smilies/icon_smile.gif] ######## POST p27145 | Stef | 2015-10-05 | t386-720.html [QUOTE] Sauraen wrote: Haven't checked yet, but this is how I think it is: - All $2X registers will update within one internal clock. - All operator registers update once every 24 internal clocks. But you never know where in the cycle you're going to be, so you have to wait at least 24 clocks in all cases to be sure. - Some channel registers are like the operator registers and only update once every 24 clocks. Others update every 6 clocks. Hopefully I'll figure this out soon. ... No, it's triggered by data write, you can write addresses all day and the BUSY flag won't be affected. But yes, it waits more than one sample, since one sample is 24 clocks and it waits 32. I would say this: ... Always give at least 1 YM2612 internal cycle (about 4 Z80 cycles) between any writes to the chip. Don't ever check the BUSY flag between writing address and data, it'll never be set anyway (unless it was already set before you wrote the address). Don't check the BUSY flag if the last address written was a $2X register. For all other writes, do software timing of just over 24 YM2612 internal cycles (about 70 Z80 cycles); this will save you about 25% from waiting for BUSY (about 90 Z80 cycles). [/QUOTE] Thanks, definitely gold informations for anyone developing Z80 driver [IMG ./images/smilies/icon_wink.gif] You sometime need to write a lot of data to the YM2612 so saving cycles for write is important ! [QUOTE] One other thing to mention: it's possible they might have changed the BUSY flag in the YM3438 to actually only wait 24 clocks--I took a quick look at the die of that chip, and it's completely different, almost unrecognizable. The YM2612 is not only similar to the YM2203, they actually copied-and-pasted blocks from the YM2203 to the YM2612--in fact the position of some of the control units in the operator unit of the YM2612 matches where they were in the YM2203, even though this positioning doesn't make sense anymore in the YM2612. But anyway, both of these chips are built in NMOS, not CMOS (there's no P-channel FETs, and they vary transistor lengths rather than widths to control current and timing--breaking all the rules I'm learning in VLSI class!), so when the chip was redesigned in CMOS, it had to be completely redone from the ground up, they couldn't keep a single register. If they indeed changed the BUSY flag timing, this might explain how that one track in that one game plays faster on one system than another. [/QUOTE] I observed than write processing time on YM3438 is actually *slower* than YM2612 ! I got some issues on my MD2 with my initial driver implementation because i only tested it on MD1 for a long time :-/ ######## POST p27153 | TmEE co.(TM) | 2015-10-06 | t386-720.html 26KHz is the effective max for the YM DAC register from my tests, going higher makes the sound worse. I haven't done any actual investigation but there cannot be anything else happening than missed writes. I played some real music and all the higher freq stuff was getting garbled when you went beyond 26KHz. The game Hellfire has 2x slower music on MD2 than on MD1. The game spams YM with unnecessary writes and is being polite about it (waits for busy). Discrete YM3438 didn't seem to run 2x slower (I no longer remember the result...), but it has issues in other games (I recall Sonic Spinball being one). ######## POST p27154 | Sik | 2015-10-06 | t386-720.html Suddenly using blind cycle counting instead of BUSY in Echo is looking like a scaringly good decision. Also this reminds me, isn't it possible for the 68000 to read BUSY before it gets the chance to get set, at least on the YM2612? ######## POST p27155 | Sauraen | 2015-10-06 | t386-720.html [QUOTE] Stef wrote: Thanks, definitely gold informations for anyone developing Z80 driver [IMG ./images/smilies/icon_wink.gif] You sometime need to write a lot of data to the YM2612 so saving cycles for write is important ! [/QUOTE] Thanks, but I hope it's right! This is why I keep asking for someone to write some tests and run them on real hardware. I will be able to do so soon with a discrete YM2612 in a prototype board for my synth, but I don't have a Genesis flash cart nor do I know Z80 or 68000 ASM. [QUOTE] I observed than write processing time on YM3438 is actually *slower* than YM2612 ! I got some issues on my MD2 with my initial driver implementation because i only tested it on MD1 for a long time :-/ [/QUOTE] [QUOTE] The game Hellfire has 2x slower music on MD2 than on MD1. The game spams YM with unnecessary writes and is being polite about it (waits for busy). Discrete YM3438 didn't seem to run 2x slower (I no longer remember the result...), but it has issues in other games (I recall Sonic Spinball being one). [/QUOTE] Interesting. I have two different revision Genesis 2's (US models), and I will probably end up with a model 1 at some point. I also plan to throw a discrete YM3438 into the synth board at some point and see what happens. Also, that seems to answer the question at least in a general way. YM3438 has a longer BUSY delay because it has a longer internal register write delay as well. So the sound driver waits for BUSY, ends up waiting longer (maybe missing every other timer rollover or something?), and ends up slower. [QUOTE] TmEE co.(TM) wrote:26KHz is the effective max for the YM DAC register from my tests, going higher makes the sound worse. I haven't done any actual investigation but there cannot be anything else happening than missed writes. I played some real music and all the higher freq stuff was getting garbled when you went beyond 26KHz. [/QUOTE] That may not be entirely true. While it may be that there's some weirdness with the chip that causes the DAC value to be outputted only once every other sample (haven't seen this yet), I think what's more likely is that since this is roughly half the sampling rate, if you play music between this and the full sampling rate, it will play some samples once and some twice, which will introduce a whole bunch of aliasing at basically random frequencies. However, it should be that if you play samples at the full sampling rate, exactly (68000 clock) / (24*6), or exactly 144x 68000 instructions per sample, it will sound crystal clear. (Well maybe that's a stretch--it's still 8-bit, or 9-bit if you use the extra bit from $2C...) [QUOTE] Sik wrote:Suddenly using blind cycle counting instead of BUSY in Echo is looking like a scaringly good decision. [/QUOTE] As long as the BUSY delay is indeed longer than it needs to be, then yes. [QUOTE] Also this reminds me, isn't it possible for the 68000 to read BUSY before it gets the chance to get set, at least on the YM2612? [/QUOTE] Yes, if you violate the address/data timing requirements for the YM2612! Remember the internal clock is divided by 6 from the 68000 clock, so it takes at least 6 cycles if not 12 or so for the YM2612 to respond to its I/O bus. If you write a data byte and manage to "read" the data bus again in 3 or 4 68000 cycles, whatever data you read will be completely invalid. But as far as its internal clock, BUSY should get set on the same cycle as the data register gets loaded internally (which is probably the cycle after the I/O bus was written), and it should be externally readable on the cycle after that. So that could be up to 18 68000 cycles--so I could easily see how the status register could be read before BUSY was set. ######## POST p27159 | Eke | 2015-10-06 | t386-720.html From what I remember, Hellfire sometimes reads the FM status (timers and busy flags) from $4001-$4003 instead of just $4000 as recommended so maybe some (or all) of those flags can only be read correctly when A0 is low ? ######## POST p27161 | Stef | 2015-10-06 | t386-720.html [QUOTE] Sik wrote: Also this reminds me, isn't it possible for the 68000 to read BUSY before it gets the chance to get set, at least on the YM2612? [/QUOTE] When i designed my sound driver i first though it was possible but then i realized i was trying to read the busy flag from port 1/2/3 instead of port 0. Even from the 68000 i am not sure you can go that fast so you can read the busy flag before it actually turns to 1, also i never saw any Sega technical information about it and i believe that an issue like this one would have been probably notified by Sega engineers back in time. [QUOTE] 26KHz is the effective max for the YM DAC register from my tests, going higher makes the sound worse. I haven't done any actual investigation but there cannot be anything else happening than missed writes. I played some real music and all the higher freq stuff was getting garbled when you went beyond 26KHz. [/QUOTE] I don't know how you achieved to obtain these result as myself i never experienced worse sound by going higher... i have to admit i never tried going above 32 Khz anyway, 32 Khz is already quite high and eat rom very quickly :p [QUOTE] Also, that seems to answer the question at least in a general way. YM3438 has a longer BUSY delay because it has a longer internal register write delay as well. So the sound driver waits for BUSY, ends up waiting longer (maybe missing every other timer rollover or something?), and ends up slower. [/QUOTE] That is the problem, if we want to maintain compatibility with the MD2 we still have to wait for that BUSY flags as we don't know how slow is the YM3438 :-/ And maybe that unlike the YM2612, it does even requires a small wait between the address write and the value write (i hope that is not the case !) ######## POST p27178 | Sik | 2015-10-07 | t386-720.html Echo just assumes 19 Z80 cycles is enough. It seems to work for the most part (the only problematic part is instrument loading where it bangs 29 writes in a row, but moving 1 or 2 more instructions in the loop does the job). [QUOTE] Stef wrote:also i never saw any Sega technical information about it and i believe that an issue like this one would have been probably notified by Sega engineers back in time. [/QUOTE] That means nothing, most addenums are still missing. Also the fact we're still missing the documentation for the 3 button controller should say something. ######## POST p27181 | Stef | 2015-10-07 | t386-720.html [QUOTE] Sik wrote:Echo just assumes 19 Z80 cycles is enough. It seems to work for the most part (the only problematic part is instrument loading where it bangs 29 writes in a row, but moving 1 or 2 more instructions in the loop does the job). [/QUOTE] 19 cycles is enough for what ? Depending the register wrote on YM2612 you actually need to wait *a lot more* than 19 Z80 cycles. ######## POST p27188 | mikejmoffitt | 2015-10-07 | t386-720.html [QUOTE] TmEE co.(TM) wrote: Discrete YM3438 didn't seem to run 2x slower (I no longer remember the result...), but it has issues in other games (I recall Sonic Spinball being one). [/QUOTE] Given that the discrete YM3438 has different behavior than the ASIC one, and the ASIC one is further different from the YM3438 design, are we sure the ASIC one isn't actually a Sega fixed-and-improved YM2612 core? ######## POST p27193 | TmEE co.(TM) | 2015-10-07 | t386-720.html Service manuals say "YM3438" in the ASIC diagram. ######## POST p27197 | Sauraen | 2015-10-08 | t386-735.html [QUOTE] mikejmoffit wrote:Given that the discrete YM3438 has different behavior than the ASIC one, and the ASIC one is further different from the YM3438 design, are we sure the ASIC one isn't actually a Sega fixed-and-improved YM2612 core? [/QUOTE] The YM2612 is implemented in depletion-mode NMOS ratioed logic with dynamic gates. It's an old process that is cheaper to fabricate (though more difficult to design), but it has a static power consumption--if the chip is running and you stop the clock, it will still draw a significant amount of power. I haven't checked myself, but based on others' info the YM3438 is probably implemented in CMOS with dynamic gates, which is roughly the same process used in modern digital logic (CPUs, etc.). It has extremely low static power consumption, and hence a lower overall power consumption. I would be extremely surprised if the VDP was implemented in the power-hungry NMOS process, simply because it would get too hot. So unless Sega designed a custom YMXXXX chip that emulated the two Yamaha chips--instead of licensing the YM3438 design--what's in the VDP is basically a YM3438. However, there's no reason Sega couldn't have modified it, especially "outer" things like the way the address/data bus works. I will be testing discrete YM2612 and discrete YM3438 in my synth. ######## POST p27198 | Sik | 2015-10-08 | t386-735.html I thought the ASIC variant was somewhere between the YM2612 and YM3438 (since it has quirks from both). ######## POST p27199 | mikejmoffitt | 2015-10-08 | t386-735.html Well, given the nature of NMOS devices and static power consumption, that's actually what led me to wonder if it was a 2612 in the VDP in the first place. My CDX's VDP gets pretty warm just from regular use. Nothing wrong with the 5V rail, it's steady at 5V. Even still, if Sega's diagrams say it's a YM3438 then I'd be inclined to believe it's a 3438, or a Sega variant. It is very strange that the Sega-YM3438 would behave so differently compared to the discrete one. It's not impossible for Sega to have re-implemented the YM2612 in a CMOS process, realize that they've made something much like the YM3438, and call it the YM3438 in a logic diagram as a result. That's a bit outlandish, but it's just so weird to have it not be quite one chip and not quite the other. ######## POST p27202 | TmEE co.(TM) | 2015-10-08 | t386-735.html The VDP should be NMOS, and it does get hot, hotter than the NMOS 68K CPU in the machine. I even put a heatsink on it. The ASIC in MD only gets warm, and it has a bunch of stuff packed in. ######## POST p27204 | Sauraen | 2015-10-09 | t386-735.html [QUOTE] mikejmoffitt wrote:Well, given the nature of NMOS devices and static power consumption, that's actually what led me to wonder if it was a 2612 in the VDP in the first place. [/QUOTE] [QUOTE] TmEE co.(TM) wrote:The VDP should be NMOS, and it does get hot, hotter than the NMOS 68K CPU in the machine. [/QUOTE] Well then... Maybe what's going on is that they put a YM2612 in there, but messed with the I/O bus to integrate it with the bus arbiter and everything else in that chip. And of course then they slightly changed some timing thing, and voila. But if someone would just decap the VDP already, we would know for sure! We wouldn't even need ultra-high-res photography--just enough to pick out the OPN2 block and match it to one or the other. ######## POST p27306 | Sauraen | 2015-10-15 | t386-735.html Potentially good news! As a graduate student in electrical engineering at a major research university in the US, I know people with access to some pretty good equipment. I'm actually getting independent study research credit for my work with the YM2612, so I can get access to a micron-level optical microscope used by the semiconductor light source group. I asked about decapsulation and the professor who'd give me access said I can use the microscope, but there's no way I'll be able to get access to the chemicals needed to eat away the plastic. However, I have a buddy in the department who has a lot of cool toys, including a CO2 laser which he says can be theoretically used for decapsulation (especially if the chip doesn't have to work afterwards). He's going to test this on a few other chips, and then we'll test this on a VDP ASIC (I have a broken US Genesis II VA1.8 with the chip 315-5660-02). If this works well and we get some nice pictures, I'd be happy to decap chips for other people for free if they send them to me. Of course the chips will be destroyed and you won't get them back. ######## POST p27310 | Nemesis | 2015-10-16 | t386-735.html Wow, seriously awesome work Sauraen! I'm especially excited by the work you did figuring out the test register, being able to read the digital output of individual operators is absolutely golden. I'm going to be spending hours going over your notes and pictures with interpreting the die shots too, this is something I seriously want to learn how to do. If you can find it somewhere on the die, see if you can figure out what data tables/process is involved in the FM modulation feature. There are still unknowns in that process. In terms of the decapping, yes please! I was actually starting up my own "at home" decapping lab, and I've got the fuming nitric acid in the garage which can attest to it. I had some success and was working out the right process (and trying to take it slow so I didn't kill myself), but in the end I had to shelve it due to lack of time, but if you have access to professional gear, the work you could do on this could open up a lot of possibilities. I'm happy to supply hardware, and the VDP would be on the top of the list, followed closely by the I/O and bus arbiter chips. There's a few extra chips for other systems I'd like to slip your way too if you get this working [IMG ./images/smilies/icon_smile.gif]. The SVP processor in Virtua Racing is a must, but so are the DSP chips on the Sega Model 1 arcade hardware, which to this day have critical, undumped embedded ROM data. And there's the MegaCD, and the Sega Saturn.... I know I know, that's a lot of chips and a year of photography work, but one can dream. [IMG ./images/smilies/icon_biggrin.gif] ######## POST p27317 | Eke | 2015-10-16 | t386-735.html [QUOTE] Nemesis wrote:I was actually starting up my own "at home" decapping lab, and I've got the fuming nitric acid in the garage which can attest to it [/QUOTE] [IMG ./images/smilies/icon_eek.gif] ######## POST p27318 | Stef | 2015-10-16 | t386-735.html Haha, when i read this i internally had the same reaction / feeling, crazy guy ! But that is how we progress [IMG ./images/smilies/icon_smile.gif] ######## POST p27319 | Sauraen | 2015-10-16 | t386-735.html [QUOTE] Nemesis wrote:Wow, seriously awesome work Sauraen! [/QUOTE] Thanks! I was hoping to see you here at some point! And I will thank you in return for the years of work on this chip--I wouldn't have known where to begin with the die, nor frankly would have had the interest, without your wonderful details. [QUOTE] Nemesis wrote:I'm especially excited by the work you did figuring out the test register, being able to read the digital output of individual operators is absolutely golden. [/QUOTE] I thought you'd be excited by some of this stuff! But there's still bits I haven't fully explained; some of them are going to take quite a while. [QUOTE] Nemesis wrote:I'm going to be spending hours going over your notes and pictures with interpreting the die shots too, this is something I seriously want to learn how to do. [/QUOTE] I can write a little tutorial, but the biggest help while I've been doing the operator unit recently is that I'm actually reading the YM2203 die, and cross-checking things with the YM2612. I can actually read all the layers off the former, but in the latter I really can't see the diffusion when there's metal and poly on top of it. As I mentioned above, blocks from the YM2203 were copied-and-pasted onto the YM2612; other chips, for instance the YM3438, are a complete reimplementation (in that case, in a different technology). [QUOTE] Nemesis wrote:If you can find it somewhere on the die, see if you can figure out what data tables/process is involved in the FM modulation feature. There are still unknowns in that process. [/QUOTE] You mean how the outputs of operators are summed and fed back to modulate the phase of another operator in the operator unit? Or the LFO modulating the frequency of a voice (which is actually the only true FM the chip can do)? If you're talking about the operator unit, I'm in the process of making a complete VHDL equivalent description of the unit, that will work in YM2203 or YM2612 depending on a generic value (number of voices, which just changes the length of the shift registers). This will directly correspond with the chip at the sub-module level, including all internal I/O lines from other modules. This is the best way to document the chip at this level. The only thing that's different between what I'm doing and what's in the original chip is that in the chip, they use latches gated by both clock phases, rather than edge-triggered flip-flops in FPGAs. For instance, what I was working on last night: the circuit taking the outputs of the operator previous-value registers and summing two of them to produce the feedback value (before the shifter controlled by the FEEDBACK register). This is done in two stages. The values that go into the section (from the registers or current operator output) are gated by one phase of the clock (let's call this "low"). There's logic to select among them and produce two values which are going to be added; the two results here are gated by the "high" phase. The results of that go through a standard adder, and the result is gated by the "low" phase. Instead, what I'm doing in VHDL is that both the selection logic and the adder are in one "section" with no latch between them, but there's a flip-flop that stores the output of the whole thing once per clock cycle (on the rising edge). These two approaches are equivalent ASSUMING there's no timing stuff that depends on one phase or the other; if I find that there is, I'll have to change my approach in the VHDL. One tidbit I've found so far here: the two selection outputs are sign-extended to 15 (from 14) bits before being added (just means the MSB is copied to the new MSB); the 15-bit result is sent to the shifter; and the carry-out of the last bit is discarded. The carry-in is fixed to zero. The shifter is next on my list to do. [QUOTE] Eke wrote: [QUOTE] Nemesis wrote:I was actually starting up my own "at home" decapping lab, and I've got the fuming nitric acid in the garage which can attest to it [/QUOTE] [IMG ./images/smilies/icon_eek.gif] [/QUOTE] Yeah, basically. The professor told me access to those chemicals was severely restricted due to safety concerns, and I shouldn't even try to get some. We'll see how the laser method goes. Let me see how it goes with this chip before you get too excited about future ones! But if all goes well, that won't be a year of work; the laser should be quick, and the photography shouldn't be that bad. If some of these chips are in unusual packages, what would help to maximize the chances of success would be if you could also send a random different chip that happens to be in the same package--that way we would get two chances to get the laser depth right. Keep in mind that reading this logic takes a long time, and reading ROMs isn't terribly easy either, depending on the photo quality and lighting as well as the chip process. ######## POST p27320 | mikejmoffitt | 2015-10-16 | t386-735.html If you can read the digital output of an operator, it would be very productive to dump with a logic analyzer the output of the carrier with TL at max, with all modulators silenced, to get a decent dump of the sine table used internally. ######## POST p27321 | Sauraen | 2015-10-17 | t386-735.html [QUOTE] mikejmoffitt wrote:If you can read the digital output of an operator, it would be very productive to dump with a logic analyzer the output of the carrier with TL at max, with all modulators silenced, to get a decent dump of the sine table used internally. [/QUOTE] That won't be necessary. Nemesis probably already has it 100% correct, and I can read it from the die shot just fine. When I release the VHDL equivalent description of the operator unit, that will include the table exactly as it is in the chip, with the additional logic that modifies its output to produce the value that an emulator would likely have. ######## POST p27332 | Nemesis | 2015-10-19 | t386-735.html [QUOTE] Sauraen wrote: [QUOTE] Eke wrote: [QUOTE] Nemesis wrote:I was actually starting up my own "at home" decapping lab, and I've got the fuming nitric acid in the garage which can attest to it [/QUOTE] [IMG ./images/smilies/icon_eek.gif] [/QUOTE] Yeah, basically. The professor told me access to those chemicals was severely restricted due to safety concerns, and I shouldn't even try to get some. [/QUOTE] [QUOTE] Stef wrote:Haha, when i read this i internally had the same reaction / feeling, crazy guy ! But that is how we progress [IMG ./images/smilies/icon_smile.gif] [/QUOTE] Yeah, you need the right balance of crazy and cautious to attempt this I think. Hopefully I've got that balance right [IMG ./images/smilies/icon_smile.gif]. I actually exaggerate slightly, because technically my nitric acid isn't "fuming" nitric acid, it's reagent grade 70%, and Wikipedia tells me that in order to be classified as "fuming" nitric acid, it needs to be 90%. I still call it fuming though, because call me silly, but my definition of fuming is "gives off fumes", and I can tell you, 70% nitric acid does that plenty well at room temperature thank you very much. I could of course distill this 70% solution to increase the concentration, but I actually don't see the need. The reactivity of the nitric acid can be increased by raising the temperature. Rather than heating the acid, I got myself an old electric fry pan, and placed a block of offcut marble from a benchtop in it, to give me a good thermal mass and something I could chemically abuse without worry. This is all wired up to a temperature controller to keep a stable temperature, and I then just stick the chip on the marble block to heat it up. I was experimenting with 70-80 degrees celcius. I then use one drop of acid at a time directly on to the chip package. With the chip so hot, it heats the acid on contact and causes a strong reaction, and after a second or two, I flush with a little acetone and repeat. This seems to work well. It's much better to have the slightly less nasty 70% nitric in storage than true fuming nitric too. I still get paranoid about this acid, and check on the bottles from time to time, just in case. They're stored in an old, thick wooden cabinet at ground level, with a magnetic lock that can only be opened by placing a magnet at the right magic place on the front door. The acid bottles are in tern surrounded by several large plastic containers of deionized water, with the theory that if it somehow escapes and starts eating away at anything, the plastic bottles will break and flood the area, diluting the acid to a harmless concentration. I'm actually not just using nitric acid through, I'm using a nitric+sulpheric acid mix. I came across a paper that talked about mixing sulpheric acid with nitric acid, to create a "buffer" which should apparently protect the metal layer, for the first few seconds of contact anyway, which I want to do at least for the initial decapping, so I'm trying a mix of 3 parts nitric (70%) to 1 part sulpheric (98%). The original paper called for 2 parts nitric to 1 part sulpheric, but they were using fuming nitric, so I've adjusted the quantities. Still yet to verify the results. Finding nitric acid was hard though, and laws vary between countries. I live in Australia, and while it's not illegal to buy or possess nitric acid in high concentrations, it's still tough to find any companies which will supply it retail to an individual, and just as tough to ship it. With how good it is at building things that go boom, and how hazardous it is to transport and store, this isn't surprising. I found a single supplier in the country where I could get it, and had it personally couriered to my door by a chemical courier company. I'm probably on some kind of terrorist watchlist now after making the purchase, but so be it. Fortunately the prices weren't too bad. In the end, this was the smallest cost though, the cash starts adding up quick when you realize all the other equipment you need in order to, you know, not die. Storing this mix is a real pain. Nitric+sulpheric acid reacts with just about everything. A lot of standard lab equipment, and basically all the standard lab safety gear, can't handle this kind of acid. You can't use any plastic, it's glassware throughout, and the fact it fumes means you can't keep it in anything with a rubber dropper or the like very long, because it'll rise up and start eating it. Made that mistake with my first attempt. Came back in the shed and found it had eaten its way out of my vials and started stripping the paint off the workbench. Makes very good paintstripper. For storage, you're basically limited to glass and teflon. Protective gear also needs to be neoprene. And then there's the fumes. That's the last barrier I had to properly address. I could mix the acids safely enough in open air, but when it comes to the actual decapping, the fumes are simply to hazardous, even with my kit that makes me look like I walked off the set of breaking bad. The vapour from this stuff can turn your lungs to soup, and outdoors is simply too uncontrolled an environment to work in for long. I ended up getting an old industrial fume cabinet off ebay for $1, just needed to set it up in an area and have another go. Haven't had a chance to get back to it since then though, and right now my garage is full of parts from my truck, the engine for which I'm rebuilding, so that's the project that needs to be finished first before I get back to this again. Still, I managed to get about halfway to the die of the chip I was testing on last time before I had to stop due to the fumes, and that only took a minute or so, so I'm hopeful with the fume cabinet, I can decap chips quickly and easily. Then it'd be on to the photography issue. I've picked up a really high-end Nikon 20x Plan microscope objective (http://www.nikoninstruments.com/index.p ... -VC-Series ), and under tests with an adapter for a telephoto lens on a digital camera, I believe it will work well. I was inspired by examples I've seen of this online, such as here: http://www.photomacrography.net/forum/v ... php?t=9664 . I still need to pick up the actual camera I'm planning to use (waiting on the right price), but with the complete setup, I should be able to capture 18 megapixel (or whatever the camera I get supports) pictures at 20x zoom, which based on research, I believe will be enough detail. My lighting solution should work, and I've got an X/Y table thingy from an old microscope to address the stability issue for taking the pictures, which is critical, because the focal depth of a microscope objective is insanely small. Apart from the camera, I'm pretty sure I have everything now to make this work, just need the time to work on it again. [QUOTE] Sauraen wrote:We'll see how the laser method goes. Let me see how it goes with this chip before you get too excited about future ones! But if all goes well, that won't be a year of work; the laser should be quick, and the photography shouldn't be that bad. If some of these chips are in unusual packages, what would help to maximize the chances of success would be if you could also send a random different chip that happens to be in the same package--that way we would get two chances to get the laser depth right. [/QUOTE] Cool, can't wait to hear how it goes! My backyard setup would be handy for the long term, and hell it's just plain fun to try, but I have a feeling you'll be able to turn around a result quicker than I'll be able to get my rig up and running, especially with how little time I've had this last year. [QUOTE] Keep in mind that reading this logic takes a long time, and reading ROMs isn't terribly easy either, depending on the photo quality and lighting as well as the chip process. [/QUOTE] Yep, no illusions about that, but even without much analysis, some things can be determined very quickly that otherwise are very hard to know. IE, is that unused pin actually connected to something internally? What might those "test" lines be wired up to? Longer term, it also serves as an indisputable, absolute reference on what's really inside a chip. After research, like the kind you're doing, we can know for certain what the internal operation of the chip is. Combining decap analysis with physical system tests, everything should be possible to reveal. The problem with system tests alone is you've still essentially got a black box, so you don't know for sure if you're missing something. Decapping can highlight things that have been missed in system testing. Into the future, a delayered die-shot will be the most important resource for emulating old hardware. Things need to start with logical documentation, either official or reverse engineered, but they can't truly be completed for any reasonably complex chip without decapping IMO. ######## POST p27333 | Sauraen | 2015-10-19 | t386-735.html [QUOTE] Nemesis wrote:Cool, can't wait to hear how it goes! My backyard setup would be handy for the long term, and hell it's just plain fun to try, but I have a feeling you'll be able to turn around a result quicker than I'll be able to get my rig up and running, especially with how little time I've had this last year. [/QUOTE] Well, we did get results quickly, but they weren't good ones. Turns out the "plastic" packages are actually glass-epoxy; the laser vaporizes the epoxy and fuses the glass, so you get a nice ugly layer of SiO2 over the chip and it's impossible to see. [IMG ./images/smilies/icon_sad.gif] My buddy is going to try a few more techniques with the laser before giving up, but it's not looking good. This is a dumb question, but wouldn't less-concentrated acid still work, just take longer? I'm sure I can get ahold of some 10% nitric acid, what if I leave that on the chip overnight? I know there was talk of getting photos of the chips with and without the metal layer, but if you can only choose one, with the metal is MUCH more helpful. For these old chips there's only one metal layer; for chips with several, you'd have to selectively eat away one at a time and take pictures between each one. Would it be possible for you to decap some of these chips, take some initial photos, and then ship them to me and I'll use the university's microscope to take the final ones? The equipment here is for looking at experimental LEDs at micron resolution, so it should be better than any consumer camera jerryrigged to a microscope. ######## POST p27343 | Nemesis | 2015-10-19 | t386-735.html [QUOTE] Well, we did get results quickly, but they weren't good ones. Turns out the "plastic" packages are actually glass-epoxy; the laser vaporizes the epoxy and fuses the glass, so you get a nice ugly layer of SiO2 over the chip and it's impossible to see. [IMG ./images/smilies/icon_sad.gif] My buddy is going to try a few more techniques with the laser before giving up, but it's not looking good. [/QUOTE] Yep, these packages are nasty little things. Not much works well for them. I'm only aware of two methods that are known to work reliably, with the right setup. The first one is of course nitric acid decapsulation. The second approach is manual drilling of the package down to the die. With xray equipment to work out the precise depth and size of the embedded die, and with an extremely precise milling machine setup, you can drill down to the die surface, or a fraction of a mm above it, then gently split the remaining tiny layer from the die surface. That said, acid decapsulation seems easier and less error prone, if not a little more risky to your health. There is a simpler, more brutal decapsulation method I've seen used. I've seen lots of examples, but there's a good description here: http://www.t4f.org/articles/ultra-low-c ... psulation/ The method is basically to heat up a beaker of nitric acid and dunk an IC in, and let it totally eat away everything but the die. I believe this is slightly safer on average in the sense that you actually handle and deal with the acid less. You don't need to actually dropper it bit by bit on the chip and stand next to it while it's fuming, but at the same time, you have to use a larger quantity of acid, and you have to heat that entire volume of acid at once, which in my mind means the "worst case" scenarios are a bit worse with this method. 100ml of boiling nitric acid sitting on a hotplate in a glass beaker? Yeah, not fun. It's much cheaper to setup and simpler on the whole though. I didn't go with this method however, because I wanted to preserve the outer package as much as possible, and more significantly, this approach doesn't give you any option to preserve the metal layer, which I wanted to be able to do. Still, I'll throw it out there as an option. [QUOTE] This is a dumb question, but wouldn't less-concentrated acid still work, just take longer? I'm sure I can get ahold of some 10% nitric acid, what if I leave that on the chip overnight? [/QUOTE] I am by no means a chemist (in fact, I hated chemistry), but my understanding is that without concentrated enough acid, or sufficient temperature, the reaction won't even begin. A 10% solution is so weak, I don't think it'll do anything. The article I linked above says as much for the 60% acid they used, so 10% would certainly be much, much worse than that. You might have to check what you can easily source in your area. The guy who wrote that article is obviously in Europe, but it seems he could buy 1 litre of 60% nitric in a bottle locally for around 30 euro. You can't buy anything like that here in Australia, no stores I found even stock nitric acid in any concentration. Maybe you can find something like that in the US though? Still I totally understand if you don't want to even investigate this option yourself. If you have access to a proper chemistry lab, or a friend who does, with all the right lab equipment and a proper fume cabinet, it should be really easy to make an attempt yourself. Pretty much all you're doing is mixing two acids together (in the right order! Pour the strong into the weak), heating up the chip, and droppering the acid mix onto the chip until you reach the die. That part is easy. 90% of the difficulty is in setting up the environment properly with the right equipment, but a proper lab should have everything ready to go. If you don't have any of that though, it's a long, expensive, hazardous road to get setup, I can tell you. [QUOTE] Would it be possible for you to decap some of these chips, take some initial photos, and then ship them to me and I'll use the university's microscope to take the final ones? The equipment here is for looking at experimental LEDs at micron resolution, so it should be better than any consumer camera jerryrigged to a microscope. [/QUOTE] What's the timeframe here? I'm really, really busy with work and life right now. I'm flying over to Denver this Saturday for a couple of weeks for work, then Adelaide shortly after I get back. I've got kids and a pregnant wife back home, and we've been moving house, with all my gear in storage. What's not in storage is in the old garage, as I said with a disassembled engine taking up most of my work area. It's really unlikely I'll be able to do anything more on this stuff until next year. I will get back to it, but obviously you won't have access to that gear forever. It's very hard for me to predict when I'll have enough time to work on this again, so you might need another option rather than waiting for me. If you can put a couple of dollars into this, it might be worth looking at commercial decapping labs. There was a place in the US called MEFAS that would do decapping for very good prices. I made an inquiry back in 2008, at that time it was $75 per chip, but unfortunately they would only FedEx post out of the US, which was $150 and made it too expensive for me. Still, you're US based, so the postage will be cheap. MEFAS would even guarantee the chip would still be operational after decapping. They were happy to deal with individuals, and didn't care what they were decapping (IE, you didn't have to be a company, or the creator of the IC). Google tells me they've since been bought out by a place called "Evans Analytical Group". Here's the page: http://www.eag.com/mte/failure-analysis-services.html You'll have to make an inquiry to find out about price, but hopefully they're still reasonable. Since you wouldn't need any photography, they should be able to offer a really cheap price. All they need to do is stick your chip in their automated decapping machine for 5 minutes. This should be a very cost effective option for a few chips. I was looking at my own at-home decapping lab because I wanted to be able to do a LOT of chips, but for a small number, this could actually be the cheapest, simplest option, and the turnaround time should be really quick. ######## POST p27344 | Nemesis | 2015-10-19 | t386-750.html I did some research on laser decapping, and found some very interesting info. http://hackaday.com/2015/08/24/using-a- ... decap-ics/ Seems this is an up and coming method. You might want to read it over and follow the links, and show it to your buddy. Looks like laser decapping is possible, might just be a matter of getting the technique and power levels right? EDIT: Just noticed this article is actually dealing with a die covered in a blob of epoxy, not a typical plastic package. I think this is a very different beast, so maybe none of this applies. ######## POST p27345 | Sauraen | 2015-10-19 | t386-750.html I've done a little more research since my last post, and I'm pretty much on the same page. The wiki at siliconpr0n lists a technique using concentrated sulfuric acid only, and it looks like this may be possible with the facilities I have access to. I will have more information in the coming weeks. Would it be helpful to everyone if a single VDP/IO/arbiter/OPN2/PSG ASIC was decapped and photographed, even if this meant multiple revisions were not documented? If so, I'll just forget about the manual method and go to EAG/MEFAS. As far as the laser, that's exactly the article my buddy saw and got him going--but those "glop tops" are epoxy only, no glass. He's going to try something with the laser and a powerful air jet next, to see if he can do something about the glass. ######## POST p27349 | mikejmoffitt | 2015-10-19 | t386-750.html I'd actually love to see a decapping of the Genesis 3 all-in-1 ASIC, if that's available. ######## POST p27353 | Sauraen | 2015-10-20 | t386-750.html [QUOTE] mikejmoffitt wrote:I'd actually love to see a decapping of the Genesis 3 all-in-1 ASIC, if that's available. [/QUOTE] You want to donate one? ######## POST p27357 | mikejmoffitt | 2015-10-20 | t386-750.html [QUOTE] Sauraen wrote: [QUOTE] mikejmoffitt wrote:I'd actually love to see a decapping of the Genesis 3 all-in-1 ASIC, if that's available. [/QUOTE] You want to donate one? [/QUOTE] I would, but mine isn't available since I'm not anywhere near it. If you can give me a few months, then yeah, that should be possible. ######## POST p27368 | Nemesis | 2015-10-22 | t386-750.html [QUOTE] Sauraen wrote:Would it be helpful to everyone if a single VDP/IO/arbiter/OPN2/PSG ASIC was decapped and photographed, even if this meant multiple revisions were not documented? If so, I'll just forget about the manual method and go to EAG/MEFAS. [/QUOTE] Eventually we'd want both, but only one chip could be done right now, doing the all-in-one would be a pretty good idea. That at least gives us a peek into all the chips in one hit. Most likely the ASIC is little more than each of the original discrete chips glued together on the one die. Although we do know there are some internal differences with some of the components like the VDP, it's a great starting place, and we can always decap the discrete versions later on. The other advantage is that if we decap the discrete versions later, we'll get the first revisions of them done, while the ASIC effectively has the last revisions of them, so it'll be able to highlight internal differences that have occurred between the versions. [QUOTE] Sauraen wrote: [QUOTE] mikejmoffitt wrote:I'd actually love to see a decapping of the Genesis 3 all-in-1 ASIC, if that's available. [/QUOTE] You want to donate one? [/QUOTE] They're actually pretty easy to get, any VA2 Genesis 3, which you can identify by a serial number beginning with "AG82", has the very last revision of that chip. The system isn't really considered a collector's item, so they're usually cheap as chips. Here's one on ebay right now for $16: http://www.ebay.com/itm/252116959245 Pretty hard to beat that price. EDIT: Since that one is sold as untested, and you're going to invest quite a bit of time and effort into this, you may only want to go ahead with the decapping of that system if you're able to test it before you proceed. Almost certainly there's absolutely nothing wrong with it (after all, this is the board: http://segaretro.org/File:PC_BD_MD3_VA2_USA.jpg ), but better to check before proceeding IMO. If you just want to buy one that's listed as working, there are plenty of other systems going, but unfortunately a lot of ebay sellers don't show the serial numbers in their pictures. This was the cheapest one I could find listed as known working which showed an AG82 serial: http://www.ebay.com/itm/161864280729 There are other cheaper systems (and even a cheaper bundle of 3 systems) you could look at If you're willing to message the sellers to check the serial numbers. I'd strongly suggest sticking to the VA2 board, since we already know it contains some important internal changes in this chip revision that have been noticed in software. ######## POST p27370 | Sik | 2015-10-22 | t386-750.html If we go with requests for decaps we could try the TCT-6705 as well. Yes, it's a clone, but I checked it against Overdrive and the whole demo behaves as expected so I imagine it's some sort of superclone. The thing that catches my attention is that the Mega 3 (the clone I tested with) has 48* of the pins unconnected (out of 128), and I don't think there are that many connections under the chip since there really isn't much room (there's nothing on the other side of the board so there's no way to dodge crosses). With that many pins unconnected I imagine there must be something going on. *Actually 49, but one has a trace going nowhere, so I assume it's just some toggle e.g. Master System or TMSS. We should probably discuss which chips to decap in another thread though (so we can keep discussion about the YM2612 separate from the rest of the stuff, and make it easier to go back and see what we want to decap =P). ######## POST p27387 | Sauraen | 2015-10-23 | t386-750.html Okay, here's a thread about the decapping: viewtopic.php?f=13&t=2191 ######## POST p28045 | SeregaZ | 2015-12-13 | t386-750.html maybe you have some dll of YM2612 for using in another programm languages? i mean send command like: SendToYM2612(register, value) like OPN.dll, that give me ValleyBell... i see full code, but i think i cant to port this to my language... ######## POST p28067 | r57shell | 2015-12-14 | t386-750.html [QUOTE] SeregaZ wrote:maybe you have some dll of YM2612 for using in another programm languages? i mean send command like: SendToYM2612(register, value) like OPN.dll, that give me ValleyBell... i see full code, but i think i cant to port this to my language... [/QUOTE] checkout any opensource emulator, then separate its YM2612 into external DLL for example here is genplus-gx YM2612 and SN76489 (PSG): https://github.com/ekeeke/Genesis-Plus- ... core/sound here is gens-rerecording YM2612: https://github.com/TASVideos/gens-rerec ... c/ym2612.c and here is YM2612 from MESS: http://git.redump.net/mame/tree/src/dev ... fm2612.cpp Don't forget to check license for compatibility ######## POST p28075 | Sik | 2015-12-14 | t386-750.html [QUOTE] r57shell wrote:Don't forget to check license for compatibility [/QUOTE] Yeah that tends to be quite the issue, either it's something based on the MAME core which has an explicit "no commercial use" clause (this can become an issue for composing music for homebrew which would be otherwise legal) or it's based on the Gens core which is not exactly the greatest out there (although at least it allows commercial use since it's GPL... or is that part of the emulator not covered by it?). ######## POST p28077 | MetalliC | 2015-12-14 | t386-750.html [QUOTE] Sik wrote:either it's something based on the MAME core which has an explicit "no commercial use" clause [/QUOTE] currently MAME in process of relicensing, so in most parts it is BSD-3 or/and GPL already. but not in the case of FM OPL/OPN cores, its commercial usage was explicit forbidden by its author (Jarek Burczynski). ######## POST p28080 | Sik | 2015-12-14 | t386-750.html And that wouldn't have helped with the derivative code either (see: Genesis Plus GX), since you can't change licenses retroactively. Nice to see that there's an attempt to relicense MAME's code though. I can see where they come from with "no commercial use" but technically the way copyright works already would forbid it anyway for starters (having permission to use MAME commercially doesn't mean you have permission to run the games =P) ######## POST p28094 | r57shell | 2015-12-15 | t386-750.html [QUOTE] Sik wrote: [QUOTE] r57shell wrote:Don't forget to check license for compatibility [/QUOTE] Yeah that tends to be quite the issue, either it's something based on the MAME core which has an explicit "no commercial use" clause (this can become an issue for composing music for homebrew which would be otherwise legal) or it's based on the Gens core which is not exactly the greatest out there (although at least it allows commercial use since it's GPL... or is that part of the emulator not covered by it?). [/QUOTE] I don't see trouble here. If you testing commercial song playback for example in MESS, does it violate its license? If no, then obviously you can make other freeware composer thing based on its source and test songs there again. Or you can't? I'm not familar with law so close [IMG ./images/smilies/icon_confused.gif] But you made me confused. But obviously you can't use its core as sound engine for commercial PC game for example. That's true. And, in the end. It's always better to test music straightforward on console itself (sega genesis I mean), via JOYPAD port or stuff like UMDK etc... ######## POST p28105 | Sik | 2015-12-16 | t386-750.html The problem being most licenses just say "non-commercial use" without giving any specifics on what counts as commercial use so in practice it's up to how angry is the lawyer =P ######## POST p28109 | SeregaZ | 2015-12-16 | t386-765.html commercial? [IMG ./images/smilies/icon_smile.gif])) this software will be used by 5-10 mans... what commercial you talking? [IMG ./images/smilies/icon_smile.gif] it is just for romhackers comunity. ######## POST p28110 | MetalliC | 2015-12-16 | t386-765.html its going off topic but... you are wrong, here is a lot of old games was released recent times, mostly from DotEmu company. all of them emulated, for example Raiden Legacy in Steam and GoG is MAME-based. so I'm not surprised some people like Jarek doesn't want to see their's code and research research results used by someone else for making money. ######## POST p28111 | Eke | 2015-12-16 | t386-765.html [QUOTE] MetalliC wrote: so I'm not surprised some people like Jarek doesn't want to see their's code and research research results used by someone else for making money. [/QUOTE] I am not sure if he is aware that his code is being used commercially in Genesis Plus GX ripoffs that have a lot of exposure and likely make huge profits out of it: - MD.emu on Google Play (https://github.com/Rakashazi/emu-ex-plu ... /ym2612.cc ) - Hyperkin's Retron 5 (http://retron5.in/node/9 ) - Cybergadget's Retrofreak (http://www.cybergadget.co.jp/support/re ... tware.html ) That's the only part they use (with ym2413 implementation) that is still not licensed under GPL, yet they don't have any issue with that. Sadly we could not claim anything since we are not copyright holders for this code. ######## POST p28114 | r57shell | 2015-12-17 | t386-765.html [QUOTE] Eke wrote:Sadly we could not claim anything since we are not copyright holders for this code. [/QUOTE] Really? I thought all contributers considered as holders, except if in license noted something different. For example you can't even change license, until you have approve from all contributers, that's why some people using BSD and other no-restrictive at all licenses to avoid any troubles, if for example too many contributers already, and you can't change politics and direction of project... Again, I'm not sure, but that what I thought. ######## POST p28164 | Sauraen | 2015-12-19 | t386-765.html I apologize for my absence from this thread for the last couple months, I've been very busy towards the end of this semester with several things (including making a complete 8-bit microprocessor at the transistor level for a VLSI class--46 instructions, 50 MHz!) I've finally finished my VHDL equivalent description of the YM2203 / YM2612 operator unit. The code is available at https://github.com/sauraen/YM2612 . As I explain in the file header as well, this is an untested implementation. Obviously I tried to get everything right, but it is very likely there will be a couple bit errors in the logsin and exponential tables, and also it's possible a signal should be inverted from how I have it. But I am confident that this matches the chip architecture at a high level--that is, the pipelining and register positions. This should also clear up questions about bit widths, when carry-outs are used and when discarded, etc. Also the exact use of Test Register $21 bit 4 is included. I'm taking requests for what to reverse engineer next. (Please don't say the EG!) I would go with the LFO, but honestly I haven't found it yet. I will tell you this, it is absolutely not a sine wave LFO, it must be a triangle wave--there's no other logic interfacing to the operator unit's sine table for the LFO, and there's no other table that would be large enough to hold any decent approximation of a sine wave. Also, in the OPL2/OPL3 which have an "exponential" waveform available, it is thought to be a "readout of the exponential table"--I doubt this, it probably just skips the logsin table completely. ######## POST p29435 | Count SymphoniC | 2016-04-08 | t386-765.html I've been puzzled over the math involved in determining the number of cycles to wait in between register writes. The number is 24 internal cycles * 6 = 144 68000 cycles? If a 68k nop is 4 cycles, does that mean it would take 36 68k nop's in between writes? I swear that doesn't sound right, that seems like a lot.... Where am I wrong? ######## POST p29436 | Sik | 2016-04-08 | t386-765.html In assuming the YM2612 is fast, it's actually way too slow, even for the Z80 it is (in Echo I have to get around this by intentionally using a slow instruction to burn cycles, without that I need to resort to adding explicit delays every time which would make code more convulted). So yes, your math is correct. ######## POST p29437 | Count SymphoniC | 2016-04-08 | t386-765.html Wouldn't that mean you'd need about 18 z80 nop instructions then? Why does this sound like too many... ######## POST p29438 | Sik | 2016-04-08 | t386-765.html You need to wait 33.6 Z80 cycles after you write to $4001/3 (the second write). You'd need about 9 NOPs for that (or be clever and waste just enough cycles as you do any other operations ;P). Note that you don't need any delay after $4000/2 (the first write), if you did then yes it would be indeed 18 NOPs as you said. This loop in Echo barely meets the limit by 3 cycles. There isn't much you can optimize without breaking it. EDIT: and let me stress it, yes the YM2612 is really that slow. ######## POST p29439 | Count SymphoniC | 2016-04-09 | t386-765.html Thank you for the clarity, I never was very sure about the best way to do this. I meant to test the wait times on hardware but wasn't sure of a good reliable method for doing so. I'm still open to doing so and posting results if someone has any accessible ideas. ######## POST p29440 | Stef | 2016-04-09 | t386-765.html The main problem for me is that ym2612 (MD1) and ym3438 (MD2) does not have same busy cycles and if you test your cycles on a MD1, you might be greatly disappointed when you will test then on a MD2 as the ym3438 seems to require more time after some register writes. In my case I preferred to test the busy flag when I require to do many ym writes in a short period of time. ######## POST p29442 | Sik | 2016-04-09 | t386-765.html Well, Echo works with both so I assume that part of the timing stands. I guess the YM3438 is just less lenient about not respecting it =P The biggest problem with checking the busy flag is that when it comes to the Z80, a busy wait loop may very well take longer than it takes for the busy flag to clear in the first place (whoops!), at which point you may as well just insert a delay instead. A wait loop may make more sense with the 68000 which is much faster. EDIT: by the way if you're using the Z80, using the IX and IY registers is a good way to burn extra cycles and reduce the amount of clobber needed to meet the timing requirements (also you can just keep $4000 always there, which frees up other registers for more important purposes). ######## POST p29443 | Sauraen | 2016-04-09 | t386-765.html FWIW here's the timing in MIDIbox Quad Genesis : http://svnmios.midibox.org/filedetails. ... gmplayer.h http://svnmios.midibox.org/filedetails. ... gmplayer.c This driver was developed on the first MIDIbox Quad Genesis synth I finished the hardware of, which contains four YM2612s (and four SN76489s). However, that synth is now in the possession of my client, and I've finished the hardware of a second copy for myself, which instead contains four hardware YM3438s. The driver worked immediately with no changes, so I left it alone. But because I don't have the YM2612 version, any experimentation with reducing the wait times can only directly be confirmed on the YM3438. Right now I'm using a wait time of 2100 ticks at 84 MHz/tick (a total of 25us or 200 external OPN2 cycles at 8 MHz [which the chip is clocked at, not at 7.67MHz] or 33.3 internal cycles). This works on both YM2612 and YM3438 with no audible dropped commands, and the performance is high enough that I can play four VGM files at the same time, one on each OPN2/PSG . So I haven't tried to push it, but I can do so and let everyone know the results. ######## POST p29448 | Count SymphoniC | 2016-04-11 | t386-765.html Whoa [IMG ./images/smilies/icon_eek.gif] talk about a show of technical prowess. Very nice. Actually, lately I've been having a wild itch for building a YM synth, I've seen posts here and there with schematics, but are these completed? I have the software programming knowledge but my electronic engineering skills are at a very basic level. I'd really like to chip away on a side project like this while developing my Sega Genesis tracker. Quad Genesis... Wow. ######## POST p29450 | Sauraen | 2016-04-12 | t386-765.html @CountSymphoniC Thanks! Not to derail the thread or shamelessly self-promote, but here's the current state of the MIDIbox Quad Genesis project. The MBHP_Genesis boards which I designed, each of which holds one YM2612/YM3438 and one SN76489 and provides appropriate glue logic for a parallel interface to your MCU of choice, are finished, fully documented (at the above link), and available for $5 each on the MIDIbox Shop . (Disclaimer: I profit from the sale of these boards.) To interface to the STM32F4 microcontroller from the MIDIbox hardware platform, a simple level shifter board is also required, which you can build by hand. The remaining hardware you need is all from the MIDIbox platform, and all the required PCBs are available on the MIDIbox Shop. Three software applications for the MBHP_CORE_STM32F4 are in progress. (All three support up to four MBHP_Genesis modules, i.e. four of each sound chip.) The first project is MIDIbox VGM Player , which just allows you to play VGM files from a SD card on the MBHP_Genesis boards. This application is completed (though I will update it as I continue to develop the VGM driver), and information is available at the link above that should be sufficient for you to build one. The second application is MIDIbox Genesis Tracker, which is currently in progress and should be released soon. This application controls the pairs of sound chips exclusively via MIDI commands, according to the GENMDM spec . Finally the third application is the entire application layer for MIDIbox Quad Genesis, the full-featured synth with the large front panel whose hardware is shown in the videos above. The software for this will probably not be anywhere near completed before the end of the summer, although when it is, I intend to sell a few sets of custom parts for constructing the front panel (finished aluminum, front panel PCB, and 3D printed button caps--it won't be cheap though, expect around $400-$500, plus you'll have to buy the hundreds of LEDs yourself, not to mention solder them all!) I'd love to have some people build some VGM Players or Trackers and give feedback to help improve the design and documentation. If you have issues building the hardware or using the software, I offer technical support on the MIDIbox Forums . ######## POST p29458 | neozeed | 2016-04-15 | t386-780.html I'm sure everyone's seen this, but the ym2151.c in mame is now GPL! Commits on Jan 21, 2016 @mmicko Setting GPL license for Jarek Burczynski, by his request (nw) https://github.com/mamedev/mame/commit/ ... 4663ba3ba9 [CODE BLOCK WITHHELD: 275 chars] ######## POST p29470 | Eke | 2016-04-18 | t386-780.html [QUOTE] Sauraen wrote:I I drew out some diagrams and these are the final results. There's no concept of a complete cycle for updating a channel, but if such a concept is artificially introduced, the four operators use the following values for their modulation in "Cycle 1": Op 1: Op 1 Cycle 0, Op 1 Cycle -1 Op 2: Op 1 Cycle 1 Op 3: Op 1 Cycle 0, Op 2 Cycle 0 Op 4: Op 1 Cycle 1, Op 2 Cycle 0, Op 3 Cycle 1 There is at least one algorithm in each case that uses each of these sources, though usually most are unusued (i.e. there's no algorithm where ops 1, 2, and 3 all modulate 4). This can also be replicated simply by processing the operators in the order 3, 1, 4, 2, and in every case using the most recent output of the needed operator. (So that when you process op 3, you're using the results of ops 1 and 2 from the previous cycle; and when you process op 4, you're using the most recent 1 and 3 but old 2.) To be clear, the operator numbering I'm using is such that in Algorithm 0 (chain of operators), they are in the order 1-2-3-4. The "two operator units in parallel" claim that Steve Snake made--that the chip processes operators 1 and 3 at the same time, then it processes 2 and 4 at the same time--is functionally correct, in so far as it produces the same relationships between operators, though it's not strictly how the chip behaves. [/QUOTE] I didn't noticed it initially but it seems MAME implementation is a little bit different. If you look at current channel algorithm calculation code: https://bitbucket.org/eke/genesis-plus- ... 2612.c-843 [CODE BLOCK WITHHELD: 1944 chars] & https://bitbucket.org/eke/genesis-plus- ... 612.c-1423 [CODE BLOCK WITHHELD: 1211 chars] I am not sure how much you can read C code but, for algorithm 0, modulators being used by each operator (OP1,OP2,OP3,OP4) at cycle n will be : OP1 (n-2) + OP1(n-1)) modulating OP1 (n) OP1 (n-1) modulating OP2 (n) OP2 (n-1) modulating OP3 (n) OP3 (n) modulating OP4 (n) The one in bold in particular contradicts your observations. More generally, the way it is implemented, OP1 will never directly modulate OP2 or OP4 on the same cycle but always modulate them with one cycle (sample) delay. More over, in case of algo 1 or algo5, OP3(n) is actually modulated by OP1(n-2) ! I am not sure if this is an error in MAME implementation when they introduced the MEM register (used to emulate the cycle delay you observed for OP3 modulator/s) in regard to OP1 feedback registers or if this is correct behavior but it seems a little weird... What do you think? ######## POST p29471 | Sauraen | 2016-04-19 | t386-780.html I took the bait and started an analysis of the control unit that generates the signals specifying which values are added during which cycles (the op_algorithm_ctl signal in my VHDL version of the operator unit ). Here's the results so far: All these observations are directly from the YM2203, not the YM2612, but the results should be equivalent. We already know that the chip processes one operator from each channel per cycle. We don't yet know the relative phase between the operators, that is whether the chip processes operator 1 from all channels before moving on to the next operator, or whether it interleaves them in some fashion (for various reasons I think the latter is much more likely). But within one channel, it definitely processes one operator, than operators from two other channels, than the next operator from the first channel again. (Remember this is on the YM2203 with three channels.) Also remember that this is from the point of view of any point in the pipeline, and that each operator takes 6 cycles to go through the whole pipeline. The result is that the operators are evaluated in the order 1-3-2-4 OR 1-4-2-3 (don't know yet which one) [EDIT: later confirmed to be 1324]. For this next bit, keep in mind that I'm considering the "first" step of evaluation to be the step of summing up to 2 operator output values to produce the feedback/feedforward phase for the next operator. Therefore: when operator 1 begins evaluation, the result from operator 2 is ready (op_result_internal is the result of the most recent evaluation of operator 2) when operator 3 begins evaluation, op_result_internal is from operator 4 when operator 2 begins evaluation, op_result_internal is from operator 1 when operator 4 begins evaluation, op_result_internal is from operator 3 So from the control unit that I've analyzed, I've made a handwritten table of the values of x and y (the operator values being added) in the case of each algorithm and each operator phase. I won't reproduce it here because it basically amounts to the same information as the diagrams of the operator connections in the algorithms, but here's the key points. Remember the operator unit stores 3 values, "Old 1" (two evaluations ago), "1" (most recent evaluation of operator 1), and "2" (most recent evaluation of operator 2). In the phase where op_result_internal is 2 (and we're beginning to evaluate operator 1), X is always "Old 1" and Y is always "1". This matches all previous results. In the phase where op_result_internal is 4 (and we're beginning to evaluate operator 3), sometimes X is "2" and sometimes Y is "1", for the appropriate algorithms. That is, operator 3 is always calculated from the most recent results of operators 1 and 2, but those will be the results received 1 and 3 phases ago and therefore BEGUN 3 and 5 phases ago. (Which is which depends on whether the overall order is 1324 or 1423. [EDIT: later confirmed to be 1324]) In the phase where op_result_internal is 1 (and we're beginning to evaluate operator 2), sometimes Y is op_result_internal (for the appropriate algorithms). This is the most recently evaluated result from operator 1, just finishing now; also available (about to be overwritten) are the previous two results from operator 1, but these are not used (consider this confirmed). That is, operator 2 is always calculated from the most recent result of operator 1, the one whose calculation was begun 2 phases ago. Finally, in the phase where op_result_internal is 3 (and we're beginning to evaluate operator 4), "1", "2", and op_result_internal (i.e. 3) are all used as necessary. The overall conclusion is that, yes, in all cases an operator's value is calculated from the most recent result of the required operator (except of course for the feedback, which intentionally uses the last two values of operator 1). However, this most recent result could have been received up to 3 phases ago and therefore begun evaluating up to 5 phases ago. Therefore, I retract my previous statement that evaluating the operators in some other order (3142 or something) will produce the correct result--it won't. If every operator is evaluated all at once (how it would normally be done in code rather than in VLSI), there has to be storage for up to 5 phases. This is how I would organize the code, assuming that the evaluation order is actually 1324 [EDIT: later confirmed]. It's based on exactly what the chip does in the same order: Each operator has a variable for its most recent output, op[n].output. (n is 1-indexed here for consistency with the above) Three other variables are available: outOld1, out1, out2 (probably not named these things!) Evaluate operator 1 using outOld1 and out1. Also copy op[2].output to out2. Evaluate operator 3 using out1 and out2. Evaluate operator 2 using op[1].output. Also copy out1 to outOld1 and op[1].output to out1. Evaluate operator 4 using out1, out2, and op[3].output. If it turns out that the actual order is 1423, simply switch the steps for evaluating operators 3 and 4. THEREFORE, I think the MEM thing is wrong, or at least your description of it is. (I certainly can read C, but that's about the least readable C I've ever seen!) No matter how you cut it, operator 2 gets evaluated with the most recent output from operator 1, and similarly operator 4 uses the most recent output from operator 3. Those are clear. The tricky part is that assuming it's 1324 [EDIT: later confirmed], operator 4 is evaluated with the result of operator 2 which was calculated 5 phases ago, not the one from last phase (on the chip it's still not done yet). Similarly, operator 3 is evaluated with the 5-phase-old operator 1 value, not the one from 1 phase ago. ######## POST p29476 | Eke | 2016-04-19 | t386-780.html Ouch, I've read your post multiple time but this is quite confusing, I guess because I'm not familiar with some terms you are using or that I am missing some basic concepts you figured about how the operator unit is functioning in hardware. [QUOTE] Sauraen wrote: The result is that the operators are evaluated in the order 1-3-2-4 OR 1-4-2-3 (don't know yet which one). For this next bit, keep in mind that I'm considering the "first" step of evaluation to be the step of summing up to 2 operator output values to produce the feedback/feedforward phase for the next operator. Therefore: when operator 1 begins evaluation, the result from operator 2 is ready (op_result_internal is the result of the most recent evaluation of operator 2) when operator 3 begins evaluation, op_result_internal is from operator 4 when operator 2 begins evaluation, op_result_internal is from operator 1 when operator 4 begins evaluation, op_result_internal is from operator 3 [/QUOTE] What do you mean by "evaluation of operator X " exactly ? Operator output calculation or its use as modulation input for another operator? And what exactly is "op_result_internal"? operator output or modulation input? It's not very clear to me what you mean by "when operator X begins evaluation", "op_result is from operator Y" and I don't quite follow what this is implying. Is that related to operator execution order or something else? [QUOTE] Sauraen wrote:So from the control unit that I've analyzed, I've made a handwritten table of the values of x and y (the operator values being added) in the case of each algorithm and each operator phase. I won't reproduce it here because it basically amounts to the same information as the diagrams of the operator connections in the algorithms, but here's the key points. Remember the operator unit stores 3 values, "Old 1" (two evaluations ago), "1" (most recent evaluation of operator 1), and "2" (most recent evaluation of operator 2). In the phase where op_result_internal is 2 (and we're beginning to evaluate operator 1), X is always "Old 1" and Y is always "1". This matches all previous results. In the phase where op_result_internal is 4 (and we're beginning to evaluate operator 3), sometimes X is "2" and sometimes Y is "1", for the appropriate algorithms. That is, operator 3 is always calculated from the most recent results of operators 1 and 2, but those will be the results received 1 and 3 phases ago and therefore BEGUN 3 and 5 phases ago. (Which is which depends on whether the overall order is 1324 or 1423.) In the phase where op_result_internal is 1 (and we're beginning to evaluate operator 2), sometimes Y is op_result_internal (for the appropriate algorithms). This is the most recently evaluated result from operator 1, just finishing now; also available (about to be overwritten) are the previous two results from operator 1, but these are not used (consider this confirmed). That is, operator 2 is always calculated from the most recent result of operator 1, the one whose calculation was begun 2 phases ago. Finally, in the phase where op_result_internal is 3 (and we're beginning to evaluate operator 4), "1", "2", and op_result_internal (i.e. 3) are all used as necessary. [/QUOTE] Again, I don't get what you mean by "op_result_internal is X / we're beginning to evaluate operator Y) ", seems like 1/2 and 3/4 go in pair for some reason I don't understand. Also, what is that "phase" you are talking about? [QUOTE] Sauraen wrote:The overall conclusion is that, yes, in all cases an operator's value is calculated from the most recent result of the required operator (except of course for the feedback, which intentionally uses the last two values of operator 1). However, this most recent result could have been received up to 3 phases ago and therefore begun evaluating up to 5 phases ago. [/QUOTE] What do you mean by "received'"? I don't understand what that last sentence is implying either. [QUOTE] Sauraen wrote:Therefore, I retract my previous statement that evaluating the operators in some other order (3142 or something) will produce the correct result--it won't. If every operator is evaluated all at once (how it would normally be done in code rather than in VLSI), there has to be storage for up to 5 phases. This is how I would organize the code, assuming that the evaluation order is actually 1324. It's based on exactly what the chip does in the same order: Each operator has a variable for its most recent output, op[n].output. (n is 1-indexed here for consistency with the above) Three other variables are available: outOld1, out1, out2 (probably not named these things!) Evaluate operator 1 using outOld1 and out1. Also copy op[2].output to out2. Evaluate operator 3 using out1 and out2. Evaluate operator 2 using op[1].output. Also copy out1 to outOld1 and op[1].output to out1. Evaluate operator 4 using out1, out2, and op[3].output. If it turns out that the actual order is 1423, simply switch the steps for evaluating operators 3 and 4. [/QUOTE] I don't understand, evaluating operators in order 3142 could give the exact same result as above , with: [*] op3 using out1 and out2 [*] op1 using outOld1 and out1 then copy out1 to outOld1 and op[1].output to out1. [*] op4 using out1 (same as op[1].output at this stage), out2 and op[3].output [*] op2 using out1 (same as op[1].output at this stage), then copy op[2].output to out2. It could even be 1342 with: [*] op1 using outOld1 and out1 then copy out1 to outOld1 and op output to out1. [*] op3 using outOld1 and out2 [*] op4 using out1 (same as op[1].output at this stage), out2 and previous op ouput (corresponding to op[3].output at this stage) [*] op2 using out1 (same as op[1].output at this stage), then copy op output to out2. with the benefit of not needing to store the output of each operator but only the last calculated output, by cleverly using the other three existing registers keeping old op1 / op2 outputs. In any case, unless I'm missing something, I don't see the difference with what you described in your initial post. [QUOTE] Sauraen wrote:THEREFORE, I think the MEM thing is wrong, or at least your description of it is. (I certainly can read C, but that's about the least readable C I've ever seen!) [/QUOTE] I agree Jarek's implementation can be quite complex to read, it took me quite some time to get familiarized with it but I can assure you the MEM thing does exactly what you are describing (i.e it corresponds to the modulation input used for op3, which is either out1, out2 or the addition of both). I can explain it if you (or anyone) are interested. Basically, in "setup_connection" function, memory pointers are used to connect (depending on algorithm): - the output of op1 (CH->connect1) to either intermediate register (mem), modulation inputs of op2 (c1) and op4 (c2) or accumulator (out_fm). - the output of op2 (CH->connect2) to either intermediate register (mem) or accumulator (out_fm). - the output of the intermediate register (CH->mem_connect) to modulation input of op3 (m2) or op4 (c2) - the output of op3 (CH->connect3) to either modulation inputs of op4 (c2) or accumulator (out_fm). NB: the output of op4 (CH->connect4) is always connected to accumulator (out_fm) by default Next, in "chan_calc" function, the intermediate register output (CH->mem_connect) is updated with saved mem value and operator outputs are calculated sequentially and added o to their respective CH->connect, with the exception of op1. For some reason, the output of op1 (CH->connect1) is updated with out1 value (previous op1 output) BEFORE op1 output is effectively calculated and copied to out1. The result is that it works the same as what you describe with the exception that: - op2 & op4 are using out1 instead of op[1].output - op3 is using outOld1 instead of out1 As I said, I'm not sure if this is intended or a mistake made when dealing with out1 and outOld1 (CH->op1_out[1] and CH->op1_out[0] in MAME code) . [QUOTE] Sauraen wrote:No matter how you cut it, operator 2 gets evaluated with the most recent output from operator 1, and similarly operator 4 uses the most recent output from operator 3. Those are clear. The tricky part is that assuming it's 1324, operator 4 is evaluated with the result of operator 2 which was calculated 5 phases ago, not the one from last phase (on the chip it's still not done yet). Similarly, operator 3 is evaluated with the 5-phase-old operator 1 value, not the one from 1 phase ago. (If it's actually 1423, the only difference is that now operator 4 uses the old operator 1, and operator 3 uses the old operator 2.) [/QUOTE] From what you said before, in both cases, op3 uses the old op2 output. Or you mean that with 1423, it would use new op2 output? ######## POST p29477 | Sauraen | 2016-04-19 | t386-780.html [QUOTE] Eke wrote:Ouch [/QUOTE] I don't have time right now for a giant answer, but I think this is what you're missing. Please also refer to my operator unit VHDL code I linked in the previous post. The operator unit, like all the other units in the YM2203, is pipelined. It takes six internal clock cycles to compute the output of an operator. But at any given moment, the six pipeline stages are all working on a different operator's data. So for instance, at one instant in the operator unit: Pipeline stage 1, the creation of the feedback/modulation signal, is processing channel 1 operator 2 Pipeline stage 2, the feedback shifter and adder of the PG phase, is processing channel 3 operator 3 Pipeline stage 3, the logsin table and adder of the EG attenuation, is processing channel 2 operator 3 Pipeline stage 4, the exponential table, is processing channel 1 operator 3 Pipeline stage 5, the floating-point-to-integer conversion, is processing channel 3 operator 1 Pipeline stage 6, which doesn't do any processing, is holding channel 2 operator 1 This example is under two assumptions, first that the operator order is 1324 [EDIT: later confirmed], and second that the chip processes the same operator from each channel before going to the next operator (it processes operator 1 of all three channels, then operator 3 of all three channels, etc.--[EDIT: later confirmed]). Because of this pipeline, in any given stage, every 3 clock cycles an operator from our chosen channel is being processed. But the previous and next stages are at the same time processing different operators from different channels. So therefore, at stage 1 above (which produces the feedback/modulation signal and is critical for answering the question of which cycle's value is used), in clock cycle 0, channel 1 operator 1 is being processed in clock cycle 3, channel 1 operator 3 is being processed in clock cycle 6, channel 1 operator 2 is being processed in clock cycle 9, channel 1 operator 4 is being processed with the other channels' operators being processed in the intervening clock cycles. This is the origin of my term "phase"--we can ignore the other channels for now and say there are 4 phases, during each one a different operator is being processed. Since it takes 6 cycles (2 phases) for an operator's value to finish being processed, in the above example operator 1 was begun on cycle 0, which means it's done and its result is available on cycle 6, which is also when operator 2 is being processed (again just by this one pipeline stage). So the question was whether at that time, the unit takes the just-finished value of operator 1, or uses the previously-stored value of operator 1, when calculating the modulation value which will be used for operator 2. And the answer, which I confirmed from the control unit, is that it takes the just-finished value of operator 1, not the old (and definitely not the oldold) value. ######## POST p29478 | Sik | 2016-04-20 | t386-780.html Is it me or are you all overcomplicating things? Can't you just do it like the YM2612 and just process one operator at a time? (whether a new or an old value gets used will be implicitly handled by just doing that) ######## POST p29479 | Mask of Destiny | 2016-04-20 | t386-780.html [QUOTE] Sik wrote:Is it me or are you all overcomplicating things? Can't you just do it like the YM2612 and just process one operator at a time? (whether a new or an old value gets used will be implicitly handled by just doing that) [/QUOTE] So the point that Sauraen is making is that the YM2612 doesn't exactly process one operator at a time (well assuming that it behaves like the YM2203 that it is based on anyway). Any given stage in the operator pipeline evaluates a single operator at a time, but the stages are operating in parallel and won't be processing the same operator. Depending on the order of evaluation it's possible that an "old" value is used when modulating due to the pipeline latency. That said, if it iterates through an operator for all the channels first (a big assumption at the moment) then it's not going to be an issue on the YM2612, regardless of operator evaluation order, since there are as many channels as there are pipeline stages. Of course, it's conceivable that it processes all the operators for part 1 before moving on to the part 2 operators in which case the behavior would be the same as the YM2203. ######## POST p29480 | Sauraen | 2016-04-20 | t386-780.html [QUOTE] Sik wrote:Is it me or are you all overcomplicating things? [/QUOTE] Yes, we are, in so far as I can't even think of a test sound that would sound audibly different whether modulators were delayed by a cycle or not. [QUOTE] Sik wrote:Can't you just do it like the YM2612 and just process one operator at a time? [/QUOTE] [QUOTE] Mask of Destiny wrote:the YM2612 doesn't exactly process one operator at a time [/QUOTE] Exactly. However... [QUOTE] Mask of Destiny wrote:if it iterates through an operator for all the channels first (a big assumption at the moment) then it's not going to be an issue on the YM2612, regardless of operator evaluation order, since there are as many channels as there are pipeline stages. [/QUOTE] Nope. I purposely didn't include any discussion of the YM2612 in the last post (though I have in past posts, plus it's covered in the VHDL model), because it's in fact MORE complicated than the YM2203, not less. For starters, the YM2612 pipeline contains a 6-stage-long shift register with the sole purpose of delaying the operator evaluation so that it's actually 12 cycles, not 6. This makes sense, because if we double the number of channels and also double the number of pipeline stages, the algorithm will be the same as in the YM2203. [EDIT: the following is not true] I am guessing, though I have not confirmed this in any way, that the chip evaluates the channels in the order 1-4-2-5-3-6; that is, it evaluates channel 1, then channel 1 in the high bank, then channel 2, etc.[EDIT: later confirmed to be 123456] So if you want to consider this all from the YM2612, in my last post make the cycles listed 0-6-12-18 instead of 0-3-6-9. Still, the result from operator 2 is available when operator 1 is being calculated, and so on--the logic is exactly the same. ######## POST p29490 | r57shell | 2016-04-21 | t386-780.html Anyway you overcomplicating things. Sorry if I'm being captian obvious [IMG ./images/smilies/icon_biggrin.gif] Let say 1) We have 3 workers. 2) Each has different profession. So, he can do only single type of job. 3) They can't do several jobs at once. 4) They do only single type product. 5) Time to make any kind of job are equal between. So, making this product, requires steps: First worker (A) don't need anything, and can create, starting product = completion state 1 Starting product can be updated to next completion state only by second worker (B) = completion state 2 And last completion state is made by last worker (C) = finished product = completion state 3 In time zero - we don't have any product. All workers free, but only A can do his job. [CODE BLOCK WITHHELD: 14 chars] where A B C - workers, 1 - id of product, X is - slacking (does nothing) Next time, A can start make next, B has to do... so whole table will looks like this: [CODE BLOCK WITHHELD: 59 chars] Idea simple: all workers "update" product to next completion state. And, you don't need to have 6 workers for each kind of job (6*3), to make 6 products. Here is same, difference is, products are remade. Channels results remade. I'll use term Channel, for 6 FM channels, and Operators, for 4 operators. (just to make it strict, at least for myself, because I was struggling to remember this stuff) So, from scratch I suppose it should look like: [CODE BLOCK WITHHELD: 43 chars] But taking into consideration, that there is 6 channels, 4 operators. So, we call "product" as channel output. Number of workers = number of steps to update one operator. One important addition in this case, that each worker must do his job 4 times (must do his job for each operator) Let say, workers again 3, then sequence will look like [CODE BLOCK WITHHELD: 172 chars] where first digit is - channel id, second is operator id processed. They can place it in other order... For example... whole cycle of channels first, then operators. Anyway, each channel update time will take only 6*4 steps, and will do all jobs at once (all workers are busy). But what I consider, should be taken from this example, is that result is not dependent to order of channels. So, you can think as about processing single channel. and only order of updating operators, and completion steps (you may say phase), does matter. Summary, I think, process should be well explainable by defining N steps. (jobs in previous examples), and their order for operators. For previous example, it is representable as array: A1 B1 C1 A2 B2 C2 A3 B3 C3 A4 B4 C4 (job, operator) To verify that, you may replace all numbers starting not from 1, to XX, and see, that processing of single channel does exactly in this way. So, in my theory, all chanels should be indpendent. ######## POST p29498 | Sauraen | 2016-04-21 | t386-780.html [QUOTE] r57shell wrote:all chanels should be indpendent [/QUOTE] Yes, I wasn't saying they weren't. Obviously parameters of one channel don't affect the others (at least not until we get to the DAC...). The order of evaluation of the channels won't make any difference to whether a software implementation produces a sample-accurate result or not. It does make a difference to my VHDL code, though--otherwise the channels will all work, but which channel's registers and values are being used by which units on what cycles will be all mixed up. (E.g. I might have ch3 op4 getting its envelope attenuation value from ch6 op4 or from ch3 op3.) ######## POST p29499 | r57shell | 2016-04-21 | t386-780.html [QUOTE] Sauraen wrote:It does make a difference to my VHDL code, though--otherwise the channels will all work, but which channel's registers and values are being used by which units on what cycles will be all mixed up. (E.g. I might have ch3 op4 getting its envelope attenuation value from ch6 op4 or from ch3 op3.) [/QUOTE] But it does not happen in YM2612? So, it may happen to your VHDL due to your bug? [IMG ./images/smilies/icon_smile.gif] I guess you can make automatic tests, that will test, that each phase access to variables only same channel, no? ######## POST p29501 | Sauraen | 2016-04-22 | t386-780.html What I mean is that behind all this crazy pipelining in the YM2612 is a number of control units which each have exactly the correct number of delays in each signal so that all the signals used in each channel are correct. There's no question that this is implemented correctly in the YM2612, and the particular order doesn't affect the sounds, so it's not relevant for a software implementation. However, my VHDL version (of which right now only the operator unit exists) attempts to match the original chip structure in every detail, not just the resulting functionality. So if I have a mistake in any of the control units--which is very likely because I don't actually map every gate one at a time, I learn as much as I need to from the die and make up the rest--the output will be all mixed up and obviously wrong. At this point I'm not even trying to make the VHDL version into a working implementation, I'm more using it to describe my findings in the chip. ######## POST p29508 | Eke | 2016-04-22 | t386-780.html [QUOTE] Sauraen wrote: I don't have time right now for a giant answer, but I think this is what you're missing. [/QUOTE] Thanks, it's a lot more clearer now, I totally missed the pipeline stuff. I also made a sheet (with configurable channel / operator order) which helped me figuring what you were referring to (see zipped file attached) [IMG ./download/file.php?id=48&sid=450ef40075b16b98a546345d13036eef] ym2612_pipeline.png (100.89 KiB) Viewed 125109 times This also helps to understand what you meant when you said it could be either 1324 or 1423. [QUOTE] Sauraen wrote: This example is under two assumptions, first that the operator order is 1324 (it might be 1423), and second that the chip processes the same operator from each channel before going to the next operator (it processes operator 1 of all three channels, then operator 3 of all three channels, etc.--this is probably not correct, it's probably in an interleaved order, but that wouldn't change the discussion below). [/QUOTE] I think 1324 makes more sense because of the operator register address order (lower address is Op1, then Op3, Op2, Op4) and the fact operators are designed to work paired initially (a modulator then a carrier). I guess that the strange channel order and the spacing (4 FM cycles between each channel output, with output remaining available during 1 FM cycle) observed by Nemesis could possibly help figuring the exact channel order as well as how operators are interleaved for each channels by tring different combinations. cf.this post: viewtopic.php?f=24&t=386&start=369 [QUOTE] Sauraen wrote:So the question was whether at that time, the unit takes the just-finished value of operator 1, or uses the previously-stored value of operator 1, when calculating the modulation value which will be used for operator 2. And the answer, which I confirmed from the control unit, is that it takes the just-finished value of operator 1, not the old (and definitely not the oldold) value. [/QUOTE] So this confirms there is an error in MAME implementation regarding Op1 output calculation as both Op2 & Op4 always use Op1 output from previous sample (one sample delay) and Op3 always use Op1 output from two samples ago (one sample delay + MEM register delay). This also causes Algorithm7 to output to accumulator/DAC the previous output of Op1 combined with current output of Op2/Op3/Op4, which definitively seems wrong. So the code below [CODE BLOCK WITHHELD: 483 chars] should be corrected to [CODE BLOCK WITHHELD: 504 chars] [QUOTE] Sauraen wrote: [QUOTE] Sik wrote:Is it me or are you all overcomplicating things? [/QUOTE] Yes, we are, in so far as I can't even think of a test sound that would sound audibly different whether modulators were delayed by a cycle or not. [/QUOTE] I am not sure, the fact that the delay was implemented in MAME (through the use of MEM value) likely means Jarek was able to notice it while testing the hardware. He wouldn't have used that complicated implementation if it wasn't worth it. By the way, it's one of the missing thing not emulated in Exodus because Nemesis was not 100% sure how this worked so I believe this is still an interesting thing to understand correctly. Anyway, my initial question was more to figure if there was an error in MAME implementation or not. Attachments YM2612-pipeline.zip (19.81 KiB) Downloaded 3397 times ######## POST p29512 | Mask of Destiny | 2016-04-22 | t386-780.html [QUOTE] Eke wrote:I am not sure, the fact that the delay was implemented in MAME (through the use of MEM value) likely means Jarek was able to notice it while testing the hardware. He wouldn't have used that complicated implementation if it wasn't worth it. [/QUOTE] Wasn't the MAME implementation originally somewhat generic in that could emulate multiple members of the OPN family? Is it possible it's only observable on certain chips it supported? [QUOTE] Eke wrote:By the way, it's one of the missing thing not emulated in Exodus because Nemesis was not 100% sure how this worked so I believe this is still an interesting thing to understand correctly. [/QUOTE] I've avoided any emulation of the MEM stuff in BlastEm for similar reasons (though there are still other unrelated things I'm missing). I'd certainly be interested in the actual behavior too. There's something I'm a bit unclear on here with regards to overall timing. On the YM-2612 it's known that it takes 144 cycles of its input clock to process all the operators for all 6 channels. Previously, my assumption was that operators were processed in a relatively linear fashion and that processing an operator took 6 cycles. 6 cycles * 6 channels * 4 operators per channel does indeed get you 144 cycles. With a pipelined design, while the execution time of a single operator would indeed be 6 cycles (or 12 in the YM-2612 as you mentioned before due to the extra dummy stages), the overlap in execution means that it only takes 24 cycles to process all the operators (ignoring the 12 cycle overlap with the next runthrough anyway). Is there in fact an internal /6 divider on the clock line or do these pipeline stages take 6 cycles to execute? Alternatively, is there something else I'm missing? ######## POST p29513 | Sauraen | 2016-04-22 | t386-780.html [QUOTE] Mask of Destiny wrote:Is there in fact an internal /6 divider on the clock line [/QUOTE] Yup, this has been known for a while. It takes 24 INTERNAL clock cycles to evaluate everything, which is 144 external clock cycles. [QUOTE] Mask of Destiny wrote:Wasn't the MAME implementation originally somewhat generic in that could emulate multiple members of the OPN family? Is it possible it's only observable on certain chips it supported? [/QUOTE] All my work so far has been from the YM2203 die because it's clearer, and then cross-checking things with the YM2612 die when necessary. They're similar enough that my VHDL operator unit covers both of them, and there's no reason MAME couldn't. But if there is a difference, it might have to do with the DAC versus the shift register output section. By the way, the difference in channel order in the YM2612 may be observable, in so far as the YM2612 outputs the channel values sequentially. That's actually where I got the 1-4-2-5-3-6 order from, I think it was Nemesis or someone who posted those findings years ago. Now, just because the chip outputs the channels in that order doesn't necessarily mean it processes them in that order, but it's a strong hint. The reason I say it's not guaranteed is that if the chip processes all the channels of one operator before going to the next operator, and then just outputs the results after operator 4 finishes, it'll have no results for 18 cycles (while operators 1, 3, and 2 were being processed) and then spit out 6 results in quick succession. Instead we know that the results are uniformly spaced, implying that there's more going on here. [EDIT: this is wrong. For any operator, channels are processed in the order 123456. But at the same time, channels are output in the order 153264, with each channel value held for four cycles. Disregard the below also.] Edit: Actually Eke linked us back to Nemesis's post about this, evidently it's 4 internal clocks of zero and then 1 of a value... Hmm. And if he got 1-5-3-2-6-4, that would mean: 1 X X X X 5 X X X X 3 X X X X 2 X X X X 6 X X X X 4 X X X X which adds up to 30 cycles, nah that's not right. It's gotta be 3 internal clocks of zero and 1 of a value. 1 X X X 5 X X X 3 X X X 2 X X X 6 X X X 4 X X X Let's fill in some blanks... 1 2 3 4 5 6 1 2 3 4 5 6 1 ut-oh! That still doesn't quite work out, simply because we know that 12 cycles after a particular channel is being evaluated (at a particular unit), a different operator from the same channel is being evaluated at the same unit. However, it clearly is 3 internal clocks of zero and 1 of a value--a couple posts down from that one of Nemesis it shows the output along with the master clock. It's clearly 18 master clocks (3 internal) between the beginning of the falling edge and the rising edge, and 6 master clocks (1 internal) between the beginning of the rising edge and the falling edge. Of course the text there is meaningless, because they're talking about an embedded serial DAC which has long since been disproven. ######## POST p29515 | Mask of Destiny | 2016-04-22 | t386-795.html [QUOTE] Sauraen wrote: [QUOTE] Mask of Destiny wrote:Is there in fact an internal /6 divider on the clock line [/QUOTE] Yup, this has been known for a while. [/QUOTE] You know, now that you mention that I'm sure I had read as much, but I must have discounted it since there was way too much going on for it to finish in a cycle. I just failed to take into account the possibility of pipelining. Oh well. [QUOTE] Sauraen wrote:By the way, the difference in channel order in the YM2612 may be observable, in so far as the YM2612 outputs the channel values sequentially. [/QUOTE] Observable if you bypass all the analog filtering circuitry anyway. From an emulation perspective, the only way it probably matters involves how the order of processing interacts with the funky register file and register write timing. [QUOTE] Sauraen wrote:It's gotta be 3 internal clocks of zero and 1 of a value. 1 X X X 5 X X X 3 X X X 2 X X X 6 X X X 4 X X X Let's fill in some blanks... 1 2 3 4 5 6 1 2 3 4 5 6 1 ut-oh! That still doesn't quite work out, simply because we know that 12 cycles after a particular channel is being evaluated (at a particular unit), a different operator from the same channel is being evaluated at the same unit. However, it clearly is 3 internal clocks of zero and 1 of a value--a couple posts down from that one of Nemesis it shows the output along with the master clock. It's clearly 18 master clocks (3 internal) between the beginning of the falling edge and the rising edge, and 6 master clocks (1 internal) between the beginning of the rising edge and the falling edge. [/QUOTE] I think I know why it's 3 clocks of zero and 1 of value: Algorithms 5-7. Those algorithms require adding together more than 2 operators for the output. I bet those zeros become the output of operators 1-3. I wonder if we can exploit that to observe the operator update order. ######## POST p29516 | Sauraen | 2016-04-23 | t386-795.html [QUOTE] Mask of Destiny wrote:From an emulation perspective, the only way it probably matters involves how the order of processing interacts with the funky register file and register write timing. [/QUOTE] And that only matters for emulators that actually care about write timings, i.e. Exodus. [QUOTE] Mask of Destiny wrote:I think I know why it's 3 clocks of zero and 1 of value: Algorithms 5-7. Those algorithms require adding together more than 2 operators for the output. I bet those zeros become the output of operators 1-3. I wonder if we can exploit that to observe the operator update order. [/QUOTE] In the YM2612 (not in the YM2203) there is, after the operator unit and before the DAC, a unit that looks at first glance like it contains 2 sets of 6-stage shift registers, plus some other stuff, all 9 bits wide. This is also where the DAC value bits and some relevant control wires enter. So obviously this unit is adding up operator values and giving them to the DAC. (Worth mentioning that the 14-bit operator outputs are lopped off to 9 bits before this unit, no rounding or anything, and the adder which adds the operator input to the stored value also must be only 9 bits.) If I do a thorough reverse engineering of this unit, we'll have our answers about the output timing. But it's hard to read actual logic from the YM2612 die shot--that's why I mostly stick to tracing wires in that die, and actually reading gates from the YM2203. (But of course this unit is not present in the YM2203.) I doubt it's as simple as the 3 zeros are for the three silent operators. Otherwise, when using algorithm 7, we'd get the four operator values out one at a time. And also that would mean that the chip was processing the four operators in consecutive cycles, which is not true (or storing them to emulate this behavior, which would be silly). ######## POST p29523 | r57shell | 2016-04-23 | t386-795.html [QUOTE] Sauraen wrote: [QUOTE] Mask of Destiny wrote:Is there in fact an internal /6 divider on the clock line [/QUOTE] Yup, this has been known for a while. It takes 24 INTERNAL clock cycles to evaluate everything, which is 144 external clock cycles. [/QUOTE] Hmm, if /6 then 24 cycles for whole processing? We have 6 channels 4 operators = 24 operators in total. Also, we have X "jobs" (stages / steps). 6*4*X = total things to do. One of X takes T time. Y pipes. Summary, total time is: 6*4*X*T/Y = 144. X*T/Y = 144/(6*4) = 6 X*T/Y = 6 So, one of possible implementation is: X = Y, and T = 6. So, pipes (workers) Y = X (stages / steps). Other possible solution: T = 3. It's if you trigger both: CLK rising, and CLK fall. Same as in M68k. Then X*3/Y = 6. X/Y = 2. Stages in twice more than wokers. Anyway, equation X*T/Y = 6. [IMG ./images/smilies/icon_smile.gif] We know, that period of output is 24. Ley say, X = Y. Then all is doable in straight forward way. [CODE BLOCK WITHHELD: 975 chars] Last 6 columns is "up to date from last 24 cycle". So channel output always store value from 24 (144) cycles back. Nothing bad in this delay, because anyway you can't do faster, except if you calculate faster. Anyway you need 24 cycles to make 6*4 operators. Ah... to make it easier to understand. In any way... there is last Stage (in this example stage F), and there is last operator (in this example operator 4). So, time for certain chanell from update to update is equal to delay from appearing this channel in last Stage with last operator. So, channel 4 is updating when last operator of channel 4 appearing in last stage (in example 44 at stage F). As far, as whole sequention has period of 24, thus sequention of operators appearint at last stage (F) has period 24 too, so update time is equal to 24, and during whole that time, it has previous value. It does not matter when we output this value, anyway it's same during 24 period. Ok, now I shut up, because... I can't help with figuring out die. I can't even open it. (: But, it would be nice, if someone would crop its units in separate images and mark all input wires. And known ones, named somehow, so we could look at it as several more small units with pins. like as some blackbox with pins. If someone made it already, then I'm slowpoke [IMG ./images/smilies/icon_sad.gif] ######## POST p29525 | Sauraen | 2016-04-23 | t386-795.html I'm not sure why you're trying to figure out the pipeline stages, I've already finished that, the information is in my VHDL operator unit at https://github.com/sauraen/YM2612/blob/ ... erator.vhd . There are five stages that actually do work, one that just stores the value, and an additional six-stage delay unit in the YM2612 only which lengthens the pipeline to 12 stages. The PG and EG have their own pipelines. The image I have of the YM2612 die with several layers of drawings on it is 1.6 GB on disk and 5.7 GB loaded into RAM. Probably at some point I should actually label things better, but it will take a huge amount of effort to label every interconnect wire. Here's the overall picture: [IMG http://i.imgur.com/jQnlY70.jpg] ######## POST p29544 | r57shell | 2016-04-24 | t386-795.html [QUOTE] Sauraen wrote:I'm not sure why you're trying to figure out the pipeline stages, I've already finished that, the information is in my VHDL operator unit at https://github.com/sauraen/YM2612/blob/ ... erator.vhd . There are five stages that actually do work, one that just stores the value, and an additional six-stage delay unit in the YM2612 only which lengthens the pipeline to 12 stages. The PG and EG have their own pipelines. [/QUOTE] Trouble that it's hard to verify. I did look at that vhd. What is suspicious for me, that all stages implemented as "process" in your code. I thought, it should be concurent, and what actually process is shift buffer that does shift. I'm not sure, but that is one of my questions around YM2612. [QUOTE] Sauraen wrote:The image I have of the YM2612 die with several layers of drawings on it is 1.6 GB on disk and 5.7 GB loaded into RAM. Probably at some point I should actually label things better, but it will take a huge amount of effort to label every interconnect wire. [/QUOTE] Thanks for brief view of YM2612 internals. I did write app to read it by parts, so I was able to look at it [IMG ./images/smilies/icon_biggrin.gif] I have new question: there is working NES emulator with visualisation of gates in action. I'm wondering what tools did they use to make it in vector graphics. Maybe they have tools suitable to make some represetnation of internal connections, to be able to use it with software processing. With raster images you can verify it only with your own eyes. Better would be have some vector representation, where you can process it and do stuff, like simulation. IDK really. But they made NES, so they did it somehow, maybe they still have all tools available. I can write my own tool for drawing vectors over schematics, and labeling + tracking them. But I guess it's repeating what already done. ######## POST p29553 | Sauraen | 2016-04-25 | t386-795.html [QUOTE] r57shell wrote:What is suspicious for me, that all stages implemented as "process" in your code. I thought, it should be concurent, and what actually process is shift buffer that does shift. [/QUOTE] Keep in mind that in VHDL, all statements in a process are executed sequentially, but in zero time. In reality, the statements in the process represent signals flowing through gates, which do happen sequentially. But all the things in a process are what happens between clock edges, which is why the process is triggered on that clock edge. So basically, I tried to have the statements in the process match the flow of data within one cycle, and the processes themselves match the pipeline stages. Actually, in the chip, any one of these processes is divided into two halves--one with high level-triggered latches, and the other with low-level triggered latches, instead of a single edge-triggered flip-flop. I decided that this would be crazy to try to implement, and also would take much more space on most FPGAs if someone actually tried to compile it. But the only way this would lead to a problem is if there was a timing issue where data had to arrive on the correct half-cycle. ######## POST p30063 | Sauraen | 2016-07-29 | t386-795.html New info! Using MIDIbox Quad Genesis and the test modes, I have confirmed the internal order of calculation of operators and channels. These tests were performed on hardware (DIP) YM3438s, which is what I have in my synth. You may say this isn't helpful, as this is neither YM2612 nor whatever's in the VDP. But I haven't found any differences between the YM3438 and what's described here for the YM2612, even on undocumented features like the test bits and SSG-EG mode. The tests were performed as follows: Turn on read data mode ($21:6 = 1). Select MSB or LSB of read data ($21:7 = 0 for MSB, 1 for LSB--this may be new information) Select the signal that appears on bit 14 of the output ($21:0, and it does seem to make a difference, but I still don't know what the two signals are) Select whether to read operator or channel outputs ($2C:4 = 0 for operators, 1 for channels) Set up to read data from the OPN2 (as if checking whether it's busy). Every OPN2 internal clock cycle, capture a new byte from the bus, for 24 cycles. Print the 24 bytes from the synth to a terminal. The data format is: [CODE] Channel output: (MSB) SX00000C CCCCCCCC (LSB) Operator output: (MSB) SXPPPPPP PPPPPPPP (LSB) where S is the SYNC signal (see below), X is the unknown signal selected with $21:0, C is the 9-bit channel output, P is the 14-bit operator output [/CODE] (I just stuck with reading the MSB all the time, since the LSB doesn't have any timing information so you just get random values. In the case of channel outputs, at least you get one bit of it, so the value is negative half the time and you can see where the 1s are.) I was hoping/expecting that bit 15 (S) would be some sort of sync pulse so I could see where the beginning of the cycle was (and therefore be able to identify every byte subsequently). The results were close to this, but a little confusing. [CODE] Operator output: 111111111100000000000000 Channel output: 111110111000000000000000 [/CODE] Just resetting the chip and setting up the test mode results in each of those patterns on the S signal for the 24 cycles. (Of course, in testing the pattern starts at an arbitrary place in the 24 captured bytes, and wraps around, since I have no idea when in the cycle I start capturing). In addition, during or after playing a note on any channel but channel 4, these patterns are maintained. However, as soon as a single operator of channel 4 starts playing, the S signal changes, and it doesn't change back to this pattern even after the note is keyed off and dies out completely. The new S signal looks like the old one, but with random bits among the first 10 bits, and then all zeros for the remaining 14. Frequently there's only three or four 1s, and they're often spaced out, but they never span more than 10 bits. So it looks like there's some sort of internal sync signal here, which is getting logical-ANDed with some other signal dependent on channel 4. I have NO idea what this is all about--I will do my best to trace this signal on the die. So the S signal can be used as a sync pulse assuming you never played anything on channel 4. Based on that, I could always align the results, and so I measured all the other operators on the other channels, and filled in the blanks according to the pattern for where channel 4 must be (since I couldn't measure it). (For clarity, operator numbers are the ones from the OPNA datasheet, not the Sega docs. The numbering is such that in algorithm 0, the four operators modulate each other in the order 1->2->3->4, and the registers are in the order 1-3-2-4.) [CODE] Operator output: S 111111111100000000000000 Ch 456123456123456123456123 Op 444111111333333222222444 Channel output: S 111110111000000000000000 Ch 226666444411115555333322 or if the S signal should actually be one more step right S 011111011100000000000000 Ch 222666644441111555533332 (though from some attempts at measuring channel 4 output, I believe it's probably the first one) [/CODE] So, in English: for operator processing, it's in the order 1324, with all channels' same operator processed next to each other, and the channels in the order 123456. This makes the most sense, and matches the registers, but it had to be confirmed. For channel output, it's in the order 153264 (which was found earlier by someone else by measuring the output with a scope). There's more work for me to do here, but I figured I'd post what I've found so far. ######## POST p30065 | Sauraen | 2016-07-31 | t386-795.html I should have known. The SYNC signal I was looking for isn't bit 15 of the test read data. It's much simpler than that. It's on the TEST pin. *facepalm.jpg* Bit $2C:7 indeed selects whether the TEST pin is an input or an output. But it's the opposite of what I initially thought (since it was "common knowledge" that the BUSY signal was output from the TEST pin in normal operation). In fact, $2C:7 being 0 means the TEST pin is an input, and 1 means it's an output. The signal it outputs is always the SYNC signal: a pulse that is high for one of the 24 internal cycles, always the same one of course. The state of $2C:6 doesn't affect the SYNC signal being output. (Since I could tell from the die that $2C:6 has something to do with what the TEST input signal does, my guess is it's an enable--if $2C:6 is 0, as in the normal chip, the input is ignored, and if it's 1 the input is used for something. Don't know what it does yet though.) Since the MBHP_Genesis boards I designed support reading back the TEST pin (as well as the IRQ pin and the PSG's DONE signal), I immediately changed the software in my synth to synchronize to the TEST pin instead of bit 15 of the read data. After some experimentation, this is what I'm using: Set $21 to $40 (output data mode) and $2C to $80 (test pin outputs SYNC). Wait for TEST to go high. Wait for TEST to go low (falling edge). Change the parallel interface to read from the OPN2's data output instead of the TEST pin and stuff. Wait 5-and-a-half OPN2 internal cycles. Capture the OPN2 data output, wait an OPN2 internal cycle. Repeat 23 more times. With this 5-and-a-half cycle delay between the falling edge of SYNC and the first data capture, the first data captured is Ch 1 Op 1. And then the remaining operator values captured are each of the channels in order, and then the operators in the order 1324. Voila! So now, whenever it has a little extra time between VGM commands, my synth captures the state of all the operators, calculates the channels' values based on which operators are being output, and displays all the results as VU meters on the front panel. It's quite a light show! And it's the real operators' states, read back from the chip, not an emulation of them. For instance if I turn on SSG-EG mode and push the chip into undocumented waters, the visualization always matches the sound without me having to understand what's actually going on in the EG. Shot a quick video for you all: [IMG http://i.imgur.com/BKdqEXa.jpg] ######## POST p30067 | TmEE co.(TM) | 2016-07-31 | t386-795.html Very awesome ! ######## POST p30069 | Stef | 2016-07-31 | t386-795.html That is really a awesome discover indeed ! Great work again Sauraen ! I really wish i could have used it for my XGM player instead of trying to emulate it :p ######## POST p30080 | foobat | 2016-08-06 | t386-795.html I'd buy one of these if you feel like making 2 instead of 1, Sauraen. Wish I had time to assemble the kit myself, but alas. Hit me up if you feel like making another. I'm flexible on the price. (serious offer btw, I'm fully aware of how much time and effort goes into a project like this) ######## POST p30083 | Sauraen | 2016-08-08 | t386-795.html [QUOTE] foobat wrote:I'd buy one of these if you feel like making 2 instead of 1, Sauraen. Wish I had time to assemble the kit myself, but alas. Hit me up if you feel like making another. I'm flexible on the price. (serious offer btw, I'm fully aware of how much time and effort goes into a project like this) [/QUOTE] I appreciate the offer, but I don't have the time. However, all the parts you would need to make it yourself are either already available for sale (including the sound chip boards, the processor board, and the MIDI board from the MIDIbox Shop , the sound chips from eBay, and all the components from Mouser), or will be for sale once I have more of the software done (the front panel board will be for sale on the same shop, and I will provide the design files for the aluminum front panel so anyone can order one). It took 10 hours for me to solder all the parts in the front panel board, by the way--there's 638 LEDs! But you don't have to build a giant flashy box to get your VGM files playing on hardware Genesises. MIDIbox VGM Player is the stripped-down version with only a few buttons and a screen, which plays VGM files from the SD card on the hardware YM2612 and SN76489. The total cost should be under $100 and while you still need soldering experience, it's much tamer. There's also another project, MIDIbox Genesis Tracker, which is just the processor board and the Genesis board with no interface, and it lets you control the chip by MIDI using the same protocol as Littlescale's GENMDM. This is in beta, so if anyone's interested let me know and I can help you build one! Also I would like to mention that this already is the second unit. The project was commissioned by an indie game composer, Josh Whelchel ; as part of the deal, he paid for two units and I got to keep one, which I'm also developing the software on. ######## POST p30087 | Eke | 2016-08-10 | t386-795.html Yes, that's really a nice synth you have done [IMG ./images/smilies/icon_cool.gif] Thanks for confirming the operator and channel order. I have some questions regarding channel and operator output seen in read data mode, not sure if you were able to figure those: 1) is the format for channel output really 9-bit signed (i.e with sign bit in MSB) or are the values similar to the 8-bit value written to Ch6 DAC register (i.e unsigned value where 0x00 is min and 0xFF is max) ? 2) same for operators, can you confirm the format being output is 14-bit signed (-8192;+8191)? 3) it was reported earlier in this this thread (viewtopic.php?f=24&t=386&start=550 ) that by summing at least two operators, it was possible to have [-256;+256] range in channel output i.e 513 distinct DAC levels while it was normally limited to [-256;+255] with a single operator as carrier. Did you see anything in the channel "accumulator" (or 9-bit "adder", not sure of the right terminology) that could explain this? ######## POST p30088 | Sauraen | 2016-08-10 | t386-795.html 1) It looks like 9-bit signed, but it's a little hard to tell since you have to read the lower 8 bits and the upper 1 bit separately. But it does appear that if there's nothing playing (or after power-up), the values is 0--it would be 0x100 if it was unsigned like you say, and that's definitely not what I'm seeing. So yes, basically confirmed. 2) Yes, definitely 14-bit signed. In my synth I'm just reading the MSB and treating it as a 6-bit signed integer (throwing out bits 14 and 15 which do other things). That's the basis for the VU meters, and as you can see they seem to work. 3) I don't know at this point. I haven't reverse engineered the accumulator unit yet. I can tell you it's 9 bits wide, but it's very possible there's a feature where if the sum clips (which we know it does rather than overflowing), it sets the output to +256. ######## POST p30097 | GManiac | 2016-08-13 | t386-795.html Hi all! I haven't read this topic for many years. Maybe, this info was discussed earlier, maybe I'm repeating myself, if so, pardon me. The subject is "ladder effect". Eke gave link to my old post about DAC output, where I say [QUOTE] operators are shifted arithmetically (not logically) by 5 bits [/QUOTE] Ladder effect is a large step between DAC levels -1 and 0. AFAIR, It is 3-4x times larger than usual step between other levels, for example, between 0 and +1. Arithmetic shift logic and large step makes sound more volumetric and in case of quiet sound makes a big sense (e.g., After Burner, track Super Stripe). Arithmetic shift is important. Why? Let's compare: -1 asr 5 = -1 -1 lsr 5 = 0 -31 asr 5 = -1 -31 lsr 5 = 0 -32 asr 5 = -1 -32 lsr 5 = -1 If our output operator is oscillating between -1 and +1, DAC digital output will be: - in case of arithmetic shift: -1; 0; -1; 0; -1; 0 - in case of logical shift: 0; 0; 0; 0; Because of ladder effect DAC analogue output will be: -3.5; 0; -3.5; 0 If emulator uses 14-bit DAC, it's "analogue output" equivalent will be: -0.03125; +0.03125; -0.03125; +0.03125 (0.03125 = 1.0/32.0). Range between maximum and minimum (0.0625) is 50 times more silent than on hardware! We will here almost nothing. So low bitness of DAC plus arithemtic shift plus large step ladder effect is NOT a bug, but feature! [IMG ./images/smilies/icon_biggrin.gif] When I was writing my YM emulator, i've simulated ladder and can confirm that After Burner sounded correctly. Can anyone add this "feature" to existing emulators / players plugins? Usually I listen music via Maxim's plugin. ######## POST p30098 | Sauraen | 2016-08-14 | t386-810.html [QUOTE] GManiac wrote: [QUOTE] operators are shifted arithmetically (not logically) by 5 bits [/QUOTE] [/QUOTE] The top 9 bits of the 14-bit operator output are sent to the accumulator, which adds the operators within one voice. So there's no question of shifting--it just takes the top 9 bits and discards the bottom 5. Only on PC where you are actually running these calculations in a 32-bit register does it matter which kind of shift you're using. The correct one here would indeed be an arithmetic shift, though depending on your implementation of the saturation (clipping) when operators are added, it may not matter. Remember, these are signed numbers, not unsigned numbers with an extra sign bit. Any emulator which is outputting 14-bit audio is not authentic, simply because the YM2612 DAC is 9 bit. The ladder effect is a result of the resistor string DAC--when the MSB is 0 and the string is between VDD and the midpoint, it pulls up the midpoint voltage slightly, and vice versa when the MSB is 1 and the string is between GND and the midpoint. Basically, the two halves of the range have decent linearity in themselves, but they don't quite meet in the middle. A decent way of emulating this would be to offset negative values by a constant amount (which it sounds like you're doing). Determining what that amount is has probably already been done quite well by someone with a good scope, but I can't do an effective job of that just by reading the die. [IMG ./images/smilies/icon_smile.gif] ######## POST p30102 | Eke | 2016-08-15 | t386-810.html [QUOTE] GManiac wrote: Can anyone add this "feature" to existing emulators / players plugins? Usually I listen music via Maxim's plugin. [/QUOTE] I am emulating the 9-bit DAC (although not 100% accurately for all algorithms since bits 0-4 masking is done after the operator 14-bit outputs have been eventually summed while it should be done on each operator carrier). Problem with emulating the "ladder effect" is that no precise measures/tests have been made on DAC output to actually emulate it accurately, we just know that an "offset" must be added for negative values but I'm still not sure how large it should be and to which levels it should be applied. So I was actually waiting to be able to accurately measure the voltage on MOL/MOR for each 512 DAC levels before implementing something. I guess that we could use the recently discovered 9th bit for Ch6 DAC mode in test register $2C (bit 3) to write a test ROM that outputs all 512 levels by muting all channels except Ch6 and writing directly to DAC register. ######## POST p30919 | jotego | 2017-02-26 | t386-810.html Hi all, I have finished reading the full thread and I have enjoyed every bit of it. Let me add to it now. First, I am working on a verilog module that replicates in hardware the YM2612/YM3438 to a very precise level. The internal operation is likely to be pretty much the same as the original. Everything runs in parallel, with pipelines, circular shift registers and stuff. I had actually developed this architecture when I did the YM2151 clone (the JT51). Then I was asked to do the YM2612, found Sauraen's and Nemesis' findings and was just very glad to see the convergence between JT51 architecture and actual hardware. On this new clone, the JT12, I am getting even closer. BTW, I also want to say thank you to HardWareMan for taking the die pictures. I have seen contributions on this thread of many others, thank to all of you. JT12 is GPL. You can have a look here . The folder hdl contains actual verilog files. Note that the work is not complete yet, though it is probably just a couple of weeks away from completition. You can check the issues page to see then pending tasks. You can also see it working with the current status here . It is running on a MiST FPGA board. Many of the things discussed in the thread make a lot of sense when you take a look at the hardware implementation in the verilog files. Aspects such as the duration of the BUSY signal, or EG behaviour are much clearer when look at from the eyes of a digital design, rather than software. By the way, the operator implementation (jt12_op.v) is pretty much a copy of Sauraen's VHDL file. Although converted to verilog and with style modifications, in essence, it is the same thing. Second, I have a blunt offer to people working on emulators. I think it might make sense to use Verilator in order to obtain a C++ model of the Verilog files, which is cycle-clock accurate. With that model you do not need an emulator, you just get the actual chip running inside your software! Although this might sound like a slow solution, I have seen some YM2612 emulator work which is so high level in terms of objects, abstraction layers, interfaces and stuff that it cannot be fast either! Third, let me make a couple of comments to things that were said at some point in the thread: [QUOTE] HardWareMan wrote: [QUOTE] TmEE co.(TM) wrote:I'm not very sure but I think the 2 big zig zags (capacitors ?) right next to each other under DAC part are part of channel switching. [/QUOTE] Yeah, it could be capacitors. Or it could be power current amplifier. I'm not sure for now. But, there are lot of capacitors, that interconnect some power rails on die. Look at bidirectional pin: [IMG http://savepic.su/1643350.png] And analog output pin: [IMG http://savepic.su/1699689.png] Analog output has only one transistor, wich connected to AVCC. Thus, analog output can only source current, not sink. External resistor required. And here those "zig-zags". Definitely this is a two transistors with some control circuit. [IMG http://savepic.su/1684328.png] [/QUOTE] I am almost certain that these zig-zags are ESD protection structures. These are compulsory protection circuits that must be placed next to the pads of a silicon die. [QUOTE] Eke wrote: ① Confirm the connection (algorithm) data. If these data are zero (0) through three (3), then the waveform does not distort, even at TL=0. ② When con. = 4, set the TL of the second individual carrier so that it will be negative six (-6) [dB] or more. ③ When con. = 5 or 6, set the TL of the third individual carrier so that it will be negative nine and one half (-9.5) [dB] or more. ④ When con. = 7, set all TL’s to negative twelve (-12) or more. [/QUOTE] This tells about the accumulator behaviour and lack of clamping and resolution. In some aspects, these chips were too cheap [IMG ./images/smilies/icon_sad.gif] [QUOTE] Stef wrote:Thanks Sauraen for the precious and detailed informations ! The internal organization in shift register explain indeed the volatile BUSY time. I guess it will be complicated to find a good formula to calculate a perfect timing. Anyway because of this unpredictable aspect almost sound driver always pool the busy flag because writing the YM registers. [/QUOTE] The YM3438 application notes PDF does contain a table with the length of BUSY time depending on the register. I have to compare it to my implementation (jt12_reg.v) but at the end we are doing the same thing: we have a circular shift register and we have to wait for the selected register to come out of it so we can insert the new value in its place. Note that in my implementation, the old value comes out and the new value in, so it takes a full 24-operator cycle to get the new value take effect. It is possible to discard the old value but it requires more logic, and if they were mean on the DAC, which is more important, I do not think they will extra logic for this. Well, thanks for reading this long post. I will keep working on JT12 and let you know when completed. ######## POST p30920 | HardWareMan | 2017-02-27 | t386-810.html Hi and welcome! [QUOTE] jotego wrote:I am almost certain that these zig-zags are ESD protection structures. These are compulsory protection circuits that must be placed next to the pads of a silicon die. [/QUOTE] [IMG http://savepic.su/1699689.png] A lot of time is passed. Now I sure that analog output have only one transistor that can only source current. You may clearly see it. [IMG http://savepic.su/1684328.png] As for about this one's, it is strong buffer for clock. It feeds from input logic of CLK pin and have some kind divider or counter (notice: with 6 steps). Also there is some kind shift register right below it. I believe this is main sync circuit, that set starts of any process inside (such start of channel and operator in it). Anyway, I can't be 100% sure until I make better die shots. ######## POST p30921 | Sauraen | 2017-02-27 | t386-810.html HardWareMan is correct, those are large drive transistors, not ESD protection devices. The one between OUT and AVCC is the driver for the output pin, and the two in a pair near the "Control" label are indeed for driving the positive and negative clock lines throughout the chip. These are labeled in my annotated die shot with the blocks labeled. The only sort of protection I've seen on the chip is some sort of resistor on the digital input pins. The YM2612 isn't CMOS so large protection transistors (really diodes) weren't required. ######## POST p30923 | jotego | 2017-03-01 | t386-810.html [QUOTE] Sauraen wrote:The only sort of protection I've seen on the chip is some sort of resistor on the digital input pins. The YM2612 isn't CMOS so large protection transistors (really diodes) weren't required. [/QUOTE] I see. ESD really became popular with CMOS processes. ######## POST p30935 | Eke | 2017-03-14 | t386-810.html [QUOTE] Sauraen wrote: I would go with the LFO, but honestly I haven't found it yet. [/QUOTE] Hi, Recently doing some correction in YM2612 core, I was wondering if you ever figured out the LFO and how it works exactly, especially regarding Phase Modulation. Some questions I have (based on current implementations): 1) how is LFO PM value calculated ? MAME implementation uses an offset table which takes LFO step (0-31) and LFO depth (0-7) as X/Y then use the seven upper bits of the FNUM value as weights to compute an offset value : for (i = 4 to 10) LFO_PM += (FNUM & (1<> (10 - i)) : 0 Exodus use similar table but uses the whole FNUM range (bits 0-10) to calculate LFO PM value and does the bitweight shifting differently: for (i = 0 to 10) LFO_PM += (FNUM & (1<> 9 See also this discussion: viewtopic.php?f=24&t=386&start=480 The difference is that MAME implementation right-shifts LFO table value for each weighted bit BEFORE adding them while Exodus first left-shift all table value, add them and THEN performs right-shift on the final sum. Result is similar but MAME implementation therefore limits itself to 7 upper bits (since right-shifted table values will always be 0 starting from bit3) while Exodus implementation provides additional bits of precision. From hardware point of view, both implementations seem plausible so it's hard to figure which one is correct. 2) how and where exactly is LFO PM value applied ? MAME applies the offset value on the whole BLOCK+FNUM register value, then recalculate BLOCK (which has been possibly impacted by LFO PM), Key-Code (which depends on FNUM and BLOCK) and Detune (which depends on Key Code) values before doing normal PG process on modified FNUM value (BLOCK shift, DETUNE add, etc). It's also notable that there is an additional bit of precision introduced here for some unknown reason (offset value is twice the one used in Exodus but bit0 is not used when adding to BLOCK/FNUM value and is instead injected during BLOCK shift). Exodus directly applies the offset value on the FNUM value then recalculate Key-Code and Detune values before doing normal PG process. Note that, while Key Code is recalculated in both implementations (and is therefore impacted by LFO PM) , Key Scale and EG rates (which depend on Key code value) are never recalculated and therefore not impacted by LFO PM. From an hardware point of view, it seems odd that BLOCK shift value would be impacted, same goes for Key Code if Key Scale is not (unless key code is recalculated by both EG and PG blocks !). I guess it would be a matter of figuring where the LFO PM adder takes place, what it takes as inputs, if it is internal or external to PM block and where its output goes). ######## POST p30937 | Sauraen | 2017-03-14 | t386-810.html [QUOTE] Eke wrote:I was wondering if you ever figured out the LFO and how it works exactly, especially regarding Phase Modulation. [/QUOTE] I never did a full reverse engineering of it, but here's what I have (from private messages to jotego): [QUOTE] Sauraen wrote:The LFO seems to have 3 sections: [*] 7-bit linear prescaler. The test bit 0x21:1 goes into what looks like the carry-in or something similar; it could go into the reset, I can't quite tell with more detailed analysis. The 7-bit output (plus maybe carry-out) gets logiced together into 8 lines (evidently perform "== N" with N hardcoded for each line), and these go into a little selector unit which is also fed by the LFO Speed and LFO Enable bits. I can't quite see the output of this, but I do see there's some sort of feedback to the prescaler's reset. So this clearly seems like a divide-by-N prescaler. I can try to read the eight N's for you if you want, but you should be able to reverse engineer them from knowing what the LFO speeds are. [*] 7-bit linear counter, with an 8-bit unit after the output (possibly inverts the output after each cycle to make a triangle wave?). Bits 1:6 of the output of this go to the EG, and stick into its pipeline at the same place where the LFO->Amplitude two bits go. (Elsewhere the operator LFO enable flag simply forces these two bits to zero for operators not affected by the LFO.) Some modified version of the 8-bit signal between the counter and the inverter unit thing goes to the third unit of the LFO. [*] Highly complex unit which modifies the frequency data as it goes from the channel registers to the PG. The block bits bypass this, but all the frequency bits get modified by it. There's a bitslice portion corresponding to bits 0:6, and then what appears to be the same logic folded over to process bits 7:A. But the interesting part is that bits 4:A of the frequency data go into the bitslices 0:6. That is, the bitslice unit for bit 0 has bit 0 enter at the middle and leave (to the PG) at the bottom. But it also has bit 4 enter at the top. And so on through bit 6 having bit A enter at the top. It looks like the top portion is some sort of shifter for bits 4:A--the wires go diagonally so that bit 4 only gets used once, bit 5 gets used in bitslice 1 and 0, bit 6 gets used in bitslices 2:0, and so on so that bit A gets used in all of them. I'm guessing this whole unit is basically a multiplier, multiplying bits 4:A of the frequency value by bits 0:7 of the LFO state, and then adding the result to bits 0:6 of the frequency value (with carry up to the higher bits). It looks like, between the multiplied output and the adder, there's another shifter whose value is based on the the LFO->Frequency bits. But it looks like it's a bit more complex than I'm describing. [/QUOTE] The upshot is that the LFO is definitely doing frequency modulation, not phase modulation. ######## POST p30938 | Eke | 2017-03-15 | t386-810.html [QUOTE] Sauraen wrote: I never did a full reverse engineering of it, but here's what I have (from private messages to jotego): [/QUOTE] Thanks, it still helps confirming a few stuff [QUOTE] [*] 7-bit linear prescaler. The test bit 0x21:1 goes into what looks like the carry-in or something similar; it could go into the reset, I can't quite tell with more detailed analysis. The 7-bit output (plus maybe carry-out) gets logiced together into 8 lines (evidently perform "== N" with N hardcoded for each line), and these go into a little selector unit which is also fed by the LFO Speed and LFO Enable bits. I can't quite see the output of this, but I do see there's some sort of feedback to the prescaler's reset. So this clearly seems like a divide-by-N prescaler. [/QUOTE] This would be LFO clock generator which is divided from internal clock based on LFO speed bits. Presumably, LFO enable bit halts the LFO clock generator as well as Test register 0x21 bit1 (similarly to YM2151 test register described here: to http://www.msxarchive.nl/pub/msx/mirror ... ym2151.txt ) [QUOTE] I can try to read the eight N's for you if you want, but you should be able to reverse engineer them from knowing what the LFO speeds are. [/QUOTE] According to MAME implementation, values are {108, 77, 71, 67, 62, 44, 8, 5} "sample clocks" where sample clock is internal clock / 24. From the value specified in YM2612 doc, assuming a 8Mhz input clock and 128 LFO clocks per period, 3.98 hz for speed 0 would give 8000000/6/24/3.98/128 = 109 samples between each LFO clock, which is one above MAME specified value. All other speed values give also one additional sample value (72.2 for speed 7 gives 8000000/6/24/72.2/128 = 6 samples) [QUOTE] [*] 7-bit linear counter, with an 8-bit unit after the output (possibly inverts the output after each cycle to make a triangle wave?). Bits 1:6 of the output of this go to the EG, and stick into its pipeline at the same place where the LFO->Amplitude two bits go. (Elsewhere the operator LFO enable flag simply forces these two bits to zero for operators not affected by the LFO.) [/QUOTE] That would be 7-bit LFO step counter (which is incremented on each LFO clock and reset when LFO enable bit is cleared). LFO AM value indeed corresponds to LFO step counter bits 0:5 shifted left by one and XORed with inversion of bit 6 (to generate an inverted triangle waveform) LFO AM sensitivity (2 bits) indicates to EG how much LFO AM value is shifted before adding to EG output [QUOTE] Some modified version of the 8-bit signal between the counter and the inverter unit thing goes to the third unit of the LFO. [/QUOTE] This would be LFO PM step (0-31), which takes bits 2:6 of LFO step counter (0-127) and goes to LFO PM calcuation unit you describe below [QUOTE] [*] Highly complex unit which modifies the frequency data as it goes from the channel registers to the PG. The block bits bypass this, but all the frequency bits get modified by it. [/QUOTE] This would be LFO PM calculation unit and this would confirm BLOCK calculation is not affected by LFO PM. Any chance you have located the "Key Code" calculation unit ? This would be a simple unit with a few OR/AND/NOT gates, taking highest 4 bits of FNUM value as inputs and outputting a 2-bit value (LSB of 5-bit Key Code value, MSB being BLOCK bits). Since this value is used by both EG and PG unit, it's more likely to be external to these units. Whether it interfaces with original frequency bits or the output of LFO PM calculation would indicate if LFO PM really has an impact on Detune value (since it depends on Key code value) as it is currently done in emulator implementations and if EG rates should be impacted as well. [QUOTE] There's a bitslice portion corresponding to bits 0:6, and then what appears to be the same logic folded over to process bits 7:A. But the interesting part is that bits 4:A of the frequency data go into the bitslices 0:6. That is, the bitslice unit for bit 0 has bit 0 enter at the middle and leave (to the PG) at the bottom. But it also has bit 4 enter at the top. And so on through bit 6 having bit A enter at the top. It looks like the top portion is some sort of shifter for bits 4:A--the wires go diagonally so that bit 4 only gets used once, bit 5 gets used in bitslice 1 and 0, bit 6 gets used in bitslices 2:0, and so on so that bit A gets used in all of them. I'm guessing this whole unit is basically a multiplier, multiplying bits 4:A of the frequency value by bits 0:7 of the LFO state, and then adding the result to bits 0:6 of the frequency value (with carry up to the higher bits). It looks like, between the multiplied output and the adder, there's another shifter whose value is based on the the LFO->Frequency bits. But it looks like it's a bit more complex than I'm describing. [/QUOTE] This seems to match with MAME implementation (more than Exodus implementation). If we look at LFO PM offset table used in MAME we can see the max offset value per FNUM bit is 96 (0x60) for when bit 10 is set so this would only require 7-bit addition/substraction (hence bitslices 0 to 6) with carry propagating on higher bits. For following FNUM bits, LFO PM offset are shifted by one, so max value would be : 0x30 (6-bits i.e bitslices 0 to 5) for bit 9 , 0x18 (5-bits i.e bitslices 0 to 4) for bit 8, ... , 0x03 (2-bits i.e bitslices 0 & 1) for bit 5 and finally 0x01 (1-bit i.e bitslice 0 only) for bit 4. I just don't understand the extra bit precision added in MAME implementation: from the chip hardware point of view, this would mean that this unit would takes 11 bits of original Frequency (FNUM) value but output 12 bits and that frequency input of PG unit is actually 12 bit or more, not 11 (with MSBs corresponding to original FNUM and LSB being forced to zero when no LFO modulation is applied) . Another solution is that LFO offset value is calculated as 7 bit (6.1 fixed point) value and the lowest bit is discarded when adding to FNUM value. Would it be possible to confirm or deny this from looking at the die shot ? ######## POST p31026 | Eke | 2017-04-02 | t386-810.html [QUOTE] TmEE co.(TM) wrote:26KHz is the effective max for the YM DAC register from my tests, going higher makes the sound worse. I haven't done any actual investigation but there cannot be anything else happening than missed writes. I played some real music and all the higher freq stuff was getting garbled when you went beyond 26KHz. The game Hellfire has 2x slower music on MD2 than on MD1. The game spams YM with unnecessary writes and is being polite about it (waits for busy). Discrete YM3438 didn't seem to run 2x slower (I no longer remember the result...), but it has issues in other games (I recall Sonic Spinball being one). [/QUOTE] About this one, I've run a few tests on VA4 MD1 (with discrete YM2612) and VA0 MD2 (with 315-5660 ASIC) regarding the BUSY flag and here is what I figured or confirmed from Sauraen die shot analysis : 1) BUSY flag can only be read from port 0 (A0=A1=0) on discrete YM2612 while it can be read from any port on ASIC-integrated version 2) BUSY flag is only set on DATA port writes (A0=1) 2) BUSY flag duration is constant and does not depend on the written register 3) BUSY flag duration seems to be 32 internal clocks (32*6 68k clocks): this was tested with my emulator against real hardware using a test program that counts number of status read with BUSY flag being set. Results were identical to real hardware on emulator with busy wait set to 32*6 68k cycles, other values (like 24, 48 or even 30) give too much different values than real hardware 4) BUSY flag duration is the same on discrete YM2612 and ASIC-integrated chip Now, this also explains why Hellfire music is slower on MD2 with ASIC-integrated FM: as mentioned before, the game spams the FM chip with writes while waiting for BUSY flag to be cleared between each of them. The problem is that they made a mistake in the sound engine as they are reading FM status from the same port they write the data to (i.e port 1 or port 2) so the result is that when run on MD1 (which is likely the model it was developed for), the BUSY flag always appears to be cleared and there isn't enough delay between each writes. This is the reason there is a lot of unnecessary writes being done as they likely noticed there was a problem with their code and they "fixed" it by repeating the same writes multiple times. When run on MD2, the BUSY flag is read correctly and the code this time waits correctly between each write. But since there are a lot of repeated writes because of the workaround implemented for MD1 hardware, it results in slower music. ######## POST p31027 | TmEE co.(TM) | 2017-04-02 | t386-810.html I'd like to add that it is possible to write stuff to YM at sample rate (1 write every 144 YM clocks). I made YM run at same clock as Z80 and made code write one sample every 144 cycles and I got all writes intact. It is not possible to get perfect synchronity to YM like that in normal condition, when 68K accesses Z80 side there are always penalty cycles, aswell as when Z80 accesses 68K side. I'll do more tests around it later on to determine what are the minimum delays per register before data gets missed. ######## POST p31049 | Sauraen | 2017-04-06 | t386-810.html [QUOTE] Eke wrote:Any chance you have located the "Key Code" calculation unit ? This would be a simple unit with a few OR/AND/NOT gates, taking highest 4 bits of FNUM value as inputs and outputting a 2-bit value (LSB of 5-bit Key Code value, MSB being BLOCK bits). Since this value is used by both EG and PG unit, it's more likely to be external to these units. Whether it interfaces with original frequency bits or the output of LFO PM calculation would indicate if LFO PM really has an impact on Detune value (since it depends on Key code value) as it is currently done in emulator implementations and if EG rates should be impacted as well. [/QUOTE] Your intuition seems to be correct. There's a unit at the beginning of the PG which takes the 3 bits of BLOCK, plus two bits from an "unknown source" (I'll call them "pink bits" because I happened to color their wires pink on my annotated chip image), delays them by 1 or 2 cycles, sends the BLOCK bits into the PG, and sends the delayed 5 bits into the PG and the EG. I traced these two pink bits back to a beginning somewhere in the logic for the channel parameter shift registers, and with a little more tracing they are definitely being computed from the top 4 bits of the raw FNUM value, pre-LFO. (By the way, this value is the FNUM for the current operator, including the cases of the operators of voice 3 with their own frequencies.) So unless the key code value is modified later (i.e. the PG's copy of the key code is modified before being used, but I don't think this is happening), it's not affected by the LFO at all. [QUOTE] Eke wrote:I just don't understand the extra bit precision added in MAME implementation: from the chip hardware point of view, this would mean that this unit would takes 11 bits of original Frequency (FNUM) value but output 12 bits and that frequency input of PG unit is actually 12 bit or more, not 11 (with MSBs corresponding to original FNUM and LSB being forced to zero when no LFO modulation is applied) . Another solution is that LFO offset value is calculated as 7 bit (6.1 fixed point) value and the lowest bit is discarded when adding to FNUM value. Would it be possible to confirm or deny this from looking at the die shot ? [/QUOTE] Not so lucky here. 11 bits enter the LFO multiplier thing, 12 bits leave and go to the PG. In fact, the first unit in the PG (unknown function) where these 12 bits enter is actually 16 bits wide: the three LSBs are zero, then the 12 bits from the LFO, then the MSB is also zero. This is followed by another unit which actually has a 17-bit output. These two units are extremely compact custom logic and I can't quite tell their function, but they appear to be shifters; the second one appears to shift right four bits depending on bit 2 of BLOCK, and I think the first one shifts one or two bits based on bits 0 or 1 of BLOCK. The unit after this, which looks like it's adding something (Detune?), is also 17 bits, with no carry-out as far as I can tell. The unit after that is 18 bits and the unit after that is 20 bits, both of which look like more elaborate shifters. Then comes what appears to be the PG state shift register addition and control unit. ######## POST p31050 | Eke | 2017-04-06 | t386-810.html [QUOTE] Sauraen wrote: Your intuition seems to be correct. There's a unit at the beginning of the PG which takes the 3 bits of BLOCK, plus two bits from an "unknown source" (I'll call them "pink bits" because I happened to color their wires pink on my annotated chip image), delays them by 1 or 2 cycles, sends the BLOCK bits into the PG, and sends the delayed 5 bits into the PG and the EG. I traced these two pink bits back to a beginning somewhere in the logic for the channel parameter shift registers, and with a little more tracing they are definitely being computed from the top 4 bits of the raw FNUM value, pre-LFO. (By the way, this value is the FNUM for the current operator, including the cases of the operators of voice 3 with their own frequencies.) So unless the key code value is modified later (i.e. the PG's copy of the key code is modified before being used, but I don't think this is happening), it's not affected by the LFO at all. [/QUOTE] Thanks a lot for confirming that. As said previously, this wasn't very logical to have key code impacted by LFO when calculating detune but not when calculating EG rates. Seems much more logical this way. On a side note, do you happen to have this annotated chip image available somewhere, I couldn't find it back in the thread? [QUOTE] Sauraen wrote:Not so lucky here. 11 bits enter the LFO multiplier thing, 12 bits leave and go to the PG. [/QUOTE] At least, it seems to confirm LFO adds a bit of precision to FNUM 11-bit input, just like Jarek's implementation in MAME is doing. [QUOTE] Sauraen wrote:In fact, the first unit in the PG (unknown function) where these 12 bits enter is actually 16 bits wide: the three LSBs are zero, then the 12 bits from the LFO, then the MSB is also zero. This is followed by another unit which actually has a 17-bit output. These two units are extremely compact custom logic and I can't quite tell their function, but they appear to be shifters; the second one appears to shift right four bits depending on bit 2 of BLOCK, and I think the first one shifts one or two bits based on bits 0 or 1 of BLOCK. [/QUOTE] Yes, I was able to see that as well on the die shot, 16-bit input with only 12-bit in the middle holding value, then converted to 17-bit but I couldn't tell where these 12-bit were coming from so thanks for confirming it comes directly out of LFO PM unit. I guess this is a way of preshifting frequency value before doing BLOCK right-shifting. In MAME implementation, this is done like that: (freqnum << 5) >> (7 - BLOCK) where freqnum = (FNUM<<1) + lfo_offset (12-bit adjusted FNUM value after LFO). Here it seems like it first does something equivalent to doing (freqnum << 3) then does BLOCK shifting in multiple passes To get equivalent formula as above implementation, it would be something like that: 1) 1-bit right-shifting if BLOCK bit 0 is cleared 2) 2-bit left-shifting if BLOCK bit 1 is set 3) 4-bit right-shifting if BLOCK bit 2 is cleared [QUOTE] The unit after this, which looks like it's adding something (Detune?), is also 17 bits, with no carry-out as far as I can tell. [/QUOTE] Yes, quite likely. Detune addition result can indeed overflow and output is 17 bit [QUOTE] The unit after that is 18 bits and the unit after that is 20 bits, both of which look like more elaborate shifters. [/QUOTE] This would be the multiplication unit, not sure why it is 18-bit but it has to handle the case where MUL=0 ( x 1/2) so there must be some pre-shifthing or post-shifting involved. ######## POST p31053 | Sauraen | 2017-04-06 | t386-810.html [QUOTE] Eke wrote:On a side note, do you happen to have this annotated chip image available somewhere, I couldn't find it back in the thread? [/QUOTE] I've posted small segments from it on occasion, but no. It's a 1.6 GB GIMP image with 6 layers or so (just different types of signals, not broken out into the actual chip layers), and it uses 6 GB of RAM to be loaded for editing. Maybe when I'm "done" (whatever that means) I can upload the flattened result somewhere, but even exporting it as a JPG would be ~200 MB. [QUOTE] Eke wrote:I guess this is a way of preshifting frequency value before doing BLOCK right-shifting. [/QUOTE] As you know, hardware doesn't care how a value is aligned, just how many bits it contains. [QUOTE] Eke wrote:This would be the multiplication unit, not sure why it is 18-bit but it has to handle the case where MUL=0 ( x 1/2) so there must be some pre-shifthing or post-shifting involved. [/QUOTE] I think both of the units I mentioned together are the multiplication unit, though I'm still not quite sure--it doesn't look like it has the adders, just the shifters, though maybe the adders are present in the subsequent unit. ######## POST p31153 | jotego | 2017-04-17 | t386-810.html I am glad to see the thread still alive. We do not know everything about the YM2612 yet! [QUOTE] Eke wrote: About this one, I've run a few tests on VA4 MD1 (with discrete YM2612) and VA0 MD2 (with 315-5660 ASIC) regarding the BUSY flag and here is what I figured or confirmed from Sauraen die shot analysis : 1) BUSY flag can only be read from port 0 (A0=A1=0) on discrete YM2612 while it can be read from any port on ASIC-integrated version 2) BUSY flag is only set on DATA port writes (A0=1) 2) BUSY flag duration is constant and does not depend on the written register 3) BUSY flag duration seems to be 32 internal clocks (32*6 68k clocks): this was tested with my emulator against real hardware using a test program that counts number of status read with BUSY flag being set. Results were identical to real hardware on emulator with busy wait set to 32*6 68k cycles, other values (like 24, 48 or even 30) give too much different values than real hardware 4) BUSY flag duration is the same on discrete YM2612 and ASIC-integrated chip [/QUOTE] I actually entered the forum today to talk about this. I didn't expect to find this post. Well, what I am going to say kind of contradicts this information. I spent the last 5 days working on JT51 , adding lessons learnt from the JT12 experience. One tool I made when developing JT51 was a sample accurate operator in C. With some parameters about the operator configuration, the tool produces an output on screen with the exact same sequence as the real YM2151. It is verified against literally thousands of chip measurements as I automated the measurement process to take samples for each set of register values. The YM2151 has digital output, which YM2612 doesn't, so that work is rather easy. (In my case it wasn't because the PCB I made for this was a disaster!) Anyway, on my v1.0 implementation of JT51 I had to make a lot of tricks to get the exact output from the Verilog RTL code. The problem is that one operator, which is called M2 in YM2151 and is equivalent to S3 in YM2612 seems to be getting output in the middle of two samples. Suppose you use algorithm 7 (all operators are just summed at the output. It is supposed to be good for organ sound emulation). Then you would expect samples to have the sum of S1,S3,S2,S4 (or M1,M2,C1,C2 in YM2151 documentation). However, as the keyon is set for all operator on a channel, M2 (S3) gets output one sample ahead of time. This is issue #1. Then, if you go for an algorithm where one operator modulates another, like S1->S2 in alg. 6 (called M1->C1 in YM2151) then if keyon did not occur first on S1 and then on S2, the modulation effect of S1 over S2 would be lost for the first sample. However, in all my measurements I found consistently that modulation was present from the very first sample. I took measurements primarily on channel 0 but I did take many measurements on the other channels to verify whether they were equal or not. They were. (NB: I could not measure channel 7. Only verified 0-6). So keyon order on the operators is important. This is issue #2. So these two issues seem to point at two hardware blocks: Issue #1 -> related to when the accumulator unit resets the output sum, produces and output and starts to sum up the next sample. Issue #2 -> related to when they keyon information gets processed. I fixed these issues on v1.0 with ugly verilog. A hack. I wanted to take Sauraen's work on the operator of YM2612 and take it to substitute my operator unit in JT51. Although the YM2151 had 8 channels instead of the 6 of YM2612 so I had to make some arrangements. As expected, -after many hours of work- the operator did actually work. When comparing outputs from Verilog to outputs from my C emulator -which is exact in value and sample time to the original- I found that issue #1 was manifesting for some algorithms (but not all). So M2 being off by one sample was creating an error in my regression tests. When I look at the waveforms the error signals are virtually identical and the difference is likely not to be hearable at all. But you know what happens to engineers, we want it perfect so eventually I will go back to issue #1 in the future. But as for issue #2, I found that a way to fix it that did not call for a complex implementation was to run the operator update not as a constant time, but at a variable. This is where the busy signal comes in. Let me explain: When the user writes to a register, the internal circular shift registers may be at any point. The easy way to get the new data in is to wait for the shift register to output the old and then feed in the new one. If the user writes data when register 2/5 (operator 2, channel 5) is being output then it just waits (busy on) until the same register 2/5 gets output again. During that time the required register has been traversed too and so the data has been written. I made it that way in JT51 and then in JT12 too. But I think my JT12 implementation may take only 24 cycles instead of 32... I should check. The problem with this is the keyon register. That register must be another circular shift register that holds the key-on state of each operator. But if it was updated as explained on the previous paragraph then sometimes S2 would get the keyon before S1 does and then the first sample of S2 would not contain modulation from S1 as S1 is still in the keyoff state. This is the key aspect here: keyon must occur in order for the operators. At least in YM2151 the keyon for M1 (S1) always occurs before that of C1 (S2) and the modulation is always present. Was it the same for YM2612? I wonder. Note that in order to make S1 keyon happen ahead of time of S2 the register update strategy cannot take a fixed number of cycles. Not at least for keyon writes. This is something I would be very grateful to Eke if he could verify on the real part. Eke has shown that it takes 32 cycles to get the busy signal cleared. But... Does it take 32 cycles too for keyon writes? By the way, you may be thinking that it is not a big deal to update the keyon register in a different way. But when dealing with actual logic gates, the design can get very complex and large easily. The update way I propose is very economical in terms of circuit area and gate count so I bet the original one is like that. I hope I have not lost you with this long post. I know it is hard to follow. Probably even with illustrations it would be hard! ######## POST p31154 | Sauraen | 2017-04-18 | t386-825.html [QUOTE] jotego wrote:I hope I have not lost you with this long post. [/QUOTE] A bit, but one thing I can say from an initial read-through: I am quite confident from viewing the die shots, and it seems to be sufficiently confirmed from testing, that whenever you write a data value, BUSY gets set, and gets cleared exactly 32 cycles later. On the die shot it's just a 5-stage counter, not connected to anything else. Of course the chip actually "consumes" the written data value at some point within the first 24 (or possibly a couple more) cycles of it being written, when its value comes around in whatever circular shift register. (They're all 24 stages or less.) I see that what you're saying is that, as far as you can see, if you write the key on register just after op 1's key on bit came around, it waits until it comes around again so that the key on bits are always updated in the order 1, 3, 2, 4. This is possible--I haven't worked out any of the control units in detail--but this is easily testible. Write all four operators key-on on one cycle. Exactly 24 cycles later, write all of them key-off. On the naive implementation, you will get each operator to output a nonzero value exactly one sample (possibly not all on the same sample, but one each). On your implementation, one of two things will happen: either the new key-on value will overwrite the old, and some of the operators will have never received a key-on; or the new value will be discarded, and some of the operators will remain keyed on afterwards. Both of these conditions should be observable even on one sample (if release is set to a long value, you can notice any operator which was keyed on for only one sample; and as long as decay level is not zero, you can also tell it apart if the operator was never keyed off). The thing is that, if your implementation is correct, it would take a maximum of 18+23=41 cycles to update the keyon states of all four operators. Which means, you could write a certain keyon value, wait the 32 cycles the dumb BUSY timer (and the datasheet) told you to, and then write a different keyon value, and have the output be blatantly incorrect (compared to what the datasheet specified), i.e. have some operators still on or never turned on. I am a bit doubtful that Yamaha would have added the additional logic to make sure the operators got keyed on in the correct order, when this could lead to strictly incorrect performance, while the only penalty for not adding this logic would be modulation being wrong for a single sample. ######## POST p31156 | jotego | 2017-04-18 | t386-825.html Very interesting. Let me comment: [QUOTE] Sauraen wrote: The thing is that, if your implementation is correct, it would take a maximum of 18+23=41 cycles to update the keyon states of all four operators. Which means, you could write a certain keyon value, wait the 32 cycles the dumb BUSY timer (and the datasheet) told you to, and then write a different keyon value, and have the output be blatantly incorrect (compared to what the datasheet specified), i.e. have some operators still on or never turned on. [/QUOTE] The chip could have a different logic to generate the BUSY for the keyon. In JT51 v1.0 I had a fixed 32 bit counter for busy_reg and then an independent busy_keyon signal. And the final busy was the OR of both of them. This means a bit more of logic, yes and: [QUOTE] Sauraen wrote: I am a bit doubtful that Yamaha would have added the additional logic to make sure the operators got keyed on in the correct order, when this could lead to strictly incorrect performance, while the only penalty for not adding this logic would be modulation being wrong for a single sample. [/QUOTE] So I think they added the extra logic to have a longer BUSY but I do not have a PCB setup to verify it at the moment. The alternative to update the keyon within a 32 bit count and still get the operator order right doesn't sound easy either. And I insist, I took literally hundreds of measurements and it is not possible that all of them just by mere chance got the same operator order for all channels... is it? I do not think my testbench was so deterministic as the PC was driving it and relied on an UART... so there are plenty of chances to get information delayed by several clock cycles even when running the same test bench. ######## POST p31160 | TmEE co.(TM) | 2017-04-18 | t386-825.html You get clicks and whatnot on note ons, they didn't try to do anything about it whatsoever (easiest thing would have been allowing te select if phase generator is reset by note on or not) and having a wrong sample or two at a noteon wasn't gonna be a problem because it is gonna be masked by the click or even be source of it. I don't see any reason they tried to handle things specially here. ######## POST p31240 | Sauraen | 2017-04-21 | t386-825.html [QUOTE] jotego wrote:The chip could have a different logic to generate the BUSY for the keyon [/QUOTE] I looked again, and as far as I can tell this is not the case. The BUSY timer's only inputs are chip reset and a signal indicating a data address was written, and it has one output. This output goes to a unit which puts values on the output bus. The connections to this unit are: the two timer overflow signals, the BUSY signal, test register 21:6 (which disables this unit and enables another unit to put test data on the output bus), a signal to teh actual /IRQ pin, a Bus Write timing control signal, and bits 7, 0, and 1 of the output bus. There's no other "mystery control signal" from the keyon logic. ######## POST p31283 | jotego | 2017-04-26 | t386-825.html [QUOTE] Sauraen wrote: [QUOTE] jotego wrote:The chip could have a different logic to generate the BUSY for the keyon [/QUOTE] I looked again, and as far as I can tell this is not the case. The BUSY timer's only inputs are chip reset and a signal indicating a data address was written, and it has one output. This output goes to a unit which puts values on the output bus. The connections to this unit are: the two timer overflow signals, the BUSY signal, test register 21:6 (which disables this unit and enables another unit to put test data on the output bus), a signal to teh actual /IRQ pin, a Bus Write timing control signal, and bits 7, 0, and 1 of the output bus. There's no other "mystery control signal" from the keyon logic. [/QUOTE] Very interesting, thanks a lot! So it is very unlikely that they could manage to have a specific sort order for operator keyon. I will try to verify it on the actual part, using the test output. I have a question about parallel data: [QUOTE] Sauraen wrote:Turn on read data mode (21:D6 = 1). Select MSB or LSB of read data (21:D7 = 0 for MSB, 1 for LSB--this may be new information) Select the signal that appears on bit 14 of the output (1:0, and it does seem to make a difference, but I still don't know what the two signals are) Select whether to read operator or channel outputs (2C:D4 = 0 for operators, 1 for channels) Set up to read data from the OPN2 (as if checking whether it's busy). Every OPN2 internal clock cycle, capture a new byte from the bus, for 24 cycles. Print the 24 bytes from the synth to a terminal. [/QUOTE] I do not understand what the interaction with the clock is. If I set to read LSB data and then read for 24 cycles, I am getting the LSB of all the 24 operators... but I am losing the MSB! If then I set to read MSB the operators are already at a different value (different clock) so I cannot get to read both the MSB and the LSB of an operator at a specific clock cycle. Is that correct? It seems odd that MSB+LSB cannot be read. Then about the test pin, when it is set to input, (2C:D7 = 1), I wonder if that input is actually a clock. Maybe when the PG and EG clocks are stopped using test modes (21:D5=1, stops EG clock and 21:D3, stops PG clock) the clock is actually handed to the test pin. However, note that even stopping the PG clock is not enough to read MSB+LSB of the same operator. Because if we have to read MSB for 24 cycles and then set to read LSB for another 24 cycles, even if PG and EG are stopped, the internal modulation shift registers and signals will make operator values shift away. So there must be another bit that stops the modulation control signals (the ones you called op_algorithm_ctl, voice_fb and op_fb_enable). If the modulation, PG and EG are stopped then we can alternate between MSB and LSB read and get all the information. Then we can advance one clock cycle using the test pin or one of the other unknown test pins: [QUOTE] Sauraen wrote: 21:D1 Goes to unknown control unit (large block above PG). 21:D0 Goes to parallel data output unit. Function unknown—maybe selects which channel to read output of? 2C:6 - Goes to the same unit as the TEST pin's input wire, which is a small control unit at the upper right of the EG. I will try to figure out whether this unit actually has to do with the EG or not. (It's also worth mentioning that it looks like BUSY is permanently wired to the TEST pin output--you can't switch it to output some other signal on this pin.) [/QUOTE] ######## POST p31285 | Sauraen | 2017-04-26 | t386-825.html [QUOTE] jotego wrote:I do not understand what the interaction with the clock is. If I set to read LSB data and then read for 24 cycles, I am getting the LSB of all the 24 operators... but I am losing the MSB! If then I set to read MSB the operators are already at a different value (different clock) so I cannot get to read both the MSB and the LSB of an operator at a specific clock cycle. Is that correct? It seems odd that MSB+LSB cannot be read. [/QUOTE] You are correct, MSB+LSB cannot be read. The info you quoted from me about the unknown test bits is obsolete. The most up-to-date information is as follows: Test Bit Functions $21:0: Select which of two unknown signals is read as bit 14 of the test read output. $21:1: Some LFO control, unknown function. $21:2: Timers increment once every internal clock rather than once every sample. (Untested by me) $21:3: Freezes PG. Presumably disables writebacks to the phase register. $21:4: Ugly bit. Inverts MSB of operators. $21:5: Freezes EG. Presumably disables writebacks to the envelope counter register. Unknown whether this affects the other EG state bits. $21:6: Enable reading test data from OPN2 rather than status flags. $21:7: Select LSB (1) or MSB (0) of read test data. (Yes, it's backwards.) $2C:2 downto 0: Ignored by OPN2, confirmed by die shot. $2C:3: Bit 0 of Channel 6 DAC value $2C:4: Read 9-bit channel output (1) instead of 14-bit operator output (0) $2C:5: Play DAC output over all channels (possibly except for Channel 5--in my testing the DAC is the only thing you hear and it's much louder, you do not get any output from Channel 5; but someone else supposedly found that the pan flags for Channel 5 don't affect the panning of this sound, which is only possible if it's not being output during that time slot for some reason. I don't have any other reason to believe this is true though). $2C:6: Select function of TEST pin input--both unknown functions. $2C:7: Set the TEST pin to be an output (1) instead of input (0). Test Read Data Format ABPPPPPP PPPPPPPP (if $2C:4 is 0) AB00000C CCCCCCCC (if $2C:4 is 1) A: Unknown signal. B: One of two unknown signals; which one is read is selected by $21:0. C: 9-bit channel output. P: 14-bit operator output. Test Bit Functions When the test bit is configured as an output ($2C:7 is 1), it outputs the SYNC signal (NOT BUSY as stated in old posts of mine). This signal goes high for one internal cycle every sample (24 cycles). Its falling edge occurs just after an internal clock pulse, so wait half an internal cycle before sampling the OPN2's output. Then, four cycles after that, the data on the output will be for Ch 1 Op 1. (Presumably, the SYNC signal is when it begins calculation of Ch 1 Op 1, and the output is available after four cycles.) Sample on each internal cycle to receive the data for channels 1-6 operator 1, then 1-6 op 3, then 1-6 op 2, then 1-6 op 4. I implemented this in my synth MIDIbox Quad Genesis to read back operator states (just the MSB) at about 500 Hz and create a VU meter display on the front panel ; the code for the routine is in this file . When the test bit is configured as an input, I have no idea what it does. So to answer your question @jotego, there is no bit which stops calculation of the operators. When I transcribed the operator unit I found no such functionality. The operator pipeline does calculation as part of the pipeline, and there's no way to skip it. Unlike the PG and EG which can essentially pop out a value, modify it, and put it back in the circular shift registers, in the OP the shift registers are throughout the pipeline. There's also no "mystery" test bit (input) which is unaccounted for which could do this, and yes I'm sure I saw them all. As I don't know what the TEST pin input does, I can't rule out that it would behave like you're saying; but there's two things which lead me to believe it's not. First, the two functions the test bit has don't seem to be linked to logic related to the PG and EG writeback disable signals, so I think the TEST pin input is active regardless of what kind of test mode the chip is in. Second, you need the TEST pin configured as an output in order to synchronize your data capture to it; and while you might be able to synchronize and then not need to look at the TEST pin anymore, to change it back to an input would require writing to $2C, which might interrupt your data collection. I guess you could keep careful timing throughout the process and still get good results--after all you have to write to $21 anyway to switch between LSB and MSB. ######## POST p31304 | jotego | 2017-04-27 | t386-825.html Very informative. I have updated the wiki on the JT12 repository with the information. I am setting up a board to take direct measurements so expect news in the coming weeks about the latest topics we have discussed. ######## POST p32605 | Eke | 2017-10-24 | t386-825.html Some more news about YM2612 DAC "ladder" effect: a guy named Nuked who analyzed YM3438 die shots recently wrote a cycle-accurate implementation in C and figured the effect was actually caused by two things: 1 ) the fact that the resistor array would not exactly reach Vcc/2 on either negative or positive side (already explained by Sauraen in a previous post) which causes a gap 2x larger than expected between 0 and -1 steps: 0 and -1 actually corresponds to same amount of resistance in DAC array i.e they are like opposed values symmetrical on each side of Vcc/2 => a way to emulate this is to add a +1 offset on positive or zero channel output (so 0 corresponds to +1 and so on). 2 ) the fact that the sign bit also has an impact when the DAC output is silenced, which can happen on one of the stereo analog output when muted but also between channels output as seen in early Nemesis captures (channel output is active for one chip internal cycle then kept "low" for 3 internal cycles) : when "silence" is needed, the output is actually forced to either +1 or -1 (max resistance output of DAC array) => a way to emulate this is to add a +3/-3 offset (+4/-4 when channel is muted) on channel output depending on sign bit This actually makes low volume instruments sounds much louder (see After Burner 2 " Super Stripe") but also cause that distinctive background noise when channel output is faded out (see Konami logo sound for example) Also see https://github.com/ekeeke/Genesis-Plus-GX/pull/179 for more details on Nuked2 YM3438 implementation (which also emulates test registers, status bit, etc) ######## POST p32647 | Kabuto | 2017-11-09 | t386-825.html I can confirm this large ladder gap from measurements of DAC output levels: https://docs.google.com/document/d/e/2P ... cbCvlG/pub (scroll down to YM2612 and zoom in on those 2 diagrams). Also, further discontinuities exist, especially for test bit $2C:3=0, where when DAC register bits 0 to 3 are 0 and register value is > 128. I tested multiple MD1s, all of them had this odd behaviour. I did not spot this on MD2, too bad that the seemingly better DAC performance is crippled by a poor amplifier circuit. Regarding $2C:5: I noticed that on a MD1 I tested this resulted in a roughly 30-fold increase of DAC levels when all channels are on. This causes distortions as the amplifier does not expect to see anything louder than all 6 channels played at once at maximum levels (which is unlikely since phases would need to match as well so there is a bit of head room left for PSG). Maybe this does not only output DAC on multiple channels but also output DAC for much longer than it does normally. ######## POST p32648 | Sauraen | 2017-11-09 | t386-825.html My understanding with the DAC "loud" test bit is that normally, channel values are output in an "impulse-like" fashion, for a fraction of their time slot (I think it should be 1/4, since there are 24 clock cycles per complete computation cycle and there are 6 channel values to output during that time, so output for 1 clock cycle would be 1/4 of a slot). Whereas, with the test bit set, the output is just constantly the DAC value. So it would be 24x as loud. ######## POST p34243 | jotego | 2018-11-21 | t386-825.html [QUOTE] Sauraen wrote: Tue Apr 18, 2017 3:04 am I am quite confident from viewing the die shots, and it seems to be sufficiently confirmed from testing, that whenever you write a data value, BUSY gets set, and gets cleared exactly 32 cycles later. On the die shot it's just a 5-stage counter, not connected to anything else. Of course the chip actually "consumes" the written data value at some point within the first 24 (or possibly a couple more) cycles of it being written, when its value comes around in whatever circular shift register. (They're all 24 stages or less.) [/QUOTE] Kabuto's Titan 2 Overdrive demo does not work well with a 24-stage circular shift register. His experimentation tells him that 12 FM cycles are enough to get a good write. He also reported that Sik, the author of echo, found that it was possible to get good writes while waiting less than 24 FM cycles. After thinking about it, I do not think that there is any other thing but a 24-stage circular shift register. But, maybe it was built out of the original 12-stage circular shift register from YM2203. We know, thanks to Sauraen, that the operator unit is pretty much a copy-paste exercise (with a difference in the number of stages) from that of YM2203. So I wonder if the original YM2203 structure of an input multiplexer, fed by the external data input on one side and the output of the shift register, followed by a 12-stage shift register was actually used twice in series. Thus having a total of 24 stages, where feedback goes from stage 24 to stage 1 but there are two multiplexers, one in front of stage 1 and another one in front of stage 13. This means that you can update operators 0 and 2 using the first multiplexer and operators 1 and 3 using the second one, within a 12-FM clock cycle period. This double-mux structure is compatible with the structural need for 24 stages and the observation from the demo scene that 12-FM clock cycles should work and makes sense historically and would have saved layout work to YM2612 designers. I wonder if Sauraen would still care to have a look at the die shot to confirm this, please. ######## POST p34246 | Sauraen | 2018-11-21 | t386-825.html [QUOTE] jotego wrote: Wed Nov 21, 2018 9:21 am So I wonder if the original YM2203 structure of an input multiplexer, fed by the external data input on one side and the output of the shift register, followed by a 12-stage shift register was actually used twice in series. Thus having a total of 24 stages, where feedback goes from stage 24 to stage 1 but there are two multiplexers, one in front of stage 1 and another one in front of stage 13. This means that you can update operators 0 and 2 using the first multiplexer and operators 1 and 3 using the second one, within a 12-FM clock cycle period. [/QUOTE] The pipeline for YM2612 is indeed 12 stages long: 6 of these are the same as YM2203, and then YM2612 has an additional 6-layer shift register stuck in the middle. Unlike PG and EG which have an important state variable to store (and so have logic to compute its new value from the old one and then enough shift registers to delay it for the remainder of 24 cycles), OP doesn't *normally* (leaving aside feedback for the moment) use the old value of an operator to compute the new one. What it does have is three additional buffers for modulation that store the last value of op 0, the last value of op 1, and the last-last value of op 0. (These are only 6 layers deep, because there are 6 voices.) At any given point in the pipeline, if you're looking at the data there, it's for (say) op 0; six cycles later it will be the same voice op 2; six cycles later the same voice op 1; and finally six cycles later the same voice op 3. In the intermediate six cycles, the other six voices are being computed. Please take a look at my VHDL model of the operator unit. I do not claim that every single logical element in this is correct, but I am confident that the overall structure of this in terms of what registers are where and how the pipeline works is correct. https://github.com/sauraen/YM2612/blob/ ... erator.vhd The operator parameters (for all units: EG, PG, OP) are stored in 24-deep circular shift registers whose outputs are basically just the control signals for all the units in the chip. There's no way to write to the middle of these--they can only be written to when that particular operator's data comes around. [EDIT: this is wrong] So, there is control logic (which I haven't analyzed in detail) which, based on which voice and operator you're writing to, waits to write your new data to these until the proper cycle. If you write one address and data at a given time and then 12 cycles later write another address and data, you might get lucky and both get captured, or the first one might get lost if it didn't come around in time. I can't see how it would be possible to make a sound engine that wrote new data every 12 clocks, consistently, without problems. ######## POST p34247 | Sik | 2018-11-21 | t386-825.html Reminds me, the other day I got reports that it's possible for a write to register $28 to go missing and you need to do key-on twice as a workaround. Now I wonder if that particular register does indeed need double the delay, seeing as it messes with the ADSR mechanism (・~・) ######## POST p34249 | jotego | 2018-11-22 | t386-825.html [QUOTE] Sauraen wrote: Wed Nov 21, 2018 5:53 pm The operator parameters (for all units: EG, PG, OP) are stored in 24-deep circular shift registers whose outputs are basically just the control signals for all the units in the chip. There's no way to write to the middle of these--they can only be written to when that particular operator's data comes around. So, there is control logic (which I haven't analyzed in detail) which, based on which voice and operator you're writing to, waits to write your new data to these until the proper cycle. If you write one address and data at a given time and then 12 cycles later write another address and data, you might get lucky and both get captured, or the first one might get lost if it didn't come around in time. I can't see how it would be possible to make a sound engine that wrote new data every 12 clocks, consistently, without problems. [/QUOTE] Thanks for your detailed account. I totally agree with it and JT12 implementation follows those lines as you know. However, in view of this new evidence from Kabuto, I remembered having seen some actual wait times in some Yamaha document, so I dug for it. It is the application notes for YM3438 , a CMOS version of YM2612 -which is NMOS logic. It is in Japanese so you may have to take my word for it. On page 10 it shows these wait times: Address register: 17 master clock cycles -> equivalent to -> 2.8=1+1.8 FM clock cycles Data on global or operator register: 83 master clock cycles -> 13.8=12+1.8 FM clock cycles Data on channel-wide register: 47 master clock cycles -> 7.8=6+1.8 FM clock cycles Now, this is how I explain it: There is a delay through the input/output latches equivalent to 2 master clock cycles. This is fixed. It might be because these are actually flip flops clocked with the master clock or just an equivalent delay through an asynchronous latch. Once that delay is taken away we are left with very interesting numbers: 12 FM clock cycles for global (0x2? registers) and operator registers. And 6 FM clock cycles for channel-wide registers. Remember than one FM clock cycles is six master clock cycles because of the internal divider. It takes 24 FM ticks for the pipeline operators to process everything and data must be poured into the pipeline one operator at a time, as Sauren also explained. My implementation -so far as v0.61 of JT12- was assuming that a 24 CSR (circular shift register) only had an update point, so it would take 24 FM ticks to get new data in. That also made sense in view of the length of the BUSY counter, which Sauren had reported to count for 32 FM ticks. However, the evidence from Kabuto and from YM3438 document tells us that the CSR can be updated in just 12 FM ticks. Thinking of different ways to accomplish this on silicon, I think that an update point just in the middle of it is economical and makes sense if they were reusing layout work from YM2203. As I explained before. Now, if someone looks at the die shots (YM33438 or YM2612 ) and checks the CSR and outputs from each flip flop just go straight to the next FF's input without any mux anywhere, then we will have to consider other implementation options. [QUOTE] Sik wrote: Wed Nov 21, 2018 7:46 pm Reminds me, the other day I got reports that it's possible for a write to register $28 to go missing and you need to do key-on twice as a workaround. Now I wonder if that particular register does indeed need double the delay, seeing as it messes with the ADSR mechanism (・~・) [/QUOTE] That makes sense. Keyon register $28 is an operator-level register because the key-on signal has to go through the pipeline. In my implementation I use another CSR to hold the key-on values and feed them to the pipeline. Original implementation must be like this too. I think I should change this CSR to have an update point in the middle too so it can get updated in 12 FM ticks rather than 24. More importantly, PCM data gets taken into account in the accumulator and the accumulator will exactly add each operator once every 24 FM ticks. So even if YM3438 says that 12 FM ticks is enough for $2? registers, I don't think you can get PCM data out of the chip at the suggested time of 13.8 FM ticks because the accumulator is only processing data at 24 FM ticks. You can write the data in the PCM register, and it will get in, but you will not get it out to the DAC. In summary, in the $2? space we have some registers that take rather immediate effect -like the frequency of the LFOSC- and others that go through the pipeline and have either a 12 or 24 FM tick time frame to become effective. ######## POST p34253 | Sik | 2018-11-22 | t386-825.html PCM data straight up can't be faster than ~26KHz (i.e. half the sample rate at which FM updates), writing faster than that outright results in missed samples. It may be slower than you think. In fact it'd be probably a good idea seeing how fast each of the $2x registers is. They by-pass the shifter (as they're global) which at first may make it look like they may work faster, but after some issues I've had some time ago and the key-on thing (not to mention the well known slowness of the PCM output) I'm starting to think they may be slower in general (probably depends on each particular register, so that's gonna need a lot more of testing). ######## POST p34255 | Sauraen | 2018-11-22 | t386-840.html [QUOTE] jotego wrote: Thu Nov 22, 2018 12:35 pm My implementation -so far as v0.61 of JT12- was assuming that a 24 CSR (circular shift register) only had an update point, so it would take 24 FM ticks to get new data in. That also made sense in view of the length of the BUSY counter, which Sauraen had reported to count for 32 FM ticks. However, the evidence from Kabuto and from YM3438 document tells us that the CSR can be updated in just 12 FM ticks. Thinking of different ways to accomplish this on silicon, I think that an update point just in the middle of it is economical and makes sense if they were reusing layout work from YM2203. As I explained before. Now, if someone looks at the die shots (YM3438 or YM2612 ) and checks the CSR and outputs from each flip flop just go straight to the next FF's input without any mux anywhere, then we will have to consider other implementation options. [/QUOTE] Surprise surprise, I was wrong. I thought I remembered them being 24 units/layers deep, and they are, but they're broken up to two groups of 12, with logic in between and at the beginning and the end. I don't have time right now to fully transcribe it, but given the other findings here, it seems reasonable that this allows a write to be made to the end or the middle. This would take more control logic, since at any given time there's two different operator's values which could be updated, but it's not that bad because the two values that could be updated would be subsequent operators in the same voice (e.g. voice 5 operator 3 is in the middle and operator 2 is at the end). The voice-level circular shift registers are 5-6 units/layers deep as expected. If I remember correctly for the YM2612, the register holding the DAC (PCM) value should update immediately (as soon as the data is in the internal data register), it just only gets used once per complete FM cycle (unless you have the DAC Loud bit turned on). ######## POST p34259 | Stef | 2018-11-22 | t386-840.html I can confirm DAC can be updated at more than 26 Khz, i don't know why people keep repeating that... maybe it depends from the system version but at least i was able to do 32 Khz on both MD1 and the MD2 and i'm confident we can get as high than 53 Khz. I think the 26 Khz mistake come from a driver using the busy bit to test the PCM write register speed, today we know we can't realy on this bit to correctly evaluate "busy" time. ######## POST p34262 | TmEE co.(TM) | 2018-11-23 | t386-840.html It is possible to update DAC once every sample if you have cycle synchronity to the YM. I did some tests where YM and Z80 were made to share the clock in MD and I could get unique samples out every 144 cycles. Doing rates between full and half sample rate are very ugly though due to the "resampling" effect, leading to pretty nasty sound (which is why I originally thought samples get missed). Unfortunately YM and Z80 don't share clock in YM and it is not possible to maintain any cycle level synchronity with the YM, especially when any ROM access is being done which adds uncertain amount of latency to the operation. ######## POST p34263 | jotego | 2018-11-23 | t386-840.html [QUOTE] Sauraen wrote: Thu Nov 22, 2018 5:57 pm Surprise surprise, I was wrong. I thought I remembered them being 24 units/layers deep, and they are, but they're broken up to two groups of 12, with logic in between and at the beginning and the end. I don't have time right now to fully transcribe it, but given the other findings here, it seems reasonable that this allows a write to be made to the end or the middle. [/QUOTE] Awesome news. So we have this piece of information confirmed. It is funny how they went for breaking up the CSR. As I said before, I think they were reusing layout from YM2203. Because the break is made at stage 12, it just happens that in comparison with the next data at the head, the difference is only in the operator MSB, let me explain. You have data flowing this way: Operator (binary) .........00...........01.........10............11..... Channel (decimal) 0-1-2-3-4-5-0-1-2-3-4-5-0-1-2-3-4-5-0-1-2-3-4-5 So from one location in the CSR to another 12 stages away the only difference in the operator-channel identification is the MSB of the operator, where in one location is 00b, in the other it will be 10b. So the logic to decide whether to update or not can be partly shared. Not sure if they actually shared it. Anyway, another mistery solved! [QUOTE] TmEE co.(TM) wrote: Fri Nov 23, 2018 4:06 am It is possible to update DAC once every sample if you have cycle synchronity to the YM. I did some tests where YM and Z80 were made to share the clock in MD and I could get unique samples out every 144 cycles. Doing rates between full and half sample rate are very ugly though due to the "resampling" effect, leading to pretty nasty sound (which is why I originally thought samples get missed). Unfortunately YM and Z80 don't share clock in YM and it is not possible to maintain any cycle level synchronity with the YM, especially when any ROM access is being done which adds uncertain amount of latency to the operation. [/QUOTE] I agree. An update of exactly 144 cycles (that is to say 24 FM ticks) will work. By the way, any PCM rate that is not an integer multiple of 24 FM ticks will eventually have sound artifacts. I don't know if software developers were aware of this. Probably not. For instance, if you update at 36 FM ticks half your samples will take two output slots (48 ticks) and the other half only one (24 ticks) so on average you do have (48+24)/2 = 36 ticks per sample but they will not be evenly output to the DAC so there will be very noticeable distortion. ######## POST p34265 | Sauraen | 2018-11-23 | t386-840.html [QUOTE] jotego wrote: Fri Nov 23, 2018 10:49 am Anyway, another mystery solved! [/QUOTE] Yeah! I was wondering why it wasn't just uniformly 24 layers... [QUOTE] jotego wrote: Fri Nov 23, 2018 10:49 am By the way, any PCM rate that is not an integer multiple of 24 FM ticks will eventually have sound artifacts. I don't know if software developers were aware of this. Probably not. [/QUOTE] Anyone who has rudimentary knowledge of DSP should realize this. But, if you sample at a much lower rate like 4 kHz used in common games (is it 8 kHz?), the effect is less noticeable since there are many samples which are the same. Plus, there is additional aliasing between the actual rate of writing to the DAC register and the mandatory 44.1kHz sampling rate of the VGM file--this was obviously not an issue when making games, but it is an issue now. Also, if my hypothesis that the DAC Loud test bit just makes the DAC value outputted all the time instead of a fraction of 1/6th of the time, you should be able to push audio out at an even higher sampling rate, since the 24 FM ticks no longer has any bearing on the output. ######## POST p34268 | nukeykt | 2018-11-24 | t386-840.html Probably my cycle accurate YM3438 emulator (which is basically translation of YM3438 schematic to C code) can give some insight about YM2612/YM3438 internals. ######## POST p34269 | jotego | 2018-11-24 | t386-840.html [QUOTE] nukeykt wrote: Sat Nov 24, 2018 7:10 am Probably my cycle accurate YM3438 emulator (which is basically translation of YM3438 schematic to C code) can give some insight about YM2612/YM3438 internals. [/QUOTE] That's an impressive piece of work. I will look at it carefully. Particularly I want to learn more about the undocumented bits. I do not see any schematic in Github, though. Only a very nice SVG file but that is very little information about the chip. Do you have something else? Apologies for saying it but It is not cycle accurate! For instance, you are not using a circular shift register for the pipeline data so you are not sensitive to inconsistency in writes. Indeed, if you do not have a clock input, I don't see how you can be cycle accurate. ######## POST p34270 | nukeykt | 2018-11-24 | t386-840.html [QUOTE] jotego wrote: Sat Nov 24, 2018 8:15 am That's an impressive piece of work. I will look at it carefully. Particularly I want to learn more about the undocumented bits. I do not see any schematic in Github, though. Only a very nice SVG file but that is very little information about the chip. Do you have something else? Apologies for saying it but It is not cycle accurate! For instance, you are not using a circular shift register for the pipeline data so you are not sensitive to inconsistency in writes. Indeed, if you do not have a clock input, I don't see how you can be cycle accurate. [/QUOTE] Thanks! [IMG ./images/smilies/icon_smile.gif] I have no any other documentation unfortnately. YM3438 die shot is pretty clean, so just labeling certain bits was enough to understand it's logic. Vectorizing entire chip is overkill i think. About cycle accuracy: Emulation core runs at YM2612's internal FM rate(i.e 24x of YM2612's sampling rate). Calling OPN_Clock will advace chip state by one FM cycle and return one stereo sample. Shift registers were replaced by arrays for performance reasons. This change doesn't affect accuracy. ######## POST p34271 | Sik | 2018-11-24 | t386-840.html On the topic of DAC output: how do DAC bits map to the actual channel output? Because DAC seems to sound too quiet compared to what FM channels can do and I always have to make samples louder to compensate (and that's considering I already make FM channels to be TL = 8 or quieter). ######## POST p34272 | nukeykt | 2018-11-24 | t386-840.html [QUOTE] Sik wrote: Sat Nov 24, 2018 2:38 pm On the topic of DAC output: how do DAC bits map to the actual channel output? Because DAC seems to sound too quiet compared to what FM channels can do and I always have to make samples louder to compensate (and that's considering I already make FM channels to be TL = 8 or quieter). [/QUOTE] 9 bits of PCM data are directly fed to YM2612's 9-bit DAC just like FM channels. ######## POST p34273 | Sik | 2018-11-24 | t386-840.html But register $2A only has 8 bits... ######## POST p34274 | nukeykt | 2018-11-24 | t386-840.html [QUOTE] Sik wrote: Sat Nov 24, 2018 4:33 pm But register $2A only has 8 bits... [/QUOTE] LSB bit of PCM is mapped to $2C:3. ######## POST p34275 | jotego | 2018-11-24 | t386-840.html [QUOTE] nukeykt wrote: Sat Nov 24, 2018 4:47 pm [QUOTE] Sik wrote: Sat Nov 24, 2018 4:33 pm But register $2A only has 8 bits... [/QUOTE] LSB bit of PCM is mapped to $2C:3. [/QUOTE] Exactly, and MSB is inverted in order to get correct sign for addition with other channels: [CODE BLOCK WITHHELD: 36 chars] (Verilog code) ######## POST p34276 | jotego | 2018-11-24 | t386-840.html [QUOTE] nukeykt wrote: Sat Nov 24, 2018 8:43 am I have no any other documentation unfortnately. YM3438 die shot is pretty clean, so just labeling certain bits was enough to understand it's logic. Vectorizing entire chip is overkill i think. About cycle accuracy: Emulation core runs at YM2612's internal FM rate(i.e 24x of YM2612's sampling rate). Calling OPN_Clock will advace chip state by one FM cycle and return one stereo sample. Shift registers were replaced by arrays for performance reasons. This change doesn't affect accuracy. [/QUOTE] I agree that it doesn't affect accuracy for well behaved software. What you called one FM cycle, is what I have been calling 24 FM clock ticks, and from the discussion above we have determined that register updates happen in a 12-FM-clock-tick frame. Thus when software changes dynamically register values while sound is still played, there will be a 12-FM tick delay between your solution and real hardware. Nothing major, unless someone writes software to actually exploit this difference. For instance, if software updates PCM at 36-FM-tick pace, as I explained before. Indeed, when a value is updated within the 24 FM tick cycle will make a difference if software is not nice behaved (which means updating register values only while key-off, using PCM update in integer multiples of 24FM ticks and reading BUSY bit). By the way, there is still one question about how the register selection works pending there: when is the part selection bit (i.e. A1 pin) latched? For instance, if user writes to address 2'b00 the value $30, and then to address $b11 the value $FF, where does $FF go to? What happens when there is inconsistency between the A1 pin value for write address and write data operations? Have you got any insight about this? [CODE BLOCK WITHHELD: 828 chars] I see that you got different latch for MSB of FNUM of channel 3 special values and the rest. That is very interesting. Have you confirmed that by inspecting the die shot? It looks like you got all test bits implemented to! That's awesome. I think I might be missing some. I will probably add all for completeness. Another question from your code: [CODE BLOCK WITHHELD: 88 chars] I thought CSM would just trigger key-on for a cycle, and after that key-off. But you seem to be altering the value in a strange way. Why TL[1]? Is that a value of TL inside the envelope pipeline? I am not sure if your implementation actually tries to replicate the pipeline, but in order to do that you should operate at the FM clock rate and not the 24*FM clock rate (i.e. sample rate) you said. And what does that line do? An OR there can only make sound quieter but why make it quieter for a key on? How confident are you about the chip actually doing this? By the way, I love your simple API and neat implementation. I have seen many and they make everything very software-ish complicating everything a lot. ######## POST p34277 | nukeykt | 2018-11-24 | t386-840.html [QUOTE] jotego wrote: Sat Nov 24, 2018 6:27 pm I agree that it doesn't affect accuracy for well behaved software. What you called one FM cycle, is what I have been calling 24 FM clock ticks, and from the discussion above we have determined that register updates happen in a 12-FM-clock-tick frame. Thus when software changes dynamically register values while sound is still played, there will be a 12-FM tick delay between your solution and real hardware. Nothing major, unless someone writes software to actually exploit this difference. For instance, if software updates PCM at 36-FM-tick pace, as I explained before. Indeed, when a value is updated within the 24 FM tick cycle will make a difference if software is not nice behaved (which means updating register values only while key-off, using PCM update in integer multiples of 24FM ticks and reading BUSY bit). [/QUOTE] One FM clock in my code is 6 master clocks. For example in Genesis Plus GX emulator OPN2_Clock is called 1.27(7.67/6) million times per second(for comparison MAME code works at 53.267 KHz). Like real hardware my implementation updates registers within 12 FM ticks. Look carefully to OPN2_DoRegWrite function. [QUOTE] jotego wrote: Sat Nov 24, 2018 6:27 pm By the way, there is still one question about how the register selection works pending there: when is the part selection bit (i.e. A1 pin) latched? For instance, if user writes to address 2'b00 the value $30, and then to address $b11 the value $FF, where does $FF go to? What happens when there is inconsistency between the A1 pin value for write address and write data operations? Have you got any insight about this? [/QUOTE] It's a bit weird i think. I'm not 100% sure, but looking at my code it's behaves like this. For global registers(0x21-0x2C) A1 of data write matters, but for register and channel registers A1 from address write matters instead. Would be cool if someone could perform hardware tests. EDIT: Looks like for global registers both address and data writes must have zero A1 pin state in order to work properly. [QUOTE] jotego wrote: Sat Nov 24, 2018 6:27 pm [CODE BLOCK WITHHELD: 828 chars] I see that you got different latch for MSB of FNUM of channel 3 special values and the rest. That is very interesting. Have you confirmed that by inspecting the die shot? [/QUOTE] Yes [QUOTE] jotego wrote: Sat Nov 24, 2018 6:27 pm It looks like you got all test bits implemented to! That's awesome. I think I might be missing some. I will probably add all for completeness. Another question from your code: [CODE BLOCK WITHHELD: 88 chars] I thought CSM would just trigger key-on for a cycle, and after that key-off. But you seem to be altering the value in a strange way. Why TL[1]? Is that a value of TL inside the envelope pipeline? I am not sure if your implementation actually tries to replicate the pipeline, but in order to do that you should operate at the FM clock rate and not the 24*FM clock rate (i.e. sample rate) you said. And what does that line do? An OR there can only make sound quieter but why make it quieter for a key on? How confident are you about the chip actually doing this? By the way, I love your simple API and neat implementation. I have seen many and they make everything very software-ish complicating everything a lot. [/QUOTE] This behavior should be consistent with real hardware. Not sure why Yamaha implemented it in that way though. In theory my code should be 1:1 to real hardware. But in practice i could make some mistakes in implementation. ######## POST p34279 | Eke | 2018-11-25 | t386-855.html Nemesis tested the address/data ports relation some years ago viewtopic.php?f=24&t=386&start=410 [QUOTE] It turns out that writing to an address register stores both the written address, and the part number of the address register you wrote to. You can then write to either the data port at $A00001, or the data port at $A00003, and the write will go to the register number you wrote, within the part of the address register you wrote to. This means you can, for example, write an address to $A00000, then write the data to $A00003, and the data will in fact be written to the part 1 register block, not the part 2 register block. [/QUOTE] Not sure if he tested also with global registers ($2x) though ######## POST p34281 | jotego | 2018-11-25 | t386-855.html [QUOTE] nukeykt wrote: Sat Nov 24, 2018 7:36 pm One FM clock in my code is 6 master clocks. For example in Genesis Plus GX emulator OPN2_Clock is called 1.27(7.67/6) million times per second(for comparison MAME code works at 53.267 KHz). Like real hardware my implementation updates registers within 12 FM ticks. Look carefully to OPN2_DoRegWrite function. [/QUOTE] I see, I agree with that approach. However, I have another question. Are you really implementing the pipeline? For instance, in function OPN2_PhaseCalcIncrement you perform a lot operations for the data of the current slot, without holding any intermmediate value in a latch. Can that be real? Of course the chip has a lot of parallel things going on that speed up things but it still looks like a lot to be done in a clock cycle. Then you have the result stored in pg_inc[slot], but data couldn't be actually stored in the same "slot" as it was passing through. You use pg_inc in the OPN2_PhaseGenerate but you calculate slot as [CODE BLOCK WITHHELD: 39 chars] My interpretation of this is that the previous function actually had 20 pipeline stages (20 latches) in hardware. Your writing to the same slot you were using as input does not affect accuracy of emulation because that position will not be read until 20 cycles later. So, in general, it looks like you are respecting the pipeline delays but just not writting a function (latch) for each pipeline stage. Is my interpretation correct? Another question is about your function OPN2_DoRegWrite. chip->write_fm_data is read at the beginning of the function (in the if statement) but it is modified at the end of the function. Are you representing a latch operation in this way? Because the data written at the end will not be read until the next call to the function. ######## POST p34283 | nukeykt | 2018-11-25 | t386-855.html [QUOTE] jotego wrote: Sun Nov 25, 2018 5:29 pm [QUOTE] nukeykt wrote: Sat Nov 24, 2018 7:36 pm One FM clock in my code is 6 master clocks. For example in Genesis Plus GX emulator OPN2_Clock is called 1.27(7.67/6) million times per second(for comparison MAME code works at 53.267 KHz). Like real hardware my implementation updates registers within 12 FM ticks. Look carefully to OPN2_DoRegWrite function. [/QUOTE] I see, I agree with that approach. However, I have another question. Are you really implementing the pipeline? For instance, in function OPN2_PhaseCalcIncrement you perform a lot operations for the data of the current slot, without holding any intermmediate value in a latch. Can that be real? Of course the chip has a lot of parallel things going on that speed up things but it still looks like a lot to be done in a clock cycle. Then you have the result stored in pg_inc[slot], but data couldn't be actually stored in the same "slot" as it was passing through. You use pg_inc in the OPN2_PhaseGenerate but you calculate slot as [CODE BLOCK WITHHELD: 39 chars] My interpretation of this is that the previous function actually had 20 pipeline stages (20 latches) in hardware. Your writing to the same slot you were using as input does not affect accuracy of emulation because that position will not be read until 20 cycles later. So, in general, it looks like you are respecting the pipeline delays but just not writting a function (latch) for each pipeline stage. Is my interpretation correct? [/QUOTE] All calculations performed in OPN2_PhaseCalcIncrement function actually take 4 cycles on real hardware. I've simplified it as all data used in this function enter to the PG block at the same time. Replicating all latches would be big headache for linear C emulator. Probably there are some other optimizations like this in my code that should not screw up core accuracy. [QUOTE] jotego wrote: Sun Nov 25, 2018 5:29 pm Another question is about your function OPN2_DoRegWrite. chip->write_fm_data is read at the beginning of the function (in the if statement) but it is modified at the end of the function. Are you representing a latch operation in this way? Because the data written at the end will not be read until the next call to the function. [/QUOTE] Yes. write_fm_data actually is register and it does exist on YM3438. So it should be consistent with real hardware. ######## POST p34289 | jotego | 2018-11-26 | t386-855.html [QUOTE] nukeykt wrote: Sun Nov 25, 2018 6:24 pm All calculations performed in OPN2_PhaseCalcIncrement function actually take 4 cycles on real hardware. I've simplified it as all data used in this function enter to the PG block at the same time. Replicating all latches would be big headache for linear C emulator. Probably there are some other optimizations like this in my code that should not screw up core accuracy. [/QUOTE] I have started to translate your code to Verilog so we can have this level of accuracy in FPGA too. I don't know whether it will make an audible difference to current JT12 or not, but once the knowledge of the real implementation is published, I think we ought to use it. I understand the original chip well because I wrote a clone so I may be able to spot a bug in your code -if there is one. Thus, this exercise of mine may also be useful to you as you get a second pair of eyes going through your code. If you have information about how many cycles -pipeline length- took each function, could you share it? That would help me as in digital design these things have more implications than in software. By the way, I see the timers do operations in cycles 1 and 2. I wonder, how do timers know the cycle in real hardware? In my implementation, I did find it useful to have a signal indicating the first stage of the pipeline. I called it zero and it goes to many places. However, your code suggests that there are signals to indicate other cycles, not only the first one. Was there another circular shift register (CSR) to indicate the current cycle in hardware? Something like a one-bit CSR feeding different circuits so Yamaha designers could have more freedom to decide when things happened? This would be a departure from YM2203 as if the timer counts on cycle 1 as in your code, it would count at twice the speed in YM2203 because there are half the number of operators (i.e. total cycles per output) ######## POST p34290 | nukeykt | 2018-11-26 | t386-855.html [QUOTE] jotego wrote: Mon Nov 26, 2018 12:03 pm I have started to translate your code to Verilog so we can have this level of accuracy in FPGA too. I don't know whether it will make an audible difference to current JT12 or not, but once the knowledge of the real implementation is published, I think we ought to use it. I understand the original chip well because I wrote a clone so I may be able to spot a bug in your code -if there is one. Thus, this exercise of mine may also be useful to you as you get a second pair of eyes going through your code. [/QUOTE] Nice to hear it. Good luck with it [IMG ./images/smilies/icon_smile.gif] [QUOTE] jotego wrote: Mon Nov 26, 2018 12:03 pm If you have information about how many cycles -pipeline length- took each function, could you share it? That would help me as in digital design these things have more implications than in software. [/QUOTE] I think i can't help much here. More than one year has passed since i worked on it. [QUOTE] jotego wrote: Mon Nov 26, 2018 12:03 pm By the way, I see the timers do operations in cycles 1 and 2. I wonder, how do timers know the cycle in real hardware? In my implementation, I did find it useful to have a signal indicating the first stage of the pipeline. I called it zero and it goes to many places. However, your code suggests that there are signals to indicate other cycles, not only the first one. Was there another circular shift register (CSR) to indicate the current cycle in hardware? Something like a one-bit CSR feeding different circuits so Yamaha designers could have more freedom to decide when things happened? This would be a departure from YM2203 as if the timer counts on cycle 1 as in your code, it would count at twice the speed in YM2203 because there are half the number of operators (i.e. total cycles per output) [/QUOTE] YM3438 actually has internal cycle counter which outputs 24 signals for each cycle value. Cycle counter is actively used throughout entire chip. For example operator unit uses it to determine channel's operator number which further used for FM algorithm control. ######## POST p37832 | Stef | 2023-01-17 | t386-855.html I finally took sometime to make some tests about the minimum safe write timings for the YM2612 / YM3438 chip. I made a lot of tests but still I couldn't test every cases and every registers but hopefully that is enough to confirm (or not) data we got from official documents. I made all my tests using the 68K CPU (I initially tried with the Z80 but it was really too painful honestly) and i assumed there is no extra delay cycle in writing the YM2612 chip from it (to be honest I had no idea but it definitely seems that this is not the case). I tested both on YM2612 (MD1 VA0) and the ASIC YM3438 (Nomad and MD3 clone) and so far the write timing seems roughly identical between the 2 (contrary to my initial belief) but I still need to do some tests with the key register on YM2612 to confirm that. Edit: I just completed my tests on the YM2612 and I can confirm that timings are identical. So far here are the timing given in official docs: - 17 YM cycles (8 Z80 cycles) between writing the address and data - no wait between writes to addresses $21-$2F - 83 YM cycles (39 Z80 cycles) between writes to addresses $30-$9E - 47 YM cycles (22 Z80 cycles) between writes to addresses $A0-$B6 The good news is that I can confirm almost all these numbers [IMG ./images/smilies/icon_smile.gif] Still there is some minor but important differences in some parts: - The documentation said 17 cycles between address / data write. That really seems pessimist and I couldn't got any problems using 12 cycles (5-6 Z80 cycles). With 10 cycles or less you indeed got some missed or corrupted writes quickly though. This is interesting to know as it means we can chain 2 fast Z80 writes (7 cycles + 7 cycles) to write a register. - The documentation said there is no wait for all $2x registers, and so far that is true except for the $28 register (key on/off) ! As i though this register really need some delay between writes otherwise you will got some unwanted results as completely missed writes or even altered envelop phase (!?!) when you chain key operations too quickly on the same channel (note play but quieter than expected). The minimum delay for safe operation is about 112-116 cycles (52-54 Z80 cycles) which is quite a lot (but I expected even more here). That is more than the 83 cycles required for writing $30-$9E registers. - The 83 cycles / 47 cycles for $30-$9E / $A0-$B6 registers seems to perfectly matches what i measured. There is some quirks about the ASIC YM3438 to be aware of as it makes it behave a bit differently when we read the status and the busy flag in particular : - unlike the YM2612 the status can only be read on the port #0. - the busy bit isn't immediately set to 1 when writing register. I dunno how much time it takes exactly to be set but waiting 20 YM cycles after the register write is enough to avoid any problem with that. ######## POST p37833 | TmEE co.(TM) | 2023-01-17 | t386-855.html I remember needing a larger than normal delay on key on/off registers when I made my sound driver many years ago, the envelope thing you mention is because the 4bits react differently and sometimes one or more won't do same as others and this can dramatically alter the sound. I also remember getting away with a little shorter address delay, but in the end it got wrapped into using convenient but slow IX and IY instructions lol ######## POST p37836 | Stef | 2023-01-17 | t386-855.html Yeah the address / register write delay seems quite short, still not short enough to use a Z80 16 bit write as LD (YMPORT), HL (16 cycles) or LD (YMPORT), DE (20 cycles) I really wanted to use it as even if high byte is written first (at addr + 1), it's not much of an issue as both address ports share the same register (it doesn't make any difference writing the address to $4001 or $4003). Unfortunately it's too fast as you have only 3 Z80 cycles between the address / register write.. At best you can do the following sequence: LD (BC), A // write address (7 cycles) LD (HL), E // write value (7 cycles) but it's unlikely to happen as you need to waste / initialize both BC and HL registers for that.. In the end myself I often use something as: LD (HL), D // write address (7 cycles) INC L // (4 cycles) LD (HL), E // write value (7 cycles) About the key registers, indeed the envelop alteration with too short delay maybe caused by only having part of the operators key ON/OFF state being properly updated. That make some sense after all.. ######## POST p37837 | TmEE co.(TM) | 2023-01-17 | t386-855.html One thing is that the write itself happens at the end of instruction so the delay really starts then and what happens next depends on what comes after. In the end I gave up trying to optimize access speeds and use IX/IY with YMPORT in them permanently, since I don't use them for anything else due to their slowness. ######## POST p38014 | HardWareMan | 2023-06-21 | t386-855.html As I already said here we opened the MD decapping project. One of it branch is was YM2612/YM3438 FM chip. Now the new dedicated to FM chip project is started and almost die perfect verilog model is available here . Testbench: [IMG https://github.com/nukeykt/Nuked-OPN2-FPGA/raw/main/imgstore/testbench.jpg] Resource usage on DE10-nano: [IMG https://github.com/nukeykt/Nuked-OPN2-FPGA/raw/main/imgstore/usage.png] Some WIP recordings. YM only (no PSG). https://soundcloud.com/user-656259515/test11 https://soundcloud.com/user-656259515/test14 https://soundcloud.com/user-656259515/test13 ######## POST p38015 | jotego | 2023-06-22 | t386-855.html Congratulations on such a feat! I’ll be comparing your implementation to mine for fine details. Thanks for sharing it.