function hFPGADeviceFamily = dlhdl_device_registration
% FPGADeviceInfo registration file for Area Estimation
% 1. Any registration file with this name on MATLAB path will be picked up.
% 2. Registration file returns a cell array of dlhdl.FPGADeviceInfo
% objects which are used to register device family information for 
% Deep Learning HDL Toolbox - Area Estimation.
% 3. Use hdlcoder.FPGADeviceInfo object to register a device family name,
% with required parameters such as DSPWidth, RAMWidth, RAMDepth, etc.

%   Copyright 2020 The MathWorks, Inc.

hFPGADeviceFamily = { ...
    arria10soc();...
    zynq_ultrascale();...
    zynq7000()
    };

end

function hFPGADeviceFamily = zynq_ultrascale()
    %Datasheet: https://www.xilinx.com/support/documentation/data_sheets/ds891-zynq-ultrascale-plus-overview.pdf    
    hFPGADeviceFamily = hdlcoder.FPGADeviceInfo('Name', 'Zynq Ultrascale+');
    hFPGADeviceFamily.Vendor = 'Xilinx';
    %DSP48E2
    dspConfig = xilinxDSP48E2();
    hFPGADeviceFamily.DSPWidth = dspConfig.DSPWidth;
    % RAM36K
    ramConfig = xilinxRAM36K();
    hFPGADeviceFamily.RAMWidth = ramConfig.RAMWidth;
    hFPGADeviceFamily.SplitRAMWidth = ramConfig.SplitRAMWidth;
    hFPGADeviceFamily.RAMDepth = ramConfig.RAMDepth;
end



function hFPGADeviceFamily = zynq7000()
    %ZC706 
    %Device datasheet: https://www.xilinx.com/support/documentation/data_sheets/ds190-Zynq-7000-Overview.pdf
    % Initialize object with Zynq ultrascale + parameters
    hFPGADeviceFamily = zynq_ultrascale();
    %Modify parameters for Zynq 7000
    hFPGADeviceFamily.Name = "Zynq";
    dspConfig = xilinxDSP48E1();
    hFPGADeviceFamily.DSPWidth = dspConfig.DSPWidth;

end


function hFPGADeviceFamily = arria10soc()
    hFPGADeviceFamily = hdlcoder.FPGADeviceInfo('Name', 'Arria 10');
    hFPGADeviceFamily.Vendor = 'Intel';
    %DSP48E2
    hFPGADeviceFamily.DSPWidth = [27 27];
    %Optional: DSP - second configuration
    hFPGADeviceFamily.SplitDSPWidth = [18 19];
    % 20K Macro
    hFPGADeviceFamily.RAMWidth = 20;
    hFPGADeviceFamily.RAMDepth = 1024;
end

function dspConfig = xilinxDSP48E1()
    dspConfig.DSPWidth = [25 18];
end

function dspConfig = xilinxDSP48E2()
    dspConfig.DSPWidth = [27 18];
end

function ramConfig = xilinxRAM36K()
    ramConfig.RAMWidth = 36;
    ramConfig.RAMDepth = 1024;
    ramConfig.SplitRAMWidth = 18;
end