--
-- TBBlue / ZX Spectrum Next project
-- Copyright (c) 2010-2017 - Fabio Belavenuto & Victor Trucco
--
-- All rights reserved
--
-- Redistribution and use in source and synthezised forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- Redistributions in synthesized form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- Neither the name of the author nor the names of other contributors may
-- be used to endorse or promote products derived from this software without
-- specific prior written permission.
--
-- THIS CODE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
--
-- You are responsible for any legal issues arising from your use of this code.
--
 
NET 'clock_50_i'            LOC='T8'        | IOSTANDARD = LVCMOS33;
 
NET 'ram_addr_o<0>'     LOC='M2'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<1>'     LOC='M1'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<2>'     LOC='N1'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<3>'     LOC='P2'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<4>'     LOC='P1'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<5>'     LOC='L3'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<6>'     LOC='M4'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<7>'     LOC='M3'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<8>'     LOC='N4'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<9>'     LOC='N3'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<10>'        LOC='C4'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<11>'        LOC='C3'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<12>'        LOC='D3'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<13>'        LOC='E4'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<14>'        LOC='E3'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<15>'        LOC='F2'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<16>'        LOC='F1'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<17>'        LOC='G1'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_addr_o<18>'        LOC='H2'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<0>'        LOC='J6'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<1>'        LOC='L5'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<2>'        LOC='K5'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<3>'        LOC='M6'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<4>'        LOC='P4'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<5>'        LOC='R3'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<6>'        LOC='T4'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<7>'        LOC='N6'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<8>'        LOC='E2'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<9>'        LOC='C1'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<10>'   LOC='G5'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<11>'   LOC='F6'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<12>'   LOC='F5'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<13>'   LOC='G6'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<14>'   LOC='D1'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_data_io<15>'   LOC='A4'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_oe_n_o'            LOC='E1'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_we_n_o'            LOC='M5'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_ce_n_o<0>'     LOC='R2'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_ce_n_o<1>'     LOC='R1'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_ce_n_o<2>'     LOC='M10'   | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'ram_ce_n_o<3>'     LOC='B3'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
 
NET 'ps2_clk_io'            LOC='K3'        | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'ps2_data_io'           LOC='J3'        | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'ps2_pin6_io'           LOC='K6'        | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'ps2_pin2_io'           LOC='J4'        | IOSTANDARD = LVCMOS33 | PULLUP;
 
NET 'sd_cs_n_o'         LOC='L1'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'sd_cs2_n_o'            LOC='L4'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'sd_sclk_o'         LOC='K1'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'sd_mosi_o'         LOC='K2'        | IOSTANDARD = LVCMOS33 | DRIVE = 8;
NET 'sd_miso_i'         LOC='J1'        | IOSTANDARD = LVCMOS33 | PULLUP;
 
NET 'flash_cs_n_o'      LOC='T3'        | IOSTANDARD = LVCMOS33;
NET 'flash_sclk_o'      LOC='R11'   | IOSTANDARD = LVCMOS33;
NET 'flash_mosi_o'      LOC='T10'   | IOSTANDARD = LVCMOS33;
NET 'flash_miso_i'      LOC='P10'   | IOSTANDARD = LVCMOS33;
NET 'flash_wp_o'            LOC='N12'   | IOSTANDARD = LVCMOS33;
NET 'flash_hold_o'      LOC='P12'   | IOSTANDARD = LVCMOS33;
 
NET 'joyp1_i'               LOC='R14'   | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'joyp2_i'               LOC='T14'   | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'joyp3_i'               LOC='R15'   | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'joyp4_i'               LOC='P16'   | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'joyp6_i'               LOC='P11'   | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'joyp7_o'               LOC='T15'   | IOSTANDARD = LVCMOS33;
NET 'joyp9_i'               LOC='P15'   | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'joysel_o'              LOC='P9'        | IOSTANDARD = LVCMOS33;
 
NET 'audioext_l_o'      LOC='B2'        | IOSTANDARD = LVCMOS33 | DRIVE = 16;
NET 'audioext_r_o'      LOC='A2'        | IOSTANDARD = LVCMOS33 | DRIVE = 16;
NET 'audioint_o'            LOC='R16'   | IOSTANDARD = LVCMOS33 | DRIVE = 16;
 
NET 'ear_port_i'            LOC='A3'        | IOSTANDARD = LVCMOS33;
NET 'mic_port_o'            LOC='R5'        | IOSTANDARD = LVCMOS33;
 
NET 'btn_divmmc_n_i'        LOC='L8'        | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'btn_multiface_n_i' LOC='M7'        | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'btn_reset_n_i'     LOC='M11'   | IOSTANDARD = LVCMOS33 | PULLUP;
 
