| 1 | 
         2 | 
         alfik | 
         /*
  | 
      
      
         | 2 | 
          | 
          | 
          * Copyright (c) 2014, Aleksander Osman
  | 
      
      
         | 3 | 
          | 
          | 
          * All rights reserved.
  | 
      
      
         | 4 | 
          | 
          | 
          *
  | 
      
      
         | 5 | 
          | 
          | 
          * Redistribution and use in source and binary forms, with or without
  | 
      
      
         | 6 | 
          | 
          | 
          * modification, are permitted provided that the following conditions are met:
  | 
      
      
         | 7 | 
          | 
          | 
          *
  | 
      
      
         | 8 | 
          | 
          | 
          * * Redistributions of source code must retain the above copyright notice, this
  | 
      
      
         | 9 | 
          | 
          | 
          *   list of conditions and the following disclaimer.
  | 
      
      
         | 10 | 
          | 
          | 
          *
  | 
      
      
         | 11 | 
          | 
          | 
          * * Redistributions in binary form must reproduce the above copyright notice,
  | 
      
      
         | 12 | 
          | 
          | 
          *   this list of conditions and the following disclaimer in the documentation
  | 
      
      
         | 13 | 
          | 
          | 
          *   and/or other materials provided with the distribution.
  | 
      
      
         | 14 | 
          | 
          | 
          *
  | 
      
      
         | 15 | 
          | 
          | 
          * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  | 
      
      
         | 16 | 
          | 
          | 
          * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  | 
      
      
         | 17 | 
          | 
          | 
          * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  | 
      
      
         | 18 | 
          | 
          | 
          * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  | 
      
      
         | 19 | 
          | 
          | 
          * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  | 
      
      
         | 20 | 
          | 
          | 
          * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  | 
      
      
         | 21 | 
          | 
          | 
          * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  | 
      
      
         | 22 | 
          | 
          | 
          * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  | 
      
      
         | 23 | 
          | 
          | 
          * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  | 
      
      
         | 24 | 
          | 
          | 
          * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  | 
      
      
         | 25 | 
          | 
          | 
          */
  | 
      
      
         | 26 | 
          | 
          | 
          
  | 
      
      
         | 27 | 
          | 
          | 
         module soc(
  | 
      
      
         | 28 | 
          | 
          | 
             input               CLOCK_50,
  | 
      
      
         | 29 | 
          | 
          | 
          
  | 
      
      
         | 30 | 
          | 
          | 
             //SDRAM
  | 
      
      
         | 31 | 
          | 
          | 
             output      [12:0]  DRAM_ADDR,
  | 
      
      
         | 32 | 
          | 
          | 
             output      [1:0]   DRAM_BA,
  | 
      
      
         | 33 | 
          | 
          | 
             output              DRAM_CAS_N,
  | 
      
      
         | 34 | 
          | 
          | 
             output              DRAM_CKE,
  | 
      
      
         | 35 | 
          | 
          | 
             output              DRAM_CLK,
  | 
      
      
         | 36 | 
          | 
          | 
             output              DRAM_CS_N,
  | 
      
      
         | 37 | 
          | 
          | 
             inout       [31:0]  DRAM_DQ,
  | 
      
      
         | 38 | 
          | 
          | 
             output      [3:0]   DRAM_DQM,
  | 
      
      
         | 39 | 
          | 
          | 
             output              DRAM_RAS_N,
  | 
      
      
         | 40 | 
          | 
          | 
             output              DRAM_WE_N,
  | 
      
      
         | 41 | 
          | 
          | 
          
  | 
      
      
         | 42 | 
          | 
          | 
             //PS2 KEYBOARD
  | 
      
      
         | 43 | 
          | 
          | 
             inout               PS2_CLK,
  | 
      
      
         | 44 | 
          | 
          | 
             inout               PS2_DAT,
  | 
      
      
         | 45 | 
          | 
          | 
             //PS2 MOUSE
  | 
      
      
         | 46 | 
          | 
          | 
             inout               PS2_CLK2,
  | 
      
      
         | 47 | 
          | 
          | 
             inout               PS2_DAT2,
  | 
      
      
         | 48 | 
          | 
          | 
          
  | 
      
      
         | 49 | 
          | 
          | 
             //KEYS
  | 
      
      
         | 50 | 
          | 
          | 
             input       [3:0]   KEY,
  | 
      
      
         | 51 | 
          | 
          | 
          
  | 
      
      
         | 52 | 
          | 
          | 
             //SD
  | 
      
      
         | 53 | 
          | 
          | 
             output              SD_CLK,
  | 
      
      
         | 54 | 
          | 
          | 
             inout               SD_CMD,
  | 
      
      
         | 55 | 
          | 
          | 
             inout       [3:0]   SD_DAT,
  | 
      
      
         | 56 | 
          | 
          | 
             input               SD_WP_N,
  | 
      
      
         | 57 | 
          | 
          | 
          
  | 
      
      
         | 58 | 
          | 
          | 
             //VGA
  | 
      
      
         | 59 | 
          | 
          | 
             output              VGA_CLK,
  | 
      
      
         | 60 | 
          | 
          | 
             output              VGA_SYNC_N,
  | 
      
      
         | 61 | 
          | 
          | 
             output              VGA_BLANK_N,
  | 
      
      
         | 62 | 
          | 
          | 
             output              VGA_HS,
  | 
      
      
         | 63 | 
          | 
          | 
             output              VGA_VS,
  | 
      
      
         | 64 | 
          | 
          | 
          
  | 
      
      
         | 65 | 
          | 
          | 
             output      [7:0]   VGA_R,
  | 
      
      
         | 66 | 
          | 
          | 
             output      [7:0]   VGA_G,
  | 
      
      
         | 67 | 
          | 
          | 
             output      [7:0]   VGA_B,
  | 
      
      
         | 68 | 
          | 
          | 
          
  | 
      
      
         | 69 | 
          | 
          | 
             //SOUND
  | 
      
      
         | 70 | 
          | 
          | 
             output              I2C_SCLK,
  | 
      
      
         | 71 | 
          | 
          | 
             inout               I2C_SDAT,
  | 
      
      
         | 72 | 
          | 
          | 
             output              AUD_XCK,
  | 
      
      
         | 73 | 
          | 
          | 
             output              AUD_BCLK,
  | 
      
      
         | 74 | 
          | 
          | 
             output              AUD_DACDAT,
  | 
      
      
         | 75 | 
          | 
          | 
             output              AUD_DACLRCK
  | 
      
      
         | 76 | 
          | 
          | 
         );
  | 
      
      
         | 77 | 
          | 
          | 
          
  | 
      
      
         | 78 | 
          | 
          | 
         //------------------------------------------------------------------------------
  | 
      
      
         | 79 | 
          | 
          | 
          
  | 
      
      
         | 80 | 
          | 
          | 
         assign DRAM_CLK = clk_sys;
  | 
      
      
         | 81 | 
          | 
          | 
          
  | 
      
      
         | 82 | 
          | 
          | 
         //------------------------------------------------------------------------------
  | 
      
      
         | 83 | 
          | 
          | 
          
  | 
      
      
         | 84 | 
          | 
          | 
         wire clk_sys;
  | 
      
      
         | 85 | 
          | 
          | 
         wire clk_vga;
  | 
      
      
         | 86 | 
          | 
          | 
         wire clk_sound;
  | 
      
      
         | 87 | 
          | 
          | 
          
  | 
      
      
         | 88 | 
          | 
          | 
         wire rst_n;
  | 
      
      
         | 89 | 
          | 
          | 
          
  | 
      
      
         | 90 | 
          | 
          | 
         pll pll_inst(
  | 
      
      
         | 91 | 
          | 
          | 
             .inclk0     (CLOCK_50),
  | 
      
      
         | 92 | 
          | 
          | 
             .c0         (clk_sys),
  | 
      
      
         | 93 | 
          | 
          | 
             .c1         (clk_vga),
  | 
      
      
         | 94 | 
          | 
          | 
             .c2         (clk_sound),
  | 
      
      
         | 95 | 
          | 
          | 
             .locked     (rst_n)
  | 
      
      
         | 96 | 
          | 
          | 
         );
  | 
      
      
         | 97 | 
          | 
          | 
          
  | 
      
      
         | 98 | 
          | 
          | 
         //------------------------------------------------------------------------------
  | 
      
      
         | 99 | 
          | 
          | 
          
  | 
      
      
         | 100 | 
          | 
          | 
         wire [7:0] pio_output;
  | 
      
      
         | 101 | 
          | 
          | 
          
  | 
      
      
         | 102 | 
          | 
          | 
         wire ps2_a20_enable;
  | 
      
      
         | 103 | 
          | 
          | 
         wire ps2_reset_n;
  | 
      
      
         | 104 | 
          | 
          | 
          
  | 
      
      
         | 105 | 
          | 
          | 
         //------------------------------------------------------------------------------
  | 
      
      
         | 106 | 
          | 
          | 
          
  | 
      
      
         | 107 | 
          | 
          | 
         system u0(
  | 
      
      
         | 108 | 
          | 
          | 
             .clk_sys_clk                       (clk_sys),
  | 
      
      
         | 109 | 
          | 
          | 
             .reset_sys_reset_n                 (rst_n),
  | 
      
      
         | 110 | 
          | 
          | 
          
  | 
      
      
         | 111 | 
          | 
          | 
             .clk_vga_clk                       (clk_vga),
  | 
      
      
         | 112 | 
          | 
          | 
             .reset_vga_reset_n                 (rst_n),
  | 
      
      
         | 113 | 
          | 
          | 
          
  | 
      
      
         | 114 | 
          | 
          | 
             .clk_sound_clk                     (clk_sound),
  | 
      
      
         | 115 | 
          | 
          | 
             .reset_sound_reset_n               (rst_n),
  | 
      
      
         | 116 | 
          | 
          | 
          
  | 
      
      
         | 117 | 
          | 
          | 
             .export_vga_clock                  (VGA_CLK),
  | 
      
      
         | 118 | 
          | 
          | 
             .export_vga_sync_n                 (VGA_SYNC_N),
  | 
      
      
         | 119 | 
          | 
          | 
             .export_vga_blank_n                (VGA_BLANK_N),
  | 
      
      
         | 120 | 
          | 
          | 
             .export_vga_horiz_sync             (VGA_HS),
  | 
      
      
         | 121 | 
          | 
          | 
             .export_vga_vert_sync              (VGA_VS),
  | 
      
      
         | 122 | 
          | 
          | 
             .export_vga_r                      (VGA_R),
  | 
      
      
         | 123 | 
          | 
          | 
             .export_vga_g                      (VGA_G),
  | 
      
      
         | 124 | 
          | 
          | 
             .export_vga_b                      (VGA_B),
  | 
      
      
         | 125 | 
          | 
          | 
          
  | 
      
      
         | 126 | 
          | 
          | 
             .sdram_conduit_end_addr            (DRAM_ADDR),
  | 
      
      
         | 127 | 
          | 
          | 
             .sdram_conduit_end_ba              (DRAM_BA),
  | 
      
      
         | 128 | 
          | 
          | 
             .sdram_conduit_end_cas_n           (DRAM_CAS_N),
  | 
      
      
         | 129 | 
          | 
          | 
             .sdram_conduit_end_cke             (DRAM_CKE),
  | 
      
      
         | 130 | 
          | 
          | 
             .sdram_conduit_end_cs_n            (DRAM_CS_N),
  | 
      
      
         | 131 | 
          | 
          | 
             .sdram_conduit_end_dq              (DRAM_DQ),
  | 
      
      
         | 132 | 
          | 
          | 
             .sdram_conduit_end_dqm             (DRAM_DQM),
  | 
      
      
         | 133 | 
          | 
          | 
             .sdram_conduit_end_ras_n           (DRAM_RAS_N),
  | 
      
      
         | 134 | 
          | 
          | 
             .sdram_conduit_end_we_n            (DRAM_WE_N),
  | 
      
      
         | 135 | 
          | 
          | 
          
  | 
      
      
         | 136 | 
          | 
          | 
             .export_sound_sclk                 (I2C_SCLK),
  | 
      
      
         | 137 | 
          | 
          | 
             .export_sound_sdat                 (I2C_SDAT),
  | 
      
      
         | 138 | 
          | 
          | 
             .export_sound_xclk                 (AUD_XCK),
  | 
      
      
         | 139 | 
          | 
          | 
             .export_sound_bclk                 (AUD_BCLK),
  | 
      
      
         | 140 | 
          | 
          | 
             .export_sound_dat                  (AUD_DACDAT),
  | 
      
      
         | 141 | 
          | 
          | 
             .export_sound_lr                   (AUD_DACLRCK),
  | 
      
      
         | 142 | 
          | 
          | 
          
  | 
      
      
         | 143 | 
         7 | 
         alfik | 
             .sd_clk_export                     (SD_CLK),
  | 
      
      
         | 144 | 
          | 
          | 
             .sd_dat_export                     (SD_DAT),
  | 
      
      
         | 145 | 
          | 
          | 
             .sd_cmd_export                     (SD_CMD),
  | 
      
      
         | 146 | 
         2 | 
         alfik | 
          
  | 
      
      
         | 147 | 
          | 
          | 
             .export_ps2_out_port_a20_enable    (ps2_a20_enable),
  | 
      
      
         | 148 | 
          | 
          | 
             .export_ps2_out_port_reset_n       (ps2_reset_n),
  | 
      
      
         | 149 | 
          | 
          | 
          
  | 
      
      
         | 150 | 
          | 
          | 
             .export_ps2_kbclk                  (PS2_CLK),
  | 
      
      
         | 151 | 
          | 
          | 
             .export_ps2_kbdat                  (PS2_DAT),
  | 
      
      
         | 152 | 
          | 
          | 
             .export_ps2_mouseclk               (PS2_CLK2),
  | 
      
      
         | 153 | 
          | 
          | 
             .export_ps2_mousedat               (PS2_DAT2),
  | 
      
      
         | 154 | 
          | 
          | 
          
  | 
      
      
         | 155 | 
          | 
          | 
             .pio_input_export                  ({ 2'd0, ps2_reset_n, ps2_a20_enable, KEY }),
  | 
      
      
         | 156 | 
          | 
          | 
             .reset_only_ao486_reset            (pio_output[0] || ~(ps2_reset_n)),
  | 
      
      
         | 157 | 
          | 
          | 
             .pio_output_export                 (pio_output)
  | 
      
      
         | 158 | 
          | 
          | 
         );
  | 
      
      
         | 159 | 
          | 
          | 
          
  | 
      
      
         | 160 | 
          | 
          | 
         endmodule
  |