function hB = plugin_board()
% Board definition

%   Copyright 2012-2014 The MathWorks, Inc.

% Construct board object
hB = hdlcoder.Board;

hB.BoardName    = 'ZedBoard';

% FPGA device information
hB.FPGAVendor   = 'Xilinx';
hB.FPGAFamily   = 'Zynq';
hB.FPGADevice   = 'xc7z020';
hB.FPGAPackage  = 'clg484';
hB.FPGASpeed    = '-1';

% Tool information
hB.SupportedTool = {'Xilinx Vivado', 'Xilinx ISE'};

% FPGA JTAG chain position
hB.JTAGChainPosition = 2;

%% Add interfaces
% Standard "External Port" interface
hB.addExternalPortInterface( ...
    'IOPadConstraint', {'IOSTANDARD = LVCMOS18'});

% Custom board external I/O interface
hB.addExternalIOInterface( ...
    'InterfaceID',    'LEDs General Purpose', ...
    'InterfaceType',  'OUT', ...
    'PortName',       'GPLEDs', ...
    'PortWidth',      8, ...
    'FPGAPin',        {'T22', 'T21', 'U22', 'U21', 'V22', 'W22', 'U19', 'U14'}, ...
    'IOPadConstraint', {'IOSTANDARD = LVCMOS33'});
    
hB.addExternalIOInterface( ...
    'InterfaceID',    'DIP Switches', ...
    'InterfaceType',  'IN', ...
    'PortName',       'DIPSwitches', ...
    'PortWidth',      8, ...
    'FPGAPin',        {'F22', 'G22', 'H22', 'F21', 'H19', 'H18', 'H17', 'M15'}, ...
    'IOPadConstraint', {'IOSTANDARD = LVCMOS25'});
    
hB.addExternalIOInterface( ...
    'InterfaceID',    'Push Buttons L-R-U-D-S', ...
    'InterfaceType',  'IN', ...
    'PortName',       'PushButtons', ...
    'PortWidth',      5, ...
    'FPGAPin',        {'N15', 'R18', 'T18', 'R16', 'P16'}, ...
    'IOPadConstraint', {'IOSTANDARD = LVCMOS25'});

hB.addExternalIOInterface( ...
    'InterfaceID',    'Pmod Connector JA1', ...
    'InterfaceType',  'INOUT', ...
    'PortName',       'PmodJA1', ...
    'PortWidth',      8, ...
    'FPGAPin',        {'Y11', 'AA11', 'Y10', 'AA9', 'AB11', 'AB10', 'AB9', 'AA8'}, ...
    'IOPadConstraint', {'IOSTANDARD = LVCMOS33'});

hB.addExternalIOInterface( ...
    'InterfaceID',    'Pmod Connector JB1', ...
    'InterfaceType',  'INOUT', ...
    'PortName',       'PmodJB1', ...
    'PortWidth',      8, ...
    'FPGAPin',        {'W12', 'W11', 'V10', 'W8', 'V12', 'W10', 'V9', 'V8'}, ...
    'IOPadConstraint', {'IOSTANDARD = LVCMOS33'});

hB.addExternalIOInterface( ...
    'InterfaceID',    'Pmod Connector JC1', ...
    'InterfaceType',  'INOUT', ...
    'PortName',       'PmodJC1', ...
    'PortWidth',      8, ...
    'FPGAPin',        {'AB7', 'AB6', 'Y4', 'AA4', 'R6', 'T6', 'T4', 'U4'}, ...
    'IOPadConstraint', {'IOSTANDARD = LVCMOS33'});

hB.addExternalIOInterface( ...
    'InterfaceID',    'Pmod Connector JD1', ...
    'InterfaceType',  'INOUT', ...
    'PortName',       'PmodJD1', ...
    'PortWidth',      8, ...
    'FPGAPin',        {'V7', 'W7', 'V5', 'V4', 'W6', 'W5', 'U6', 'U5'}, ...
    'IOPadConstraint', {'IOSTANDARD = LVCMOS33'});

%% Add custom device tree
thirdPartyInstallDir = matlab.internal.get3pInstallLocation('xilinxlinuxbinaries.instrset');
dtsIncludeDir = fullfile(thirdPartyInstallDir, 'dts_repository', 'kernel_dtsi');
hB.addDeviceTreeIncludeDirectory(dtsIncludeDir);
hB.addDeviceTree('zynq-zed.dtsi');