NET 'keyb_row_o<3>'     LOC='H13'   | IOSTANDARD = LVCMOS33;                # 1
NET 'keyb_row_o<2>'     LOC='L12'   | IOSTANDARD = LVCMOS33;                # 2
NET 'keyb_row_o<1>'     LOC='K11'   | IOSTANDARD = LVCMOS33;                # 3
NET 'keyb_row_o<4>'     LOC='J12'   | IOSTANDARD = LVCMOS33;                # 4
NET 'keyb_row_o<5>'     LOC='K12'   | IOSTANDARD = LVCMOS33;                # 5
NET 'keyb_row_o<0>'     LOC='H11'   | IOSTANDARD = LVCMOS33;                # 6
NET 'keyb_row_o<6>'     LOC='J11'   | IOSTANDARD = LVCMOS33;                # 7
NET 'keyb_row_o<7>'     LOC='G12'   | IOSTANDARD = LVCMOS33;                # 8
 
NET 'keyb_col_i<4>'     LOC='T5'        | IOSTANDARD = LVCMOS33 | PULLUP;   # 1
NET 'keyb_col_i<3>'     LOC='P7'        | IOSTANDARD = LVCMOS33 | PULLUP;   # 2
NET 'keyb_col_i<2>'     LOC='N8'        | IOSTANDARD = LVCMOS33 | PULLUP;   # 3
NET 'keyb_col_i<1>'     LOC='P8'        | IOSTANDARD = LVCMOS33 | PULLUP;   # 4
NET 'keyb_col_i<0>'     LOC='L7'        | IOSTANDARD = LVCMOS33 | PULLUP;   # 5
 
NET 'bus_rst_n_io'      LOC='M9'        | IOSTANDARD = LVCMOS33 | PULLUP | DRIVE = 16;
NET 'bus_clk35_o'           LOC='G11'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<0>'     LOC='A8'        | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<1>'     LOC='A9'        | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<2>'     LOC='A10'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<3>'     LOC='E8'        | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<4>'     LOC='A14'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<5>'     LOC='A13'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<6>'     LOC='B12'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<7>'     LOC='A12'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<8>'     LOC='B14'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<9>'     LOC='F9'        | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<10>'        LOC='D12'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<11>'        LOC='E12'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<12>'        LOC='B8'        | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<13>'        LOC='A7'        | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<14>'        LOC='F7'        | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_addr_o<15>'        LOC='E7'        | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_data_io<0>'        LOC='D5'        | IOSTANDARD = LVCMOS33 | PULLUP | DRIVE = 4;
NET 'bus_data_io<1>'        LOC='C5'        | IOSTANDARD = LVCMOS33 | PULLUP | DRIVE = 4;
NET 'bus_data_io<2>'        LOC='C6'        | IOSTANDARD = LVCMOS33 | PULLUP | DRIVE = 4;
NET 'bus_data_io<3>'        LOC='C8'        | IOSTANDARD = LVCMOS33 | PULLUP | DRIVE = 4;
NET 'bus_data_io<4>'        LOC='E6'        | IOSTANDARD = LVCMOS33 | PULLUP | DRIVE = 4;
NET 'bus_data_io<5>'        LOC='D8'        | IOSTANDARD = LVCMOS33 | PULLUP | DRIVE = 4;
NET 'bus_data_io<6>'        LOC='C7'        | IOSTANDARD = LVCMOS33 | PULLUP | DRIVE = 4;
NET 'bus_data_io<7>'        LOC='A6'        | IOSTANDARD = LVCMOS33 | PULLUP | DRIVE = 4;
NET 'bus_int_n_i'           LOC='F10'   | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'bus_nmi_n_i'           LOC='E11'   | IOSTANDARD = LVCMOS33;
NET 'bus_ramcs_i'           LOC='C16'   | IOSTANDARD = LVCMOS33 | PULLDOWN;
NET 'bus_romcs_i'           LOC='C15'   | IOSTANDARD = LVCMOS33;
NET 'bus_wait_n_i'      LOC='B16'   | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'bus_halt_n_o'      LOC='B15'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_iorq_n_o'      LOC='D9'        | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_m1_n_o'            LOC='D11'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_mreq_n_o'      LOC='E10'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_rd_n_o'            LOC='C9'        | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_wr_n_o'            LOC='C10'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_rfsh_n_o'      LOC='C11'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_busreq_n_i'        LOC='M12'   | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'bus_busack_n_o'        LOC='J13'   | IOSTANDARD = LVCMOS33 | DRIVE = 4;
NET 'bus_iorqula_n_i'   LOC='F12'   | IOSTANDARD = LVCMOS33 | PULLDOWN;
 
