Subversion Repositories tsfmpro

Rev

Rev 115 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. // TurboFMpro project
  2. // (C) 2018 NedoPC
  3.  
  4. // configuration control:
  5. //  "port" Fx writes, jumpers -- inputs
  6. // config signals -- outputs
  7.  
  8. module cfg
  9. (
  10.         input  wire clk,
  11.         input  wire rst_n,
  12.  
  13.         input  wire [7:0] d, // data bus to latch config "port" writes from
  14.         input  wire       wrstb, // write strobe
  15.  
  16.         input  wire        mode_enable_saa,   //0 - saa disabled (board equals to TurboFM)
  17.         input  wire        mode_enable_ymfm,  //0 - single AY mode (no two AY, no FM, no SAA)
  18.  
  19.  
  20.         // for bus
  21.         output wire ym_sel,
  22.         output wire ym_stat,
  23.         output wire saa_sel,
  24.  
  25.         // for DAC gate
  26.         output wire fm_dac_ena
  27. );
  28.  
  29.         reg [3:0] cfg_port;
  30.  
  31.  
  32.         // conf[0] - YM curchip select ( 0 - select D0, 1 - select D1, !!!1 after reset!!! )
  33.         // conf[1] - YM stat reg select ( 1 - read register, 0 - read status )
  34.         // conf[2] - YM fm part disable ( 0 - enable, 1 - disable )
  35.         // conf[3] - SAA enable ( 0 - enable, 1 - disable )
  36.         always @(posedge clk, negedge rst_n)
  37.         if( !rst_n )
  38.                 cfg_port <= 4'b1111;
  39.         else if( wrstb )
  40.                 cfg_port <= d[3:0];
  41.  
  42.  
  43.         // make outputs
  44.         assign ym_sel = cfg_port[0] || !mode_enable_ymfm; // select #1 when 2ay/fm disabled
  45.        
  46.         assign ym_stat = !cfg_port[1] && mode_enable_ymfm && !cfg_port[2]; // no status reads are possible when fm disabled
  47.  
  48.         assign saa_sel = !cfg_port[3] && mode_enable_saa && mode_enable_ymfm;
  49.  
  50.  
  51.         assign fm_dac_ena = mode_enable_ymfm && !cfg_port[2];
  52.  
  53. endmodule
  54.  
  55.