Top secrets sources NedoPC tsfmpro

Rev

Rev 563 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed | ?url?

// TurboFMpro project
// (C) 2018 NedoPC

// configuration control:
//  "port" Fx writes, jumpers -- inputs
// config signals -- outputs

module cfg
(
        input  wire clk,
        input  wire rst_n,

        input  wire [7:0] d, // data bus to latch config "port" writes from
        input  wire       wrstb, // write strobe

        input  wire [1:0] mode, // 00 - single AY, 01 - turbo AY
                                // 10 - turbo FM,  11 - turbo FM + SAA


        // for bus
        output wire ym_sel,
        output wire ym_stat,
        output wire saa_sel,

        // for DAC gate
        output wire fm_dac_ena
);

        reg [3:0] cfg_port;


        // conf[0] - YM curchip select ( 0 - select D0, 1 - select D1, !!!1 after reset!!! )
        // conf[1] - YM stat reg select ( 1 - read register, 0 - read status )
        // conf[2] - YM fm part disable ( 0 - enable, 1 - disable )
        // conf[3] - SAA enable ( 0 - enable, 1 - disable )
        always @(posedge clk, negedge rst_n)
        if( !rst_n )
                cfg_port <= 4'b1111;
        else if( wrstb )
                cfg_port <= d[3:0];


        // make outputs
        assign ym_sel = cfg_port[0] || (mode==2'b00); // select chip #1 forever when turbo anything is disabled
       
        assign ym_stat = mode[1] && !cfg_port[2] && !cfg_port[1]; // no status reads are possible when fm disabled either in config reg or by mode[1:0]

        assign saa_sel = !cfg_port[3] && (mode==2'b11);


        assign fm_dac_ena = mode[1] && !cfg_port[2];

endmodule