NET 'rgb_r_o<0>'            LOC='H4'        | IOSTANDARD = LVCMOS33;
NET 'rgb_r_o<1>'            LOC='H3'        | IOSTANDARD = LVCMOS33;
NET 'rgb_r_o<2>'            LOC='H5'        | IOSTANDARD = LVCMOS33;
NET 'rgb_g_o<0>'            LOC='F4'        | IOSTANDARD = LVCMOS33;
NET 'rgb_g_o<1>'            LOC='F3'        | IOSTANDARD = LVCMOS33;
NET 'rgb_g_o<2>'            LOC='G3'        | IOSTANDARD = LVCMOS33;
NET 'rgb_b_o<0>'            LOC='B1'        | IOSTANDARD = LVCMOS33;
NET 'rgb_b_o<1>'            LOC='C2'        | IOSTANDARD = LVCMOS33;
NET 'rgb_b_o<2>'            LOC='H1'        | IOSTANDARD = LVCMOS33;
NET 'vsync_o'               LOC='A11'   | IOSTANDARD = LVCMOS33;
NET 'hsync_o'               LOC='B10'   | IOSTANDARD = LVCMOS33;
NET 'csync_o'               LOC='D6'        | IOSTANDARD = LVCMOS33;
 
NET 'hdmi_n_o<0>'           LOC='P5'        | IOSTANDARD = TMDS_33;
NET 'hdmi_p_o<0>'           LOC='N5'        | IOSTANDARD = TMDS_33;
NET 'hdmi_n_o<1>'           LOC='A5'        | IOSTANDARD = TMDS_33;
NET 'hdmi_p_o<1>'           LOC='B5'        | IOSTANDARD = TMDS_33;
NET 'hdmi_n_o<2>'           LOC='T6'        | IOSTANDARD = TMDS_33;
NET 'hdmi_p_o<2>'           LOC='P6'        | IOSTANDARD = TMDS_33;
NET 'hdmi_n_o<3>'           LOC='T7'        | IOSTANDARD = TMDS_33;
NET 'hdmi_p_o<3>'           LOC='R7'        | IOSTANDARD = TMDS_33;
 
NET 'i2c_scl_io'            LOC='T9'        | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'i2c_sda_io'            LOC='R9'        | IOSTANDARD = LVCMOS33 | PULLUP;
 
NET 'esp_gpio0_io'      LOC='R12'   | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'esp_gpio2_io'      LOC='T13'   | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'esp_rx_i'              LOC='N9'    | IOSTANDARD = LVCMOS33 | PULLUP;
NET 'esp_tx_o'              LOC='T12'       | IOSTANDARD = LVCMOS33;
 
NET 'accel_io<0>'           LOC='H14'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<1>'           LOC='G14'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<2>'           LOC='L16'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<3>'           LOC='K15'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<4>'           LOC='K16'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<5>'           LOC='F13'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<6>'           LOC='F14'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<7>'           LOC='F15'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<8>'           LOC='F16'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<9>'           LOC='H16'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<10>'      LOC='L10'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<11>'      LOC='G16'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<12>'      LOC='E13'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<13>'      LOC='D14'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<14>'      LOC='J16'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<15>'      LOC='N14'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<16>'      LOC='E16'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<17>'      LOC='M14'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<18>'      LOC='M13'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<19>'      LOC='C13'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<20>'      LOC='D16'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<21>'      LOC='B6'        | IOSTANDARD = LVCMOS33;
NET 'accel_io<22>'      LOC='L13'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<23>'      LOC='K14'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<24>'      LOC='J14'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<25>'      LOC='H15'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<26>'      LOC='E15'   | IOSTANDARD = LVCMOS33;
NET 'accel_io<27>'      LOC='L14'   | IOSTANDARD = LVCMOS33;
 
#vagos: M15, M16, N16
 
# Timings
 
NET "clock_50_i"         PERIOD = 20 ns;
 
NET "clock_28_s"            KEEP | S | PERIOD = 35.7142857 ns;     
NET "clock_28_180o_s"   KEEP | S | PERIOD = 35.7142857 ns;     
NET "clock_14_s"            KEEP | S | PERIOD = 71.428571 ns;      
NET "clock_7_s"         KEEP | S | PERIOD = 142.857142 ns; 
NET "clock_hdmi_s"      KEEP | S | PERIOD = 7.1428571428571 ns;    
NET "clock_hdmi_n_s"        KEEP | S | PERIOD = 7.1428571428571 ns;    

    NET "clock_3m5_s"           KEEP | S | PERIOD = 285.7142857 ns;