Here you go, this took a good bunch of hours, so please follow the instructions and test...
A) Question, why are you doing this in the Z80 bridge>
Lines 598 to 609:
// PSG writes
if (WRITE_PORT_STROBE[PSG_LATCH]) psg_addr <= WRITE_PORT_DATA[PSG_LATCH] ;
if (WRITE_PORT_STROBE[PSG_WRITE]) psg_data_o <= WRITE_PORT_DATA[PSG_WRITE] ;
psg_wr_en <= WRITE_PORT_STROBE[PSG_LATCH] | WRITE_PORT_STROBE[PSG_WRITE] ;
You do know I went through the trouble of latching and holding everything for you...
Why didn't you just do this located right at the top, just after the IO port definitions? :
// PSG writes
assign psg_addr = WRITE_PORT_DATA[PSG_LATCH] ;
assign psg_data_o = WRITE_PORT_DATA[PSG_WRITE] ;
assign psg_wr_en = WRITE_PORT_STROBE[PSG_LATCH] | WRITE_PORT_STROBE[PSG_WRITE] ;
Also, isn't this all wrong? Shouldn't it be:
// PSG writes
assign psg_addr = WRITE_PORT_DATA[PSG_ADDR][3:0] ; // Wire out the PSG address, just the bottom 4 bits.
assign psg_data_o = WRITE_PORT_DATA[PSG_DATA] ; // Wire out the PSG data, all 8 bits.
assign psg_wr_en = WRITE_PORT_STROBE[PSG_DATA]; // Only perform the write enable when the data is sent and not when the address is sent.
// IE, set the address, PSG wont do anything, then set the data, the PSG will use the previously sent address and the data strobe will tell it to write that data at the address which was already set prior.
(I changed the port names because what you had is confusing.)
The only thing I can think of is some sort of required reset value. If so, then you can add this line to the reset:
WRITE_PORT_DATA <= '{default:0} ;
Now, when a reset comes in, all the write ports will be 0'ed out. I hope this clears thing up.
I've attached an updated code. I did not touch the Z80 stuff as you will need to fix that.
Ok, hopefully the sound should work, but it is still the jt49 audio filters which do occasionally clip-invert making a nasty crackle buzz noise when all 3 channels are at full volume (something I saw in Modelsim). The one I am working on tomorrow should not have this problem.
Everything has changed as I moved to using `include "xxxx.v' instead of Quartuses include files in project. (Just for the audio right now...) So, update everything and take a look at the Z80 bridge for the audio stuff above.