plateform
stringclasses
1 value
repo_name
stringlengths
13
113
name
stringlengths
3
74
ext
stringclasses
1 value
path
stringlengths
12
229
size
int64
23
843k
source_encoding
stringclasses
9 values
md5
stringlengths
32
32
text
stringlengths
23
843k
github
mstrader/mlib_devel-master
gen_mhs_ip.m
.m
mlib_devel-master/xps_library/@xps_dram/gen_mhs_ip.m
15,668
utf_8
7ab3d15c2831b6019db92a50c3d8aca3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [str,opb_addr_end,opb_addr_start] = gen_mhs_ip(blk_obj,opb_addr_start,opb_name) fprintf('Calling DRAM function...') str = ''; opb_addr_end = opb_addr_start; ip_name = get(blk_obj,'ip_name'); interfaces = get(blk_obj,'interfaces'); misc_ports = get(blk_obj,'misc_ports'); hw_sys = get(blk_obj,'hw_sys'); clk_freq = get(blk_obj,'clk_freq'); inst_name = clear_name(get(blk_obj,'simulink_name')); xsg_obj = get(blk_obj,'xsg_obj'); fprintf('Looking for dimm number...') dimm = num2str(get(blk_obj,'dimm')); half_burst = get(blk_obj,'half_burst'); wide_data = get(blk_obj,'wide_data'); bank_mgt = get(blk_obj,'bank_mgt'); bram_fifos = get(blk_obj,'bram_fifos'); disable_tag = get(blk_obj,'disable_tag'); use_sniffer = get(blk_obj,'use_sniffer'); [M,O,D] = clk_factors(100,2*clk_freq); % Generate 'infrastructure' MHS entry switch hw_sys case 'ROACH' str = [str, 'BEGIN dram_infrastructure', '\n']; str = [str, ' PARAMETER INSTANCE = dram_infrastructure_inst', '\n']; str = [str, ' PARAMETER HW_VER = 1.00.a', '\n']; str = [str, ' PARAMETER CLK_FREQ = ', num2str(clk_freq), '\n']; str = [str, ' BUS_INTERFACE DRAM_SYS = dram_sys', '\n']; str = [str, ' PORT reset = sys_reset', '\n']; str = [str, ' PORT clk_in = dly_clk', '\n']; str = [str, ' PORT clk_in_locked = 0b1', '\n']; str = [str, ' PORT clk_out = dram_user_clk', '\n']; str = [str, 'END\n']; str = [str, '\n']; case 'ROACH2' str = [str, 'BEGIN ddr3_clk', '\n']; str = [str, ' PARAMETER INSTANCE = ddr3_clk_inst', '\n']; str = [str, ' PARAMETER HW_VER = 1.00.a', '\n']; str = [str, ' PARAMETER DRAM_FREQUENCY = ',num2str(2*clk_freq), '\n']; str = [str, ' PARAMETER CLKFBOUT_MULT_F = ',num2str(M), '\n']; str = [str, ' PARAMETER DIVCLK_DIVIDE = ', num2str(D), '\n']; str = [str, ' PARAMETER CLKOUT0_DIVIDE_F = ',num2str(O), '\n']; str = [str, ' PARAMETER CLKOUT1_DIVIDE = ',num2str(O*2), '\n']; str = [str, ' PARAMETER CLKOUT2_DIVIDE = ',num2str(O), '\n']; str = [str, ' PARAMETER PERIOD = ',num2str(1000*(1/(100))), '\n']; str = [str, ' BUS_INTERFACE DDR3_CLK = ddr3_clk ', '\n']; str = [str, ' PORT clk_100 = clk_100', '\n']; str = [str, ' PORT iodelay_ctrl_rdy = idelay_rdy', '\n']; str = [str, ' PORT clk_app = ddr3_clk_app', '\n']; str = [str, 'END', '\n']; str = [str, '\n']; otherwise % case ROACH/ROACH2* end % switch hw_sys % Generate 'controller' MHS entry switch hw_sys case 'ROACH' str = [str, 'BEGIN dram_controller', '\n']; str = [str, ' PARAMETER INSTANCE = dram_controller_inst', '\n']; str = [str, ' PARAMETER HW_VER = 1.00.a', '\n']; str = [str, ' PARAMETER CLK_FREQ = ', num2str(clk_freq), '\n']; str = [str, ' BUS_INTERFACE DRAM_USER = dram_ctrl', '\n']; str = [str, ' BUS_INTERFACE DRAM_SYS = dram_sys', '\n']; str = [str, ' PORT phy_rdy = ', inst_name, '_phy_ready', '\n']; str = [str, ' PORT dram_ck = dram_ck', '\n']; str = [str, ' PORT dram_ck_n = dram_ck_n', '\n']; str = [str, ' PORT dram_a = dram_a', '\n']; str = [str, ' PORT dram_ba = dram_ba', '\n']; str = [str, ' PORT dram_ras_n = dram_ras_n', '\n']; str = [str, ' PORT dram_cas_n = dram_cas_n', '\n']; str = [str, ' PORT dram_we_n = dram_we_n', '\n']; str = [str, ' PORT dram_cs_n = dram_cs_n', '\n']; str = [str, ' PORT dram_cke = dram_cke', '\n']; str = [str, ' PORT dram_odt = dram_odt', '\n']; str = [str, ' PORT dram_dm = dram_dm', '\n']; str = [str, ' PORT dram_dqs = dram_dqs', '\n']; str = [str, ' PORT dram_dqs_n = dram_dqs_n', '\n']; str = [str, ' PORT dram_dq = dram_dq', '\n']; str = [str, ' PORT dram_reset_n = dram_reset_n', '\n']; str = [str, 'END\n']; str = [str, 'PORT dram_ck = dram_ck, DIR = O, VEC = [2:0]', '\n']; str = [str, 'PORT dram_ck_n = dram_ck_n, DIR = O, VEC = [2:0]', '\n']; str = [str, 'PORT dram_a = dram_a, DIR = O, VEC = [15:0]', '\n']; str = [str, 'PORT dram_ba = dram_ba, DIR = O, VEC = [2:0]', '\n']; str = [str, 'PORT dram_ras_n = dram_ras_n, DIR = O', '\n']; str = [str, 'PORT dram_cas_n = dram_cas_n, DIR = O', '\n']; str = [str, 'PORT dram_we_n = dram_we_n, DIR = O', '\n']; str = [str, 'PORT dram_cs_n = dram_cs_n, DIR = O, VEC = [1:0]', '\n']; str = [str, 'PORT dram_cke = dram_cke, DIR = O, VEC = [1:0]', '\n']; str = [str, 'PORT dram_odt = dram_odt, DIR = O, VEC = [1:0]', '\n']; str = [str, 'PORT dram_dm = dram_dm, DIR = O, VEC = [8:0]', '\n']; str = [str, 'PORT dram_dqs = dram_dqs, DIR = IO, VEC = [8:0]', '\n']; str = [str, 'PORT dram_dqs_n = dram_dqs_n, DIR = IO, VEC = [8:0]', '\n']; str = [str, 'PORT dram_dq = dram_dq, DIR = IO, VEC = [71:0]', '\n']; str = [str, 'PORT dram_reset_n = dram_reset_n, DIR = O', '\n']; str = [str, '\n']; case 'ROACH2' str = [str, 'BEGIN ddr3_controller', '\n']; str = [str, ' PARAMETER INSTANCE = ddr3_controller_inst', '\n']; str = [str, ' PARAMETER HW_VER = 1.00.a', '\n']; str = [str, ' PARAMETER tCK = ',num2str(floor(1000*1000*(1/(clk_freq*2)))), '\n']; str = [str, ' BUS_INTERFACE DDR3_CLK = ddr3_clk', '\n']; str = [str, ' BUS_INTERFACE DDR3_APP = ddr3_ctrl', '\n']; str = [str, ' PORT clk_div2 = ddr3_clk_app', '\n']; str = [str, ' PORT ddr3_dq = ddr3_dq', '\n']; str = [str, ' PORT ddr3_addr = ddr3_a', '\n']; str = [str, ' PORT ddr3_ba = ddr3_ba', '\n']; str = [str, ' PORT ddr3_ras_n = ddr3_rasn', '\n']; str = [str, ' PORT ddr3_cas_n = ddr3_casn', '\n']; str = [str, ' PORT ddr3_we_n = ddr3_wen', '\n']; str = [str, ' PORT ddr3_reset_n = ddr3_resetn', '\n']; str = [str, ' PORT ddr3_cs_n = ddr3_sn_2', '\n']; str = [str, ' PORT ddr3_odt = ddr3_odt', '\n']; str = [str, ' PORT ddr3_cke = ddr3_cke', '\n']; str = [str, ' PORT ddr3_dm = ddr3_dm', '\n']; str = [str, ' PORT ddr3_dqs_p = ddr3_dqs_p', '\n']; str = [str, ' PORT ddr3_dqs_n = ddr3_dqs_n', '\n']; str = [str, ' PORT ddr3_ck_p = ddr3_ck_p', '\n']; str = [str, ' PORT ddr3_ck_n = ddr3_ck_n', '\n']; str = [str, ' PORT phy_rdy = ', inst_name, '_phy_ready', '\n']; str = [str, 'END', '\n']; str = [str, 'PORT ddr3_dq = ddr3_dq, DIR = IO , VEC = [71:0]', '\n']; str = [str, 'PORT ddr3_a = ddr3_a, DIR = O, VEC = [15:0]', '\n']; str = [str, 'PORT ddr3_ba = ddr3_ba, DIR = O, VEC = [2:0]', '\n']; str = [str, 'PORT ddr3_rasn = ddr3_rasn , DIR = O', '\n']; str = [str, 'PORT ddr3_casn = ddr3_casn, DIR = O', '\n']; str = [str, 'PORT ddr3_wen = ddr3_wen, DIR = O', '\n']; str = [str, 'PORT ddr3_resetn = ddr3_resetn, DIR = O', '\n']; str = [str, 'PORT ddr3_sn = 0b111 & ddr3_sn_2, DIR = O, VEC = [3:0]', '\n']; str = [str, 'PORT ddr3_odt = ddr3_odt, DIR = O, VEC = [1:0]', '\n']; str = [str, 'PORT ddr3_cke = ddr3_cke, DIR = O, VEC = [1:0]', '\n']; str = [str, 'PORT ddr3_dm = ddr3_dm, DIR = O, VEC = [8:0]', '\n']; str = [str, 'PORT ddr3_dqs_p = ddr3_dqs_p, DIR = IO, VEC = [8:0]', '\n']; str = [str, 'PORT ddr3_dqs_n = ddr3_dqs_n, DIR = IO, VEC = [8:0]', '\n']; str = [str, 'PORT ddr3_ck_p = ddr3_ck_p, DIR = O', '\n']; str = [str, 'PORT ddr3_ck_n = ddr3_ck_n, DIR = O', '\n']; str = [str, '\n']; end % switch hw_sys % Generate 'sniffer' MHS entry switch hw_sys case 'ROACH' str = [str, 'BEGIN opb_dram_sniffer', '\n']; str = [str, ' PARAMETER INSTANCE = opb_dram_sniffer_inst', '\n']; str = [str, ' PARAMETER HW_VER = 1.00.a', '\n']; str = [str, ' PARAMETER CTRL_C_BASEADDR = 0x00050000', '\n']; str = [str, ' PARAMETER CTRL_C_HIGHADDR = 0x0005FFFF', '\n']; str = [str, ' PARAMETER MEM_C_BASEADDR = 0x04000000', '\n']; str = [str, ' PARAMETER MEM_C_HIGHADDR = 0x07FFFFFF', '\n']; str = [str, ' PARAMETER ENABLE = ', use_sniffer, '\n']; str = [str, ' BUS_INTERFACE SOPB_CTRL = opb0', '\n']; str = [str, ' BUS_INTERFACE SOPB_MEM = opb0', '\n']; str = [str, ' BUS_INTERFACE DRAM_CTRL = dram_ctrl', '\n']; str = [str, ' BUS_INTERFACE DRAM_APP = dram_user_dimm', dimm,'_async', '\n']; str = [str, ' PORT dram_clk = dram_user_clk', '\n']; str = [str, ' PORT dram_rst = dram_user_reset', '\n']; str = [str, ' PORT phy_ready = ', inst_name, '_phy_ready', '\n']; str = [str, 'END', '\n']; str = [str, '\n']; case 'ROACH2' str = [str, 'BEGIN opb_dram_sniffer', '\n']; str = [str, ' PARAMETER INSTANCE = opb_dram_sniffer_inst', '\n']; str = [str, ' PARAMETER HW_VER = 1.00.a', '\n']; str = [str, ' PARAMETER CTRL_C_BASEADDR = 0x00050000', '\n']; str = [str, ' PARAMETER CTRL_C_HIGHADDR = 0x0005FFFF', '\n']; str = [str, ' PARAMETER MEM_C_BASEADDR = 0x010B0000', '\n']; str = [str, ' PARAMETER MEM_C_HIGHADDR = 0x010BFFFF', '\n']; str = [str, ' PARAMETER ENABLE = 1', '\n']; str = [str, ' BUS_INTERFACE SOPB_CTRL = opb0', '\n']; str = [str, ' BUS_INTERFACE SOPB_MEM = opb0', '\n']; str = [str, ' BUS_INTERFACE DRAM_CTRL = ddr3_ctrl', '\n']; str = [str, ' BUS_INTERFACE DRAM_APP = ddr3_app', '\n']; str = [str, ' PORT dram_clk = ddr3_clk_app', '\n']; str = [str, ' PORT dram_rst = ', inst_name, '_Mem_Rst', '\n']; str = [str, ' PORT phy_ready = ', inst_name, '_phy_ready', '\n']; str = [str, 'END', '\n']; str = [str, '\n']; end % switch hw_sys % Generate 'async_ddr' MHS entry switch hw_sys case 'ROACH' str = [str, 'BEGIN async_dram\n']; str = [str, ' PARAMETER INSTANCE = async_dram_', dimm, '\n']; str = [str, ' PARAMETER HW_VER = 1.00.a', '\n']; str = [str, ' PARAMETER C_WIDE_DATA = ', wide_data, '\n']; str = [str, ' PARAMETER C_HALF_BURST = ', half_burst, '\n']; str = [str, ' PARAMETER BRAM_FIFOS = ', bram_fifos, '\n']; str = [str, ' PARAMETER TAG_BUFFER_EN = ', disable_tag, '\n']; str = [str, ' BUS_INTERFACE MEM_CMD = ', inst_name, '_MEM_CMD', '\n']; str = [str, ' BUS_INTERFACE DRAM_USER = dram_user_dimm', dimm, '_async', '\n']; str = [str, ' PORT Mem_Clk = ', get(xsg_obj, 'clk_src'), '\n']; str = [str, ' PORT Mem_Rst = ', inst_name, '_Mem_Rst', '\n']; str = [str, ' PORT dram_clk = dram_user_clk', '\n']; str = [str, ' PORT dram_reset = dram_user_reset', '\n']; str = [str, 'END\n']; str = [str, '\n']; case 'ROACH2' str = [str, 'BEGIN ddr3_async_fifo', '\n']; str = [str, ' PARAMETER INSTANCE = ddr3_async_fifo_inst', '\n']; str = [str, ' PARAMETER HW_VER = 1.00.a', '\n']; str = [str, ' PORT ui_app_clk = ',get(xsg_obj, 'clk_src'), '\n']; str = [str, ' PORT ddr3_app_clk = ddr3_clk_app', '\n']; str = [str, ' PORT ui_rst = ', inst_name, '_Mem_Rst', '\n']; str = [str, ' BUS_INTERFACE DDR3_UI = ', inst_name, '_MEM_CMD' '\n']; str = [str, ' BUS_INTERFACE DDR3_APP = ddr3_app', '\n']; str = [str, 'END', '\n']; str = [str, '\n']; end % switch hw_sys
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_x64_adc/get.m
1,963
utf_8
d565195cea642f1d9159e99a3b5c975a
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']) catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_x64_adc/drc.m
1,777
utf_8
88a823a8e1aec61219004afbe0b08646
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = '';
github
mstrader/mlib_devel-master
gen_ucf.m
.m
mlib_devel-master/xps_library/@xps_x64_adc/gen_ucf.m
17,423
utf_8
b3fa6ca62c0796c6df36312ad2320d8d
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function str = gen_ucf(blk_obj) disp('x64_adc gen_ucf'); disp('x64_adc trying generic ucf generation'); str = gen_ucf(blk_obj.xps_block); blk_name = get(blk_obj, 'simulink_name'); inst_name = clear_name(blk_name); disp('x64_adc trying specific ucf generation'); clk_rate = get(blk_obj,'adc_clk_rate'); clk_period = 1000/(6*clk_rate); use_spi = get(blk_obj,'use_spi'); %str = [str, 'NET "adc_clk_p" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | PERIOD = ', num2str(clk_period), ' ns | LOC = H19;', '\n']; %str = [str, 'NET "adc_clk_n" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | PERIOD = ', num2str(clk_period), ' ns | LOC = H20;', '\n']; %str = [str, 'NET "fc_0_p" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = C34;', '\n']; %str = [str, 'NET "fc_0_n" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = D34;', '\n']; %str = [str, 'NET "fc_1_p" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = B33;', '\n']; %str = [str, 'NET "fc_1_n" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = C33;', '\n']; %str = [str, 'NET "fc_2_p" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = E28;', '\n']; %str = [str, 'NET "fc_2_n" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = F28;', '\n']; %str = [str, 'NET "fc_3_p" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = C32;', '\n']; %str = [str, 'NET "fc_3_n" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = D32;', '\n']; %str = [str, 'NET "fc_4_p" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AB27;', '\n']; %str = [str, 'NET "fc_4_n" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AC27;', '\n']; %str = [str, 'NET "fc_5_p" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AD31;', '\n']; %str = [str, 'NET "fc_5_n" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AE31;', '\n']; %str = [str, 'NET "fc_6_p" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AD32;', '\n']; %str = [str, 'NET "fc_6_n" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AE32;', '\n']; %str = [str, 'NET "fc_7_p" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AC34;', '\n']; %str = [str, 'NET "fc_7_n" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AD34;', '\n']; %str = [str, 'NET "in_0_p<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = L30;', '\n']; %str = [str, 'NET "in_0_n<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = M30;', '\n']; %str = [str, 'NET "in_0_p<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = K31;', '\n']; %str = [str, 'NET "in_0_n<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = L31;', '\n']; %str = [str, 'NET "in_0_p<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = H34;', '\n']; %str = [str, 'NET "in_0_n<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = J34;', '\n']; %str = [str, 'NET "in_0_p<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = J27;', '\n']; %str = [str, 'NET "in_0_n<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = J26;', '\n']; %str = [str, 'NET "in_0_p<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = G32;', '\n']; %str = [str, 'NET "in_0_n<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = H32;', '\n']; %str = [str, 'NET "in_0_p<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = F33;', '\n']; %str = [str, 'NET "in_0_n<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = E34;', '\n']; %str = [str, 'NET "in_0_p<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = E32;', '\n']; %str = [str, 'NET "in_0_n<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = E33;', '\n']; %str = [str, 'NET "in_0_p<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = F25;', '\n']; %str = [str, 'NET "in_0_n<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = F26;', '\n']; %str = [str, 'NET "in_1_p<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = L34;', '\n']; %str = [str, 'NET "in_1_n<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = K34;', '\n']; %str = [str, 'NET "in_1_p<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = K33;', '\n']; %str = [str, 'NET "in_1_n<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = K32;', '\n']; %str = [str, 'NET "in_1_p<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = J32;', '\n']; %str = [str, 'NET "in_1_n<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = H33;', '\n']; %str = [str, 'NET "in_1_p<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = K27;', '\n']; %str = [str, 'NET "in_1_n<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = K26;', '\n']; %str = [str, 'NET "in_1_p<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = H30;', '\n']; %str = [str, 'NET "in_1_n<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = G31;', '\n']; %str = [str, 'NET "in_1_p<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = J24;', '\n']; %str = [str, 'NET "in_1_n<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = J25;', '\n']; %str = [str, 'NET "in_1_p<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = G27;', '\n']; %str = [str, 'NET "in_1_n<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = H27;', '\n']; %str = [str, 'NET "in_1_p<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = G25;', '\n']; %str = [str, 'NET "in_1_n<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = G26;', '\n']; %str = [str, 'NET "in_2_p<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = M31;', '\n']; %str = [str, 'NET "in_2_n<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = N30;', '\n']; %str = [str, 'NET "in_2_p<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = M28;', '\n']; %str = [str, 'NET "in_2_n<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = N28;', '\n']; %str = [str, 'NET "in_2_p<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = M25;', '\n']; %str = [str, 'NET "in_2_n<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = M26;', '\n']; %str = [str, 'NET "in_2_p<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = K28;', '\n']; %str = [str, 'NET "in_2_n<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = L28;', '\n']; %str = [str, 'NET "in_2_p<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = K24;', '\n']; %str = [str, 'NET "in_2_n<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = L24;', '\n']; %str = [str, 'NET "in_2_p<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = H29;', '\n']; %str = [str, 'NET "in_2_n<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = J29;', '\n']; %str = [str, 'NET "in_2_p<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = H28;', '\n']; %str = [str, 'NET "in_2_n<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = G28;', '\n']; %str = [str, 'NET "in_2_p<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = F31;', '\n']; %str = [str, 'NET "in_2_n<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = E31;', '\n']; %str = [str, 'NET "in_3_p<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = N27;', '\n']; %str = [str, 'NET "in_3_n<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = M27;', '\n']; %str = [str, 'NET "in_3_p<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = L29;', '\n']; %str = [str, 'NET "in_3_n<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = K29;', '\n']; %str = [str, 'NET "in_3_p<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = L25;', '\n']; %str = [str, 'NET "in_3_n<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = L26;', '\n']; %str = [str, 'NET "in_3_p<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = J30;', '\n']; %str = [str, 'NET "in_3_n<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = J31;', '\n']; %str = [str, 'NET "in_3_p<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = G33;', '\n']; %str = [str, 'NET "in_3_n<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = F34;', '\n']; %str = [str, 'NET "in_3_p<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = G30;', '\n']; %str = [str, 'NET "in_3_n<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = F30;', '\n']; %str = [str, 'NET "in_3_p<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = H25;', '\n']; %str = [str, 'NET "in_3_n<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = H24;', '\n']; %str = [str, 'NET "in_3_p<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = E29;', '\n']; %str = [str, 'NET "in_4_n<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = F29;', '\n']; %str = [str, 'NET "in_4_p<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AK26;', '\n']; %str = [str, 'NET "in_4_n<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AJ27;', '\n']; %str = [str, 'NET "in_4_p<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AK28;', '\n']; %str = [str, 'NET "in_4_n<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AK27;', '\n']; %str = [str, 'NET "in_4_p<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AJ30;', '\n']; %str = [str, 'NET "in_4_n<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AH30;', '\n']; %str = [str, 'NET "in_4_p<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AF24;', '\n']; %str = [str, 'NET "in_4_n<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AG25;', '\n']; %str = [str, 'NET "in_4_p<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AG28;', '\n']; %str = [str, 'NET "in_4_n<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AH28;', '\n']; %str = [str, 'NET "in_4_p<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AG32;', '\n']; %str = [str, 'NET "in_4_n<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AH32;', '\n']; %str = [str, 'NET "in_4_p<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AF31;', '\n']; %str = [str, 'NET "in_4_n<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AG31;', '\n']; %str = [str, 'NET "in_4_p<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AF33;', '\n']; %str = [str, 'NET "in_4_n<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AE33;', '\n']; %str = [str, 'NET "in_5_p<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AN32;', '\n']; %str = [str, 'NET "in_5_n<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AP32;', '\n']; %str = [str, 'NET "in_5_p<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AM33;', '\n']; %str = [str, 'NET "in_5_n<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AM32;', '\n']; %str = [str, 'NET "in_5_p<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AH27;', '\n']; %str = [str, 'NET "in_5_n<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AJ26;', '\n']; %str = [str, 'NET "in_5_p<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AH29;', '\n']; %str = [str, 'NET "in_5_n<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AG30;', '\n']; %str = [str, 'NET "in_5_p<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AF25;', '\n']; %str = [str, 'NET "in_5_n<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AF26;', '\n']; %str = [str, 'NET "in_5_p<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AD24;', '\n']; %str = [str, 'NET "in_5_n<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AE24;', '\n']; %str = [str, 'NET "in_5_p<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AE28;', '\n']; %str = [str, 'NET "in_5_n<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AF28;', '\n']; %str = [str, 'NET "in_5_p<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AC25;', '\n']; %str = [str, 'NET "in_5_n<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AC24;', '\n']; %str = [str, 'NET "in_6_p<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AN34;', '\n']; %str = [str, 'NET "in_6_n<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AN33;', '\n']; %str = [str, 'NET "in_6_p<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AK29;', '\n']; %str = [str, 'NET "in_6_n<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AJ29;', '\n']; %str = [str, 'NET "in_6_p<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AJ31;', '\n']; %str = [str, 'NET "in_6_n<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AK31;', '\n']; %str = [str, 'NET "in_6_p<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AJ32;', '\n']; %str = [str, 'NET "in_6_n<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AK32;', '\n']; %str = [str, 'NET "in_6_p<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AH34;', '\n']; %str = [str, 'NET "in_6_n<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AJ34;', '\n']; %str = [str, 'NET "in_6_p<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AE27;', '\n']; %str = [str, 'NET "in_6_n<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AE26;', '\n']; %str = [str, 'NET "in_6_p<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AD26;', '\n']; %str = [str, 'NET "in_6_n<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AD25;', '\n']; %str = [str, 'NET "in_6_p<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AF34;', '\n']; %str = [str, 'NET "in_6_n<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AE34;', '\n']; %str = [str, 'NET "in_7_p<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AJ25;', '\n']; %str = [str, 'NET "in_7_n<0>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AH25;', '\n']; %str = [str, 'NET "in_7_p<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AL34;', '\n']; %str = [str, 'NET "in_7_n<1>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AL33;', '\n']; %str = [str, 'NET "in_7_p<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AK34;', '\n']; %str = [str, 'NET "in_7_n<2>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AK33;', '\n']; %str = [str, 'NET "in_7_p<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AG27;', '\n']; %str = [str, 'NET "in_7_n<3>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AG26;', '\n']; %str = [str, 'NET "in_7_p<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AF29;', '\n']; %str = [str, 'NET "in_7_n<4>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AF30;', '\n']; %str = [str, 'NET "in_7_p<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AG33;', '\n']; %str = [str, 'NET "in_7_n<5>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AH33;', '\n']; %str = [str, 'NET "in_7_p<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AE29;', '\n']; %str = [str, 'NET "in_7_n<6>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AD29;', '\n']; %str = [str, 'NET "in_7_p<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AD30;', '\n']; %str = [str, 'NET "in_7_n<7>" IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE | LOC = AC29;', '\n']; str = [str, '', '\n']; str = [str, 'INST "*async_data_fifo_inst/BU2/U0/grf.rf/mem/gdm.dm/Mram*" TNM= RAMSOURCE;', '\n']; str = [str, 'INST "*async_data_fifo_inst/BU2/U0/grf.rf/mem/gdm.dm/dout*" TNM= FFDEST;', '\n']; str = [str, 'TIMESPEC TS_RAM_FF= FROM "RAMSOURCE" TO "FFDEST" ', num2str(clk_period*(6/4)), ' ns DATAPATHONLY;', '\n']; str = [str, 'NET "*BU2/U0/grf.rf/gcx.clkx/wr_pntr_gc*" TIG;', '\n']; str = [str, 'NET "*BU2/U0/grf.rf/gcx.clkx/rd_pntr_gc*" TIG;', '\n']; %str = [str, '', '\n']; %str = [str, '', '\n']; %str = [str, 'NET "', inst_name, '_rst_gpio_ext<0>" LOC = R33 | IOSTANDARD = LVCMOS25;', '\n']; %str = [str, '', '\n']; %if strcmp(use_spi,'on') % str = [str, 'NET "', inst_name, '_spi_data_gpio_ext<0>" LOC = P34 | IOSTANDARD = LVCMOS25;', '\n']; % str = [str, 'NET "', inst_name, '_spi_clk_gpio_ext<0>" LOC = N34 | IOSTANDARD = LVCMOS25;', '\n']; % str = [str, 'NET "', inst_name, '_spi_cs_gpio_ext<0>" LOC = N33 | IOSTANDARD = LVCMOS25;', '\n']; % str = [str, '', '\n']; % str = [str, '', '\n']; %end
github
mstrader/mlib_devel-master
xps_x64_adc.m
.m
mlib_devel-master/xps_library/@xps_x64_adc/xps_x64_adc.m
10,359
utf_8
ebd6ee0d8bbe271207787ba3c8d222bc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_x64_adc(blk_obj) if ~isa(blk_obj,'xps_block') error('XPS_ADC class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_x64_adc') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj,'simulink_name'); inst_name = clear_name(blk_name); xsg_obj = get(blk_obj,'xsg_obj'); s.hw_sys = get(xsg_obj,'hw_sys'); s.adc_clk_rate = eval_param(blk_name,'adc_clk_rate'); s.use_spi = eval_param(blk_name,'spi'); s.ctrl_gpio = get_param(blk_name,'ctrl_gpio'); switch s.hw_sys case 'ROACH' ucf_constraints_clock = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE', 'PERIOD', [num2str(1000/(s.adc_clk_rate*6)),' ns']); ucf_constraints_term = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE'); ucf_constraints_noterm = struct('IOSTANDARD', 'LVDS_25'); if strcmp(s.ctrl_gpio, 'GPIO_A') s.ctrl_gpio = 'gpioa'; elseif strcmp(s.ctrl_gpio, 'GPIO_B') s.ctrl_gpio = 'gpiob'; else error('X64_ADC block ctrl interface is neither GPIO_A or GPIO_B'); end case 'ROACH2' ucf_constraints_clock = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE', 'PERIOD', [num2str(1000/(s.adc_clk_rate*6)),' ns']); ucf_constraints_term = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE'); ucf_constraints_noterm = struct('IOSTANDARD', 'LVDS_25'); s.ctrl_gpio = 'gpio'; %ROACH2 only has one gpio bank otherwise error(['Unsupported hardware system: ',s.hw_sys]); end b = class(s,'xps_x64_adc',blk_obj); % ip name and version b = set(b, 'ip_name', 'x64_adc_interface'); b = set(b, 'ip_version', '1.00.a'); supp_ip_names = {'', 'opb_x64_adc', 'spi_controller'}; supp_ip_versions = {'', '1.00.a', '1.00.a'}; b = set(b, 'supp_ip_names', supp_ip_names); b = set(b, 'supp_ip_versions', supp_ip_versions); % misc ports %misc_ports.ctrl_reset = {1 'in' [s.adc_str,'_ddrb']}; %misc_ports.ctrl_clk_in = {1 'in' get(xsg_obj,'clk_src')}; %misc_ports.ctrl_clk_out = {1 'out' [s.adc_str,'_clk']}; %misc_ports.ctrl_clk90_out = {1 'out' [s.adc_str,'_clk90']}; %misc_ports.ctrl_dcm_locked = {1 'out' [s.adc_str,'_dcm_locked']}; % %end %misc_ports.dcm_psclk = {1 'in' [s.adc_str,'_psclk']}; %misc_ports.dcm_psen = {1 'in' [s.adc_str,'_psen']}; %misc_ports.dcm_psincdec = {1 'in' [s.adc_str,'_psincdec']}; % %b = set(b,'misc_ports',misc_ports); % external ports mhs_constraints = struct('SIGIS','CLK', 'CLK_FREQ',num2str(s.adc_clk_rate*1e6)); ctrl_iobname = [s.hw_sys, '.', s.ctrl_gpio]; switch s.hw_sys case 'ROACH' ctrl_out_en_iobname = [s.hw_sys, '.', s.ctrl_gpio, '_oe_n']; gpio_oe_n_constraints = struct('IOSTANDARD', 'LVCMOS33'); if strcmp(s.ctrl_gpio, 'gpioa') gpio_constraints = struct('IOSTANDARD', 'LVCMOS25'); else gpio_constraints = struct('IOSTANDARD', 'LVCMOS15'); end case 'ROACH2' gpio_constraints = struct('IOSTANDARD', 'LVCMOS15'); end s.adc_str = 'adc0'; adcport0 = [s.hw_sys, '.', 'zdok', s.adc_str(length(s.adc_str))]; s.adc_str = 'adc1'; adcport1 = [s.hw_sys, '.', 'zdok', s.adc_str(length(s.adc_str))]; ext_ports.in_0_n = {8 'in' 'in_0_n' ['{',adcport1,'_n{[30 31 32 33 34 35 36 37]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_1_n = {8 'in' 'in_1_n' ['{',adcport1,'_n{[20 21 22 23 24 25 26 27]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_2_n = {8 'in' 'in_2_n' ['{',adcport1,'_n{[0 1 2 3 4 5 6 7 ]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_3_n = {8 'in' 'in_3_n' ['{',adcport1,'_n{[10 11 12 13 14 15 16 17]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_4_n = {8 'in' 'in_4_n' ['{',adcport0,'_n{[30 31 32 33 34 35 36 37]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_5_n = {8 'in' 'in_5_n' ['{',adcport0,'_n{[20 21 22 23 24 25 26 27]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_6_n = {8 'in' 'in_6_n' ['{',adcport0,'_n{[0 1 2 3 4 5 6 7 ]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_7_n = {8 'in' 'in_7_n' ['{',adcport0,'_n{[10 11 12 13 14 15 16 17]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_0_p = {8 'in' 'in_0_p' ['{',adcport1,'_p{[30 31 32 33 34 35 36 37]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_1_p = {8 'in' 'in_1_p' ['{',adcport1,'_p{[20 21 22 23 24 25 26 27]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_2_p = {8 'in' 'in_2_p' ['{',adcport1,'_p{[0 1 2 3 4 5 6 7 ]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_3_p = {8 'in' 'in_3_p' ['{',adcport1,'_p{[10 11 12 13 14 15 16 17]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_4_p = {8 'in' 'in_4_p' ['{',adcport0,'_p{[30 31 32 33 34 35 36 37]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_5_p = {8 'in' 'in_5_p' ['{',adcport0,'_p{[20 21 22 23 24 25 26 27]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_6_p = {8 'in' 'in_6_p' ['{',adcport0,'_p{[0 1 2 3 4 5 6 7 ]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.in_7_p = {8 'in' 'in_7_p' ['{',adcport0,'_p{[10 11 12 13 14 15 16 17]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; ext_ports.fc_0_n = {1 'in' 'fc_0_n' ['{',adcport1,'_n{[18]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_1_n = {1 'in' 'fc_1_n' ['{',adcport1,'_n{[38]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_2_n = {1 'in' 'fc_2_n' ['{',adcport1,'_n{[8 ]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_3_n = {1 'in' 'fc_3_n' ['{',adcport1,'_n{[9 ]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_4_n = {1 'in' 'fc_4_n' ['{',adcport0,'_n{[18]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_5_n = {1 'in' 'fc_5_n' ['{',adcport0,'_n{[38]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_6_n = {1 'in' 'fc_6_n' ['{',adcport0,'_n{[8 ]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_7_n = {1 'in' 'fc_7_n' ['{',adcport0,'_n{[9 ]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_0_p = {1 'in' 'fc_0_p' ['{',adcport1,'_p{[18]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_1_p = {1 'in' 'fc_1_p' ['{',adcport1,'_p{[38]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_2_p = {1 'in' 'fc_2_p' ['{',adcport1,'_p{[8 ]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_3_p = {1 'in' 'fc_3_p' ['{',adcport1,'_p{[9 ]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_4_p = {1 'in' 'fc_4_p' ['{',adcport0,'_p{[18]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_5_p = {1 'in' 'fc_5_p' ['{',adcport0,'_p{[38]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_6_p = {1 'in' 'fc_6_p' ['{',adcport0,'_p{[8 ]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.fc_7_p = {1 'in' 'fc_7_p' ['{',adcport0,'_p{[9 ]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; ext_ports.adc_clk_p = {1 'in' 'adc_clk_p' ['{',adcport0,'_p{[39]+1,:}}'] 'vector=false' struct() ucf_constraints_clock}; ext_ports.adc_clk_n = {1 'in' 'adc_clk_n' ['{',adcport0,'_n{[39]+1,:}}'] 'vector=false' struct() ucf_constraints_clock}; ext_ports.adc_rst = {1 'out' [inst_name, '_rst_gpio_ext'] [ctrl_iobname, ' ([','0',']+1)'] 'vector=true' struct() gpio_constraints }; if strcmp(s.hw_sys,'ROACH') % ROACH 1 needs an external port to drive the GPIO buffers ext_ports.ctrl_out_en = {1 'out' [inst_name, '_ctrl_out_en' ] [ctrl_out_en_iobname, ' ([','0',']+1)'] 'vector=true' struct() gpio_oe_n_constraints }; end if strcmp(s.use_spi,'on') ext_ports.spi_data = {1 'out' [inst_name, '_spi_data_gpio_ext'] [ctrl_iobname, ' ([','1',']+1)'] 'vector=true' struct() gpio_constraints}; ext_ports.spi_sclk = {1 'out' [inst_name, '_spi_sclk_gpio_ext'] [ctrl_iobname, ' ([','2',']+1)'] 'vector=true' struct() gpio_constraints }; ext_ports.spi_cs_n = {1 'out' [inst_name, '_spi_cs_gpio_ext' ] [ctrl_iobname, ' ([','3',']+1)'] 'vector=true' struct() gpio_constraints }; end b = set(b,'ext_ports',ext_ports);
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_x64_adc/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_adc083000_ctrl/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_adc083000_ctrl/drc.m
2,118
utf_8
60145324772f7335c69b7970ae3e68e3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = ''; for i=1:length(xps_objs) try if strcmp(get(blk_obj,'hw_adc'),get(xps_objs{i},'hw_adc')) if ~strcmp(get(blk_obj,'simulink_name'),get(xps_objs{i},'simulink_name')) msg = ['ADC ',get(blk_obj,'simulink_name'),' and ADC ',get(xps_objs{i},'simulink_name'),' are located on the same port.']; result = 1; end end end end
github
mstrader/mlib_devel-master
gen_ucf.m
.m
mlib_devel-master/xps_library/@xps_adc083000_ctrl/gen_ucf.m
25,126
utf_8
655f8863445950ebfad48f56d7f1e373
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function str = gen_ucf(blk_obj) disp('adc086000 gen_ucf') hw_sys = blk_obj.hw_sys; adc_str = blk_obj.adc_str; disp('adc086000 trying generic ucf generation') str = gen_ucf(blk_obj.xps_block); simulink_name = clear_name(get(blk_obj,'simulink_name')); disp('adc08600 trying specific ucf generation') switch hw_sys case 'ROACH' switch adc_str case 'adc0' % str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_sync" MAXDELAY = 1ns;\n']; % end case 'adc0' case 'adc1' % str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_sync" MAXDELAY = 1ns;\n']; % end case 'adc1' end % switch adc_str case 'iBOB' switch adc_str case 'adc0' str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_clk_buf" PERIOD = ',num2str(1000/blk_obj.adc_clk_rate*4),'ns;\n']; str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_clk_buf" MAXDELAY = 452ps;\n']; str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_clk_dcm" MAXDELAY = 853ps;\n']; str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_clk90_dcm" MAXDELAY = 853ps;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/CLK_CLKBUF" LOC = BUFGMUX1P;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/CLK90_CLKBUF" LOC = BUFGMUX3P;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/CLKSHIFT_DCM" LOC = DCM_X2Y1;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/CLKSHIFT_DCM" CLKOUT_PHASE_SHIFT = VARIABLE;\n']; str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_sync" MAXDELAY = 323ps;\n']; str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_sync" ROUTE = "{3;1;2vp50ff1152;46c47c12!-1;156520;5632;S!0;-159;0!1;-1884;-1248!1;-1884;744!2;-1548;992!2;-1548;304!3;-1548;-656!3;-1548;-1344!4;327;0;L!5;167;0;L!6;327;0;L!7;167;0;L!}";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_sync_ddr_3" LOC = SLICE_X139Y91;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_sync_ddr_2" LOC = SLICE_X138Y91;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_sync_ddr_1" LOC = SLICE_X139Y90;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_sync_ddr_0" LOC = SLICE_X138Y90;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_0" LOC = "SLICE_X138Y128" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_1" LOC = "SLICE_X138Y126" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_2" LOC = "SLICE_X139Y122" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_3" LOC = "SLICE_X138Y120" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_4" LOC = "SLICE_X138Y102" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_5" LOC = "SLICE_X139Y98" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_6" LOC = "SLICE_X138Y96" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_7" LOC = "SLICE_X138Y94" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_8" LOC = "SLICE_X139Y126" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_9" LOC = "SLICE_X138Y124" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_10" LOC = "SLICE_X138Y122" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_11" LOC = "SLICE_X139Y118" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_12" LOC = "SLICE_X138Y100" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_13" LOC = "SLICE_X138Y98" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_14" LOC = "SLICE_X139Y94" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_15" LOC = "SLICE_X138Y92" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_16" LOC = "SLICE_X138Y128" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_17" LOC = "SLICE_X138Y126" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_18" LOC = "SLICE_X139Y122" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_19" LOC = "SLICE_X138Y120" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_20" LOC = "SLICE_X138Y102" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_21" LOC = "SLICE_X139Y98" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_22" LOC = "SLICE_X138Y96" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_23" LOC = "SLICE_X138Y94" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_24" LOC = "SLICE_X139Y126" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_25" LOC = "SLICE_X138Y124" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_26" LOC = "SLICE_X138Y122" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_27" LOC = "SLICE_X139Y118" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_28" LOC = "SLICE_X138Y100" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_29" LOC = "SLICE_X138Y98" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_30" LOC = "SLICE_X139Y94" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_31" LOC = "SLICE_X138Y92" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_0" LOC = "SLICE_X138Y132" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_1" LOC = "SLICE_X139Y134" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_2" LOC = "SLICE_X138Y170" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_3" LOC = "SLICE_X138Y172" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_4" LOC = "SLICE_X139Y106" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_5" LOC = "SLICE_X138Y110" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_6" LOC = "SLICE_X138Y112" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_7" LOC = "SLICE_X139Y114" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_8" LOC = "SLICE_X138Y134" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_9" LOC = "SLICE_X138Y168" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_10" LOC = "SLICE_X139Y170" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_11" LOC = "SLICE_X138Y174" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_12" LOC = "SLICE_X138Y108" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_13" LOC = "SLICE_X139Y110" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_14" LOC = "SLICE_X138Y114" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_15" LOC = "SLICE_X138Y116" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_16" LOC = "SLICE_X138Y132" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_17" LOC = "SLICE_X139Y134" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_18" LOC = "SLICE_X138Y170" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_19" LOC = "SLICE_X138Y172" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_20" LOC = "SLICE_X139Y106" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_21" LOC = "SLICE_X138Y110" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_22" LOC = "SLICE_X138Y112" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_23" LOC = "SLICE_X139Y114" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_24" LOC = "SLICE_X138Y134" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_25" LOC = "SLICE_X138Y168" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_26" LOC = "SLICE_X139Y170" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_27" LOC = "SLICE_X138Y174" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_28" LOC = "SLICE_X138Y108" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_29" LOC = "SLICE_X139Y110" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_30" LOC = "SLICE_X138Y114" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_31" LOC = "SLICE_X138Y116" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_outofrangei_recapture_0" LOC = "SLICE_X138Y118" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_outofrangei_recapture_1" LOC = "SLICE_X138Y118" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_outofrangeq_recapture_0" LOC = "SLICE_X138Y104" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_outofrangeq_recapture_1" LOC = "SLICE_X138Y104" | BEL = "FFY";\n']; % end case 'adc0' case 'adc1' str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_clk_buf" PERIOD = ',num2str(1000/blk_obj.adc_clk_rate*4),'ns;\n']; str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_clk_buf" MAXDELAY = 452ps;\n']; str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_clk_dcm" MAXDELAY = 854ps;\n']; str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_clk90_dcm" MAXDELAY = 854ps;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/CLK_CLKBUF" LOC = BUFGMUX0P;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/CLK90_CLKBUF" LOC = BUFGMUX2P;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/CLKSHIFT_DCM" LOC = DCM_X2Y0;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/CLKSHIFT_DCM" CLKOUT_PHASE_SHIFT = VARIABLE;\n']; str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_sync" MAXDELAY = 323ps;\n']; str = [str, 'NET "',simulink_name,'/',simulink_name,'/adc_sync" ROUTE = "{3;1;2vp50ff1152;6b4b9e45!-1;156520;-144648;S!0;-159;0!1;-1884;-1248!1;-1884;744!2;-1548;992!2;-1548;304!3;-1548;-656!3;-1548;-1344!4;327;0;L!5;167;0;L!6;327;0;L!7;167;0;L!}";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_sync_ddr_3" LOC = SLICE_X139Y3;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_sync_ddr_2" LOC = SLICE_X138Y3;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_sync_ddr_1" LOC = SLICE_X139Y2;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_sync_ddr_0" LOC = SLICE_X138Y2;\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_0" LOC = "SLICE_X139Y70" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_1" LOC = "SLICE_X138Y68" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_2" LOC = "SLICE_X139Y64" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_3" LOC = "SLICE_X139Y62" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_4" LOC = "SLICE_X139Y44" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_5" LOC = "SLICE_X139Y42" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_6" LOC = "SLICE_X138Y40" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_7" LOC = "SLICE_X139Y4" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_8" LOC = "SLICE_X139Y68" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_9" LOC = "SLICE_X139Y66" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_10" LOC = "SLICE_X138Y64" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_11" LOC = "SLICE_X139Y60" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_12" LOC = "SLICE_X138Y44" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_13" LOC = "SLICE_X139Y40" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_14" LOC = "SLICE_X139Y6" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_15" LOC = "SLICE_X138Y4" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_16" LOC = "SLICE_X139Y70" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_17" LOC = "SLICE_X138Y68" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_18" LOC = "SLICE_X139Y64" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_19" LOC = "SLICE_X139Y62" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_20" LOC = "SLICE_X139Y44" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_21" LOC = "SLICE_X139Y42" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_22" LOC = "SLICE_X138Y40" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_23" LOC = "SLICE_X139Y4" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_24" LOC = "SLICE_X139Y68" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_25" LOC = "SLICE_X139Y66" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_26" LOC = "SLICE_X138Y64" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_27" LOC = "SLICE_X139Y60" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_28" LOC = "SLICE_X138Y44" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_29" LOC = "SLICE_X139Y40" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_30" LOC = "SLICE_X139Y6" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_datai_recapture_31" LOC = "SLICE_X138Y4" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_0" LOC = "SLICE_X139Y74" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_1" LOC = "SLICE_X139Y78" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_2" LOC = "SLICE_X139Y80" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_3" LOC = "SLICE_X138Y84" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_4" LOC = "SLICE_X139Y48" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_5" LOC = "SLICE_X138Y52" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_6" LOC = "SLICE_X139Y54" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_7" LOC = "SLICE_X139Y56" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_8" LOC = "SLICE_X138Y76" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_9" LOC = "SLICE_X138Y80" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_10" LOC = "SLICE_X139Y82" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_11" LOC = "SLICE_X139Y84" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_12" LOC = "SLICE_X139Y50" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_13" LOC = "SLICE_X139Y52" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_14" LOC = "SLICE_X138Y56" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_15" LOC = "SLICE_X139Y58" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_16" LOC = "SLICE_X139Y74" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_17" LOC = "SLICE_X139Y78" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_18" LOC = "SLICE_X139Y80" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_19" LOC = "SLICE_X138Y84" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_20" LOC = "SLICE_X139Y48" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_21" LOC = "SLICE_X138Y52" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_22" LOC = "SLICE_X139Y54" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_23" LOC = "SLICE_X139Y56" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_24" LOC = "SLICE_X138Y76" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_25" LOC = "SLICE_X138Y80" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_26" LOC = "SLICE_X139Y82" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_27" LOC = "SLICE_X139Y84" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_28" LOC = "SLICE_X139Y50" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_29" LOC = "SLICE_X139Y52" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_30" LOC = "SLICE_X138Y56" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_dataq_recapture_31" LOC = "SLICE_X139Y58" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_outofrangei_recapture_0" LOC = "SLICE_X138Y60" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_outofrangei_recapture_1" LOC = "SLICE_X138Y60" | BEL = "FFY";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_outofrangeq_recapture_0" LOC = "SLICE_X138Y48" | BEL = "FFX";\n']; str = [str, 'INST "',simulink_name,'/',simulink_name,'/adc_outofrangeq_recapture_1" LOC = "SLICE_X138Y48" | BEL = "FFY";\n']; % end case 'adc1' end % switch adc_str % end case 'iBOB' end % switch hw_sys
github
mstrader/mlib_devel-master
xps_adc083000_ctrl.m
.m
mlib_devel-master/xps_library/@xps_adc083000_ctrl/xps_adc083000_ctrl.m
12,028
utf_8
ea808c81245c80dcd9690a19915c1d88
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_adc083000_ctrl(blk_obj) fprintf('Creating block object: xps_adc083000_ctrl\n') if ~isa(blk_obj,'xps_block') error('XPS_ADC class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_adc083000_ctrl') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj,'simulink_name'); xsg_obj = get(blk_obj,'xsg_obj'); % % % Most of these parameters are hacks on top of the existing toolflow... s.hw_sys = get(xsg_obj,'hw_sys'); s.adc_str = 'adc0'; % s.use_adc0 = strcmp( get_param(blk_name, 'use_adc0'), 'on'); % s.use_adc1 = strcmp( get_param(blk_name, 'use_adc1'), 'on'); % s.demux_adc = strcmp( get_param(blk_name, 'demux_adc'), 'on'); % if s.demux_adc % s.sysclk_rate = eval_param(blk_name,'adc_clk_rate')/8; % else % s.sysclk_rate = eval_param(blk_name,'adc_clk_rate')/4; % end % if s.use_adc0 % s.adc_str = 'adc0'; % else % s.adc_str = 'adc1'; % end % s.adc_clk_rate = eval_param(blk_name,'adc_clk_rate'); % s.adc_interleave = strcmp( get_param(blk_name,'clock_sync'), 'on'); % s.adc_str = 'adc0'; % "dominant" ADC is in ZDOK 0 % % switch s.hw_sys % case 'ROACH' % ucf_constraints_clock = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE', 'PERIOD', [num2str(1000/s.adc_clk_rate*4),' ns']); % ucf_constraints_term = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE'); % ucf_constraints_noterm = struct('IOSTANDARD', 'LVDS_25'); % ucf_constraints_single = struct('IOSTANDARD', 'LVCMOS25'); % % end case 'ROACH' % otherwise % error(['Unsupported hardware system: ',s.hw_sys]); % end % end switch s.hw_sys % b = class(s,'xps_adc083000_ctrl',blk_obj); % % % ip name and version b = set(b, 'ip_name', 'opb_adc083000ctrl'); switch s.hw_sys case 'ROACH' b = set(b, 'ip_version', '1.00.a'); end % switch s.hw_sys % % % misc ports % % misc_ports.ctrl_reset = {1 'in' [s.adc_str,'_ddrb']}; % misc_ports.ctrl_clk_in = {1 'in' get(xsg_obj,'clk_src')}; % misc_ports.ctrl_clk_out = {1 'out' [s.adc_str,'_clk']}; % misc_ports.ctrl_clk90_out = {1 'out' [s.adc_str,'_clk90']}; % misc_ports.ctrl_dcm_locked = {1 'out' [s.adc_str,'_dcm_locked']}; % if strcmp(get(b,'ip_version'), '1.01.a') % misc_ports.dcm_reset = {1 'in' [s.adc_str,'_dcm_reset']}; % misc_ports.dcm_psdone = {1 'out' [s.adc_str,'_psdone']}; % misc_ports.ctrl_clk180_out = {1 'out' [s.adc_str,'_clk180']}; % misc_ports.ctrl_clk270_out = {1 'out' [s.adc_str,'_clk270']}; % end misc_ports.sys_clk = {1 'in' 'sys_clk'}; % misc_ports.adc_ctrl_notSCS = {1 'out' 'adc_ctrl_notSCS'}; % misc_ports.adc_ctrl_clk = {1 'out' 'adc_ctrl_clk'}; % misc_ports.adc_ctrl_sdata = {1 'out' 'adc_ctrl_sdata'}; % % misc_ports.dcm_psen = {1 'in' [s.adc_str,'_psen']}; % % misc_ports.dcm_psincdec = {1 'in' [s.adc_str,'_psincdec']}; % % misc_ports.control_data = {1, 'in', 'adc_control_data'}; b = set(b,'misc_ports',misc_ports); % % % external ports % mhs_constraints = struct('SIGIS','CLK', 'CLK_FREQ',num2str(s.adc_clk_rate*1e6)); % % % adcport = [s.hw_sys, '.', 'zdok', s.adc_str(length(s.adc_str))]; % adc0port = [s.hw_sys, '.', 'zdok0'];%, s.adc_str(length(s.adc_str))]; % adc1port = [s.hw_sys, '.', 'zdok1'];%, s.adc_str(length(s.adc_str))]; % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ADC0 % ext_ports.adc0_clk_p = {1 'in' ['adc0','clk_p'] ['{',adc0port,'_p{[39]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock }; % ext_ports.adc0_clk_n = {1 'in' ['adc0','clk_n'] ['{',adc0port,'_n{[39]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock }; % ext_ports.adc0_sync_p = {1 'in' ['adc0','sync_p'] ['{',adc0port,'_p{[38]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; % ext_ports.adc0_sync_n = {1 'in' ['adc0','sync_n'] ['{',adc0port,'_n{[38]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; % ext_ports.adc0_outofrange_p = {1 'in' ['adc0','outofrange_p'] ['{',adc0port,'_p{[18]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; % ext_ports.adc0_outofrange_n = {1 'in' ['adc0','outofrange_n'] ['{',adc0port,'_n{[18]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; % ext_ports.adc0_dataeveni_p = {8 'in' ['adc0','dataeveni_p'] ['{',adc0port,'_p{[0 1 2 3 4 5 6 7]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc0_dataeveni_n = {8 'in' ['adc0','dataeveni_n'] ['{',adc0port,'_n{[0 1 2 3 4 5 6 7]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc0_dataoddi_p = {8 'in' ['adc0','dataoddi_p'] ['{',adc0port,'_p{[10 11 12 13 14 15 16 17]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc0_dataoddi_n = {8 'in' ['adc0','dataoddi_n'] ['{',adc0port,'_n{[10 11 12 13 14 15 16 17]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc0_dataevenq_p = {8 'in' ['adc0','dataevenq_p'] ['{',adc0port,'_p{[20 21 22 23 24 25 26 27]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc0_dataevenq_n = {8 'in' ['adc0','dataevenq_n'] ['{',adc0port,'_n{[20 21 22 23 24 25 26 27]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc0_dataoddq_p = {8 'in' ['adc0','dataoddq_p'] ['{',adc0port,'_p{[30 31 32 33 34 35 36 37]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc0_dataoddq_n = {8 'in' ['adc0','dataoddq_n'] ['{',adc0port,'_n{[30 31 32 33 34 35 36 37]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc0_reset = {1 'out' ['adc0','_reset'] ['{',adc0port,'_p{[19]+1,:}}'] 'vector=false' struct() ucf_constraints_single }; % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ADC1 % ext_ports.adc1_clk_p = {1 'in' ['adc1','clk_p'] ['{',adc1port,'_p{[39]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock }; % ext_ports.adc1_clk_n = {1 'in' ['adc1','clk_n'] ['{',adc1port,'_n{[39]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock }; % ext_ports.adc1_sync_p = {1 'in' ['adc1','sync_p'] ['{',adc1port,'_p{[38]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; % ext_ports.adc1_sync_n = {1 'in' ['adc1','sync_n'] ['{',adc1port,'_n{[38]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; % ext_ports.adc1_outofrange_p = {1 'in' ['adc1','outofrange_p'] ['{',adc1port,'_p{[18]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; % ext_ports.adc1_outofrange_n = {1 'in' ['adc1','outofrange_n'] ['{',adc1port,'_n{[18]+1,:}}'] 'vector=false' struct() ucf_constraints_term }; % ext_ports.adc1_dataeveni_p = {8 'in' ['adc1','dataeveni_p'] ['{',adc1port,'_p{[0 1 2 3 4 5 6 7]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc1_dataeveni_n = {8 'in' ['adc1','dataeveni_n'] ['{',adc1port,'_n{[0 1 2 3 4 5 6 7]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc1_dataoddi_p = {8 'in' ['adc1','dataoddi_p'] ['{',adc1port,'_p{[10 11 12 13 14 15 16 17]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc1_dataoddi_n = {8 'in' ['adc1','dataoddi_n'] ['{',adc1port,'_n{[10 11 12 13 14 15 16 17]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc1_dataevenq_p = {8 'in' ['adc1','dataevenq_p'] ['{',adc1port,'_p{[20 21 22 23 24 25 26 27]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc1_dataevenq_n = {8 'in' ['adc1','dataevenq_n'] ['{',adc1port,'_n{[20 21 22 23 24 25 26 27]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc1_dataoddq_p = {8 'in' ['adc1','dataoddq_p'] ['{',adc1port,'_p{[30 31 32 33 34 35 36 37]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc1_dataoddq_n = {8 'in' ['adc1','dataoddq_n'] ['{',adc1port,'_n{[30 31 32 33 34 35 36 37]+1,:}}'] 'vector=true' struct() ucf_constraints_term }; % ext_ports.adc1_reset = {1 'out' ['adc1','_reset'] ['{',adc1port,'_p{[19]+1,:}}'] 'vector=false' struct() ucf_constraints_single }; adc0port = [s.hw_sys, '.', 'zdok0'];%, s.adc_str(length(s.adc_str))]; adc1port = [s.hw_sys, '.', 'zdok1'];%, s.adc_str(length(s.adc_str))]; ucf_constraints_single = struct('IOSTANDARD', 'LVCMOS25'); ext_ports.adc1_notSCS = {1 'out' ['adc1','_notSCS'] ['{',adc1port,'_p{[9]+1,:}}'] 'vector=false' struct() ucf_constraints_single }; ext_ports.adc1_sdata = {1 'out' ['adc1','_sdata'] ['{',adc1port,'_n{[9]+1,:}}'] 'vector=false' struct() ucf_constraints_single }; ext_ports.adc1_sclk = {1 'out' ['adc1','_sclk'] ['{',adc1port,'_n{[8]+1,:}}'] 'vector=false' struct() ucf_constraints_single }; ext_ports.adc0_notSCS = {1 'out' ['adc0','_notSCS'] ['{',adc0port,'_p{[9]+1,:}}'] 'vector=false' struct() ucf_constraints_single }; ext_ports.adc0_sdata = {1 'out' ['adc0','_sdata'] ['{',adc0port,'_n{[9]+1,:}}'] 'vector=false' struct() ucf_constraints_single }; ext_ports.adc0_sclk = {1 'out' ['adc0','_sclk'] ['{',adc0port,'_n{[8]+1,:}}'] 'vector=false' struct() ucf_constraints_single }; b = set(b,'ext_ports',ext_ports); % parameters.DEMUX_DATA_OUT = num2str(s.demux_adc); % parameters.USE_ADC0 = num2str(s.use_adc0); % parameters.USE_ADC1 = num2str(s.use_adc1); % parameters.INTERLEAVE_BOARDS = num2str(s.adc_interleave); % b = set(b,'parameters',parameters); % Software parameters % b = set(b,'c_params',['adc = ',s.adc_str,' / interleave = ',num2str(s.adc_interleave)]);
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_adc083000_ctrl/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_tengbe_v2/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_tengbe_v2/drc.m
3,505
utf_8
1356c1b0a660474d8e7554de2a61e6b2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = ''; for i=1:length(xps_objs) try our_hw = get(blk_obj, 'hw_sys'); our_port = get(blk_obj, 'port'); their_port = get(xps_objs{i},'port'); our_name = get(blk_obj, 'simulink_name'); their_name = get(xps_objs{i},'simulink_name'); %check two blocks not assigned to same port if strcmp(our_port, their_port), %same port if ~strcmp(our_name, their_name) % and name not the same msg = ['10Ge port ', our_name,' and 10Ge port ', their_name,' are located on the same port.']; result = 1; end end %check ports in the same slot are using the same mezzanine flavour our_flavour = get(blk_obj,'flavour'); their_flavour = get(xps_objs{i},'flavour'); our_slot = get(blk_obj,'slot'); their_slot = get(xps_objs{i},'slot'); if strcmp(our_hw, 'ROACH2'), %roach2 if strcmp(our_slot, their_slot), % and card in the same slot if ~strcmp(our_flavour, their_flavour), % and not the same mezzanine flavour msg = ['10Ge ports ''', our_name,''' and ''', their_name,''' are both located in mezzanine slot ',our_slot,', but have different mezzanine flavours.']; result = 1; end end end if strcmp(our_hw, 'MKDIG'), %mkdig if strcmp(our_slot, their_slot), % and card in the same slot if ~strcmp(our_flavour, their_flavour), % and not the same mezzanine flavour msg = ['10Ge ports ''', our_name,''' and ''', their_name,''' are both located in mezzanine slot ',our_slot,', but have different mezzanine flavours.']; result = 1; end end end end %try end
github
mstrader/mlib_devel-master
xps_tengbe_v2.m
.m
mlib_devel-master/xps_library/@xps_tengbe_v2/xps_tengbe_v2.m
8,128
utf_8
44f808b56e60b384ac86bcf4e622af26
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_tengbe_v2(blk_obj) if ~isa(blk_obj,'xps_block') error('XPS_TENGBE class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_tengbe_v2') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj,'simulink_name'); xsg_obj = get(blk_obj,'xsg_obj'); s.hw_sys = get(xsg_obj,'hw_sys'); s.flavour = get_param(blk_name, 'flavour'); s.slot = get_param(blk_name, 'slot'); s.preemph = get_param(blk_name, 'pre_emph'); s.preemph_r2 = get_param(blk_name, 'pre_emph_r2'); s.postemph_r2 = get_param(blk_name, 'post_emph_r2'); s.rxeqmix_r2 = get_param(blk_name, 'rxeqmix_r2'); s.swing = get_param(blk_name, 'swing'); s.swing_r2 = get_param(blk_name, 'swing_r2'); s.rx_dist_ram = num2str(strcmp(get_param(blk_name, 'rx_dist_ram'), 'on')); s.cpu_rx_enable = num2str(strcmp(get_param(blk_name, 'cpu_rx_en'), 'on')); s.cpu_tx_enable = num2str(strcmp(get_param(blk_name, 'cpu_tx_en'), 'on')); s.fab_mac = ['0x', dec2hex(eval(get_param(blk_name, 'fab_mac'))) ]; s.fab_ip = ['0x', dec2hex(eval(get_param(blk_name, 'fab_ip'))) ]; s.fab_udp = ['0x', dec2hex(eval(get_param(blk_name, 'fab_udp'))) ]; s.fab_gate = ['0x', dec2hex(eval(get_param(blk_name, 'fab_gate'))) ]; s.fab_en = num2str(strcmp(get_param(blk_name, 'fab_en'),'on')); s.large_packets = num2str(strcmp(get_param(blk_name, 'large_frames'),'on')); s.ttl = ['0x', dec2hex(eval(get_param(blk_name, 'ttl'))) ]; s.promisc_mode = num2str(strcmp(get_param(blk_name, 'promisc_mode'),'on')); %convert (more intuitive) mask values to defines to be passed on if using ROACH2 switch s.hw_sys case {'ROACH'}, s.port = get_param(blk_name, 'port_r1'); case {'ROACH2','MKDIG'}, %get the port from the appropriate parameter, roach2 mezzanine slot 0 has 4-7, roach2 mezzanine slot 1 has 0-3, so barrel shift if(strcmp(s.flavour,'cx4')), s.port = num2str(str2num(get_param(blk_name, 'port_r2_cx4')) + 4*(mod(s.slot+1,2))); elseif strcmp(s.flavour,'sfp+'), s.port = num2str(str2num(get_param(blk_name, 'port_r2_sfpp')) + 4*(mod(s.slot+1,2))); else end %values below taken from ug366 transceiver user guide (should match with tengbe_v2_loadfcn) postemph_lookup = [0.18;0.19;0.18;0.18;0.18;0.18;0.18;0.18;0.19;0.2;0.39;0.63;0.82;1.07;1.32;1.6;1.65;1.94;2.21;2.52;2.76;3.08;3.41;3.77;3.97;4.36;4.73;5.16;5.47;5.93;6.38;6.89]; index = find(postemph_lookup == str2num(s.postemph_r2)); if isempty(index), error(['xps_tengbe_v2:''',str2num(s.postemph_r2),''' not found in ''',postemph_lookup,'''']); return; end s.postemph_r2 = num2str(index(1)-1); preemph_lookup = [0.15;0.3;0.45;0.61;0.74;0.91;1.07;1.25;1.36;1.55;1.74;1.94;2.11;2.32;2.54;2.77]; index = find(preemph_lookup == str2num(s.preemph_r2)); if index == [], error(['xps_tengbe_v2:''',str2num(s.preemph_r2),''' not found in ''',preemph_lookup,'''']); return; end s.preemph_r2 = num2str(index(1)-1); swing_lookup = [110;210;310;400;480;570;660;740;810;880;940;990;1040;1080;1110;1130]; index = find(swing_lookup == str2num(s.swing_r2)); if index == [], error(['xps_tengbe_v2:''',str2num(s.swing_r2),''' not found in ''',swing_lookup,'''']); return; end s.swing_r2 = num2str(index(1)-1); otherwise end b = class(s,'xps_tengbe_v2',blk_obj); % ip name & version b = set(b,'ip_name','kat_ten_gb_eth'); switch s.hw_sys case {'ROACH','ROACH2','MKDIG'}, b = set(b,'ip_version','1.00.a'); otherwise error(['10GbE not supported for platform ', s.hw_sys]); end % bus offset % ROACH/ROACH2 have OPB Ten Gig Eth interfaces switch s.hw_sys case {'ROACH','ROACH2','MKDIG'}, b = set(b,'opb_clk','epb_clk'); b = set(b,'opb_address_offset',16384); b = set(b,'opb_address_align', hex2dec('4000')); % end case {'ROACH','ROACH2'} end % switch s.hw_sys parameters.FABRIC_MAC = s.fab_mac; parameters.FABRIC_IP = s.fab_ip; parameters.FABRIC_PORT = s.fab_udp; parameters.FABRIC_GATEWAY = s.fab_gate; parameters.FABRIC_ENABLE = s.fab_en; parameters.LARGE_PACKETS = s.large_packets; parameters.RX_DIST_RAM = s.rx_dist_ram; parameters.CPU_RX_ENABLE = s.cpu_rx_enable; parameters.CPU_TX_ENABLE = s.cpu_tx_enable; parameters.TTL = s.ttl; switch s.hw_sys case {'MKDIG'}, parameters.PREEMPHASIS = s.preemph_r2; parameters.POSTEMPHASIS = s.postemph_r2; parameters.DIFFCTRL = s.swing_r2; parameters.RXEQMIX = s.rxeqmix_r2; case {'ROACH2'}, parameters.PREEMPHASIS = s.preemph_r2; parameters.POSTEMPHASIS = s.postemph_r2; parameters.DIFFCTRL = s.swing_r2; parameters.RXEQMIX = s.rxeqmix_r2; parameters.PROMISC_MODE = s.promisc_mode; otherwise, s.swing = get_param(blk_name, 'swing'); parameters.SWING = s.swing; parameters.PREEMPHASYS = s.preemph; end b = set(b,'parameters',parameters); % bus interfaces switch s.hw_sys case {'ROACH'}, interfaces.XAUI_CONF = ['xaui_conf',s.port]; interfaces.XGMII = ['xgmii',s.port]; b = set(b,'interfaces',interfaces); % end case 'ROACH' case {'ROACH2','MKDIG'}, interfaces.PHY_CONF = ['phy_conf',s.port]; interfaces.XAUI_CONF = ['xaui_conf',s.port]; interfaces.XGMII = ['xgmii',s.port]; b = set(b,'interfaces',interfaces); % end case 'ROACH2' end % switch s.hw_sys % miscellaneous and external ports misc_ports.clk = {1 'in' get(xsg_obj,'clk_src')}; ext_ports = {}; switch s.hw_sys case {'ROACH'}, if strcmp(s.port, '0') || strcmp(s.port, '1') misc_ports.xaui_clk = {1 'in' 'mgt_clk_0'}; else misc_ports.xaui_clk = {1 'in' 'mgt_clk_1'}; end case {'ROACH2','MKDIG'}, misc_ports.xaui_clk = {1 'in' 'xaui_clk'}; misc_ports.xaui_reset = {1 'in' 'sys_reset'}; end % switch s.hw_sys b = set(b,'misc_ports',misc_ports); b = set(b,'ext_ports',ext_ports); % borf parameters switch s.hw_sys case {'ROACH','ROACH2','MKDIG'}, borph_info.size = hex2dec('4000'); borph_info.mode = 3; b = set(b,'borph_info',borph_info); otherwise borph_info.size = 1; borph_info.mode = 7; b = set(b,'borph_info',borph_info); end
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_tengbe_v2/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
gen_mhs_ip.m
.m
mlib_devel-master/xps_library/@xps_tengbe_v2/gen_mhs_ip.m
3,638
utf_8
86e0eb5822538ade94beb9891e89f228
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [str,opb_addr_end,opb_addr_start] = gen_mhs_ip(blk_obj,opb_addr_start,opb_name) xaui_port = get(blk_obj, 'port'); hw_sys = get(blk_obj, 'hw_sys'); [str,opb_addr_end,opb_addr_start] = gen_mhs_ip(blk_obj.xps_block, opb_addr_start, opb_name); str = [str, '\n']; switch hw_sys case {'ROACH'} mgt_clk_num = num2str(floor(str2num(xaui_port)/2)); str = [str, 'BEGIN xaui_phy', '\n']; str = [str, ' PARAMETER INSTANCE = xaui_phy_', xaui_port, '\n']; str = [str, ' PARAMETER HW_VER = 1.00.a', '\n']; str = [str, ' PARAMETER USE_KAT_XAUI = 0', '\n']; str = [str, ' BUS_INTERFACE XAUI_SYS = xaui_sys', xaui_port, '\n']; str = [str, ' BUS_INTERFACE XGMII = xgmii', xaui_port, '\n']; str = [str, ' PORT reset = sys_reset' , '\n']; str = [str, ' PORT mgt_clk = mgt_clk_', mgt_clk_num, '\n']; str = [str, 'END', '\n']; % end case {'ROACH'} case {'ROACH2','MKDIG'} str = [str, 'BEGIN xaui_phy', '\n']; str = [str, ' PARAMETER INSTANCE = xaui_phy_', xaui_port, '\n']; str = [str, ' PARAMETER HW_VER = 1.00.a', '\n']; str = [str, ' BUS_INTERFACE XAUI_SYS = xaui_sys', xaui_port, '\n']; str = [str, ' BUS_INTERFACE XAUI_CONF = xaui_conf', xaui_port, '\n']; str = [str, ' BUS_INTERFACE XGMII = xgmii', xaui_port, '\n']; str = [str, ' PORT reset = sys_reset' , '\n']; str = [str, ' PORT xaui_clk = xaui_clk', '\n']; %from xaui_infrastructure str = [str, 'END', '\n']; % end case {'ROACH'} otherwise % end otherwise end % switch hw_sys
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_fifo/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
xps_fifo.m
.m
mlib_devel-master/xps_library/@xps_fifo/xps_fifo.m
3,265
utf_8
d661803b23ad9780d87e1825f78d00ad
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_fifo(blk_obj) if ~isa(blk_obj,'xps_block') error('XPS_FIFO class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_fifo') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj,'simulink_name'); xsg_obj = get(blk_obj,'xsg_obj'); s.hw_sys = 'any'; switch get_param(blk_name,'io_dir') case 'From Processor' s.io_dir = 'in'; case 'To Processor' s.io_dir = 'out'; end % switch get_param(blk_name','io_dir') b = class(s,'xps_fifo',blk_obj); % opb clk % bus clock switch get(xsg_obj,'hw_sys') case 'ROACH' b = set(b,'opb_clk','epb_clk'); otherwise b = set(b,'opb_clk','sys_clk'); end % switch get(xsg_obj,'hw_sys') % address offset b = set(b,'opb_address_offset',256); % misc ports misc_ports.user_clk = {1 'in' get(xsg_obj,'clk_src')}; b = set(b,'misc_ports',misc_ports); % %ip name, software parameters, borph mode switch get_param(blk_name,'io_dir') case 'From Processor' b = set(b,'ip_name','opb_asyncfifo_ppc2simulink'); b = set(b,'c_params','in'); borph_info.mode = 6; case 'To Processor' b = set(b,'c_params','out'); b = set(b,'ip_name','opb_asyncfifo_simulink2ppc'); borph_info.mode = 5; end % switch get_param('blk_name,'io_dir') %parameters parameters.FIFO_LENGTH = num2str(eval_param(blk_name,'fifo_length')); parameters.FIFO_WIDTH = num2str(eval_param(blk_name,'data_width')); b = set(b,'parameters',parameters); % borph parameters borph_info.size = 512; b = set(b,'borph_info',borph_info);
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_fifo/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_adc2x14_400/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_adc2x14_400/drc.m
1,751
utf_8
805b22d398f2f8ef4c982d1cd1e67683
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = '';
github
mstrader/mlib_devel-master
gen_ucf.m
.m
mlib_devel-master/xps_library/@xps_adc2x14_400/gen_ucf.m
2,924
utf_8
89a6841bb7cfff129da7b6ae1f5e67d7
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function str = gen_ucf(blk_obj) str = ''; simulink_name = clear_name(get(blk_obj,'simulink_name')); I_clk_p_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_I_p']; I_clk_n_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_I_n']; Q_clk_p_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_Q_p']; Q_clk_n_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_Q_n']; str = [str, 'NET ', I_clk_p_str, ' TNM_NET = ', I_clk_p_str, ';\n']; str = [str, 'TIMESPEC TS_', I_clk_p_str, ' = PERIOD ', I_clk_p_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; str = [str, 'NET ', I_clk_n_str, ' TNM_NET = ', I_clk_n_str, ';\n']; str = [str, 'TIMESPEC TS_', I_clk_n_str, ' = PERIOD ', I_clk_n_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; str = [str, '\n']; str = [str, 'NET ', Q_clk_p_str, ' TNM_NET = ', Q_clk_p_str, ';\n']; str = [str, 'TIMESPEC TS_', Q_clk_p_str, ' = PERIOD ', Q_clk_p_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; str = [str, 'NET ', Q_clk_n_str, ' TNM_NET = ', Q_clk_n_str, ';\n']; str = [str, 'TIMESPEC TS_', Q_clk_n_str, ' = PERIOD ', Q_clk_n_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; str = [str, '\n']; str = [str, gen_ucf(blk_obj.xps_block)]; end
github
mstrader/mlib_devel-master
xps_adc2x14_400.m
.m
mlib_devel-master/xps_library/@xps_adc2x14_400/xps_adc2x14_400.m
5,504
utf_8
a00952e81b80fcb5368968e7edb699a1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_adc2x14_400(blk_obj) if ~isa(blk_obj,'xps_block') error('xps_quadc class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_adc2x14_400') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj,'simulink_name'); xsg_obj = get(blk_obj,'xsg_obj'); s.hw_sys = get(xsg_obj,'hw_sys'); s.adc_brd = get_param(blk_name, 'adc_brd'); s.adc_str = ['adc', s.adc_brd]; s.adc_clk_rate = eval_param(blk_name,'adc_clk_rate'); s.clk_sys = get(xsg_obj,'clk_src'); b = class(s,'xps_adc2x14_400',blk_obj); % ip name & version b = set(b,'ip_name','adc2x14_400_interface'); b = set(b,'ip_version','1.00.a'); parameters.OUTPUT_CLK = '0'; if strfind(s.clk_sys,'adc') parameters.OUTPUT_CLK = '1'; end b = set(b,'parameters',parameters); %%%%%%%%%%%%%%%%% % external ports %%%%%%%%%%%%%%%%% ucf_constraints_clock = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE', 'PERIOD', [num2str(2*1000/s.adc_clk_rate),' ns']); ucf_constraints_term = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE'); ucf_constraints_noterm = struct('IOSTANDARD', 'LVDS_25'); mhs_constraints = struct('SIGIS','CLK', 'CLK_FREQ',num2str(1e6*s.adc_clk_rate/2)); ext_ports.DRDY_I_p = {1 'in' ['adcmkid',s.adc_brd,'_DRDY_I_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[20],:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.DRDY_I_n = {1 'in' ['adcmkid',s.adc_brd,'_DRDY_I_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[20],:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.DRDY_Q_p = {1 'in' ['adcmkid',s.adc_brd,'_DRDY_Q_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[40],:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.DRDY_Q_n = {1 'in' ['adcmkid',s.adc_brd,'_DRDY_Q_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[40],:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.DI_p = {14 'in' ['adcmkid',s.adc_brd,'_DI_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[8 28 17 37 7 27 26 36 25 35 16 15 6 5],:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.DI_n = {14 'in' ['adcmkid',s.adc_brd,'_DI_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[8 28 17 37 7 27 26 36 25 35 16 15 6 5],:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.DQ_p = {14 'in' ['adcmkid',s.adc_brd,'_DQ_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[4 24 13 33 3 23 22 32 21 31 12 11 2 1],:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.DQ_n = {14 'in' ['adcmkid',s.adc_brd,'_DQ_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[4 24 13 33 3 23 22 32 21 31 12 11 2 1],:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.ADC_ext_in_p = {1 'in' ['adcmkid',s.adc_brd,'_ADC_ext_in_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[29],:}}'] 'vector=false' struct() ucf_constraints_term}; ext_ports.ADC_ext_in_n = {1 'in' ['adcmkid',s.adc_brd,'_ADC_ext_in_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[29],:}}'] 'vector=false' struct() ucf_constraints_term}; b = set(b,'ext_ports',ext_ports); %%%%%%%%%%%%% % misc ports %%%%%%%%%%%%% misc_ports.fpga_clk = {1 'in' get(xsg_obj,'clk_src')}; if strfind(s.clk_sys,'adc') misc_ports.adc_clk_out = {1 'out' [s.adc_str,'_clk']}; misc_ports.adc_clk90_out = {1 'out' [s.adc_str,'_clk90']}; misc_ports.adc_clk180_out = {1 'out' [s.adc_str,'_clk180']}; misc_ports.adc_clk270_out = {1 'out' [s.adc_str,'_clk270']}; end misc_ports.adc_dcm_locked = {1 'out' [s.adc_str, '_dcm_locked']}; b = set(b,'misc_ports',misc_ports);
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_adc2x14_400/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_adc2x14_400_4x/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_adc2x14_400_4x/drc.m
1,751
utf_8
805b22d398f2f8ef4c982d1cd1e67683
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = '';
github
mstrader/mlib_devel-master
gen_ucf.m
.m
mlib_devel-master/xps_library/@xps_adc2x14_400_4x/gen_ucf.m
2,925
utf_8
189c0d343b00d74728a5855a98569d17
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function str = gen_ucf(blk_obj) str = ''; simulink_name = clear_name(get(blk_obj,'simulink_name')); I_clk_p_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_I_p']; I_clk_n_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_I_n']; Q_clk_p_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_Q_p']; Q_clk_n_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_Q_n']; str = [str, 'NET ', I_clk_p_str, ' TNM_NET = ', I_clk_p_str, ';\n']; str = [str, 'TIMESPEC TS_', I_clk_p_str, ' = PERIOD ', I_clk_p_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; str = [str, 'NET ', I_clk_n_str, ' TNM_NET = ', I_clk_n_str, ';\n']; str = [str, 'TIMESPEC TS_', I_clk_n_str, ' = PERIOD ', I_clk_n_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; str = [str, '\n']; str = [str, 'NET ', Q_clk_p_str, ' TNM_NET = ', Q_clk_p_str, ';\n']; str = [str, 'TIMESPEC TS_', Q_clk_p_str, ' = PERIOD ', Q_clk_p_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; str = [str, 'NET ', Q_clk_n_str, ' TNM_NET = ', Q_clk_n_str, ';\n']; str = [str, 'TIMESPEC TS_', Q_clk_n_str, ' = PERIOD ', Q_clk_n_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; str = [str, '\n']; str = [str, gen_ucf(blk_obj.xps_block)]; end
github
mstrader/mlib_devel-master
xps_adc2x14_400_4x.m
.m
mlib_devel-master/xps_library/@xps_adc2x14_400_4x/xps_adc2x14_400_4x.m
5,526
utf_8
3031c113c5a1ec3af9b37277baaad0c8
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_adc2x14_400_4x(blk_obj) if ~isa(blk_obj,'xps_block') error('xps_adc2x14_400_4x class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_adc2x14_400_4x') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj,'simulink_name'); xsg_obj = get(blk_obj,'xsg_obj'); s.hw_sys = get(xsg_obj,'hw_sys'); s.adc_brd = get_param(blk_name, 'adc_brd'); s.adc_str = ['adc', s.adc_brd]; s.adc_clk_rate = eval_param(blk_name,'adc_clk_rate'); s.clk_sys = get(xsg_obj,'clk_src'); b = class(s,'xps_adc2x14_400_4x',blk_obj); % ip name & version b = set(b,'ip_name','adc2x14_400_4x_interface'); b = set(b,'ip_version','1.00.a'); parameters.OUTPUT_CLK = '0'; if strfind(s.clk_sys,'adc') parameters.OUTPUT_CLK = '1'; end b = set(b,'parameters',parameters); %%%%%%%%%%%%%%%%% % external ports %%%%%%%%%%%%%%%%% ucf_constraints_clock = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE', 'PERIOD', [num2str(2*1000/s.adc_clk_rate),' ns']); ucf_constraints_term = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE'); ucf_constraints_noterm = struct('IOSTANDARD', 'LVDS_25'); mhs_constraints = struct('SIGIS','CLK', 'CLK_FREQ',num2str(1e6*s.adc_clk_rate/2)); ext_ports.DRDY_I_p = {1 'in' ['adcmkid',s.adc_brd,'_DRDY_I_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[20],:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.DRDY_I_n = {1 'in' ['adcmkid',s.adc_brd,'_DRDY_I_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[20],:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.DRDY_Q_p = {1 'in' ['adcmkid',s.adc_brd,'_DRDY_Q_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[40],:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.DRDY_Q_n = {1 'in' ['adcmkid',s.adc_brd,'_DRDY_Q_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[40],:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.DI_p = {14 'in' ['adcmkid',s.adc_brd,'_DI_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[8 28 17 37 7 27 26 36 25 35 16 15 6 5],:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.DI_n = {14 'in' ['adcmkid',s.adc_brd,'_DI_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[8 28 17 37 7 27 26 36 25 35 16 15 6 5],:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.DQ_p = {14 'in' ['adcmkid',s.adc_brd,'_DQ_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[4 24 13 33 3 23 22 32 21 31 12 11 2 1],:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.DQ_n = {14 'in' ['adcmkid',s.adc_brd,'_DQ_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[4 24 13 33 3 23 22 32 21 31 12 11 2 1],:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.ADC_ext_in_p = {1 'in' ['adcmkid',s.adc_brd,'_ADC_ext_in_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[29],:}}'] 'vector=false' struct() ucf_constraints_term}; ext_ports.ADC_ext_in_n = {1 'in' ['adcmkid',s.adc_brd,'_ADC_ext_in_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[29],:}}'] 'vector=false' struct() ucf_constraints_term}; b = set(b,'ext_ports',ext_ports); %%%%%%%%%%%%% % misc ports %%%%%%%%%%%%% misc_ports.fpga_clk = {1 'in' get(xsg_obj,'clk_src')}; if strfind(s.clk_sys,'adc') misc_ports.adc_clk_out = {1 'out' [s.adc_str,'_clk']}; misc_ports.adc_clk90_out = {1 'out' [s.adc_str,'_clk90']}; misc_ports.adc_clk180_out = {1 'out' [s.adc_str,'_clk180']}; misc_ports.adc_clk270_out = {1 'out' [s.adc_str,'_clk270']}; end misc_ports.adc_dcm_locked = {1 'out' [s.adc_str, '_dcm_locked']}; b = set(b,'misc_ports',misc_ports);
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_adc2x14_400_4x/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_quadc/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
xps_quadc.m
.m
mlib_devel-master/xps_library/@xps_quadc/xps_quadc.m
7,993
utf_8
2021aaf6e4fb0394de620b949e3b8b39
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_quadc(blk_obj) if ~isa(blk_obj,'xps_block') error('xps_quadc class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_quadc') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj,'simulink_name'); xsg_obj = get(blk_obj,'xsg_obj'); [hw_sys, hw_subsys] = xps_get_hw_plat(get(xsg_obj, 'hw_sys')); s.hw_sys = hw_sys; s.adc_brd = get_param(blk_name, 'adc_brd'); s.adc_str = ['adc', s.adc_brd]; s.adc_clk_rate = eval_param(blk_name,'adc_clk_rate'); switch s.hw_sys case 'iBOB' if isempty(find(strcmp(s.adc_brd, {'0', '1'}))) error(['Unsupported adc board: ',s.adc_brd]); end % if isempty(find(strcmp(s.hw_adc, {'0', '1'}))) ucf_constraints_clock = struct('IOSTANDARD', 'LVDS_25_DT', 'PERIOD', [num2str(1000/s.adc_clk_rate),' ns']); ucf_constraints_term = struct('IOSTANDARD', 'LVDS_25_DT'); ucf_constraints_noterm = struct('IOSTANDARD', 'LVDS_25'); parameters = ''; % end case 'iBOB' case 'ROACH' if isempty(find(strcmp(s.adc_brd, {'0', '1'}))) error(['Unsupported adc board: ',s.adc_brd]); end % if ~isempty(find(strcmp(s.hw_adc, {'0', '1'}))) ucf_constraints_clock = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE', 'PERIOD', [num2str(1000/s.adc_clk_rate),' ns']); ucf_constraints_term = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE'); ucf_constraints_noterm = struct('IOSTANDARD', 'LVDS_25'); parameters.CLK_FREQ = num2str(s.adc_clk_rate); % end case 'ROACH' otherwise error(['Unsupported hardware system: ',s.hw_sys]); end % end switch s.hw_sys b = class(s,'xps_quadc',blk_obj); % ip name & version b = set(b,'ip_name','quadc_interface'); b = set(b,'ip_version','1.00.a'); % parameters b = set(b,'parameters',parameters); % misc ports misc_ports.user_clk = {1 'in' get(xsg_obj,'clk_src')}; misc_ports.dcm_reset = {1 'in' 'net_gnd'}; misc_ports.reset = {1 'in' 'net_gnd'}; misc_ports.adc0_clk = {1 'out' [s.adc_str, '_clk']}; misc_ports.adc1_clk = {1 'out' ['quadc0_', s.adc_brd, '_adc1_clk']}; misc_ports.adc2_clk = {1 'out' ['quadc0_', s.adc_brd, '_adc2_clk']}; misc_ports.adc3_clk = {1 'out' ['quadc0_', s.adc_brd, '_adc3_clk']}; misc_ports.adc0_clk90 = {1 'out' [s.adc_str, '_clk90']}; misc_ports.adc0_clk180 = {1 'out' [s.adc_str, '_clk180']}; misc_ports.adc0_clk270 = {1 'out' [s.adc_str, '_clk270']}; b = set(b,'misc_ports',misc_ports); % external ports mhs_constraints = struct('SIGIS','CLK', 'CLK_FREQ',num2str(s.adc_clk_rate*1e6)); % port indices are 0-indexed, +1 to convert to Matlab 1-indexing ext_ports.adc0_clk_in_p = {1 'in' ['quadc',s.adc_brd,'_adc0_clk_in_p'] ['{',hw_sys,'.zdok',s.adc_brd,'_p{[19]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.adc1_clk_in_p = {1 'in' ['quadc',s.adc_brd,'_adc1_clk_in_p'] ['{',hw_sys,'.zdok',s.adc_brd,'_p{[39]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.adc2_clk_in_p = {1 'in' ['quadc',s.adc_brd,'_adc2_clk_in_p'] ['{',hw_sys,'.zdok',s.adc_brd,'_p{[32]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.adc3_clk_in_p = {1 'in' ['quadc',s.adc_brd,'_adc3_clk_in_p'] ['{',hw_sys,'.zdok',s.adc_brd,'_p{[30]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.adc0_data_in_p = {8 'in' ['quadc',s.adc_brd,'_adc0_data_in_p'] ['{',hw_sys,'.zdok',s.adc_brd,'_p{[29 9 18 28 8 7 17 27]+1 ,:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.adc1_data_in_p = {8 'in' ['quadc',s.adc_brd,'_adc1_data_in_p'] ['{',hw_sys,'.zdok',s.adc_brd,'_p{[37 6 16 26 36 5 15 25]+1 ,:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.adc2_data_in_p = {8 'in' ['quadc',s.adc_brd,'_adc2_data_in_p'] ['{',hw_sys,'.zdok',s.adc_brd,'_p{[35 4 14 24 34 3 13 23]+1 ,:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.adc3_data_in_p = {8 'in' ['quadc',s.adc_brd,'_adc3_data_in_p'] ['{',hw_sys,'.zdok',s.adc_brd,'_p{[33 2 12 22 20 10 11 21]+1 ,:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.adc0_clk_in_n = {1 'in' ['quadc',s.adc_brd,'_adc0_clk_in_n'] ['{',hw_sys,'.zdok',s.adc_brd,'_n{[19]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.adc1_clk_in_n = {1 'in' ['quadc',s.adc_brd,'_adc1_clk_in_n'] ['{',hw_sys,'.zdok',s.adc_brd,'_n{[39]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.adc2_clk_in_n = {1 'in' ['quadc',s.adc_brd,'_adc2_clk_in_n'] ['{',hw_sys,'.zdok',s.adc_brd,'_n{[32]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.adc3_clk_in_n = {1 'in' ['quadc',s.adc_brd,'_adc3_clk_in_n'] ['{',hw_sys,'.zdok',s.adc_brd,'_n{[30]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.adc0_data_in_n = {8 'in' ['quadc',s.adc_brd,'_adc0_data_in_n'] ['{',hw_sys,'.zdok',s.adc_brd,'_n{[29 9 18 28 8 7 17 27]+1 ,:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.adc1_data_in_n = {8 'in' ['quadc',s.adc_brd,'_adc1_data_in_n'] ['{',hw_sys,'.zdok',s.adc_brd,'_n{[37 6 16 26 36 5 15 25]+1 ,:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.adc2_data_in_n = {8 'in' ['quadc',s.adc_brd,'_adc2_data_in_n'] ['{',hw_sys,'.zdok',s.adc_brd,'_n{[35 4 14 24 34 3 13 23]+1 ,:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.adc3_data_in_n = {8 'in' ['quadc',s.adc_brd,'_adc3_data_in_n'] ['{',hw_sys,'.zdok',s.adc_brd,'_n{[33 2 12 22 20 10 11 21]+1 ,:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.sync_in_p = {1 'in' ['quadc',s.adc_brd,'_sync_in_p'] ['{',hw_sys,'.zdok',s.adc_brd,'_p{[38]+1,:}}'] 'vector=false' struct() ucf_constraints_term}; ext_ports.sync_in_n = {1 'in' ['quadc',s.adc_brd,'_sync_in_n'] ['{',hw_sys,'.zdok',s.adc_brd,'_n{[38]+1,:}}'] 'vector=false' struct() ucf_constraints_term}; b = set(b,'ext_ports',ext_ports);
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_quadc/drc.m
1,751
utf_8
805b22d398f2f8ef4c982d1cd1e67683
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = '';
github
mstrader/mlib_devel-master
gen_ucf.m
.m
mlib_devel-master/xps_library/@xps_quadc/gen_ucf.m
2,408
utf_8
acd646b9d25811dc1c75024b656787ce
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function str = gen_ucf(blk_obj) str = ''; simulink_name = clear_name(get(blk_obj,'simulink_name')); adc0_clk_p_str = ['quadc', blk_obj.adc_brd,'_adc0_clk_in_p']; adc0_clk_n_str = ['quadc', blk_obj.adc_brd,'_adc0_clk_in_n']; str = [str, 'NET ', adc0_clk_p_str, ' TNM_NET = ', adc0_clk_p_str, ';\n']; str = [str, 'TIMESPEC TS_', adc0_clk_p_str, ' = PERIOD ', adc0_clk_p_str, ' ', num2str(1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; str = [str, 'NET ', adc0_clk_n_str, ' TNM_NET = ', adc0_clk_n_str, ';\n']; str = [str, 'TIMESPEC TS_', adc0_clk_n_str, ' = PERIOD ', adc0_clk_n_str, ' ', num2str(1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; str = [str, '\n']; str = [str, gen_ucf(blk_obj.xps_block)]; end
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_quadc/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_dac/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_dac/drc.m
2,992
utf_8
3ab77bfce809915097a39d56418ecd9a
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = ''; for i=1:length(xps_objs) try if strcmp(get(blk_obj,'hw_dac'), get(xps_objs{i},'hw_dac')) if ~strcmp(get(blk_obj, 'simulink_name'), get(xps_objs{i},'simulink_name')) msg = ['DAC ', get(blk_obj, 'simulink_name'),' and DAC ', get(xps_objs{i}, 'simulink_name'), ' are using the same connector.']; result = 1; end end end try if strcmp(get(blk_obj,'type'),'xps_dac') && strcmp(get(xps_objs{i},'type'), 'xps_adc') if (strcmp(get(blk_obj,'hw_dac'),'dac0') && strcmp(get(xps_objs{i},'hw_adc'),'adc0')) || (strcmp(get(blk_obj,'hw_dac'),'dac1') && strcmp(get(xps_objs{i},'hw_adc'),'adc1')) msg = ['DAC ', get(blk_obj,'simulink_name'), ' and ADC ', get(xps_objs{i},'simulink_name'),' are located on the same Z-DOK connector.']; result = 1; end end end try if strcmp(get(blk_obj,'type'),'xps_dac') && strcmp(get(xps_objs{i},'type'), 'xps_vsi') if strcmp(get(blk_obj,'hw_dac'),'dac1') && strcmp(get(xps_objs{i},'hw_vsi'),'ZDOK 1') msg = ['DAC ', get(blk_obj,'simulink_name'), ' and VSI ', get(xps_objs{i},'simulink_name'),' are located on the same Z-DOK connector.']; result = 1; end end end end
github
mstrader/mlib_devel-master
xps_dac.m
.m
mlib_devel-master/xps_library/@xps_dac/xps_dac.m
4,674
utf_8
a64840961507464b332f4452efda00b2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_dac(blk_obj) if ~isa(blk_obj,'xps_block') error('XPS_DAC class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_dac') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj,'simulink_name'); xsg_obj = get(blk_obj,'xsg_obj'); s.dac_clk_rate = eval_param(blk_name,'dac_clk_rate'); [s.hw_sys,s.hw_dac] = xps_get_hw_info(get_param(blk_name,'dac_brd')); switch s.hw_sys case 'iBOB' switch s.hw_dac case 'dac0' s.dac_str = 'dac0'; case 'dac1' s.dac_str = 'dac1'; otherwise error(['Unsupported dac board: ',s.hw_dac]); end otherwise error(['Unsupported hardware system: ',s.hw_sys]); end s.invert_clk = get_param(gcb, 'invert_clock'); b = class(s,'xps_dac',blk_obj); % ip name b = set(b,'ip_name','dac_interface'); b = set(b,'ip_version','1.00.b'); % parameters parameters.CTRL_CLK_PHASE = num2str(strcmp(s.invert_clk, 'on')); b = set(b,'parameters',parameters); % misc ports misc_ports.user_data_clk = {1 'out' [s.dac_str,'_clk']}; misc_ports.user_data_clk90 = {1 'out' [s.dac_str,'_clk90']}; b = set(b,'misc_ports',misc_ports); % external ports ucf_constraints = struct('IOSTANDARD', 'LVDS_25'); ext_ports.dac_dsp_clk_p = {1 'in' [s.dac_str,'_dsp_clk_p'] ['iBOB.',s.dac_str,'.dsp_clk_p'] 'vector=false' struct() ucf_constraints}; ext_ports.dac_dsp_clk_n = {1 'in' [s.dac_str,'_dsp_clk_n'] ['iBOB.',s.dac_str,'.dsp_clk_n'] 'vector=false' struct() ucf_constraints}; ext_ports.dac_data_clk_p = {1 'out' [s.dac_str,'_data_clk_p'] ['iBOB.',s.dac_str,'.data_clk_p'] 'vector=false' struct() ucf_constraints}; ext_ports.dac_data_clk_n = {1 'out' [s.dac_str,'_data_clk_n'] ['iBOB.',s.dac_str,'.data_clk_n'] 'vector=false' struct() ucf_constraints}; ext_ports.dac_data_a_p = {9 'out' [s.dac_str,'_data_a_p'] ['iBOB.',s.dac_str,'.data_a_p'] 'vector=true' struct() ucf_constraints}; ext_ports.dac_data_a_n = {9 'out' [s.dac_str,'_data_a_n'] ['iBOB.',s.dac_str,'.data_a_n'] 'vector=true' struct() ucf_constraints}; ext_ports.dac_data_b_p = {9 'out' [s.dac_str,'_data_b_p'] ['iBOB.',s.dac_str,'.data_b_p'] 'vector=true' struct() ucf_constraints}; ext_ports.dac_data_b_n = {9 'out' [s.dac_str,'_data_b_n'] ['iBOB.',s.dac_str,'.data_b_n'] 'vector=true' struct() ucf_constraints}; ext_ports.dac_data_c_p = {9 'out' [s.dac_str,'_data_c_p'] ['iBOB.',s.dac_str,'.data_c_p'] 'vector=true' struct() ucf_constraints}; ext_ports.dac_data_c_n = {9 'out' [s.dac_str,'_data_c_n'] ['iBOB.',s.dac_str,'.data_c_n'] 'vector=true' struct() ucf_constraints}; ext_ports.dac_data_d_p = {9 'out' [s.dac_str,'_data_d_p'] ['iBOB.',s.dac_str,'.data_d_p'] 'vector=true' struct() ucf_constraints}; ext_ports.dac_data_d_n = {9 'out' [s.dac_str,'_data_d_n'] ['iBOB.',s.dac_str,'.data_d_n'] 'vector=true' struct() ucf_constraints}; b = set(b, 'ext_ports', ext_ports);
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_dac/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_adcdac_2g_ctrl/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
xps_adcdac_2g_ctrl.m
.m
mlib_devel-master/xps_library/@xps_adcdac_2g_ctrl/xps_adcdac_2g_ctrl.m
3,717
utf_8
7bbd49bb50610152e5e78aca47a6c116
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Make sure this is an XPS object function b = xps_adcdac_2g_ctrl(blk_obj) disp('calling xps_adcdac_2g_ctrl!'); if ~isa(blk_obj,'xps_block') error('xps_adcdac_2g_ctrl class requires a xps_block class object'); end % Then check that it's the right type if ~strcmp(get(blk_obj,'type'),'xps_adcdac_2g_ctrl') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end disp('.1'); disp('.1'); blk_name = get(blk_obj,'simulink_name'); xsg_obj = get(blk_obj,'xsg_obj'); s.hw_sys = get(xsg_obj,'hw_sys'); % Get the mask parameters we need to know s.clk_sys = get(xsg_obj,'clk_src'); disp('.1'); b = class(s,'xps_adcdac_2g_ctrl',blk_obj); % ip name & version b = set(b,'ip_name','adcdac_2g_ctrl'); b = set(b,'ip_version','1.00.a'); disp('.1'); %b = set(b,'parameters',parameters); n_adc_samples_per_fabric_cycle = 8; % external ports ucf_constraints_term = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE'); ucf_constraints_noterm = struct('IOSTANDARD', 'LVDS_25'); disp('.1'); %data in adcport1 = [s.hw_sys, '.', 'zdok1']; adcport0 = [s.hw_sys, '.', 'zdok0']; %first 3 bits in each are (valid,sysref,overrange) ext_ports.zdok_tx_data_p = {1 'out' ['adc_ctrl_tx_data_p'] ['{',adcport1,'_p{[10],:}}'] 'vector=false' struct() ucf_constraints_term}; ext_ports.zdok_tx_data_n = {1 'out' ['adc_ctrl_tx_data_n'] ['{',adcport1,'_n{[10],:}}'] 'vector=false' struct() ucf_constraints_term}; ext_ports.zdok_rx_data_p = {1 'in' ['adc_ctrl_rx_data_p'] ['{',adcport1,'_p{[30],:}}'] 'vector=false' struct() ucf_constraints_term}; ext_ports.zdok_rx_data_n = {1 'in' ['adc_ctrl_rx_data_n'] ['{',adcport1,'_n{[30],:}}'] 'vector=false' struct() ucf_constraints_term}; b = set(b,'ext_ports',ext_ports); % Add ports not explicitly provided in the yellow block %clock from fpga misc_ports.fpga_clk = {1 'in' get(xsg_obj,'clk_src')}; %100 MHz clock for the uart %misc_ports.sys_clk = {1 'in' 'sys_clk'}; b = set(b,'misc_ports',misc_ports); disp('done calling xps_adcdac_2g_ctrl!');
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_adcdac_2g_ctrl/drc.m
1,751
utf_8
805b22d398f2f8ef4c982d1cd1e67683
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = '';
github
mstrader/mlib_devel-master
gen_ucf.m
.m
mlib_devel-master/xps_library/@xps_adcdac_2g_ctrl/gen_ucf.m
3,032
utf_8
26e3675df4b10667893187319a84bbc2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function str = gen_ucf(blk_obj) str = gen_ucf(blk_obj.xps_block); simulink_name = clear_name(get(blk_obj,'simulink_name')); %str = ''; %simulink_name = clear_name(get(blk_obj,'simulink_name')); %I_clk_p_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_I_p']; %I_clk_n_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_I_n']; %Q_clk_p_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_Q_p']; %Q_clk_n_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_Q_n']; %str = [str, 'NET ', I_clk_p_str, ' TNM_NET = ', I_clk_p_str, ';\n']; %str = [str, 'TIMESPEC TS_', I_clk_p_str, ' = PERIOD ', I_clk_p_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; %str = [str, 'NET ', I_clk_n_str, ' TNM_NET = ', I_clk_n_str, ';\n']; %str = [str, 'TIMESPEC TS_', I_clk_n_str, ' = PERIOD ', I_clk_n_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; %str = [str, '\n']; %str = [str, 'NET ', Q_clk_p_str, ' TNM_NET = ', Q_clk_p_str, ';\n']; %str = [str, 'TIMESPEC TS_', Q_clk_p_str, ' = PERIOD ', Q_clk_p_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; %str = [str, 'NET ', Q_clk_n_str, ' TNM_NET = ', Q_clk_n_str, ';\n']; %str = [str, 'TIMESPEC TS_', Q_clk_n_str, ' = PERIOD ', Q_clk_n_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; %str = [str, '\n']; %str = [str, gen_ucf(blk_obj.xps_block)]; end
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_adcdac_2g_ctrl/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_ucf/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_ucf/drc.m
1,750
utf_8
1182852afc273984ab70c6751547f164
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = '';
github
mstrader/mlib_devel-master
gen_ucf.m
.m
mlib_devel-master/xps_library/@xps_ucf/gen_ucf.m
1,793
utf_8
9383c96970079c7bcd7e637f32c43718
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function str = gen_ucf(blk_obj) disp('Adding custom UCF entries:'); str = fileread(get(blk_obj,'ucf_file'))
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_ucf/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
xps_ucf.m
.m
mlib_devel-master/xps_library/@xps_ucf/xps_ucf.m
2,109
utf_8
9e3b552cf030f5556e63ce0600c82728
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_ucf(blk_obj) if ~isa(blk_obj,'xps_block') error('XPS_UCF class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_ucf') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj, 'simulink_name'); xsg_obj = get(blk_obj,'xsg_obj'); s.ucf_file = get_param(blk_name,'ucf_file') s.hw_sys = get(xsg_obj,'hw_sys'); b = class(s,'xps_ucf',blk_obj);
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_gpio/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_gpio/drc.m
7,117
utf_8
cab0cd6351bb291c5d27b8c1a5784ba3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = ''; if ~exist(blk_obj.hw_sys) | ~isstruct(blk_obj.hw_sys) load_hw_routes(); end % ~exist(blk_obj.hw_sys) | ~isstruct(blk_obj.hw_sys) try eval(['pads = ',blk_obj.hw_sys,'.',blk_obj.io_group,';']); catch try eval(['pads = ',blk_obj.hw_sys,'.',blk_obj.io_group,'_p;']); catch msg = ['Undefined routing table for hardware system: ',blk_obj.hw_sys,'(',blk_obj.io_group,')']; result = 1; end % try end % try if ~isempty(find(blk_obj.bit_index>=length(pads))) msg = 'Gateway bit index contain values that exceeds the io_bitwidth'; result = 1; end % ~isempty(find(blk_obj.bit_index>=length(pads))) if blk_obj.use_ddr if ~blk_obj.reg_iob msg = 'When using DDR signaling mode, "Pack register in the pad" option must be on'; result = 1; end % ~blk_obj.reg_iob if blk_obj.io_bitwidth/2 > length(pads) msg = 'Gateway io_bitwidth is larger than the number of available pads'; result = 1; end % blk_obj.io_bitwidth/2 > length(pads) if length(blk_obj.bit_index) ~= blk_obj.io_bitwidth/2 msg = 'Gateway bit index does not have half the number of elements of the I/O io_bitwidth'; result = 1; end % length(blk_obj.bit_index) ~= blk_obj.io_bitwidth/2 else if blk_obj.io_bitwidth > length(pads) msg = 'Gateway io_bitwidth is larger than the number of available pads'; result = 1; end % if blk_obj.io_bitwidth > length(pads) if length(blk_obj.bit_index) ~= blk_obj.io_bitwidth msg = 'Gateway bit index does not have the same number of elements as the I/O io_bitwidth'; result = 1; end % if length(blk_obj.bit_index) ~= blk_obj.io_bitwidth end %blk_obj.use_ddr xsg_obj = get(blk_obj,'xsg_obj'); clk_src = get(xsg_obj,'clk_src'); if strcmp(blk_obj.hw_sys, 'iBOB') & strmatch('usr_clk', clk_src) try if strcmp(get(xsg_obj, 'gpioclk_grp'), blk_obj.io_group) bit_index = blk_obj.bit_index; for n=1:length(bit_index) if ~isempty(find(get(xsg_obj,'gpioclkbit')==bit_index(n))) msg = ['User clock input and GPIO ',get(blk_obj,'simulink_name'),' share the same I/O pin.']; result = 1; end % if ~isempty(find(get(xsg_obj,'gpioclkbit')==bit_index(n))) end % for n=1:length(bit_index) end % if strcmp(get(xsg_obj, 'gpioclk_grp'), blk_obj.io_group) end % try end % if strcmp(blk_obj.hw_sys, 'iBOB') & strmatch('usr_clk', clk_src) for n=1:length(xps_objs) try if strcmp(blk_obj.hw_sys,get(xps_objs{n},'hw_sys')) && strcmp(blk_obj.io_group,get(xps_objs{n},'io_group')) if ~strcmp(get(blk_obj,'simulink_name'),get(xps_objs{n},'simulink_name')) bit_index = blk_obj.bit_index; % Check for single-ended/differential I/O conflicts if ~isempty(find(strcmp(blk_obj.io_group,{'zdok0', 'zdok1', 'mdr'}))) if strcmp(get(blk_obj,'single_ended'), 'on') & strcmp(get(xps_objs{n},'single_ended'), 'off') for k=1:length(bit_index) if ~isempty(find(get(xps_objs{n},'bit_index')==floor(bit_index(k)/2))) msg = ['GPIO ',get(blk_obj,'simulink_name'),' and GPIO ',get(xps_objs{n},'simulink_name'),' share the same I/O pin.']; result = 1; end % if ~isempty(find(get(xps_objs{n},'bit_index')==floor(bit_index(k)/2))) end % for k=1:length(bit_index) elseif strcmp(get(blk_obj,'single_ended'), 'off') & strcmp(get(xps_objs{n}, 'single_ended'), 'on') for k=1:length(bit_index) if ~isempty(find(get(xps_objs{i},'bit_index')==floor(bit_index(j)/2))) msg = ['GPIO ',get(blk_obj,'simulink_name'),' and GPIO ',get(xps_objs{n},'simulink_name'),' share the same I/O pin.']; result = 1; end % if ~isempty(find(get(xps_objs{i},'bit_index')==floor(bit_index(j)/2))) end % for k=1:length(bit_index) else for k=1:length(bit_index) if ~isempty(find(get(xps_objs{n},'bit_index')==bit_index(k))) msg = ['GPIO ',get(blk_obj,'simulink_name'),' and GPIO ',get(xps_objs{n},'simulink_name'),' share the same I/O pin.']; result = 1; end % if ~isempty(find(get(xps_objs{n},'bit_index')==bit_index(k))) end % for k=1:length(bit_index) end % if strcmp(get(blk_obj,'single_ended'), 'on') & strcmp(get(xps_objs{n},'single_ended'), 'off') else for k=1:length(bit_index) if ~isempty(find(get(xps_objs{n},'bit_index')==bit_index(k))) msg = ['GPIO ',get(blk_obj,'simulink_name'),' and GPIO ',get(xps_objs{n},'simulink_name'),' share the same I/O pin.']; result = 1; end % if ~isempty(find(get(xps_objs{n},'bit_index')==bit_index(k))) end % for k=1:length(bit_index) end % if ~isempty(find(strcmp(blk_obj.io_group,{'zdok0', 'zdok1', 'mdr'}))) end % if ~strcmp(get(blk_obj,'simulink_name'),get(xps_objs{n},'simulink_name')) end % if strcmp(blk_obj.hw_sys,get(xps_objs{n},'hw_sys')) && strcmp(blk_obj.io_group,get(xps_objs{n},'io_group')) end % try end % for n=1:length(xps_objs)
github
mstrader/mlib_devel-master
xps_gpio.m
.m
mlib_devel-master/xps_library/@xps_gpio/xps_gpio.m
5,834
utf_8
117f464211a8a12255f6b15482755002
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_gpio(blk_obj) if ~isa(blk_obj,'xps_block') error('XPS_GPIO class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_gpio') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj,'simulink_name'); [s.hw_sys,s.io_group] = xps_get_hw_info(get_param(blk_name,'io_group')); s.bit_index = eval_param(blk_name,'bit_index'); s.io_dir = get_param(blk_name,'io_dir'); s.reg_iob = get_param(blk_name,'reg_iob'); s.arith_type = get_param(blk_name,'arith_type'); if strcmp(s.arith_type,'Boolean') s.io_bitwidth = 1; else s.io_bitwidth = eval_param(blk_name,'bitwidth'); end s.reg_clk_phase = get_param(blk_name,'reg_clk_phase'); s.use_ddr = strcmp(get_param(blk_name,'use_ddr'),'on'); s.termtype = get_param(blk_name,'termination'); s.single_ended = get_param(blk_name,'use_single_ended'); b = class(s,'xps_gpio',blk_obj); use_diffio = ~isempty(strmatch(s.io_group, {'zdok0', 'zdok1', 'mdr', 'qsh', 'sync_in', 'sync_out'})) & strcmp(s.single_ended, 'off'); if ~isempty(strmatch(s.termtype, {'Pullup', 'Pulldown'})) termination = s.termtype; else termination = ''; end % ~isempty(strmatch(s.termtype, {'Pullup', 'Pulldown'})) % ip name if use_diffio switch s.io_dir case 'in' b = set(b, 'ip_name','diffgpio_ext2simulink'); case 'out' b = set(b, 'ip_name','diffgpio_simulink2ext'); end else switch s.io_dir case 'in' b = set(b, 'ip_name','gpio_ext2simulink'); case 'out' b = set(b, 'ip_name','gpio_simulink2ext'); end end % external ports switch s.hw_sys case 'ROACH' if use_diffio iostandard = 'LVDS_25'; else switch s.io_group case 'led' iostandard = 'LVCMOS18'; case 'gpioa_oe_n' iostandard = 'LVCMOS33'; case 'gpiob_oe_n' iostandard = 'LVCMOS33'; case 'gpiob' iostandard = 'LVCMOS15'; otherwise iostandard = 'LVCMOS25'; end end % if use_diffio % end case 'ROACH' case 'ROACH2' if use_diffio iostandard = 'LVDS_25'; else iostandard = 'LVCMOS15'; end % if use_diffio % end case 'ROACH2' otherwise iostandard = 'LVCMOS25'; end % switch 'hw_sys' ucf_fields = {}; ucf_values = {}; %ucf_fields = [ucf_fields, 'IOSTANDARD', termination]; %ucf_values = [ucf_values, iostandard, '']; if ~isempty(termination) ucf_constraints = struct('IOSTANDARD',iostandard, termination,''); else ucf_constraints = struct('IOSTANDARD',iostandard); end % if ~isempty(termination) switch s.use_ddr case 0 pad_bitwidth = s.io_bitwidth; case 1 pad_bitwidth = s.io_bitwidth/2; end % switch s.use_ddr extportname = [clear_name(blk_name), '_ext']; iobname = [s.hw_sys, '.', s.io_group]; %ucf_constraints = cell2struct(ucf_values, ucf_fields, length(ucf_fields)); switch use_diffio case 0 ext_ports.io_pad = {pad_bitwidth s.io_dir extportname [iobname,' ([',num2str(s.bit_index),']+1)'] 'vector=true' struct() ucf_constraints }; case 1 ext_ports.io_pad_p = {pad_bitwidth s.io_dir [extportname, '_p'] [iobname,'_p([',num2str(s.bit_index),']+1)'] 'vector=true' struct() ucf_constraints }; ext_ports.io_pad_n = {pad_bitwidth s.io_dir [extportname, '_n'] [iobname,'_n([',num2str(s.bit_index),']+1)'] 'vector=true' struct() ucf_constraints }; end % switch use_diffio b = set(b,'ext_ports',ext_ports); % parameters parameters.DDR = num2str(s.use_ddr); parameters.WIDTH = num2str(s.io_bitwidth); parameters.CLK_PHASE = num2str(s.reg_clk_phase); if strcmp(s.reg_iob,'on') parameters.REG_IOB = 'true'; else parameters.REG_IOB = 'false'; end % if strcmp(s.reg_iob,'on') b = set(b,'parameters',parameters); % misc ports xsg_obj = get(blk_obj,'xsg_obj'); misc_ports.clk = {1 'in' get(xsg_obj,'clk_src')}; misc_ports.clk90 = {1 'in' get(xsg_obj,'clk90_src')}; b = set(b,'misc_ports',misc_ports);
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_gpio/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_ethlite/get.m
1,965
utf_8
e4447d00c910af45efa20e63d8451e64
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknown to block object: ', field]); end end
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_ethlite/drc.m
2,036
utf_8
41e9985e657e9783c74f5507be37bbff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = ''; try if ( strcmp(get(xps_objs{i},'type'), 'xps_xsg') && ~strcmp(get(xps_objs{i},'hw_sys'), 'iBOB')) msg = ['Ethernetlite ', get(blk_obj,'simulink_name'), ' can not be used on a platform other than IBOB.']; result = 1; end end
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_ethlite/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
xps_ethlite.m
.m
mlib_devel-master/xps_library/@xps_ethlite/xps_ethlite.m
3,692
utf_8
8b52790b2798d513add9f5b003e18f64
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_ethlite(blk_obj) if ~isa(blk_obj,'xps_block') error('XPS_ETHLITE class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_ethlite') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj,'simulink_name'); xsg_obj = get(blk_obj,'xsg_obj'); s.hw_sys = 'iBOB'; b = class(s,'xps_ethlite',blk_obj); % ip name & version b = set(b,'ip_name','opb_ethernetlite'); b = set(b,'ip_version','1.01.b'); % software driver b = set(b, 'soft_driver', {'emaclite','1.01.a'}); % bus offset b = set(b,'opb_address_offset',hex2dec('2000')); b = set(b,'opb_address_align', hex2dec('2000')); % parameters parameters.C_OPB_CLK_PERIOD_PS = '10000'; b = set(b,'parameters',parameters); % external ports ucf_constraints = struct('IOSTANDARD', 'LVCMOS25'); ext_ports.PHY_col = {1 'in' 'opb_ethlite_phy_col' {'J32'} 'vector=false' struct() ucf_constraints}; ext_ports.PHY_crs = {1 'in' 'opb_ethlite_phy_crs' {'J31'} 'vector=false' struct() ucf_constraints}; ext_ports.PHY_dv = {1 'in' 'opb_ethlite_phy_dv' {'F33'} 'vector=false' struct() ucf_constraints}; ext_ports.PHY_rx_clk = {1 'in' 'opb_ethlite_phy_rx_clk' {'H29'} 'vector=false' struct() ucf_constraints}; ext_ports.PHY_rx_data = {4 'in' 'opb_ethlite_phy_rx_data' {'G30' 'G29' 'G32' 'G31'} 'vector=false' struct() ucf_constraints}; ext_ports.PHY_rx_er = {1 'in' 'opb_ethlite_phy_rx_err' {'F34'} 'vector=false' struct() ucf_constraints}; ext_ports.PHY_tx_clk = {1 'in' 'opb_ethlite_phy_tx_clk' {'H30'} 'vector=false' struct() ucf_constraints}; ext_ports.PHY_tx_data = {4 'out' 'opb_ethlite_phy_tx_data' {'J30' 'J29' 'G34' 'G33'} 'vector=false' struct() ucf_constraints}; ext_ports.PHY_tx_en = {1 'out' 'opb_ethlite_phy_tx_en' {'L26'} 'vector=false' struct() ucf_constraints}; b = set(b,'ext_ports',ext_ports);
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_probe/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_probe/drc.m
2,780
utf_8
2942cff975cd5cc6481184f3341b1a34
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = ''; for i=1:length(xps_objs) try if strcmp(get(blk_obj,'ila_number'),get(xps_objs{i},'ila_number')) if ~strcmp(get(blk_obj,'simulink_name'),get(xps_objs{i},'simulink_name')) msg = ['Probe ',get(blk_obj,'simulink_name'),' and probe ',get(xps_objs{i},'simulink_name'),' have the same ILA number.']; result = 1; end end end end nb_probes = 0; max_ila_n = 0; for i=1:length(xps_objs) if strcmp(get(xps_objs{i},'type'),'xps_probe') nb_probes = nb_probes + 1; ila_n = get(xps_objs{i},'ila_number'); if ila_n > max_ila_n max_ila_n = ila_n; end end end if nb_probes ~= max_ila_n + 1 msg = ['ILA numbers not organized correctly for the chipscope probes. They should be growing from 0 to ',num2str(nb_probes-1)]; result = 1; end % EDK 7.1 limits the number of ILA probes to 1 if nb_probes ~= 1 msg = 'Due to current implementation limitations in EDK 7.1, you can only use one probe in a design and it has to have the ILA number 0'; result = 1; end
github
mstrader/mlib_devel-master
xps_probe.m
.m
mlib_devel-master/xps_library/@xps_probe/xps_probe.m
3,006
utf_8
fd3e447973d24f0c52dc4a1adf8a2af4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_probe(blk_obj) if ~isa(blk_obj,'xps_block') error('XPS_PROBE class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_probe') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj,'simulink_name'); s.hw_sys = 'any'; s.match_type = get_param(blk_name,'match_type'); s.match_counter_width = get_param(blk_name,'match_counter_width'); s.ila_number = str2num(get_param(blk_name,'ila_number')); s.capture_depth = get_param(blk_name, 'capture_depth'); if strcmp(get_param(blk_name,'arith_type'),'Boolean') s.bitwidth = 1; else s.bitwidth = get_param(blk_name,'bitwidth'); end b = class(s,'xps_probe',blk_obj); % ip name b = set(b,'ip_name','chipscope_ila'); % misc ports misc_ports.chipscope_ila_control = {36 'in' ['chipscope_icon_control',num2str(s.ila_number)]}; xsg_obj = get(blk_obj,'xsg_obj'); misc_ports.clk = {1 'in' get(xsg_obj,'clk_src')}; b = set(b,'misc_ports',misc_ports); % parameters parameters.C_TRIG0_UNITS = '1'; parameters.C_TRIG0_TRIGGER_IN_WIDTH = num2str(s.bitwidth); parameters.C_TRIG0_UNIT_MATCH_TYPE = s.match_type; parameters.C_TRIG0_UNIT_COUNTER_WIDTH = s.match_counter_width; parameters.C_NUM_DATA_SAMPLES = s.capture_depth; b = set(b,'parameters',parameters);
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_probe/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_xsg/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
gen_mhs_xsg.m
.m
mlib_devel-master/xps_library/@xps_xsg/gen_mhs_xsg.m
2,117
utf_8
765b8f9469a275a56eb973e06fa66959
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [str,opb_addr_end] = gen_mhs_xsg(blk_obj, opb_addr_start, opb_name) str = ''; opb_addr_end = opb_addr_start; str = [str, ' PARAMETER INSTANCE = ',clear_name(get(blk_obj,'simulink_name')),'\n']; str = [str, ' PARAMETER HW_VER = 1.00.a\n']; str = [str, ' PORT clk = ',blk_obj.clk_src,'\n']; %fprintf('\n\n\n\n\n\n\n\n\n\nNew call to gen_mhs_xsg\n'); %fprintf(str); %fprintf('\n\n\n\n'); end
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_xsg/drc.m
2,359
utf_8
6cc498c1bcad6131e8bdc5101c82a019
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = ''; %check hw_sys consistancy hw_sys = get(blk_obj,'hw_sys'); for i=1:length(xps_objs) tmp = get(xps_objs{i},'hw_sys'); if ~strcmp(hw_sys,tmp) & ~strcmp(tmp,'any') & isempty(strfind(hw_sys,tmp)) result = 1; msg = ['Block ',get(xps_objs{i},'simulink_name'),' has an inconsistent hardware platform: ',tmp]; return; end end clk_src = get(blk_obj,'clk_src'); if strcmp(hw_sys,'CORR') if strcmp(clk_src,'usr_clk') || strcmp(clk_src,'usr_clk2x') msg = ['Cannot use usr_clk or usr_clk2x on the CORR',tmp]; return; end end
github
mstrader/mlib_devel-master
gen_ucf.m
.m
mlib_devel-master/xps_library/@xps_xsg/gen_ucf.m
2,771
utf_8
efd06701d7ccbd8ea5814ae735cae97f
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function str = gen_ucf(blk_obj) str = ''; hw_sys = blk_obj.hw_sys; app_clk = blk_obj.clk_src; app_clk_rate = blk_obj.clk_rate; if ~isempty(strmatch(app_clk, {'aux_clk', 'aux_clk2x', 'aux0_clk', 'aux1_clk', 'aux0_clk2x'})) toks = regexp(app_clk, '(.+_clk)2x', 'tokens'); if isempty(toks) clk_rate_constraint = num2str(app_clk_rate); timespec_clk = app_clk; else clk_rate_constraint = num2str(app_clk_rate/2); timespec_clk = toks{1}{1}; end % if isempty(toks) str = [str, '##############################################\n']; str = [str, '# External Clock constraints #\n']; str = [str, '##############################################\n']; str = [str, '\n']; str = [str, 'NET "', timespec_clk,'_p" TNM_NET = "', timespec_clk,'_p" ;\n']; str = [str, 'TIMESPEC "TS_', timespec_clk,'_p" = PERIOD "', timespec_clk, '_p" ', clk_rate_constraint,' MHz ;\n']; str = [str, '\n\n']; end % if ~isempty(strmatch(app_clk, {'aux0_clk', 'aux1_clk', 'aux0_clk2x'})) str = [str, gen_ucf(blk_obj.xps_block)];
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_xsg/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
xps_xsg.m
.m
mlib_devel-master/xps_library/@xps_xsg/xps_xsg.m
2,876
utf_8
6261238cc0ed593263f9d73503125a03
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_xsg(blk_obj) if ~isa(blk_obj,'xps_block') error('XPS_PPC class requires a xps_block class object'); end % if ~isa(blk_obj,'xps_block') if ~strcmp(get(blk_obj,'type'),'xps_xsg') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end % if ~strcmp(get(blk_obj,'type'),'xps_xsg') blk_name = get(blk_obj,'simulink_name'); [hw_sys, hw_subsys] = xps_get_hw_plat(get_param(blk_name,'hw_sys')); s.hw_sys = hw_sys; s.hw_subsys = hw_subsys; supp_ip_names = {}; supp_ip_versions = {}; switch s.hw_sys case 'ROACH' s.sw_os = 'none'; % end case 'ROACH' case 'ROACH2' s.sw_os = 'none'; % end case 'ROACH2' case 'MKDIG' s.sw_os = 'none'; % end case 'MKDIG' otherwise error(['Unsupported Platform: ',s.hw_sys]); end % switch s.hw_sys s.clk_src = get_param(blk_name,'clk_src'); s.clk90_src = [s.clk_src,'90']; s.clk180_src = [s.clk_src,'180']; s.clk270_src = [s.clk_src,'270']; s.clk_rate = eval_param(blk_name,'clk_rate'); b = class(s,'xps_xsg',blk_obj); b = set(b, 'supp_ip_names', supp_ip_names); b = set(b, 'supp_ip_versions', supp_ip_versions); mhs_constraints = struct('SIGIS','CLK', 'CLK_FREQ',num2str(s.clk_rate*1e6));
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_adc_mkid_4x/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
drc.m
.m
mlib_devel-master/xps_library/@xps_adc_mkid_4x/drc.m
1,751
utf_8
805b22d398f2f8ef4c982d1cd1e67683
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [result,msg] = drc(blk_obj, xps_objs) result = 0; msg = '';
github
mstrader/mlib_devel-master
gen_ucf.m
.m
mlib_devel-master/xps_library/@xps_adc_mkid_4x/gen_ucf.m
3,032
utf_8
26e3675df4b10667893187319a84bbc2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function str = gen_ucf(blk_obj) str = gen_ucf(blk_obj.xps_block); simulink_name = clear_name(get(blk_obj,'simulink_name')); %str = ''; %simulink_name = clear_name(get(blk_obj,'simulink_name')); %I_clk_p_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_I_p']; %I_clk_n_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_I_n']; %Q_clk_p_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_Q_p']; %Q_clk_n_str = ['adcmkid', blk_obj.adc_brd,'_DRDY_Q_n']; %str = [str, 'NET ', I_clk_p_str, ' TNM_NET = ', I_clk_p_str, ';\n']; %str = [str, 'TIMESPEC TS_', I_clk_p_str, ' = PERIOD ', I_clk_p_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; %str = [str, 'NET ', I_clk_n_str, ' TNM_NET = ', I_clk_n_str, ';\n']; %str = [str, 'TIMESPEC TS_', I_clk_n_str, ' = PERIOD ', I_clk_n_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; %str = [str, '\n']; %str = [str, 'NET ', Q_clk_p_str, ' TNM_NET = ', Q_clk_p_str, ';\n']; %str = [str, 'TIMESPEC TS_', Q_clk_p_str, ' = PERIOD ', Q_clk_p_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; %str = [str, 'NET ', Q_clk_n_str, ' TNM_NET = ', Q_clk_n_str, ';\n']; %str = [str, 'TIMESPEC TS_', Q_clk_n_str, ' = PERIOD ', Q_clk_n_str, ' ', num2str(2*1000/blk_obj.adc_clk_rate, '%3.3f'), ' ns;\n']; %str = [str, '\n']; %str = [str, gen_ucf(blk_obj.xps_block)]; end
github
mstrader/mlib_devel-master
xps_adc_mkid_4x.m
.m
mlib_devel-master/xps_library/@xps_adc_mkid_4x/xps_adc_mkid_4x.m
5,483
utf_8
87ec020d87ad9081c8e08a80d0aeb73b
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_adc_mkid_4x(blk_obj) if ~isa(blk_obj,'xps_block') error('xps_quadc class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_adc_mkid_4x') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj,'simulink_name'); xsg_obj = get(blk_obj,'xsg_obj'); s.hw_sys = get(xsg_obj,'hw_sys'); s.adc_brd = get_param(blk_name, 'adc_brd'); s.adc_str = ['adc', s.adc_brd]; s.adc_clk_rate = eval_param(blk_name,'adc_clk_rate'); s.clk_sys = get(xsg_obj,'clk_src'); b = class(s,'xps_adc_mkid_4x',blk_obj); % ip name & version b = set(b,'ip_name','adc_mkid_4x_interface'); b = set(b,'ip_version','1.00.a'); parameters.OUTPUT_CLK = '0'; if strfind(s.clk_sys,'adc') parameters.OUTPUT_CLK = '1'; end b = set(b,'parameters',parameters); %%%%%%%%%%%%%%%%% % external ports %%%%%%%%%%%%%%%%% ucf_constraints_clock = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE', 'PERIOD', [num2str(2*1000/s.adc_clk_rate),' ns']); ucf_constraints_term = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE'); ucf_constraints_noterm = struct('IOSTANDARD', 'LVDS_25'); mhs_constraints = struct('SIGIS','CLK', 'CLK_FREQ',num2str(1e6*s.adc_clk_rate/2)); ext_ports.DRDY_I_p = {1 'in' ['adcmkid',s.adc_brd,'_DRDY_I_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[20],:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.DRDY_I_n = {1 'in' ['adcmkid',s.adc_brd,'_DRDY_I_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[20],:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.DRDY_Q_p = {1 'in' ['adcmkid',s.adc_brd,'_DRDY_Q_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[40],:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.DRDY_Q_n = {1 'in' ['adcmkid',s.adc_brd,'_DRDY_Q_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[40],:}}'] 'vector=false' mhs_constraints ucf_constraints_clock}; ext_ports.DI_p = {12 'in' ['adcmkid',s.adc_brd,'_DI_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[17 37 7 27 26 36 25 35 16 15 6 5],:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.DI_n = {12 'in' ['adcmkid',s.adc_brd,'_DI_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[17 37 7 27 26 36 25 35 16 15 6 5],:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.DQ_p = {12 'in' ['adcmkid',s.adc_brd,'_DQ_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[13 33 3 23 22 32 21 31 12 11 2 1],:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.DQ_n = {12 'in' ['adcmkid',s.adc_brd,'_DQ_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[13 33 3 23 22 32 21 31 12 11 2 1],:}}'] 'vector=true' struct() ucf_constraints_term}; ext_ports.ADC_ext_in_p = {1 'in' ['adcmkid',s.adc_brd,'_ADC_ext_in_p'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_p{[29],:}}'] 'vector=false' struct() ucf_constraints_term}; ext_ports.ADC_ext_in_n = {1 'in' ['adcmkid',s.adc_brd,'_ADC_ext_in_n'] ['{',s.hw_sys,'.zdok',s.adc_brd,'_n{[29],:}}'] 'vector=false' struct() ucf_constraints_term}; b = set(b,'ext_ports',ext_ports); %%%%%%%%%%%%% % misc ports %%%%%%%%%%%%% misc_ports.fpga_clk = {1 'in' get(xsg_obj,'clk_src')}; if strfind(s.clk_sys,'adc') misc_ports.adc_clk_out = {1 'out' [s.adc_str,'_clk']}; misc_ports.adc_clk90_out = {1 'out' [s.adc_str,'_clk90']}; misc_ports.adc_clk180_out = {1 'out' [s.adc_str,'_clk180']}; misc_ports.adc_clk270_out = {1 'out' [s.adc_str,'_clk270']}; end misc_ports.adc_dcm_locked = {1 'out' [s.adc_str, '_dcm_locked']}; b = set(b,'misc_ports',misc_ports);
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_adc_mkid_4x/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
get.m
.m
mlib_devel-master/xps_library/@xps_mkadc/get.m
1,964
utf_8
b339b0c993e6a4d4c7245ee5a81c130c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = get(b,field) try eval(['result = b.',field,';']); catch try result = get(b.xps_block,field); catch error(['Field name unknow to block object: ', field]); end end
github
mstrader/mlib_devel-master
gen_ucf.m
.m
mlib_devel-master/xps_library/@xps_mkadc/gen_ucf.m
21,511
utf_8
e61f6c429fe372c562e3b95094a78704
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function str = gen_ucf(blk_obj) disp('meerKAT ADC gen_ucf') hw_sys = blk_obj.hw_sys; adc_str = blk_obj.adc_str; disp('meerKAT ADC trying generic ucf generation') str = gen_ucf(blk_obj.xps_block); simulink_name = clear_name(get(blk_obj,'simulink_name')); blk_name = get(blk_obj,'simulink_name'); adc_clk_rate = eval_param(blk_name,'adc_clk_rate'); disp('meerKAT ADC trying specific ucf generation') switch hw_sys case {'ROACH2', 'MKDIG'} switch adc_str case 'adc0' % MeerKAT ADC ZDOK 0 str = [str,'#MeerKAT ADC ZDOK 0 Constraints\n']; str = [str, 'INST "', simulink_name, '/', simulink_name, ... '/adc5g_inst/data_buf[?].D*_1" AREA_GROUP = ZDOK_0 ;\n']; str = [str, 'AREA_GROUP "ZDOK_0" RANGE = ', ... 'SLICE_X88Y200:SLICE_X89Y276 ;\n']; str = [str,'\n']; % MeerKAT ADC Setup & Hold Constraints for FPGA str = [str,'#ZDOK0 MeerKAT ADC Setup & Hold Constraints for FPGA\n']; %str = [str, 'OFFSET=IN ',sprintf('%1.3f',(2000.0/adc_clk_rate)-0.4),' ns VALID 1.1 ns BEFORE "adc0_adc_clk_p" RISING;\n']; %str = [str, 'OFFSET=IN ',sprintf('%1.3f',(2000.0/adc_clk_rate)-0.4),' ns VALID 1.1 ns BEFORE "adc0_adc_clk_p" FALLING;\n']; str = [str,'\n']; str = [str,'# meerKAT ADC0 Pins\n']; str = [str,'\n']; str = [str,'# ZDOK A\n']; str = [str,'NET "adc0_adc_data_b_p<9>" LOC = L35 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB9+ ZDOK A5, P<2>\n']; str = [str,'NET "adc0_adc_data_b_n<9>" LOC = L36 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB9- ZDOK A6, N<2>\n']; str = [str,'NET "adc0_adc_data_b_p<6>" LOC = K35 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB6+ ZDOK A7, P<3>\n']; str = [str,'NET "adc0_adc_data_b_n<6>" LOC = K34 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB6- ZDOK A8, N<3>\n']; str = [str,'NET "adc0_adc_data_b_p<4>" LOC = J35 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB4+ ZDOK A9 P<4>\n']; str = [str,'NET "adc0_adc_data_b_n<4>" LOC = H35 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB4- ZDOK A10, N<4>\n']; str = [str,'\n']; str = [str,'# ZDOK D\n']; str = [str,'NET "adc0_adc_reset" LOC = N28 | IOSTANDARD = LVCMOS25; # ASYNC_RST ZDOK D1, P<10>\n']; str = [str,'#NET "adc0_adc_i2c_sda" LOC = P28 | IOSTANDARD = LVCMOS25; # i2c_sda ZDOK D2, N<10>\n']; str = [str,'NET "adc0_adc_data_b_p<7>" LOC = K39 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB7+ ZDOK D7, P<13>\n']; str = [str,'NET "adc0_adc_data_b_n<7>" LOC = K40 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB7- ZDOK D8, N<13>\n']; str = [str,'NET "adc0_adc_or_a_p" LOC = E42 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # AOR+ ZDOK D13, P<16>\n']; str = [str,'NET "adc0_adc_or_a_n" LOC = F42 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # AOR- ZDOK D14, N<16>\n']; str = [str,'NET "adc0_adc_data_a_p<6>" LOC = C40 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA6+ ZDOK D15, P<17>\n']; str = [str,'NET "adc0_adc_data_a_n<6>" LOC = C41 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA6- ZDOK D16, N<17>\n']; str = [str,'NET "adc0_adc_data_a_p<3>" LOC = E39 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA3+ ZDOK D17, P<18>\n']; str = [str,'NET "adc0_adc_data_a_n<3>" LOC = E38 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA3- ZDOK D18, N<18>\n']; str = [str,'NET "adc0_adc_data_a_p<1>" LOC = B37 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA1+ ZDOK D19, P<19>\n']; str = [str,'NET "adc0_adc_data_a_n<1>" LOC = A37 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA1- ZDOK D20, N<19>\n']; str = [str,'\n']; str = [str,'# ZDOK C\n']; str = [str,'NET "adc0_adc_or_b_p" LOC = M33 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # BOR+ ZDOK C3, P<21>\n']; str = [str,'NET "adc0_adc_or_b_n" LOC = M32 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # BOR- ZDOK C4, N<21>\n']; str = [str,'NET "adc0_adc_data_b_p<8>" LOC = N29 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB8+ ZDOK C5, P<22>\n']; str = [str,'NET "adc0_adc_data_b_n<8>" LOC = N30 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB8- ZDOK C6, N<22>\n']; str = [str,'NET "adc0_adc_data_b_p<5>" LOC = L34 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB5+ ZDOK C7, P<23>\n']; str = [str,'NET "adc0_adc_data_b_n<5>" LOC = M34 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB5- ZDOK C8, N<23>\n']; str = [str,'NET "adc0_adc_data_b_p<3>" LOC = G34 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB3+ ZDOK C9, P<24>\n']; str = [str,'NET "adc0_adc_data_b_n<3>" LOC = H34 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB3- ZDOK C10, N<24>\n']; str = [str,'NET "adc0_adc_data_b_p<1>" LOC = F39 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB1+ ZDOK C11, P<25>\n']; str = [str,'NET "adc0_adc_data_b_n<1>" LOC = G39 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB1- ZDOK C12, N<25>\n']; str = [str,'NET "adc0_adc_data_a_p<9>" LOC = F37 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA9+ ZDOK C13, P<26>\n']; str = [str,'NET "adc0_adc_data_a_n<9>" LOC = E37 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA9- ZDOK C14, N<26>\n']; str = [str,'NET "adc0_adc_data_a_p<7>" LOC = D42 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA7+ ZDOK C15, P<27>\n']; str = [str,'NET "adc0_adc_data_a_n<7>" LOC = D41 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA7- ZDOK C16, N<27>\n']; str = [str,'NET "adc0_adc_data_a_p<4>" LOC = A40 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA4+ ZDOK C17, P<28>\n']; str = [str,'NET "adc0_adc_data_a_n<4>" LOC = A41 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA4- ZDOK C18, N<28>\n']; str = [str,'\n']; str = [str,'# ZDOK F\n']; str = [str,'NET "adc0_adc_demux_bist" LOC = L31 | IOSTANDARD = LVCMOS25; # DMUX_BIST ZDOK F1, P<29>\n']; str = [str,'#NET "adc0_adc_i2c_scl" LOC = L32 | IOSTANDARD = LVCMOS25; # I2C_SCL ZDOK F2, N<29>\n']; str = [str,'NET "adc0_adc_sync_p" LOC = J37 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # SYNC+ ZDOK F3 P<30>\n']; str = [str,'NET "adc0_adc_sync_n" LOC = J36 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # SYNC- ZDOK F4 N<30>\n']; str = [str,'NET "adc0_adc_data_b_p<2>" LOC = H39 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB2+ ZDOK F9 P<33>\n']; str = [str,'NET "adc0_adc_data_b_n<2>" LOC = H38 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB2- ZDOK F10 N<33>\n']; str = [str,'NET "adc0_adc_data_b_p<0>" LOC = D40 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB0+ ZDOK F11 P<34>\n']; str = [str,'NET "adc0_adc_data_b_n<0>" LOC = E40 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB0- ZDOK F12 N<34>\n']; str = [str,'NET "adc0_adc_data_a_p<8>" LOC = F40 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA8+ ZDOK F13 P<35>\n']; str = [str,'NET "adc0_adc_data_a_n<8>" LOC = F41 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA8- ZDOK F14 N<35>\n']; str = [str,'NET "adc0_adc_data_a_p<5>" LOC = F35 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA5+ ZDOK F15, P<36>\n']; str = [str,'NET "adc0_adc_data_a_n<5>" LOC = F36 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA5- ZDOK F16, N<36>\n']; str = [str,'NET "adc0_adc_data_a_p<2>" LOC = D38 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA2+ ZDOK F17, P<37>\n']; str = [str,'NET "adc0_adc_data_a_n<2>" LOC = C38 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA2- ZDOK F18, N<37>\n']; str = [str,'NET "adc0_adc_data_a_p<0>" LOC = P30 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA0+ ZDOK F19, adc0_clk_p<1>\n']; str = [str,'NET "adc0_adc_data_a_n<0>" LOC = P31 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA0- ZDOK F20, adc0_clk_n<1>\n']; str = [str,'\n']; str = [str,'NET "adc0_iic_sda" LOC = P28 | IOSTANDARD = LVCMOS25 | SLEW = SLOW;\n']; str = [str,'NET "adc0_iic_scl" LOC = L32 | IOSTANDARD = LVCMOS25 | SLEW = SLOW;\n']; str = [str,'\n']; str = [str,'NET "adc0_ser_clk" LOC = P27 | IOSTANDARD = LVCMOS25 | SLEW = SLOW;\n']; str = [str,'NET "adc0_ser_dat" LOC = M31 | IOSTANDARD = LVCMOS25 | SLEW = SLOW;\n']; str = [str,'NET "adc0_ser_cs" LOC = R27 | IOSTANDARD = LVCMOS25 | SLEW = SLOW;\n']; str = [str,'\n']; % end case 'adc0' case 'adc1' % MeerKAT ADC ZDOK 1 str = [str,'\n']; str = [str,'#MeerKAT ADC ZDOK 1 Constraints\n']; str = [str,'\n']; str = [str, 'INST "', simulink_name, '/', simulink_name, ... '/adc5g_inst/data_buf[?].D*_1" AREA_GROUP = ZDOK_1 ;\n']; str = [str, 'AREA_GROUP "ZDOK_1" RANGE = ', ... 'SLICE_X0Y246:SLICE_X1Y308 ;\n']; str = [str, 'INST "', simulink_name, '/', simulink_name, ... '/adc5g_inst/data_buf[0].D0?_1" AREA_GROUP = ZDOK_1_0 ;\n']; str = [str, 'AREA_GROUP "ZDOK_1_r0" RANGE = ', ... 'SLICE_X86Y197:SLICE_X87Y198 ;\n']; % MeerKAT ADC Setup & Hold Constraints for FPGA str = [str,'#ZDOK1 MeerKAT ADC Setup & Hold Constraints for FPGA\n']; %str = [str, 'OFFSET=IN ',sprintf('%1.3f',(2000.0/adc_clk_rate)-0.4),' ns BEFORE "adc1_adc_clk_p" RISING;\n']; %str = [str, 'OFFSET=IN ',sprintf('%1.3f',(2000.0/adc_clk_rate)-0.4),' ns BEFORE "adc1_adc_clk_p" FALLING;\n']; str = [str,'\n']; str = [str,'# meerKAT ADC1 Pins\n']; str = [str,'\n']; str = [str,'# ZDOK A\n']; str = [str,'NET "adc1_adc_data_b_p<9>" LOC = W35 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB9+ ZDOK A5, P<2>\n']; str = [str,'NET "adc1_adc_data_b_n<9>" LOC = V35 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB9- ZDOK A6, N<2>\n']; str = [str,'NET "adc1_adc_data_b_p<6>" LOC = U32 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB6+ ZDOK A7, P<3>\n']; str = [str,'NET "adc1_adc_data_b_n<6>" LOC = U33 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB6- ZDOK A8, N<3>\n']; str = [str,'NET "adc1_adc_data_b_p<4>" LOC = U42 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB4+ ZDOK A9 P<4>\n']; str = [str,'NET "adc1_adc_data_b_n<4>" LOC = U41 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB4- ZDOK A10, N<4>\n']; str = [str,'\n']; str = [str,'# ZDOK D\n']; str = [str,'NET "adc1_adc_reset" LOC = AA32 | IOSTANDARD = LVCMOS25; # ASYNC_RST ZDOK D1, P<10>\n']; str = [str,'#NET "adc1_adc_i2c_sda" LOC = Y32 | IOSTANDARD = LVCMOS25; # i2c_sda ZDOK D2, N<10>\n']; str = [str,'NET "adc1_adc_data_b_p<7>" LOC = V41 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB7+ ZDOK D7, P<13>\n']; str = [str,'NET "adc1_adc_data_b_n<7>" LOC = W41 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB7- ZDOK D8, N<13>\n']; str = [str,'NET "adc1_adc_or_a_p" LOC = T41 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # AOR+ ZDOK D13, P<16>\n']; str = [str,'NET "adc1_adc_or_a_n" LOC = T42 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # AOR- ZDOK D14, N<16>\n']; str = [str,'NET "adc1_adc_data_a_p<6>" LOC = R39 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA6+ ZDOK D15, P<17>\n']; str = [str,'NET "adc1_adc_data_a_n<6>" LOC = P38 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA6- ZDOK D16, N<17>\n']; str = [str,'NET "adc1_adc_data_a_p<3>" LOC = N36 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA3+ ZDOK D17, P<18>\n']; str = [str,'NET "adc1_adc_data_a_n<3>" LOC = P37 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA3- ZDOK D18, N<18>\n']; str = [str,'NET "adc1_adc_data_a_p<1>" LOC = N40 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA1+ ZDOK D19, P<19>\n']; str = [str,'NET "adc1_adc_data_a_n<1>" LOC = N41 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA1- ZDOK D20, N<19>\n']; str = [str,'\n']; str = [str,'# ZDOK C\n']; str = [str,'NET "adc1_adc_or_b_p" LOC = W32 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # BOR+ ZDOK C3, P<21>\n']; str = [str,'NET "adc1_adc_or_b_n" LOC = Y33 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # BOR- ZDOK C4, N<21>\n']; str = [str,'NET "adc1_adc_data_b_p<8>" LOC = W36 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB8+ ZDOK C5, P<22>\n']; str = [str,'NET "adc1_adc_data_b_n<8>" LOC = V36 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB8- ZDOK C6, N<22>\n']; str = [str,'NET "adc1_adc_data_b_p<5>" LOC = V40 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB5+ ZDOK C7, P<23>\n']; str = [str,'NET "adc1_adc_data_b_n<5>" LOC = W40 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB5- ZDOK C8, N<23>\n']; str = [str,'NET "adc1_adc_data_b_p<3>" LOC = U37 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB3+ ZDOK C9, P<24>\n']; str = [str,'NET "adc1_adc_data_b_n<3>" LOC = U38 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB3- ZDOK C10, N<24>\n']; str = [str,'NET "adc1_adc_data_b_p<1>" LOC = T39 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB1+ ZDOK C11, P<25>\n']; str = [str,'NET "adc1_adc_data_b_n<1>" LOC = R38 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB1- ZDOK C12, N<25>\n']; str = [str,'NET "adc1_adc_data_a_p<9>" LOC = P42 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA9+ ZDOK C13, P<26>\n']; str = [str,'NET "adc1_adc_data_a_n<9>" LOC = R42 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA9- ZDOK C14, N<26>\n']; str = [str,'NET "adc1_adc_data_a_p<7>" LOC = P40 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA7+ ZDOK C15, P<27>\n']; str = [str,'NET "adc1_adc_data_a_n<7>" LOC = P41 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA7- ZDOK C16, N<27>\n']; str = [str,'NET "adc1_adc_data_a_p<4>" LOC = M38 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA4+ ZDOK C17, P<28>\n']; str = [str,'NET "adc1_adc_data_a_n<4>" LOC = M39 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA4- ZDOK C18, N<28>\n']; str = [str,'\n']; str = [str,'# ZDOK F\n']; str = [str,'NET "adc1_adc_demux_bist" LOC = AA36 | IOSTANDARD = LVCMOS25; # DMUX_BIST ZDOK F1, P<29>\n']; str = [str,'#NET "adc1_adc_i2c_scl" LOC = AA37 | IOSTANDARD = LVCMOS25; # I2C_SCL ZDOK F2, N<29>\n']; str = [str,'NET "adc1_adc_sync_p" LOC = W42 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # SYNC+ ZDOK F3 P<30>\n']; str = [str,'NET "adc1_adc_sync_n" LOC = Y42 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # SYNC- ZDOK F4 N<30>\n']; str = [str,'NET "adc1_adc_data_b_p<2>" LOC = V34 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB2+ ZDOK F9 P<33>\n']; str = [str,'NET "adc1_adc_data_b_n<2>" LOC = U34 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB2- ZDOK F10 N<33>\n']; str = [str,'NET "adc1_adc_data_b_p<0>" LOC = T34 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB0+ ZDOK F11 P<34>\n']; str = [str,'NET "adc1_adc_data_b_n<0>" LOC = T35 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DB0- ZDOK F12 N<34>\n']; str = [str,'NET "adc1_adc_data_a_p<8>" LOC = R40 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA8+ ZDOK F13 P<35>\n']; str = [str,'NET "adc1_adc_data_a_n<8>" LOC = T40 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA8- ZDOK F14 N<35>\n']; str = [str,'NET "adc1_adc_data_a_p<5>" LOC = M36 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA5+ ZDOK F15, P<36>\n']; str = [str,'NET "adc1_adc_data_a_n<5>" LOC = M37 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA5- ZDOK F16, N<36>\n']; str = [str,'NET "adc1_adc_data_a_p<2>" LOC = N38 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA2+ ZDOK F17, P<37>\n']; str = [str,'NET "adc1_adc_data_a_n<2>" LOC = N39 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA2- ZDOK F18, N<37>\n']; str = [str,'NET "adc1_adc_data_a_p<0>" LOC = AE30 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA0+ ZDOK F19, adc1_clk_p<1>\n']; str = [str,'NET "adc1_adc_data_a_n<0>" LOC = AF30 | IOSTANDARD = LVDS_25 | DIFF_TERM = TRUE; # DA0- ZDOK F20, adc1_clk_n<1>\n']; str = [str,'\n']; str = [str,'NET "adc1_iic_sda" LOC = Y32 | IOSTANDARD = LVCMOS25 | SLEW = SLOW;\n']; str = [str,'NET "adc1_iic_scl" LOC = AA37 | IOSTANDARD = LVCMOS25 | SLEW = SLOW;\n']; str = [str,'\n']; str = [str,'NET "adc1_ser_clk" LOC = AA34 | IOSTANDARD = LVCMOS25 | SLEW = SLOW;\n']; str = [str,'NET "adc1_ser_dat" LOC = Y34 | IOSTANDARD = LVCMOS25 | SLEW = SLOW;\n']; str = [str,'NET "adc1_ser_cs" LOC = Y37 | IOSTANDARD = LVCMOS25 | SLEW = SLOW;\n']; str = [str,'\n']; % end case 'adc1' end % switch adc_str % end case 'ROACH2' otherwise error(['Unsupported hardware system: ',s.hw_sys]); end % switch hw_sys
github
mstrader/mlib_devel-master
set.m
.m
mlib_devel-master/xps_library/@xps_mkadc/set.m
1,837
utf_8
36e88663abfc3840e2a2596d6628fb05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = set(b,field,value) try eval(['b.',field,'=value;']); catch b.xps_block = set(b.xps_block,field,value); end
github
mstrader/mlib_devel-master
gen_mhs_ip.m
.m
mlib_devel-master/xps_library/@xps_mkadc/gen_mhs_ip.m
5,823
utf_8
35fd1f212f1606710287df4f4021f557
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [str,opb_addr_end,opb_addr_start] = gen_mhs_ip(blk_obj,opb_addr_start,opb_name) hw_adc = get(blk_obj, 'hw_adc'); %% HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK %% Remove gain control ports from adc_interface intstantiation %gain_load_port = ''; %gain_value_port = ''; %clk_src = get(blk_obj,'clk_src'); %en_gain = get(blk_obj,'en_gain'); %foo = get(blk_obj,'ports'); %portname = fieldnames(foo); %for n = 1:length(portname) % if (~isempty(regexp(portname{n},'gain_value'))) % gain_value_port = portname{n}; % foo = rmfield(foo, portname{n}); % end % if (~isempty(regexp(portname{n},'gain_load'))) % gain_load_port = portname{n}; % foo = rmfield(foo, portname{n}); % end % %port_names{n} %end %blk_obj = set(blk_obj,'ports',foo); % Add the MHS entry for the ADC Interface [str,opb_addr_end,opb_addr_start] = gen_mhs_ip(blk_obj.xps_block, opb_addr_start, opb_name); str = [str, '\n']; if (strcmp(hw_adc, 'adc1')) base_addr = '0x00048000'; high_addr = '0x000487ff'; else base_addr = '0x00040000'; high_addr = '0x000407ff'; end % Add IIC controller str = [str, 'BEGIN kat_adc_iic_controller', '\n']; str = [str, ' PARAMETER HW_VER = 1.00.a', '\n']; str = [str, ' PARAMETER INSTANCE = iic_', hw_adc, '\n']; str = [str, ' PARAMETER C_BASEADDR = ', base_addr, '\n']; str = [str, ' PARAMETER C_HIGHADDR = ', high_addr, '\n']; %if (strcmp(en_gain,'on')) % str = [str, ' PARAMETER EN_GAIN = 1', '\n']; %end str = [str, ' PARAMETER CORE_FREQ = 66666', '\n']; str = [str, ' PARAMETER IIC_FREQ = 100', '\n']; str = [str, ' BUS_INTERFACE SOPB = opb0', '\n']; str = [str, ' PORT OPB_Clk = epb_clk', '\n']; str = [str, '', '\n']; str = [str, ' PORT sda_i = iic_', hw_adc, '_sda_i', '\n']; str = [str, ' PORT sda_o = iic_', hw_adc, '_sda_o', '\n']; str = [str, ' PORT sda_t = iic_', hw_adc, '_sda_t', '\n']; str = [str, ' PORT scl_i = iic_', hw_adc, '_scl_i', '\n']; str = [str, ' PORT scl_o = iic_', hw_adc, '_scl_o', '\n']; str = [str, ' PORT scl_t = iic_', hw_adc, '_scl_t', '\n']; %str = [str, ' PORT gain_value = ', gain_value_port, '\n']; %str = [str, ' PORT gain_load = ', gain_load_port, '\n']; str = [str, ' PORT app_clk = epb_clk', '\n']; str = [str, 'END', '\n']; str = [str, '', '\n']; str = [str, 'PORT ', hw_adc, '_iic_sda = ', hw_adc, '_iic_sda, DIR = IO', '\n']; str = [str, 'PORT ', hw_adc, '_iic_scl = ', hw_adc, '_iic_scl, DIR = IO', '\n']; str = [str, '', '\n']; str = [str, 'BEGIN iic_infrastructure', '\n']; str = [str, ' PARAMETER HW_VER = 1.00.a', '\n']; str = [str, ' PARAMETER INSTANCE = iic_infrastructure_', hw_adc, '\n']; str = [str, ' PORT Sda_I = iic_', hw_adc, '_sda_i', '\n']; str = [str, ' PORT Sda_O = iic_', hw_adc, '_sda_o', '\n']; str = [str, ' PORT Sda_T = iic_', hw_adc, '_sda_t', '\n']; str = [str, ' PORT Scl_I = iic_', hw_adc, '_scl_i', '\n']; str = [str, ' PORT Scl_O = iic_', hw_adc, '_scl_o', '\n']; str = [str, ' PORT Scl_T = iic_', hw_adc, '_scl_t', '\n']; str = [str, ' PORT Sda = ', hw_adc, '_iic_sda', '\n']; str = [str, ' PORT Scl = ', hw_adc, '_iic_scl', '\n']; str = [str, 'END', '\n'];
github
mstrader/mlib_devel-master
xps_mkadc.m
.m
mlib_devel-master/xps_library/@xps_mkadc/xps_mkadc.m
6,159
utf_8
6092f2e173a6a4c90471cfdbb7f80b76
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Center for Astronomy Signal Processing and Electronics Research % % http://seti.ssl.berkeley.edu/casper/ % % Copyright (C) 2006 University of California, Berkeley % % % % This program is free software; you can redistribute it and/or modify % % it under the terms of the GNU General Public License as published by % % the Free Software Foundation; either version 2 of the License, or % % (at your option) any later version. % % % % This program is distributed in the hope that it will be useful, % % but WITHOUT ANY WARRANTY; without even the implied warranty of % % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % % GNU General Public License for more details. % % % % You should have received a copy of the GNU General Public License along % % with this program; if not, write to the Free Software Foundation, Inc., % % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function b = xps_mkadc(blk_obj) if ~isa(blk_obj,'xps_block') error('XPS_ADC class requires a xps_block class object'); end if ~strcmp(get(blk_obj,'type'),'xps_mkadc') error(['Wrong XPS block type: ',get(blk_obj,'type')]); end blk_name = get(blk_obj,'simulink_name'); xsg_obj = get(blk_obj,'xsg_obj'); s.hw_sys = get(xsg_obj,'hw_sys'); s.hw_adc = get_param(blk_name,'adc_brd'); s.adc_clk_rate = eval_param(blk_name,'adc_clk_rate'); s.clk_src = get(xsg_obj,'clk_src'); % Get MASK paramters from the one_GbE yellow block s.hw_sys = get(xsg_obj,'hw_sys'); s.gray_en = num2str(strcmp(get_param(blk_name, 'gray_en'), 'on')); % These MASK parameters ends up to be generics for the HDL (mkadc_interface.vhd) % also see mkadc_interface_v2_1_0.mpd for connections and parameter declarations parameters.G_GRAY_EN = s.gray_en; switch s.hw_sys case {'ROACH2', 'MKDIG'} if ~isempty(find(strcmp(s.hw_adc, {'adc0', 'adc1'}))) s.adc_str = s.hw_adc; else error(['Unsupported adc board: ',s.hw_adc]); end % if ~isempty(find(strcmp(s.hw_adc, {'adc0', 'adc1'}))) ucf_constraints_clock = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE', 'PERIOD', [num2str(1000/s.adc_clk_rate*4),' ns']); ucf_constraints_term = struct('IOSTANDARD', 'LVDS_25', 'DIFF_TERM', 'TRUE'); ucf_constraints_noterm = struct('IOSTANDARD', 'LVDS_25'); % end case {'ROACH', 'ROACH2'} otherwise error(['Unsupported hardware system: ',s.hw_sys]); end % end switch s.hw_sys b = class(s,'xps_mkadc',blk_obj); % ip name and version b = set(b, 'ip_name', 'mkadc_interface'); switch s.hw_sys case {'ROACH2', 'MKDIG'} b = set(b, 'ip_version', '1.00.a'); %hard-coded opb0 devices b = set(b, 'opb0_devices', 2); %IIC and controller end % switch s.hw_sys supp_ip_names = {'', 'opb_katadccontroller'}; supp_ip_versions = {'', '1.00.a'}; b = set(b, 'supp_ip_names', supp_ip_names); b = set(b, 'supp_ip_versions', supp_ip_versions); b = set(b,'parameters',parameters); % misc ports misc_ports.ctrl_clk_in = {1 'in' get(xsg_obj,'clk_src')}; misc_ports.ctrl_clk_out = {1 'out' [s.adc_str,'_clk']}; misc_ports.ctrl_clk90_out = {1 'out' [s.adc_str,'_clk90']}; misc_ports.ctrl_clk180_out = {1 'out' [s.adc_str,'_clk180']}; misc_ports.ctrl_clk270_out = {1 'out' [s.adc_str,'_clk270']}; misc_ports.power_on_rst = {1 'in' ['power_on_rst']}; switch s.hw_sys case {'ROACH2', 'MKDIG'} misc_ports.ctrl_mmcm_locked = {1 'out' [s.adc_str,'_mmcm_locked']}; misc_ports.mmcm_reset = {1 'in' [s.adc_str,'_mmcm_reset']}; misc_ports.mmcm_psdone = {1 'out' [s.adc_str,'_psdone']}; misc_ports.mmcm_psclk = {1 'in' ['epb_clk']}; misc_ports.mmcm_psen = {1 'in' [s.adc_str,'_psen']}; misc_ports.mmcm_psincdec = {1 'in' [s.adc_str,'_psincdec']}; otherwise error(['Unsupported hardware system: ',s.hw_sys]); end b = set(b,'misc_ports',misc_ports); % external ports mhs_constraints = struct('SIGIS','CLK', 'CLK_FREQ',num2str(s.adc_clk_rate*1e6*2)); adcport = [s.hw_sys, '.', 'zdok', s.adc_str(length(s.adc_str))]; ext_ports.adc_clk_p = {1 'in' [s.adc_str,'_adc_clk_p'] ['{',adcport,'_p{[19]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock }; ext_ports.adc_clk_n = {1 'in' [s.adc_str,'_adc_clk_n'] ['{',adcport,'_n{[19]+1,:}}'] 'vector=false' mhs_constraints ucf_constraints_clock }; ext_ports.adc_sync_p = {1 'in' [s.adc_str,'_adc_sync_p'] }; ext_ports.adc_sync_n = {1 'in' [s.adc_str,'_adc_sync_n'] }; ext_ports.adc_or_a_p = {1 'in' [s.adc_str,'_adc_or_a_p'] }; ext_ports.adc_or_a_n = {1 'in' [s.adc_str,'_adc_or_a_n'] }; ext_ports.adc_or_b_p = {1 'in' [s.adc_str,'_adc_or_b_p'] }; ext_ports.adc_or_b_n = {1 'in' [s.adc_str,'_adc_or_b_n'] }; ext_ports.adc_data_a_p = {10 'in' [s.adc_str,'_adc_data_a_p'] }; ext_ports.adc_data_a_n = {10 'in' [s.adc_str,'_adc_data_a_n'] }; ext_ports.adc_data_b_p = {10 'in' [s.adc_str,'_adc_data_b_p'] }; ext_ports.adc_data_b_n = {10 'in' [s.adc_str,'_adc_data_b_n'] }; ext_ports.adc_reset = {1 'out' [s.adc_str,'_adc_reset'] }; ext_ports.adc_demux_bist = {1 'out' [s.adc_str,'_adc_demux_bist'] }; b = set(b,'ext_ports',ext_ports);
github
roboticslab-uc3m/yarp-devices-master
testRemoteVelEnc_sfun.m
.m
yarp-devices-master/examples/simulink/testRemoteVelEnc_sfun.m
11,273
utf_8
e13541a729d0c52f84759a0ffbb91504
function [sys,x0,str,ts,simStateCompliance] = testRemoteVelEnc_sfun(t,x,u,flag,theName,theNumAxes) %SFUNTMPL General M-file S-function template % With M-file S-functions, you can define you own ordinary differential % equations (ODEs), discrete system equations, and/or just about % any type of algorithm to be used within a Simulink block diagram. % % The general form of an M-File S-function syntax is: % [SYS,X0,STR,TS,SIMSTATECOMPLIANCE] = SFUNC(T,X,U,FLAG,P1,...,Pn) % % What is returned by SFUNC at a given point in time, T, depends on the % value of the FLAG, the current state vector, X, and the current % input vector, U. % % FLAG RESULT DESCRIPTION % ----- ------ -------------------------------------------- % 0 [SIZES,X0,STR,TS] Initialization, return system sizes in SYS, % initial state in X0, state ordering strings % in STR, and sample times in TS. % 1 DX Return continuous state derivatives in SYS. % 2 DS Update discrete states SYS = X(n+1) % 3 Y Return outputs in SYS. % 4 TNEXT Return next time hit for variable step sample % time in SYS. % 5 Reserved for future (root finding). % 9 [] Termination, perform any cleanup SYS=[]. % % % The state vectors, X and X0 consists of continuous states followed % by discrete states. % % Optional parameters, P1,...,Pn can be provided to the S-function and % used during any FLAG operation. % % When SFUNC is called with FLAG = 0, the following information % should be returned: % % SYS(1) = Number of continuous states. % SYS(2) = Number of discrete states. % SYS(3) = Number of outputs. % SYS(4) = Number of inputs. % Any of the first four elements in SYS can be specified % as -1 indicating that they are dynamically sized. The % actual length for all other flags will be equal to the % length of the input, U. % SYS(5) = Reserved for root finding. Must be zero. % SYS(6) = Direct feedthrough flag (1=yes, 0=no). The s-function % has direct feedthrough if U is used during the FLAG=3 % call. Setting this to 0 is akin to making a promise that % U will not be used during FLAG=3. If you break the promise % then unpredictable results will occur. % SYS(7) = Number of sample times. This is the number of rows in TS. % % % X0 = Initial state conditions or [] if no states. % % STR = State ordering strings which is generally specified as []. % % TS = An m-by-2 matrix containing the sample time % (period, offset) information. Where m = number of sample % times. The ordering of the sample times must be: % % TS = [0 0, : Continuous sample time. % 0 1, : Continuous, but fixed in minor step % sample time. % PERIOD OFFSET, : Discrete sample time where % PERIOD > 0 & OFFSET < PERIOD. % -2 0]; : Variable step discrete sample time % where FLAG=4 is used to get time of % next hit. % % There can be more than one sample time providing % they are ordered such that they are monotonically % increasing. Only the needed sample times should be % specified in TS. When specifying more than one % sample time, you must check for sample hits explicitly by % seeing if % abs(round((T-OFFSET)/PERIOD) - (T-OFFSET)/PERIOD) % is within a specified tolerance, generally 1e-8. This % tolerance is dependent upon your model's sampling times % and simulation time. % % You can also specify that the sample time of the S-function % is inherited from the driving block. For functions which % change during minor steps, this is done by % specifying SYS(7) = 1 and TS = [-1 0]. For functions which % are held during minor steps, this is done by specifying % SYS(7) = 1 and TS = [-1 1]. % % SIMSTATECOMPLIANCE = Specifices how to handle this block when saving and % restoring the complete simulation state of the % model. The allowed values are: 'DefaultSimState', % 'HasNoSimState' or 'DisallowSimState'. If this value % is not speficified, then the block's compliance with % simState feature is set to 'UknownSimState'. % % Copyright 1990-2007 The MathWorks, Inc. % $Revision: 1.18.2.3 $ % % The following outlines the general structure of an S-function. % switch flag, %%%%%%%%%%%%%%%%%% % Initialization % %%%%%%%%%%%%%%%%%% case 0, [sys,x0,str,ts,simStateCompliance]=mdlInitializeSizes(theName,theNumAxes); %%%%%%%%%%%%%%% % Derivatives % %%%%%%%%%%%%%%% case 1, sys=mdlDerivatives(t,x,u); %%%%%%%%%% % Update % %%%%%%%%%% case 2, sys=mdlUpdate(t,x,u); %%%%%%%%%%% % Outputs % %%%%%%%%%%% case 3, sys=mdlOutputs(t,x,u); %%%%%%%%%%%%%%%%%%%%%%% % GetTimeOfNextVarHit % %%%%%%%%%%%%%%%%%%%%%%% case 4, sys=mdlGetTimeOfNextVarHit(t,x,u); %%%%%%%%%%%%% % Terminate % %%%%%%%%%%%%% case 9, sys=mdlTerminate(t,x,u); %%%%%%%%%%%%%%%%%%%% % Unexpected flags % %%%%%%%%%%%%%%%%%%%% otherwise DAStudio.error('Simulink:blocks:unhandledFlag', num2str(flag)); end % end testRemoteVelEnc %============================================================================= % mdlInitializeSizes % Return the sizes, initial conditions, and sample times for the S-function. %============================================================================= % function [sys,x0,str,ts,simStateCompliance]=mdlInitializeSizes(fName,fAxes) % % call simsizes for a sizes structure, fill it in and convert it to a % sizes array. % % Note that in this example, the values are hard coded. This is not a % recommended practice as the characteristics of the block are typically % defined by the S-function parameters. % sizes = simsizes; global keepAxes; keepAxes = fAxes; sizes.NumContStates = 0; sizes.NumDiscStates = 0; sizes.NumOutputs = fAxes; sizes.NumInputs = fAxes; sizes.DirFeedthrough = 1; sizes.NumSampleTimes = 1; % at least one sample time is needed sys = simsizes(sizes); % % initialize the initial conditions % x0 = []; % % str is always an empty matrix % str = []; % % initialize the array of sample times % ts = [0 0]; % Specify the block simStateComliance. The allowed values are: % 'UnknownSimState', < The default setting; warn and assume DefaultSimState % 'DefaultSimState', < Same sim state as a built-in block % 'HasNoSimState', < No sim state % 'DisallowSimState' < Error out when saving or restoring the model sim state simStateCompliance = 'UnknownSimState'; % Now do all the YARP stuff. fprintf('Welcome to testRemoteVelEnc. This program tries to open a port\n'); fprintf('called /testRemoteVelEnc, connect to a remote controlboard called\n'); fprintf('%s, and then stream some doubles!!!\n',fName); LoadYarp; global dd; global vel; global enc; options = yarp.Property; % create an instance of Property, a nice YARP class for storing name-value (key-value) pairs options.put('device','remote_controlboard'); % we add a name-value pair that indicates the YARP device options.put('remote',fName); % we add info on to whom we will connect options.put('local','/testRemoteVelEnc'); % we add info on how we will call ourselves on the YARP network dd = yarp.PolyDriver(options); % create a YARP multi-use driver with the given options if isequal(dd.isValid,1) disp '[success] robot available'; else disp '[warning] robot NOT available, does it exist?'; end vel = dd.viewIVelocityControl; % make a velocity controller object we call 'vel' if isequal(vel,[]) disp '[warning] velocity NOT available, does it exist?'; else disp '[success] robot velocity interface available'; end enc = dd.viewIEncoders; % make an encoder controller object we call 'enc' if isequal(enc,[]) disp '[warning] encoders NOT available, does it exist?'; else disp '[success] robot encoder interface available'; end if isequal(enc.getAxes,fAxes) fprintf('[success] robot reports %d axes as configured in block\n',fAxes); else fprintf('[warning] block configured for %d axes but robot reports %d axes\n',fAxes,enc.getAxes); end global dUpdated; dUpdated = zeros(fAxes,1); vel.setVelocityMode; % end mdlInitializeSizes %============================================================================= % mdlDerivatives % Return the derivatives for the continuous states. %============================================================================= % function sys=mdlDerivatives(t,x,u) sys = []; % end mdlDerivatives %============================================================================= % mdlUpdate % Handle discrete state updates, sample time hits, and major time step % requirements. %============================================================================= % function sys=mdlUpdate(t,x,u) global keepAxes; global enc; global vel; global dUpdated; vEnc = yarp.DVector(keepAxes); % create a YARP vector of doubles the size of the number of axes enc.getEncoders(vEnc); for i=1:1:keepAxes dUpdated(i) = vEnc.get(i-1); end %vVel = yarp.DVector; % create a YARP vector of doubles %for i=1:1:keepAxes % vVel.add(u(i)); %end %vel.velocityMove(vVel); for i=1:1:keepAxes vel.velocityMove(i-1,u(i)); end sys = []; % end mdlUpdate %============================================================================= % mdlOutputs % Return the block outputs. %============================================================================= % function sys=mdlOutputs(t,x,u) global dUpdated; sys = [dUpdated]; % end mdlOutputs %============================================================================= % mdlGetTimeOfNextVarHit % Return the time of the next hit for this block. Note that the result is % absolute time. Note that this function is only used when you specify a % variable discrete-time sample time [-2 0] in the sample time array in % mdlInitializeSizes. %============================================================================= % function sys=mdlGetTimeOfNextVarHit(t,x,u) sampleTime = 1; % Example, set the next hit to be one second later. sys = t + sampleTime; % end mdlGetTimeOfNextVarHit %============================================================================= % mdlTerminate % Perform any end of simulation tasks. %============================================================================= % function sys=mdlTerminate(t,x,u) global dd; global vel; vel.stop; dd.close; disp '[success] called for device close' sys = []; % end mdlTerminate
github
aedanli/Snake-master
snakegame.m
.m
Snake-master/snakegame.m
5,320
utf_8
7a54572334d579d97de117f4ccd4fafd
clear all; % Aedan Yue Li % Memory & Perception Lab, University of Toronto % August 27, 2017 %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%% SNAKE GAME %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % CONTROLS: % A - LEFT % D - RIGHT % W - UP % S - DOWN % ESC - PAUSE % 0 - RESTART %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OPTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% world_size = [30]; % set world size game_speed = [0.05]; % set snake travel speed in seconds item_size = [400]; % size of items snake_size = 1; % set default snake size winning_points = [30]; % set points to win game borders_on = [1]; % if one, turn borders on; if 0, turn off self_harm_on = [1]; % if one, turn self harm on %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% rng('shuffle'); % reinitialize rng snake_game = figure('KeyPressFcn', {@keypress_Callback}); % State builder game_state = 1; % while true % rand food position food_pos_x = randi((world_size),1); food_pos_y = randi((world_size),1); % resize snake relative to world size item_size = item_size/world_size; % generate the snake position on game state current_pos_x = randi(world_size,1); current_pos_y = randi(world_size,1); while game_state == 1 % build snake snake_matrix = [current_pos_x, current_pos_y]; for ii = 1:snake_size snake_matrix(ii,:) = [current_pos_x - ii, current_pos_y]; end moving_snake = snake_matrix; % while true snake_game = 1; game_speed_mode = game_speed; while snake_game == 1 % food if moving_snake(1,1) == food_pos_x && moving_snake(1,2) == food_pos_y food_pos_x = randi(world_size,1); food_pos_y = randi(world_size,1); snake_size = snake_size + 1; end % if left key if get(snake_game, 'CurrentKey') == 'a' moving_snake(2:snake_size,1) = moving_snake(1:snake_size-1,1); moving_snake(2:snake_size,2) = moving_snake(1:snake_size-1,2); moving_snake(1,1) = moving_snake(1,1) - 1; moving_snake(1,2) = moving_snake(1,2); if borders_on == 0 if moving_snake(1,1) < 0 moving_snake(1,1) = moving_snake(1,1) + world_size; end end % if right key elseif get(snake_game, 'CurrentKey') == 'd' moving_snake(2:snake_size,1) = moving_snake(1:snake_size-1,1); moving_snake(2:snake_size,2) = moving_snake(1:snake_size-1,2); moving_snake(1,1) = moving_snake(1,1) + 1; moving_snake(1,2) = moving_snake(1,2); if borders_on == 0 if moving_snake(1,1) > world_size moving_snake(1,1) = moving_snake(1,1) - world_size; end end % if up key elseif get(snake_game, 'CurrentKey') == 'w' moving_snake(2:snake_size,1) = moving_snake(1:snake_size-1,1); moving_snake(2:snake_size,2) = moving_snake(1:snake_size-1,2); moving_snake(1,1) = moving_snake(1,1); moving_snake(1,2) = moving_snake(1,2) + 1; if borders_on == 0 if moving_snake(1,2) > world_size moving_snake(1,2) = moving_snake(1,2) - world_size; end end % if down key elseif get(snake_game, 'CurrentKey') == 's' moving_snake(2:snake_size,1) = moving_snake(1:snake_size-1,1); moving_snake(2:snake_size,2) = moving_snake(1:snake_size-1,2); moving_snake(1,1) = moving_snake(1,1); moving_snake(1,2) = moving_snake(1,2) - 1; if borders_on == 0 if moving_snake(1,2) < 0 moving_snake(1,2) = moving_snake(1,2) + world_size; end end end if borders_on == 1 % if you hit border, end game if abs(moving_snake(1,1)) == world_size+1 || moving_snake(1,1) < 0 snake_size = 0; disp('GG') elseif abs(moving_snake(1,2)) == world_size+1 || moving_snake(1,2) < 0 snake_size = 0; disp('GG') else end end % if you press 0, restart game if get(snake_game, 'CurrentKey') == '0' snake_size = 1; snake_game = 0; else current_pos_x = randi(world_size,1); current_pos_y = randi(world_size,1); end if self_harm_on == 1 % if you hit yourself, end game if snake_size > 1 if sum(ismember(moving_snake(2:snake_size,:), moving_snake(1,:),'rows')) == 1 snake_size = 0; disp('GG') end end end % if points greater than winning points set if snake_size > winning_points disp('You win!') waitforbuttonpress; end % plot snake for ii = 1:snake_size plot([moving_snake(ii,1) moving_snake(ii,1)], [moving_snake(ii,2) moving_snake(ii,2)], 's', 'MarkerFaceColor', [.95 .95 .95], 'MarkerSize', item_size); hold on end plot(food_pos_x, food_pos_y, '.', 'MarkerSize', item_size); axis([0, world_size, 0, world_size])%creates the axis for gameplay title(['Score = ' num2str(snake_size-1)]) set(gca,'xtick',[]) set(gca,'xticklabel',[]) set(gca,'ytick',[]) set(gca,'yticklabel',[]) hold off pause(game_speed_mode) % delay end end function keypress_Callback(keypress, ~) get(keypress, 'CurrentKey'); end
github
mahyarnajibi/caffe-ssh-master
classification_demo.m
.m
caffe-ssh-master/matlab/demo/classification_demo.m
5,466
utf_8
45745fb7cfe37ef723c307dfa06f1b97
function [scores, maxlabel] = classification_demo(im, use_gpu) % [scores, maxlabel] = classification_demo(im, use_gpu) % % Image classification demo using BVLC CaffeNet. % % IMPORTANT: before you run this demo, you should download BVLC CaffeNet % from Model Zoo (http://caffe.berkeleyvision.org/model_zoo.html) % % **************************************************************************** % For detailed documentation and usage on Caffe's Matlab interface, please % refer to the Caffe Interface Tutorial at % http://caffe.berkeleyvision.org/tutorial/interfaces.html#matlab % **************************************************************************** % % input % im color image as uint8 HxWx3 % use_gpu 1 to use the GPU, 0 to use the CPU % % output % scores 1000-dimensional ILSVRC score vector % maxlabel the label of the highest score % % You may need to do the following before you start matlab: % $ export LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64:/usr/local/cuda-5.5/lib64 % $ export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 % Or the equivalent based on where things are installed on your system % and what versions are installed. % % Usage: % im = imread('../../examples/images/cat.jpg'); % scores = classification_demo(im, 1); % [score, class] = max(scores); % Five things to be aware of: % caffe uses row-major order % matlab uses column-major order % caffe uses BGR color channel order % matlab uses RGB color channel order % images need to have the data mean subtracted % Data coming in from matlab needs to be in the order % [width, height, channels, images] % where width is the fastest dimension. % Here is the rough matlab code for putting image data into the correct % format in W x H x C with BGR channels: % % permute channels from RGB to BGR % im_data = im(:, :, [3, 2, 1]); % % flip width and height to make width the fastest dimension % im_data = permute(im_data, [2, 1, 3]); % % convert from uint8 to single % im_data = single(im_data); % % reshape to a fixed size (e.g., 227x227). % im_data = imresize(im_data, [IMAGE_DIM IMAGE_DIM], 'bilinear'); % % subtract mean_data (already in W x H x C with BGR channels) % im_data = im_data - mean_data; % If you have multiple images, cat them with cat(4, ...) % Add caffe/matlab to your Matlab search PATH in order to use matcaffe if exist('../+caffe', 'dir') addpath('..'); else error('Please run this demo from caffe/matlab/demo'); end % Set caffe mode if exist('use_gpu', 'var') && use_gpu caffe.set_mode_gpu(); gpu_id = 0; % we will use the first gpu in this demo caffe.set_device(gpu_id); else caffe.set_mode_cpu(); end % Initialize the network using BVLC CaffeNet for image classification % Weights (parameter) file needs to be downloaded from Model Zoo. model_dir = '../../models/bvlc_reference_caffenet/'; net_model = [model_dir 'deploy.prototxt']; net_weights = [model_dir 'bvlc_reference_caffenet.caffemodel']; phase = 'test'; % run with phase test (so that dropout isn't applied) if ~exist(net_weights, 'file') error('Please download CaffeNet from Model Zoo before you run this demo'); end % Initialize a network net = caffe.Net(net_model, net_weights, phase); if nargin < 1 % For demo purposes we will use the cat image fprintf('using caffe/examples/images/cat.jpg as input image\n'); im = imread('../../examples/images/cat.jpg'); end % prepare oversampled input % input_data is Height x Width x Channel x Num tic; input_data = {prepare_image(im)}; toc; % do forward pass to get scores % scores are now Channels x Num, where Channels == 1000 tic; % The net forward function. It takes in a cell array of N-D arrays % (where N == 4 here) containing data of input blob(s) and outputs a cell % array containing data from output blob(s) scores = net.forward(input_data); toc; scores = scores{1}; scores = mean(scores, 2); % take average scores over 10 crops [~, maxlabel] = max(scores); % call caffe.reset_all() to reset caffe caffe.reset_all(); % ------------------------------------------------------------------------ function crops_data = prepare_image(im) % ------------------------------------------------------------------------ % caffe/matlab/+caffe/imagenet/ilsvrc_2012_mean.mat contains mean_data that % is already in W x H x C with BGR channels d = load('../+caffe/imagenet/ilsvrc_2012_mean.mat'); mean_data = d.mean_data; IMAGE_DIM = 256; CROPPED_DIM = 227; % Convert an image returned by Matlab's imread to im_data in caffe's data % format: W x H x C with BGR channels im_data = im(:, :, [3, 2, 1]); % permute channels from RGB to BGR im_data = permute(im_data, [2, 1, 3]); % flip width and height im_data = single(im_data); % convert from uint8 to single im_data = imresize(im_data, [IMAGE_DIM IMAGE_DIM], 'bilinear'); % resize im_data im_data = im_data - mean_data; % subtract mean_data (already in W x H x C, BGR) % oversample (4 corners, center, and their x-axis flips) crops_data = zeros(CROPPED_DIM, CROPPED_DIM, 3, 10, 'single'); indices = [0 IMAGE_DIM-CROPPED_DIM] + 1; n = 1; for i = indices for j = indices crops_data(:, :, :, n) = im_data(i:i+CROPPED_DIM-1, j:j+CROPPED_DIM-1, :); crops_data(:, :, :, n+5) = crops_data(end:-1:1, :, :, n); n = n + 1; end end center = floor(indices(2) / 2) + 1; crops_data(:,:,:,5) = ... im_data(center:center+CROPPED_DIM-1,center:center+CROPPED_DIM-1,:); crops_data(:,:,:,10) = crops_data(end:-1:1, :, :, 5);
github
adrianbg/kaldi.js-master
Generate_mcTrainData_cut.m
.m
kaldi.js-master/egs/reverb/s5/local/Generate_mcTrainData_cut.m
7,311
utf_8
f59dd892f0f8da04a515a2c58ff50a69
function Generate_mcTrainData_cut(WSJ_dir_name, save_dir) % % Input variables: % WSJ_dir_name: string name of user's clean wsjcam0 corpus directory % (*Directory structure for wsjcam0 corpushas to be kept as it is after obtaining it from LDC. % Otherwise this script does not work.) % % This function generates multi-condition traiing data % based on the following items: % 1. wsjcam0 corpus (distributed from the LDC) % 2. room impulse responses (ones under ./RIR/) % 3. noise (ones under ./NOISE/). % Generated data has the same directory structure as original wsjcam0 corpus. % if nargin<2 error('Usage: Generate_mcTrainData(WSJCAM0_data_path, save_dir) *Note that the input variable WSJCAM0_data_path should indicate the directory name of your clean WSJCAM0 corpus. '); end if exist([WSJ_dir_name,'/data/'])==0 error(['Could not find wsjcam0 corpus : Please confirm if ',WSJ_dir_name,' is a correct path to your clean WSJCAM0 corpus']); end if ~exist('save_dir', 'var') error('You have to set the save_dir variable in the code before running this script!') end display(['Name of directory for original wsjcam0: ',WSJ_dir_name]) display(['Name of directory to save generated multi-condition training data: ',save_dir]) unix(['chmod u+x sphere_to_wave.csh']); unix(['chmod u+x bin/*']); % Parameters related to acoustic conditions SNRdB=20; % List of WSJ speech data flist1='etc/audio_si_tr.lst'; % % List of RIRs % num_RIRvar=24; RIR_sim1='./RIR/RIR_SmallRoom1_near_AnglA.wav'; RIR_sim2='./RIR/RIR_SmallRoom1_near_AnglB.wav'; RIR_sim3='./RIR/RIR_SmallRoom1_far_AnglA.wav'; RIR_sim4='./RIR/RIR_SmallRoom1_far_AnglB.wav'; RIR_sim5='./RIR/RIR_MediumRoom1_near_AnglA.wav'; RIR_sim6='./RIR/RIR_MediumRoom1_near_AnglB.wav'; RIR_sim7='./RIR/RIR_MediumRoom1_far_AnglA.wav'; RIR_sim8='./RIR/RIR_MediumRoom1_far_AnglB.wav'; RIR_sim9='./RIR/RIR_LargeRoom1_near_AnglA.wav'; RIR_sim10='./RIR/RIR_LargeRoom1_near_AnglB.wav'; RIR_sim11='./RIR/RIR_LargeRoom1_far_AnglA.wav'; RIR_sim12='./RIR/RIR_LargeRoom1_far_AnglB.wav'; RIR_sim13='./RIR/RIR_SmallRoom2_near_AnglA.wav'; RIR_sim14='./RIR/RIR_SmallRoom2_near_AnglB.wav'; RIR_sim15='./RIR/RIR_SmallRoom2_far_AnglA.wav'; RIR_sim16='./RIR/RIR_SmallRoom2_far_AnglB.wav'; RIR_sim17='./RIR/RIR_MediumRoom2_near_AnglA.wav'; RIR_sim18='./RIR/RIR_MediumRoom2_near_AnglB.wav'; RIR_sim19='./RIR/RIR_MediumRoom2_far_AnglA.wav'; RIR_sim20='./RIR/RIR_MediumRoom2_far_AnglB.wav'; RIR_sim21='./RIR/RIR_LargeRoom2_near_AnglA.wav'; RIR_sim22='./RIR/RIR_LargeRoom2_near_AnglB.wav'; RIR_sim23='./RIR/RIR_LargeRoom2_far_AnglA.wav'; RIR_sim24='./RIR/RIR_LargeRoom2_far_AnglB.wav'; % % List of noise % num_NOISEvar=6; noise_sim1='./NOISE/Noise_SmallRoom1'; noise_sim2='./NOISE/Noise_MediumRoom1'; noise_sim3='./NOISE/Noise_LargeRoom1'; noise_sim4='./NOISE/Noise_SmallRoom2'; noise_sim5='./NOISE/Noise_MediumRoom2'; noise_sim6='./NOISE/Noise_LargeRoom2'; % % Start generating noisy reverberant data with creating new directories % fcount=1; rcount=1; ncount=1; if save_dir(end)=='/'; save_dir_tr=[save_dir,'data/mc_train/']; else save_dir_tr=[save_dir,'/data/mc_train/']; end mkdir([save_dir_tr]); %mkdir([save_dir,'/taskfiles/']) mic_idx=['A';'B';'C';'D';'E';'F';'G';'H']; prev_fname='dummy'; for nlist=1:1 % Open file list eval(['fid=fopen(flist',num2str(nlist),',''r'');']); while 1 % Set data file name fname=fgetl(fid); if ~ischar(fname); break; end idx1=find(fname=='/'); % Make directory if there isn't any if ~strcmp(prev_fname,fname(1:idx1(end))) mkdir([save_dir_tr fname(1:idx1(end))]) end prev_fname=fname(1:idx1(end)); % load (sphere format) speech signal x=read_sphere([WSJ_dir_name,'/data/', fname]); x=x/(2^15); % conversion from short-int to float % load RIR and noise for "THIS" utterance eval(['RIR=wavread(RIR_sim',num2str(rcount),');']); eval(['NOISE=wavread([noise_sim',num2str(ceil(rcount/4)),',''_',num2str(ncount),'.wav'']);']); % Generate 8ch noisy reverberant data y=gen_obs(x,RIR,NOISE,SNRdB); % cut to length of original signal y = y(1:size(x,2),:); % rotine to cyclicly switch RIRs and noise, utterance by utterance rcount=rcount+1; if rcount>num_RIRvar;rcount=1;ncount=ncount+1;end if ncount>10;ncount=1;end % save the data y=y/4; % common normalization to all the data to prevent clipping % denominator was decided experimentally for ch=1:8 eval(['wavwrite(y(:,',num2str(ch),'),16000,''',save_dir_tr fname,'_ch',num2str(ch),'.wav'');']); end display(['sentence ',num2str(fcount),' (out of 7861) finished! (Multi-condition training data)']) fcount=fcount+1; end end %%%% function [y]=gen_obs(x,RIR,NOISE,SNRdB) % function to generate noisy reverberant data x=x'; % calculate direct+early reflection signal for calculating SNR [val,delay]=max(RIR(:,1)); before_impulse=floor(16000*0.001); after_impulse=floor(16000*0.05); RIR_direct=RIR(delay-before_impulse:delay+after_impulse,1); direct_signal=fconv(x,RIR_direct); % obtain reverberant speech for ch=1:8 rev_y(:,ch)=fconv(x,RIR(:,ch)); end % normalize noise data according to the prefixed SNR value NOISE=NOISE(1:size(rev_y,1),:); NOISE_ref=NOISE(:,1); iPn = diag(1./mean(NOISE_ref.^2,1)); Px = diag(mean(direct_signal.^2,1)); Msnr = sqrt(10^(-SNRdB/10)*iPn*Px); scaled_NOISE = NOISE*Msnr; y = rev_y + scaled_NOISE; y = y(delay:end,:); %%%% function [y]=fconv(x, h) %FCONV Fast Convolution % [y] = FCONV(x, h) convolves x and h, and normalizes the output % to +-1. % % x = input vector % h = input vector % % See also CONV % % NOTES: % % 1) I have a short article explaining what a convolution is. It % is available at http://stevem.us/fconv.html. % % %Version 1.0 %Coded by: Stephen G. McGovern, 2003-2004. % %Copyright (c) 2003, Stephen McGovern %All rights reserved. % %THIS SOFTWARE 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 COPYRIGHT OWNER 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. Ly=length(x)+length(h)-1; % Ly2=pow2(nextpow2(Ly)); % Find smallest power of 2 that is > Ly X=fft(x, Ly2); % Fast Fourier transform H=fft(h, Ly2); % Fast Fourier transform Y=X.*H; % y=real(ifft(Y, Ly2)); % Inverse fast Fourier transform y=y(1:1:Ly); % Take just the first N elements
github
pantonante/3dRegistration-master
plotly_cloud.m
.m
3dRegistration-master/PointCloudGenerator/lib/plotly_cloud.m
724
utf_8
db349dcd404dc67861f6e4ee48936335
function plotly_cloud(filename, ptCloud ) if ischar(ptCloud) ptCloud = pcread(ptCloud); end % Convert pt cloud to CSV [pathstr, name] = fileparts(filename); save_csv(ptCloud,[pathstr,name,'.csv']); % Generate page context.ptCloud = [pathstr,name,'.csv']; template = fileread('ptCloud.tpl'); tpl = LTemplate(template); doc = tpl.render(context); %Save fileID = fopen(filename,'w'); fprintf(fileID, doc); fclose(fileID); end function save_csv(ptCloud, filename) fileID = fopen(filename,'w'); fprintf(fileID,'x,y,z\n'); for i=1:length(ptCloud.Location) p = ptCloud.Location(i,:); fprintf(fileID,strjoin(arrayfun(@(n) num2str(n),p,'UniformOutput',false),',')); fprintf(fileID,'\n'); end fclose(fileID); end
github
pantonante/3dRegistration-master
textprogressbar.m
.m
3dRegistration-master/PointCloudGenerator/lib/textprogressbar.m
3,501
utf_8
efc143ea349fd442ba90b097affea8ad
% LICENSE % Copyright (c) 2010, Paul Proteus % All rights reserved. % % Redistribution and use in source and binary 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 binary 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 % % THIS SOFTWARE 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 COPYRIGHT OWNER 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. function textprogressbar(c) % This function creates a text progress bar. It should be called with a % STRING argument to initialize and terminate. Otherwise the number correspoding % to progress in % should be supplied. % INPUTS: C Either: Text string to initialize or terminate % Percentage number to show progress % OUTPUTS: N/A % Example: Please refer to demo_textprogressbar.m % Author: Paul Proteus (e-mail: proteus.paul (at) yahoo (dot) com) % Version: 1.0 % Changes tracker: 29.06.2010 - First version % Inspired by: http://blogs.mathworks.com/loren/2007/08/01/monitoring-progress-of-a-calculation/ %% Initialization persistent strCR; % Carriage return pesistent variable % Vizualization parameters strPercentageLength = 10; % Length of percentage string (must be >5) strDotsMaximum = 10; % The total number of dots in a progress bar %% Main if isempty(strCR) && ~ischar(c), % Progress bar must be initialized with a string error('The text progress must be initialized with a string'); elseif isempty(strCR) && ischar(c), % Progress bar - initialization fprintf('%s',c); strCR = -1; elseif ~isempty(strCR) && ischar(c), % Progress bar - termination strCR = []; fprintf([c '\n']); elseif isnumeric(c) % Progress bar - normal progress c = floor(c); percentageOut = [num2str(c) '%%']; percentageOut = [percentageOut repmat(' ',1,strPercentageLength-length(percentageOut)-1)]; nDots = floor(c/100*strDotsMaximum); dotOut = ['[' repmat('.',1,nDots) repmat(' ',1,strDotsMaximum-nDots) ']']; strOut = [percentageOut dotOut]; % Print it on the screen if strCR == -1, % Don't do carriage return during first run fprintf(strOut); else % Do it during all the other runs fprintf([strCR strOut]); end % Update carriage return strCR = repmat('\b',1,length(strOut)-1); else % Any other unexpected input error('Unsupported argument type'); end
github
pantonante/3dRegistration-master
ApplyRandomTransformation.m
.m
3dRegistration-master/PointCloudGenerator/lib/ApplyRandomTransformation.m
1,000
utf_8
bf5f79c45c62c463628b45f00387a120
function [ptCloud_P, T] = ApplyRandomTransformation( ptCloud, max_rot, min_t, max_t ) % apply a random rigid transformation to a point cloud to get a roto-translated % point cloud % Parameters: % ptCloud: point cloud to wich apply the random transformation % max_rot: 3D vector of max rotations (ideally 0,2?) % min_t/max_t: minimum and maximum translation, in terms of norm % random rotation with angles in [0 max_rot] R=eul2rotm([abs(max_rot(1))*rand(), ... abs(max_rot(2))*rand(), ... abs(max_rot(3))*rand()]); % random translation min_v = abs(min_t); max_v = abs(max_t); t=[ rnd_sign()*rnd_in_interval(min_v(1), max_v(1)),... rnd_sign()*rnd_in_interval(min_v(2), max_v(2)),... rnd_sign()*rnd_in_interval(min_v(3), max_v(3))]'; % compose rigid transformation T=[R,t;[0 0 0 1]]; ptCloud_P=transformPtCloud(ptCloud,T); end function s = rnd_sign() s = sign(rand()-1/2); end function r = rnd_in_interval(min_v, max_v) r = min_v + (max_v-min_v)*rand(); end
github
pantonante/3dRegistration-master
savepcd.m
.m
3dRegistration-master/PointCloudGenerator/lib/savepcd.m
4,547
utf_8
b6fc9de72f9c31f773ed98eb76072db1
%SAVEPCD Write a point cloud to file in PCD format % % SAVEPCD(FNAME, P) writes the point cloud P to the file FNAME as an % as a PCD format file. % % SAVEPCD(FNAME, P, 'binary') as above but save in binary format. Default % is ascii format. % % If P is a 2-dimensional matrix (MxN) then the columns of P represent the % 3D points and an unorganized point cloud is generated. % % If M=3 then the rows of P are x, y, z. % If M=6 then the rows of P are x, y, z, R, G, B where R,G,B are in the % range 0 to 1. % If M=7 then the rows of P are x, y, z, R, G, B, A where R,G,B,A are in % the range 0 to 1. % % If P is a 3-dimensional matrix (HxWxM) then an organized point cloud is % generated. % % If M=3 then the planes of P are x, y, z. % If M=6 then the planes of P are x, y, z, R, G, B where R,G,B are in the % range 0 to 1. % If M=7 then the planes of P are x, y, z, R, G, B, A where R,G,B,A are in % the range 0 to 1. % % Notes:: % - Only the "x y z", "x y z rgb" and "x y z rgba" field formats are currently % supported. % - Cannot write binary_compressed format files % See also pclviewer, lspcd, loaddpcd. % % Copyright (C) 2013, by Peter I. Corke % TODO % - option for binary write function savepcd(fname, points, binmode) % save points in xyz format % TODO % binary format, RGB ascii = true; if nargin < 3 ascii = true; else switch binmode case 'binary' ascii = false; case 'ascii' ascii = true; otherwise error('specify ascii or binary'); end end fp = fopen(fname, 'w'); % find the attributes of the point cloud if ndims(points) == 2 % unorganized point cloud npoints = size(points, 2); width = npoints; height = 1; nfields = size(points, 1); else width = size(points, 2); height = size(points, 1); npoints = width*height; nfields = size(points, 3); % put the data in order with one column per point points = permute(points, [2 1 3]); points = reshape(points, [], size(points,3))'; end switch nfields case 3 fields = 'x y z'; count = '1 1 1'; typ = 'F F F'; siz = '4 4 4'; case 6 fields = 'x y z rgb'; count = '1 1 1 1'; if ascii typ = 'F F F I'; else typ = 'F F F F'; end siz = '4 4 4 4'; case 7 fields = 'x y z rgba'; fields = 'x y z rgb'; count = '1 1 1 1'; if ascii typ = 'F F F I'; else typ = 'F F F F'; end siz = '4 4 4 4'; end % write the PCD file header fprintf(fp, '# .PCD v.7 - Point Cloud Data file format\n'); fprintf(fp, 'VERSION .7\n'); fprintf(fp, 'FIELDS %s\n', fields); fprintf(fp, 'SIZE %s\n', siz); fprintf(fp, 'TYPE %s\n', typ); fprintf(fp, 'COUNT %s\n', count); fprintf(fp, 'WIDTH %d\n', width); fprintf(fp, 'HEIGHT %d\n', height); fprintf(fp, 'POINTS %d\n', npoints); switch nfields case 3 case 6 % RGB data RGB = uint32(points(4:6,:)*255); rgb = (RGB(1,:)*256+RGB(2,:))*256+RGB(3,:); points = [ points(1:3,:); double(rgb)]; case 7 % RGBA data RGBA = uint32(points(4:7,:)*255); rgba = ((RGBA(1,:)*256+RGBA(2,:))*256+RGBA(3,:))*256+RGBA(4,:); points = [ points(1:3,:); double(rgba)]; end if ascii % Write ASCII format data fprintf(fp, 'DATA ascii\n'); if nfields == 3 % uncolored points fprintf(fp, '%f %f %f\n', points); else % colored points fprintf(fp, '%f %f %f %d\n', points); end else % Write binary format data fprintf(fp, 'DATA binary\n'); % for a full color point cloud the colors are not quite right in pclviewer, % color as a float has only 23 bits of mantissa precision, not enough for % RGB as 8 bits each % write color as a float not an int fwrite(fp, points, 'float32'); end fclose(fp); end
github
pantonante/3dRegistration-master
eval_with_context.m
.m
3dRegistration-master/PointCloudGenerator/lib/Lobster/eval_with_context.m
967
utf_8
919da534a968218595a7afdfebd3afa7
% TODO: reraise the error if necessary function out = eval_with_context(expression, context) % Unpack the context stuct into this workspace fields__ = fieldnames(context); for k__ = 1:length(fields__) feval(@() assignin('caller', fields__{k__}, context.(fields__{k__}))); end clear fields__ k__; try out = eval(expression); catch ME err_msg = { '' 'The following error occurred whilst evaluating a matlab expression. ' '' ' [%s] %s' '' 'The expression was: ' ' >> %s' '' 'The context variable contained the following fields: ' ' %s' '' }; fields = strjoin(fieldnames(context), ', '); error('Lobster:TemplateContextError', strjoin(err_msg, '\n'), ... ME.identifier, ME.message, expression, fields); end end
github
pantonante/3dRegistration-master
dump_template_ast.m
.m
3dRegistration-master/PointCloudGenerator/lib/Lobster/dump_template_ast.m
1,222
utf_8
439f8f173fe426bdcf5233be7647b716
function dump_template_ast(root) if isa(root, 'LTemplate') root = root.root; end print_node(root, 0) end function print_node(node, indent) node_type = class(node); indent_str = repmat(' ', 1, indent); if strcmp(node_type, 'LRoot') fprintf('%s[LRoot]\n', indent_str); elseif strcmp(node_type, 'LTextNode') fprintf('%s[Text Node] - <%s>\n', indent_str, ... strrep(node.text, sprintf('\n'), '')); elseif strcmp(node_type, 'LVarNode') fprintf('%s[Var Node] - <{{ %s }}>\n', indent_str, node.name); elseif strcmp(node_type, 'LIfNode') fprintf('%s[If Node] - <Expr: %s>\n', indent_str, node.expression); elseif strcmp(node_type, 'LElseNode') fprintf('%s[Else Node]\n', indent_str); elseif strcmp(node_type, 'LForNode') fprintf('%s[For Node] - Expr: %s in %s>\n', indent_str, node.lhs, node.rhs); elseif strcmp(node_type, 'LCallNode') fprintf('%s[Call Node] - <Expr: %s>\n', indent_str, node.expression); else fprintf('%s[Unknown Node Type] <%s>\n', indent_str, class(node)); end for k = 1:length(node.children) print_node(node.children{k}, indent+2); end end
github
ganlubbq/Target-Tracking-using-Kalman-Filter-master
KARAN_GUI_new.m
.m
Target-Tracking-using-Kalman-Filter-master/KARAN_GUI_new.m
32,190
utf_8
c71e484ddb4255d611df6cd7b672d542
function varargout = KARAN_GUI_new(varargin) % KARAN_GUI_new M-file for KARAN_GUI_new.fig % KARAN_GUI_new, by itself, creates a new KARAN_GUI_new or raises the existing % singleton*. % % H = KARAN_GUI_new returns the handle to a new KARAN_GUI_new or the handle to % the existing singleton*. % % KARAN_GUI_new('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in KARAN_GUI_new.M with the given input arguments. % % KARAN_GUI_new('Property','Value',...) creates a new KARAN_GUI_new or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before KARAN_GUI_new_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to KARAN_GUI_new_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help KARAN_GUI_new % Last Modified by GUIDE v2.5 05-Aug-2011 01:32:27 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @KARAN_GUI_new_OpeningFcn, ... 'gui_OutputFcn', @KARAN_GUI_new_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before KARAN_GUI_new is made visible. function KARAN_GUI_new_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to KARAN_GUI_new (see VARARGIN) % Choose default command line output for KARAN_GUI_new handles.output = hObject; % data.number= 0; % set(handles.videoselect,'UserData',data) % setappdata(hObject,'Push Button',slider_data); % Update handles structure guidata(hObject, handles); % UIWAIT makes KARAN_GUI_new wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = KARAN_GUI_new_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in kalman. function kalman_Callback(hObject, eventdata, handles) % hObject handle to kalman (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) R=[[0.0045,0.0045]',[0.0045,0.0455]']; H=[[1,0]',[0,1]',[0,0]',[0,0]']; num1 = str2double(get(handles.QNOISE,'String')); num2 = str2double(get(handles.PNOISE,'String')); Q = num1*eye(4); P = num2*eye(4); % Q=0.01*eye(4); % P = 10*eye(4); dt=.2; A=[[1,0,0,0]',[0,1,0,0]',[dt,0,1,0]',[0,dt,0,1]']; g = 1; % pixels^2/time step Bu = [0,0,0,dt*g]'; kfinit=0; %a=getframe(a); global avi_file; for i = 1 :size(avi_file,2) imshow(avi_file(1,i).cdata,'Parent',handles.IMAGE1); pause(.001); tic; frame=ind2rgb(avi_file(1,i).cdata,avi_file(1,i).colormap); %image(frame,'Parent',handles.axes1); axis off; frame_rgb = rgb2gray(frame); filtertype = get(handles.filter, 'String'); switch filtertype case 'Mean Filter' h = fspecial('average'); frame_rgb= imfilter(frame_rgb,h); thresh=graythresh(frame_rgb); bw=~(im2bw(frame_rgb,thresh)); labeled = bwlabel( bw,8); stats = regionprops(labeled,['basic']);%basic mohem nist [N,W] = size(stats); if N < 1 return end % do bubble sort (large to small) on regions in case there are more than 1 id = zeros(N); for k = 1 : N id(k) = k; end for k = 1 : N-1 for j = k+1 : N if stats(k).Area < stats(j).Area tmp = stats(k); stats(k) = stats(j); stats(j) = tmp; tmp = id(k); id(k) = id(j); id(j) = tmp; end end end selected = (labeled==id(2)); % get center of mass and radius of largest k = stats(2).Centroid; % frame_rgb= imfilter(frame_rgb,h); % thresh=graythresh(frame_rgb); % bw=~(im2bw(frame_rgb,thresh)); % bw = BWMORPH(bw,'clean') % gdata=regionprops(bw,'area'); % idx = find([gdata.Area] > 100); % BW2 = ismember(bw, idx); % [l num]=bwlabel(BW2,4); % CC = bwconncomp(BW2); % L = labelmatrix(CC); % gdata1=regionprops(L==2,'centroid'); % %imshow(l==3,'Parent',handles.axes3); % %set(handles.edit2,'String',num2str(num)); imshow(bw,'Parent',handles.IMAGE2); %k=gdata1.Centroid; imshow(frame_rgb,'Parent',handles.IMAGE3); hold on; plot(k(1),k(2),'b*'); hold on; if kfinit==0 xp = [0,0,0,0]'; else xp=A*x(i-1,:)' + Bu; % predict phase end kfinit=1; PP = A*P*A' + Q; K = PP*H'*inv(H*PP*H'+R); x(i,:) = (xp + K*([k(1),k(2)]' - H*xp))';%update P = (eye(4)-K*H)*PP; measure=norm(P); tme=toc; plot(x(i,1),x(i,2),'r*'); err1=k(1)-x(i,1); err2=k(2)-x(i,2); hold off; set(handles.centroidX,'String',num2str(k(1))); set(handles.centroidY,'String',num2str(k(2))); set(handles.TSTATUS,'String','KALMAN TRACKING'); set(handles.TFRAME,'String',num2str(tme)); set(handles.FRAME,'String',num2str(i)); set(handles.ERRORCX,'String',num2str(measure)); set(handles.ERRORCY,'String',num2str(measure)); set(handles.ERRORX,'String',num2str(err1)); set(handles.ERRORY,'String',num2str(err2)); pause(.001); case 'Gaussian Filter' h = fspecial('gaussian'); frame_rgb= imfilter(frame_rgb,h); imshow(frame_rgb,'Parent',handles.IMAGE3); thresh=graythresh(frame_rgb); bw=~(im2bw(frame_rgb,thresh)); labeled = bwlabel( bw,8); stats = regionprops(labeled,['basic']);%basic mohem nist [N,W] = size(stats); if N < 1 return end % do bubble sort (large to small) on regions in case there are more than 1 id = zeros(N); for k = 1 : N id(k) = k; end for k = 1 : N-1 for j = k+1 : N if stats(k).Area < stats(j).Area tmp = stats(k); stats(k) = stats(j); stats(j) = tmp; tmp = id(k); id(k) = id(j); id(j) = tmp; end end end selected = (labeled==id(2)); % get center of mass and radius of largest k = stats(2).Centroid; % frame_rgb= imfilter(frame_rgb,h); % thresh=graythresh(frame_rgb); % bw=~(im2bw(frame_rgb,thresh)); % bw = BWMORPH(bw,'clean') % gdata=regionprops(bw,'area'); % idx = find([gdata.Area] > 100); % BW2 = ismember(bw, idx); % [l num]=bwlabel(BW2,4); % CC = bwconncomp(BW2); % L = labelmatrix(CC); % gdata1=regionprops(L==2,'centroid'); % %imshow(l==3,'Parent',handles.axes3); % %set(handles.edit2,'String',num2str(num)); imshow(bw,'Parent',handles.IMAGE2); %k=gdata1.Centroid; hold on; plot(k(1),k(2),'b*'); hold on; if kfinit==0 xp = [0,0,0,0]'; else xp=A*x(i-1,:)' + Bu; % predict phase end kfinit=1; PP = A*P*A' + Q; K = PP*H'*inv(H*PP*H'+R); x(i,:) = (xp + K*([k(1),k(2)]' - H*xp))';%update P = (eye(4)-K*H)*PP; tme=toc; plot(x(i,1),x(i,2),'r*'); err1=k(1)-x(i,1); err2=k(2)-x(i,2); hold on; set(handles.centroidX,'String',num2str(k(1))); set(handles.centroidY,'String',num2str(k(2))); set(handles.TSTATUS,'String','Object is being tracked through Kalman Filter'); set(handles.TFRAME,'String',num2str(tme)); set(handles.FRAME,'String',num2str(i)); set(handles.ERRORX,'String',num2str(err1)); set(handles.ERRORY,'String',num2str(err2)); pause(.001); end end %set(handles.edit2,'String','File has been succesfully imported') %msgbox('File has been succesfully imported','Status','help') % --- Executes on button press in pushbutton2. function QNOISE_Callback(hObject, eventdata, handles) % hObject handle to QNOISE (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of QNOISE as text % str2double(get(hObject,'String')) returns contents of QNOISE as a double % --- Executes during object creation, after setting all properties. function QNOISE_CreateFcn(hObject, eventdata, handles) % hObject handle to QNOISE (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function PNOISE_Callback(hObject, eventdata, handles) % hObject handle to PNOISE (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of PNOISE as text % str2double(get(hObject,'String')) returns contents of PNOISE as a double % --- Executes during object creation, after setting all properties. function PNOISE_CreateFcn(hObject, eventdata, handles) % hObject handle to PNOISE (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function ERRORCX_Callback(hObject, eventdata, handles) % hObject handle to ERRORCX (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of ERRORCX as text % str2double(get(hObject,'String')) returns contents of ERRORCX as a double % --- Executes during object creation, after setting all properties. function ERRORCX_CreateFcn(hObject, eventdata, handles) % hObject handle to ERRORCX (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function ERRORCY_Callback(hObject, eventdata, handles) % hObject handle to ERRORCY (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of ERRORCY as text % str2double(get(hObject,'String')) returns contents of ERRORCY as a double % --- Executes during object creation, after setting all properties. function ERRORCY_CreateFcn(hObject, eventdata, handles) % hObject handle to ERRORCY (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function ERRORX_Callback(hObject, eventdata, handles) % hObject handle to ERRORX (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of ERRORX as text % str2double(get(hObject,'String')) returns contents of ERRORX as a double % --- Executes during object creation, after setting all properties. function ERRORX_CreateFcn(hObject, eventdata, handles) % hObject handle to ERRORX (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function ERRORY_Callback(hObject, eventdata, handles) % hObject handle to ERRORY (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of ERRORY as text % str2double(get(hObject,'String')) returns contents of ERRORY as a double % --- Executes during object creation, after setting all properties. function ERRORY_CreateFcn(hObject, eventdata, handles) % hObject handle to ERRORY (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in tracking. function tracking_Callback(hObject, eventdata, handles) % hObject handle to tracking (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global str2; global val2; global avi_file; str2 = get(hObject, 'String'); val2 = get(hObject,'Value'); % set(handles.videoselect,'String',... % (get(hObject,'Value'))); % Set current data to the selected data set. switch val2 case 1 [filename, pathname] = uigetfile('C:\Documents and Settings\karan\My Documents\My Pictures\*.avi','Input file selector'); %[filename, pathname] = uigetfile('C:\Documents and Settings\admin\Desktop\clipped video files\avi\*.avi','Input file selector'); a=strcat(pathname,filename); %giving the path for the file bowsing avi_file=aviread(a); %reading the image by each frame set(handles.tracking,'String','Centroid Tracking'); case 2 [filename, pathname] = uigetfile('C:\Documents and Settings\karan\My Documents\My Pictures\*.avi','Input file selector'); %[filename, pathname] = uigetfile('C:\Documents and Settings\admin\Desktop\clipped video files\avi\*.avi','Input file selector'); a=strcat(pathname,filename); %giving the path for the file bowsing avi_file=aviread(a); %reading the image by each frame set(handles.tracking,'String','Thresholding'); case 3 [filename, pathname] = uigetfile('C:\Documents and Settings\karan\My Documents\My Pictures\*.avi','Input file selector'); %[filename, pathname] = uigetfile('C:\Documents and Settings\admin\Desktop\clipped video files\avi\*.avi','Input file selector'); a=strcat(pathname,filename); %giving the path for the file bowsing avi_file=aviread(a); %reading the image by each frame set(handles.tracking,'String','Phase Correlation'); end % Hints: contents = get(hObject,'String') returns tracking contents as cell array % contents{get(hObject,'Value')} returns selected item from tracking % --- Executes during object creation, after setting all properties. function tracking_CreateFcn(hObject, eventdata, handles) % hObject handle to tracking (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in track. function track_Callback(hObject, eventdata, handles) % hObject handle to track (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global datatrack; global avi_file; datatrack = get(handles.tracking,'String'); switch datatrack case 'Centroid Tracking' global avi_file; for i = 1 :size(avi_file,2) imshow(avi_file(1,i).cdata,'Parent',handles.IMAGE1); pause(.001); tic; frame=ind2rgb(avi_file(1,i).cdata,avi_file(1,i).colormap); %image(frame,'Parent',handles.axes1); axis off; frame_rgb = rgb2gray(frame); h = fspecial('average'); frame_rgb= imfilter(frame_rgb,h); thresh=graythresh(frame_rgb); bw=~(im2bw(frame_rgb,thresh)); labeled = bwlabel( bw,8); stats = regionprops(labeled,['basic']);%basic mohem nist [N,W] = size(stats); if N < 1 return end % do bubble sort (large to small) on regions in case there are more than 1 id = zeros(N); for k = 1 : N id(k) = k; end for k = 1 : N-1 for j = k+1 : N if stats(k).Area < stats(j).Area tmp = stats(k); stats(k) = stats(j); stats(j) = tmp; tmp = id(k); id(k) = id(j); id(j) = tmp; end end end selected = (labeled==id(2)); % get center of mass and radius of largest k = stats(2).Centroid; imshow(bw,'Parent',handles.IMAGE3) %k=gdata1.Centroid; hold on; plot(k(1),k(2),'b*'); hold on; tme=toc; set(handles.centroidX,'String',num2str(k(1))); set(handles.centroidY,'String',num2str(k(2))); set(handles.TSTATUS,'String','CENTROID TRACKING'); set(handles.TFRAME,'String',num2str(tme)); set(handles.FRAME,'String',num2str(i)); pause(.001); end case 'Thresholding' global avi_file; for i = 1 :size(avi_file,2) imshow(avi_file(1,i).cdata,'Parent',handles.IMAGE1); pause(.001); tic; frame=ind2rgb(avi_file(1,i).cdata,avi_file(1,i).colormap); %image(frame,'Parent',handles.axes1); axis off; frame_rgb = rgb2gray(frame); h = fspecial('average'); frame_rgb= imfilter(frame_rgb,h); thresh=graythresh(frame_rgb); bw=~(im2bw(frame_rgb,thresh)); imshow(bw,'Parent',handles.IMAGE3); tme=toc; set(handles.TSTATUS,'String','KALMAN TRACKING'); set(handles.TFRAME,'String',num2str(tme)); set(handles.FRAME,'String',num2str(i)); pause(.001); end case 'Phase Correlation' global avi_file; frame1=ind2rgb(avi_file(1,1).cdata,avi_file(1,1).colormap); %image(frame,'Parent',handles.axes1); axis off; frame_rgb1 = rgb2gray(frame1); h1 = fspecial('average'); frame_rgb1= imfilter(frame_rgb1,h1); thresh1=graythresh(frame_rgb1); bw1=~(im2bw(frame_rgb1,thresh1)); for i = 2 :size(avi_file,2) tic; frame2=ind2rgb(avi_file(1,i).cdata,avi_file(1,i).colormap); %image(frame,'Parent',handles.axes1); axis off; frame_rgb2 = rgb2gray(frame2); h2 = fspecial('average'); frame_rgb2= imfilter(frame_rgb2,h2); thresh2=graythresh(frame_rgb2); bw2=~(im2bw(frame_rgb2,thresh2)); imshow(bw2,'Parent',handles.IMAGE2); imshow(bw1,'Parent',handles.IMAGE1); t=zeros(240,320); L=fft2(bw1); M=fft2(bw2); c= real(ifft2(L .* fft2(rot90(bw2,2),240,320))); imshow(c,'Parent',handles.IMAGE3); bw1=bw2; tme=toc; set(handles.TSTATUS,'String','KALMAN TRACKING'); set(handles.TFRAME,'String',num2str(tme)); set(handles.FRAME,'String',num2str(i)); pause(.001); end end % --- Executes on button press in reset. function reset_Callback(hObject, eventdata, handles) % hObject handle to reset (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % cla(IMAGE1); % cla(IMAGE2); % cla(IMAGE2); % cla(handles.IMAGE1); function handles = ResetGUI(IMAGE1); % --- Executes on selection change in videoselect. function videoselect_Callback(hObject, eventdata, handles) % hObject handle to videoselect (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Determine the selected data set. global str; global val; global avi_file; str = get(hObject, 'String'); val = get(hObject,'Value'); % set(handles.videoselect,'String',... % (get(hObject,'Value'))); % Set current data to the selected data set. switch val case 1 % if the user selected browsing videos % User selected the first item %creating a global variable [filename, pathname] = uigetfile('C:\Documents and Settings\karan\My Documents\My Pictures\*.avi','Input file selector'); %[filename, pathname] = uigetfile('C:\Documents and Settings\admin\Desktop\clipped video files\avi\*.avi','Input file selector'); a=strcat(pathname,filename); %giving the path for the file bowsing avi_file=aviread(a); %reading the image by each frame set(handles.videoselect,'String','BrowseVideos'); % for i = 1 :size(avi_file,2) % running the loop till the number of frames of the video % imshow(avi_file(1,i).cdata,'Parent',handles.IMAGE1); %displaying the image by each frame % pause(.001); %pause each frame so can we can see each frame % end case 2 %if the user selected video input from usb cam global vid; handles.vidobj=videoinput('winvideo',1,'RGB24_320x240'); vid=handles.vidobj; %vidRes=get(handles.vidobj,'VideoResolution') %nBands=get(handles.vidobj,'NumberOfBands') hImage=image(zeros(240,320,3),'Parent',handles.axes1); set(handles.videoselect,'String','FetchfromUSBCAM'); % preview(handles.vidobj,hImage); end % Save the handles structure. guidata(hObject,handles); % Hints: contents = get(hObject,'String') returns videoselect contents as cell array % contents{get(hObject,'Value')} returns selected item from videoselect % --- Executes during object creation, after setting all properties. function videoselect_CreateFcn(hObject, eventdata, handles) % hObject handle to videoselect (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % --- Executes on button press in vidselect. function vidselect_Callback(hObject, eventdata, handles) global data; global avi_file; data = get(handles.videoselect,'String'); % var3= lower(data); switch data % strcmp(data,'BrowseVideos')==1 case 'BrowseVideos' for i = 1 :size(avi_file,2) % running the loop till the number of frames of the video imshow(avi_file(1,i).cdata,'Parent',handles.IMAGE1); %displaying the image by each frame pause(.001); %pause each frame so can we can see each frame end case 'FetchfromUSBCAM' % elseif strcmp(data,'FetchfromUSBCAM') % preview(handles.vidobj,hImage); end % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % hObject handle to vidselect (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in close. function close_Callback(hObject, eventdata, handles) % hObject handle to close (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) close(gcf); % close the gui window function TSTATUS_Callback(hObject, eventdata, handles) % hObject handle to TSTATUS (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of TSTATUS as text % str2double(get(hObject,'String')) returns contents of TSTATUS as a double % --- Executes during object creation, after setting all properties. function TSTATUS_CreateFcn(hObject, eventdata, handles) % hObject handle to TSTATUS (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function FRAME_Callback(hObject, eventdata, handles) % hObject handle to FRAME (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of FRAME as text % str2double(get(hObject,'String')) returns contents of FRAME as a double % --- Executes during object creation, after setting all properties. function FRAME_CreateFcn(hObject, eventdata, handles) % hObject handle to FRAME (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function TFRAME_Callback(hObject, eventdata, handles) % hObject handle to TFRAME (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of TFRAME as text % str2double(get(hObject,'String')) returns contents of TFRAME as a double % --- Executes during object creation, after setting all properties. function TFRAME_CreateFcn(hObject, eventdata, handles) % hObject handle to TFRAME (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in filter. function filter_Callback(hObject, eventdata, handles) % hObject handle to filter (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global val3; global avi_file; str3 = get(hObject, 'String'); val3 = get(hObject,'Value'); % set(handles.videoselect,'String',... % (get(hObject,'Value'))); % Set current data to the selected data set. switch val3 case 1 [filename, pathname] = uigetfile('C:\Documents and Settings\karan\My Documents\My Pictures\*.avi','Input file selector'); %[filename, pathname] = uigetfile('C:\Documents and Settings\admin\Desktop\clipped video files\avi\*.avi','Input file selector'); a=strcat(pathname,filename); %giving the path for the file bowsing avi_file=aviread(a); %reading the image by each frame set(handles.filter,'String','Mean Filter'); case 2 [filename, pathname] = uigetfile('C:\Documents and Settings\karan\My Documents\My Pictures\*.avi','Input file selector'); %[filename, pathname] = uigetfile('C:\Documents and Settings\admin\Desktop\clipped video files\avi\*.avi','Input file selector'); a=strcat(pathname,filename); %giving the path for the file bowsing avi_file=aviread(a); %reading the image by each frame set(handles.filter,'String','Gaussian Filter'); end % Hints: contents = get(hObject,'String') returns filter contents as cell array % contents{get(hObject,'Value')} returns selected item from filter % --- Executes during object creation, after setting all properties. function filter_CreateFcn(hObject, eventdata, handles) % hObject handle to filter (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function centroidX_Callback(hObject, eventdata, handles) % hObject handle to centroidX (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of centroidX as text % str2double(get(hObject,'String')) returns contents of centroidX as a double % --- Executes during object creation, after setting all properties. function centroidX_CreateFcn(hObject, eventdata, handles) % hObject handle to centroidX (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function centroidY_Callback(hObject, eventdata, handles) % hObject handle to centroidY (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of centroidY as text % str2double(get(hObject,'String')) returns contents of centroidY as a double % --- Executes during object creation, after setting all properties. function centroidY_CreateFcn(hObject, eventdata, handles) % hObject handle to centroidY (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on key press with focus on videoselect and none of its controls. function videoselect_KeyPressFcn(hObject, eventdata, handles) % hObject handle to videoselect (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA)
github
Oscarlight/PiNN_Caffe2-master
ids.m
.m
PiNN_Caffe2-master/transiNXOR_modeling/c_model/ids.m
1,627
utf_8
a8aadb608cf6e30c23dd185e70bf0255
function [ id ] = ids( vtg, vbg, vds, w, params ) %IDS calculates ids vs vtg, vbg, vds, w % All voltages are in volts, w is in microns and acts as scale factor % params should be preloaded from mat file % % Re apply preprocessing vg = (vtg+vbg-params.VG_SHIFT)/params.VG_SCALE; vds = vds/params.VD_SCALE; % first layer [sig_0_act, tanh_0_act] = pinn_layer(vg, vds, params.tanh_fc_layer_0_w,... params.sig_fc_layer_0_w, params.sig_fc_layer_0_b', params.inter_embed_layer_0_w,... params.inter_embed_layer_0_b'); % second layer [sig_1_act, tanh_1_act] = pinn_layer(sig_0_act, tanh_0_act, params.tanh_fc_layer_1_w,... params.sig_fc_layer_1_w, params.sig_fc_layer_1_b', params.inter_embed_layer_1_w,... params.inter_embed_layer_1_b'); % third layer [sig_2_act, tanh_2_act] = pinn_layer(sig_1_act, tanh_1_act, params.tanh_fc_layer_2_w,... params.sig_fc_layer_2_w, params.sig_fc_layer_2_b', params.inter_embed_layer_2_w,... params.inter_embed_layer_2_b'); % calculate id id = w * sig_2_act * tanh_2_act * params.ID_SCALE * 1e-6; end function [sig_act, tanh_act] = pinn_layer(sig_in, tanh_in, tanh_w, sig_w, sig_b, inter_w, inter_b) tanh_z = tanh_w*tanh_in; sig_z = fc(sig_in, sig_w, sig_b); inter_z = fc(tanh_z, inter_w, inter_b); sig_act = sigmoid(sig_z + inter_z); tanh_act = tanh(tanh_z); end function out = fc(in, w, b) % fully connected layer out = w*in + b; end function sig = sigmoid(x) %sig = 1./(1 + exp(-x)); sig = (tanh(x/2) + 1)/2; end
github
kd383/GPML_SLD-master
likBeta.m
.m
GPML_SLD-master/gpml-matlab-v4.1-2017-10-19/lik/likBeta.m
4,829
utf_8
7146612206c56203c34b7f78e46e1383
function [varargout] = likBeta(link, hyp, y, mu, s2, inf, i) % likBeta - Beta likelihood function for interval data y from [0,1]. % The expression for the likelihood is % likBeta(f) = 1/Z * y^(mu*phi-1) * (1-y)^((1-mu)*phi-1) with % mean=mu and variance=mu*(1-mu)/(1+phi) where mu = g(f) is the Beta intensity, % f is a Gaussian process, y is the interval data and % Z = Gamma(phi)/Gamma(phi*mu)/Gamma(phi*(1-mu)). % Hence, we have % llik(f) = log(likBeta(f)) = -lam*(y-mu)^2/(2*mu^2*y) - log(Zy). % % We provide two inverse link functions 'logit' and 'expexp': % g(f) = 1/(1+exp(-f)) and g(f) = exp(-exp(-f))). % The link functions are located at util/glm_invlink_*.m. % % Note that for neither link function the likelihood lik(f) is log concave. % % The hyperparameters are: % % hyp = [ log(phi) ] % % Several modes are provided, for computing likelihoods, derivatives and moments % respectively, see likFunctions.m for the details. In general, care is taken % to avoid numerical issues when the arguments are extreme. % % See also LIKFUNCTIONS.M. % % Copyright (c) by Hannes Nickisch, 2014-03-04. if nargin<4, varargout = {'1'}; return; end % report number of hyperparameters phi = exp(hyp); if nargin<6 % prediction mode if inf is not present if numel(y)==0, y = zeros(size(mu)); end s2zero = 1; if nargin>4&&numel(s2)>0&&norm(s2)>eps, s2zero = 0; end % s2==0 ? if s2zero % log probability lg = g(mu,link); elg = exp(lg); v = phi*elg; w = phi-v; a0 = gammaln(w)-gammaln(phi); lp = (v-1).*log(y) + (w-1).*log(1-y) - gammaln(v) - a0; else lp = likBeta(link, hyp, y, mu, s2, 'infEP'); end ymu = {}; ys2 = {}; if nargout>1 % compute y moments by quadrature n = max([length(y),length(mu),length(s2)]); on = ones(n,1); N = 20; [t,w] = gauher(N); oN = ones(1,N); lw = ones(n,1)*log(w'); mu = mu(:).*on; sig = sqrt(s2(:)).*on; % vectors only lg = g(sig*t'+mu*oN,link); ymu = exp(logsumexp2(lg+lw)); % first moment using Gaussian-Hermite quad if nargout>2 elg = exp(lg); yv = elg.*(1-elg)/(1+phi); % second y moment from Beta distribution ys2 = (yv+(elg-ymu*oN).^2)*w; end end varargout = {lp,ymu,ys2}; else switch inf case 'infLaplace' [lg,dlg,d2lg,d3lg] = g(mu,link); elg = exp(lg); v = phi*elg; w = phi-v; if nargin<7 % no derivative mode a0 = gammaln(phi-v)-gammaln(phi); lp = (v-1).*log(y) + (w-1).*log(1-y) - gammaln(v) - a0; dlp = {}; d2lp = {}; d3lp = {}; % return arguments if nargout>1 % dlp, derivative of log likelihood a1 = v.*(log(y)-log(1-y) + psi(0,w)-psi(0,v)); dlp = dlg.*a1; if nargout>2 % d2lp, 2nd derivative of log likelihood a2 = v.^2.*(psi(1,w)+psi(1,v)); z = dlg.^2+d2lg; d2lp = z.*a1 - dlg.^2.*a2; if nargout>3 % d3lp, 3rd derivative of log likelihood a3 = v.^3.*(psi(2,w)-psi(2,v)); d3lp = (dlg.*z+2*dlg.*d2lg+d3lg).*a1 - 3*dlg.*z.*a2 + dlg.^3.*a3; end end end varargout = {lp,dlp,d2lp,d3lp}; else % derivative mode % deriv. of log lik w.r.t. phi lp_dhyp = v.*log(y)+w.*log(1-y)-v.*psi(0,v)-w.*psi(0,w)+phi*psi(0,phi); a1 = v.*(log(y)-log(1-y) + psi(0,w)-psi(0,v)); da1 = a1 + v.*(w.*psi(1,w)-v.*psi(1,v)); dlp_dhyp = dlg.*da1; % first derivative a2 = v.^2.*(psi(1,w)+psi(1,v)); z = dlg.^2+d2lg; da2 = v.^2.*(w.*psi(2,w)+v.*psi(2,v)) + 2*a2; d2lp_dhyp = z.*da1 - dlg.^2.*da2; % second derivative varargout = {lp_dhyp,dlp_dhyp,d2lp_dhyp}; end case 'infEP' if nargin<7 % no derivative mode % Since we are not aware of an analytical expression of the integral, % we use quadrature. varargout = cell(1,nargout); [varargout{:}] = lik_epquad({@likBeta,link},hyp,y,mu,s2); else % derivative mode varargout = {[]}; % deriv. wrt hyp.lik end case 'infVB' error('infVB not supported') end end % compute the log intensity using the inverse link function function varargout = g(f,link) varargout = cell(nargout, 1); % allocate the right number of output arguments if strcmp(link,'expexp') [varargout{:}] = glm_invlink_expexp(f); else [varargout{:}] = glm_invlink_logit(f); end
github
kd383/GPML_SLD-master
likT.m
.m
GPML_SLD-master/gpml-matlab-v4.1-2017-10-19/lik/likT.m
4,860
utf_8
91a941561b5c8cd3d0df4959b399bae8
function [varargout] = likT(hyp, y, mu, s2, inf, i) % likT - Student's t likelihood function for regression. % The expression for the likelihood is % likT(t) = Z * ( 1 + (t-y)^2/(nu*sn^2) ).^(-(nu+1)/2), % where Z = gamma((nu+1)/2) / (gamma(nu/2)*sqrt(nu*pi)*sn) % and y is the mean (for nu>1) and nu*sn^2/(nu-2) is the variance (for nu>2). % % The hyperparameters are: % % hyp = [ log(nu-1) % log(sn) ] % % Note that the parametrisation guarantees nu>1, thus the mean always exists. % % Several modes are provided, for computing likelihoods, derivatives and moments % respectively, see likFunctions.m for the details. In general, care is taken % to avoid numerical issues when the arguments are extreme. % % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-10-01. % % See also LIKFUNCTIONS.M. if nargin<3, varargout = {'2'}; return; end % report number of hyperparameters if ~exist('psi'), mypsi = @digamma; else mypsi = @psi; end % no psi in Octave numin = 1; % minimum value of nu nu = exp(hyp(1))+numin; sn2 = exp(2*hyp(2)); % extract hyperparameters lZ = gammaln(nu/2+1/2) - gammaln(nu/2) - log(nu*pi*sn2)/2; if nargin<5 % prediction mode if inf is not present if numel(y)==0, y = zeros(size(mu)); end s2zero = 1; if nargin>3&&numel(s2)>0&&norm(s2)>eps, s2zero = 0; end % s2==0 ? if s2zero % log probability evaluation lp = lZ - (nu+1)*log( 1+(y-mu).^2./(nu.*sn2) )/2; s2 = 0; else % prediction lp = likT(hyp, y, mu, s2, 'infEP'); end ymu = {}; ys2 = {}; if nargout>1 ymu = mu; % first y moment; for nu<=1 this is the mode if nargout>2 if nu<=2 ys2 = Inf(size(mu)); % variance does not always exist else ys2 = (s2 + nu*sn2/(nu-2)).*ones(size(mu)); % second y moment end end end varargout = {lp,ymu,ys2}; else switch inf case 'infLaplace' r = y-mu; r2 = r.*r; if nargin<6 % no derivative mode dlp = {}; d2lp = {}; d3lp = {}; lp = lZ - (nu+1)*log( 1+r2./(nu.*sn2) )/2; if nargout>1 a = r2+nu*sn2; dlp = (nu+1)*r./a; % dlp, derivative of log likelihood if nargout>2 % d2lp, 2nd derivative of log likelihood d2lp = (nu+1)*(r2-nu*sn2)./a.^2; if nargout>3 % d3lp, 3rd derivative of log likelihood d3lp = (nu+1)*2*r.*(r2-3*nu*sn2)./a.^3; end end end varargout = {lp,dlp,d2lp,d3lp}; else % derivative mode a = r2+nu*sn2; a2 = a.*a; a3 = a2.*a; if i==1 % derivative w.r.t. nu lp_dhyp = nu*( mypsi(nu/2+1/2)-mypsi(nu/2) )/2 - 1/2 ... -nu*log(1+r2/(nu*sn2))/2 +(nu/2+1/2)*r2./(nu*sn2+r2); lp_dhyp = (1-numin/nu)*lp_dhyp; % correct for lower bound on nu dlp_dhyp = nu*r.*( a - sn2*(nu+1) )./a2; dlp_dhyp = (1-numin/nu)*dlp_dhyp; % correct for lower bound on nu d2lp_dhyp = nu*( r2.*(r2-3*sn2*(1+nu)) + nu*sn2^2 )./a3; d2lp_dhyp = (1-numin/nu)*d2lp_dhyp; % correct for lower bound on nu else % derivative w.r.t. sn lp_dhyp = (nu+1)*r2./a - 1; dlp_dhyp = -(nu+1)*2*nu*sn2*r./a2; d2lp_dhyp = (nu+1)*2*nu*sn2*(a-4*r2)./a3; end varargout = {lp_dhyp,dlp_dhyp,d2lp_dhyp}; end case 'infEP' if nargout>1 error('infEP not supported since likT is not log-concave') end n = max([length(y),length(mu),length(s2)]); on = ones(n,1); y = y(:).*on; mu = mu(:).*on; sig = sqrt(s2(:)).*on; % vectors only % since we are not aware of an analytical expression of the integral, % we use Gaussian-Hermite quadrature N = 20; [t,w] = gauher(N); oN = ones(1,N); lZ = likT(hyp, y*oN, sig*t'+mu*oN, []); lZ = log_expA_x(lZ,w); % log( exp(lZ)*w ) varargout = {lZ}; case 'infVB' % variational lower site bound % t(s) \propto (1+(s-y)^2/(nu*s2))^(-nu/2+1/2) % the bound has the form: (b+z/ga)*f - f.^2/(2*ga) - h(ga)/2 n = numel(s2); b = zeros(n,1); y = y.*ones(n,1); z = y; varargout = {b,z}; end end % computes y = log( exp(A)*x ) in a numerically safe way by subtracting the % maximal value in each row to avoid cancelation after taking the exp function y = log_expA_x(A,x) N = size(A,2); maxA = max(A,[],2); % number of columns, max over columns y = log(exp(A-maxA*ones(1,N))*x) + maxA; % exp(A) = exp(A-max(A))*exp(max(A))
github
kd383/GPML_SLD-master
likLaplace.m
.m
GPML_SLD-master/gpml-matlab-v4.1-2017-10-19/lik/likLaplace.m
6,922
iso_8859_13
7f5fd5418abdf573e28f68fff76fec84
function [varargout] = likLaplace(hyp, y, mu, s2, inf, i) % likLaplace - Laplacian likelihood function for regression. % The expression for the likelihood is % likLaplace(t) = exp(-|t-y|/b)/(2*b) with b = sn/sqrt(2), % where y is the mean and sn^2 is the variance. % % The hyperparameters are: % % hyp = [ log(sn) ] % % Several modes are provided, for computing likelihoods, derivatives and moments % respectively, see likFunctions.m for the details. In general, care is taken % to avoid numerical issues when the arguments are extreme. % % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2013-10-16. % % See also LIKFUNCTIONS.M. if nargin<3, varargout = {'1'}; return; end % report number of hyperparameters sn = exp(hyp); b = sn/sqrt(2); if nargin<5 % prediction mode if inf is not present if numel(y)==0, y = zeros(size(mu)); end s2zero = 1; if nargin>3&&numel(s2)>0&&norm(s2)>eps, s2zero = 0; end % s2==0 ? if s2zero % log probability evaluation lp = -abs(y-mu)./b -log(2*b); s2 = 0; else % prediction lp = likLaplace(hyp, y, mu, s2, 'infEP'); end ymu = {}; ys2 = {}; if nargout>1 ymu = mu; % first y moment if nargout>2 ys2 = s2 + sn.^2; % second y moment end end varargout = {lp,ymu,ys2}; else % inference mode switch inf case 'infLaplace' if nargin<6 % no derivative mode if numel(y)==0, y=0; end ymmu = y-mu; dlp = {}; d2lp = {}; d3lp = {}; lp = -abs(ymmu)/b -log(2*b); if nargout>1 dlp = sign(ymmu)/b; % dlp, derivative of log likelihood if nargout>2 % d2lp, 2nd derivative of log likelihood d2lp = zeros(size(ymmu)); if nargout>3 % d3lp, 3rd derivative of log likelihood d3lp = zeros(size(ymmu)); end end end varargout = {lp,dlp,d2lp,d3lp}; else % derivative mode lp_dhyp = abs(y-mu)/b - 1; % derivative of log likelihood w.r.t. hypers dlp_dhyp = sign(mu-y)/b; % first derivative, d2lp_dhyp = zeros(size(mu)); % and also of the second mu derivative varargout = {lp_dhyp,dlp_dhyp,d2lp_dhyp}; end case 'infEP' n = max([numel(y),numel(mu),numel(s2),numel(sn)]); on = ones(n,1); y = y(:).*on; mu = mu(:).*on; s2 = s2(:).*on; sn = sn(:).*on; % vectors only fac = 1e3; % factor between the widths of the two distributions ... % ... from when one considered a delta peak, we use 3 orders of magnitude idlik = fac*sn<sqrt(s2); % Likelihood is a delta peak idgau = fac*sqrt(s2)<sn; % Gaussian is a delta peak id = ~idgau & ~idlik; % interesting case in between if nargin<6 % no derivative mode lZ = zeros(n,1); dlZ = lZ; d2lZ = lZ; % allocate memory if any(idlik) [lZ(idlik),dlZ(idlik),d2lZ(idlik)] = ... likGauss(log(s2(idlik))/2, mu(idlik), y(idlik)); end if any(idgau) [lZ(idgau),dlZ(idgau),d2lZ(idgau)] = ... likLaplace(log(sn(idgau)), mu(idgau), y(idgau)); end if any(id) % substitution to obtain unit variance, zero mean Laplacian tmu = (mu(id)-y(id))./sn(id); tvar = s2(id)./sn(id).^2; % an implementation based on logphi(t) = log(normcdf(t)) zp = (tmu+sqrt(2)*tvar)./sqrt(tvar); zm = (tmu-sqrt(2)*tvar)./sqrt(tvar); ap = logphi(-zp)+sqrt(2)*tmu; am = logphi( zm)-sqrt(2)*tmu; lZ(id) = logsumexp2([ap,am]) + tvar - log(sn(id)*sqrt(2)); if nargout>1 lqp = -zp.^2/2 - log(2*pi)/2 - logphi(-zp); % log( N(z)/Phi(z) ) lqm = -zm.^2/2 - log(2*pi)/2 - logphi( zm); dap = -exp(lqp-log(s2(id))/2) + sqrt(2)./sn(id); dam = exp(lqm-log(s2(id))/2) - sqrt(2)./sn(id); % ( exp(ap).*dap + exp(am).*dam )./( exp(ap) + exp(am) ) dlZ(id) = expABz_expAx([ap,am],[1;1],[dap,dam],[1;1]); if nargout>2 a = sqrt(8)./sn(id)./sqrt(s2(id)); bp = 2./sn(id).^2 - (a - zp./s2(id)).*exp(lqp); bm = 2./sn(id).^2 - (a + zm./s2(id)).*exp(lqm); % d2lZ(id) = ( exp(ap).*bp + exp(am).*bm )./( exp(ap) + exp(am) )... % - dlZ(id).^2; d2lZ(id) = expABz_expAx([ap,am],[1;1],[bp,bm],[1;1]) - dlZ(id).^2; end end end varargout = {lZ,dlZ,d2lZ}; else % derivative mode dlZhyp = zeros(n,1); if any(idlik) dlZhyp(idlik) = 0; end if any(idgau) dlZhyp(idgau) = ... likLaplace(log(sn(idgau)), mu(idgau), y(idgau), 'infLaplace', 1); end if any(id) % substitution to obtain unit variance, zero mean Laplacian tmu = (mu(id)-y(id))./sn(id); tvar = s2(id)./sn(id).^2; zp = (tvar+tmu/sqrt(2))./sqrt(tvar); vp = tvar+sqrt(2)*tmu; zm = (tvar-tmu/sqrt(2))./sqrt(tvar); vm = tvar-sqrt(2)*tmu; dzp = (-s2(id)./sn(id)+tmu.*sn(id)/sqrt(2)) ./ sqrt(s2(id)); dvp = -2*tvar - sqrt(2)*tmu; dzm = (-s2(id)./sn(id)-tmu.*sn(id)/sqrt(2)) ./ sqrt(s2(id)); dvm = -2*tvar + sqrt(2)*tmu; lezp = logerfc(zp); % ap = exp(vp).*ezp lezm = logerfc(zm); % am = exp(vm).*ezm vmax = max([vp+lezp,vm+lezm],[],2); % subtract max to avoid numerical pb ep = exp(vp+lezp-vmax); em = exp(vm+lezm-vmax); dap = ep.*(dvp - 2/sqrt(pi)*exp(-zp.^2-lezp).*dzp); dam = em.*(dvm - 2/sqrt(pi)*exp(-zm.^2-lezm).*dzm); dlZhyp(id) = (dap+dam)./(ep+em) - 1; end varargout = {dlZhyp}; % deriv. wrt hypers end case 'infVB' % variational lower site bound % t(s) = exp(-sqrt(2)|y-s|/sn) / sqrt(2*sn²) % the bound has the form: (b+z/ga)*f - f.^2/(2*ga) - h(ga)/2 n = numel(s2); b = zeros(n,1); y = y.*ones(n,1); z = y; varargout = {b,z}; end end % logerfc(z) = log(1-erf(z)) function lc = logerfc(z) lc = logphi(-z*sqrt(2)) + log(2); function y = expABz_expAx(A,x,B,z) N = size(A,2); maxA = max(A,[],2); % number of columns, max over columns A = A-maxA*ones(1,N); % subtract maximum value y = ( (exp(A).*B)*z ) ./ ( exp(A)*x );
github
kd383/GPML_SLD-master
likGaussWarp.m
.m
GPML_SLD-master/gpml-matlab-v4.1-2017-10-19/lik/likGaussWarp.m
9,109
utf_8
db71c7f4569eb37a505d530f36c01284
function [varargout] = likGaussWarp(warp, hyp, y, mu, varargin) % likGaussWarp - Warped Gaussian likelihood for regression. % The expression for the likelihood is % likGaussWarp( y | t ) = likGauss( g(y) | t ) * g'(y), % where likGauss is the Gaussian likelihood and g is the warping function. % % The hyperparameters are: % % hyp = [ theta_1 % theta_2 % .. % theta_ng % log(sn) ] % % Here, sn is the standard deviation of the underlying Gaussian and theta_i for % i=1..ng are the ng hyperparameters of the warping function g. % % At the moment, likGaussWarp offers 3 different warping functions: % id yields g(y) = y => likGaussWarp = likGauss % poly<m> e.g. 'poly1' yields g(y) = y => likGaussWarp = likGauss % 'poly3' yields g(y) = y + c1*sy*ay^2 + c2*sy*ay^3 % where sy = sign(y), ay = abs(y), cj = exp(theta_j) % tanh<m> e.g. 'tanh0' yields g(y) = y => likGaussWarp = likGauss % 'tanh2' yields g(y) = y + a1*tanh(b1*(y+c1)) + a2*tanh(b2*(y+c2)) % where aj = exp(theta_j), bj = exp(theta_j+m), bj = theta_j+2*m % % The code is based on the exposition in the paper Warped Gaussian Processes, % NIPS, 2003 by Edward Snelson, Carl Rasmussen and Zoubin Ghahramani. % % Several modes are provided, for computing likelihoods, derivatives and moments % respectively, see likFunctions.m for the details. In general, care is taken % to avoid numerical issues when the arguments are extreme. % % Copyright (c) by Hannes Nickisch, 2013-10-24. % % See also LIKFUNCTIONS.M. lik = {@likGauss}; % in principle any likelihood function can be warped but only % for homoscedastic likelihoods, in particular Gaussian has feasible integrals if numel(warp)==0, warp = 'id'; end % set default warping function ng = g(warp); % number of hyperparameters for the warping function nhyp = ['(',num2str(ng),'+',feval(lik{:}),')']; % number of hyperparameters if nargin<4, varargout = {nhyp}; return, end % report number of parameters nhyp = eval(nhyp); if nhyp>length(hyp), error('not enough hyperparameters'), end [gy,lgpy] = g(warp,y,hyp(1:ng)); % evaluate warping function i = 0; if nargin>6, i = varargin{3}; varargin{3} = varargin{3}-ng; end varargout = cell(nargout,1); % allocate memory for output arguments if i==0 || ng<i % only evaluate the required parts [varargout{:}] = feval(lik{:},hyp(ng+1:end),gy,mu,varargin{:}); % eval lik end if nargin<6 % prediction mode if inf is not present if numel(y)==0, y = zeros(size(mu)); end s2zero = 1; if nargin>4, s2 = varargin{1}; end % s2==0 ? if nargin>4&&numel(s2)>0&&norm(s2)>eps>0, s2zero = 0; end if s2zero % log probability lp = likGaussWarp(warp, hyp, y, mu, [], 'infLaplace'); s2 = 0*mu; else lp = likGaussWarp(warp, hyp, y, mu, s2, 'infEP'); % prediction end if nargout>0, varargout{1} = lp; end % works for any lik % the predictive moments are very hard to compute for lik not being likGauss if nargout>1 ymu = mu; % first g(y) moment sn2 = exp(2*hyp(ng+1)); % Gaussian noise variance ys2 = s2 + sn2; % second g(y) moment % ymuM = ig(warp,ymu,hyp(1:ng)); % median % yupp = ig(warp,ymu+2*sqrt(ys2),hyp(1:ng)); % 95% confidence interval % ylow = ig(warp,ymu-2*sqrt(ys2),hyp(1:ng)); % ys2C = (yupp-ylow).^2/16; N = 20; [t,w] = gauher(N); oN = ones(1,N); % Gaussian-Hermite quadrature Z = sqrt(ys2(:))*t'+ymu(:)*oN; Y = ig(warp,Z,hyp(1:ng)); ymu = Y*w; ys2 = (Y-ymu*oN).^2*w; % first and second y moment varargout{2} = reshape(ymu,size(mu)); if nargout>2 varargout{3} = ys2; end end else inf = varargin{2}; % obtain input variables switch inf case {'infLaplace','infEP'} % they have the same structure if nargin<7 % no derivative mode if nargout>0, varargout{1} = varargout{1} + lgpy; end else % derivative mode if i<=ng % derivatives w.r.t. warping function parameters n = max([numel(y),numel(mu)]); for j=2:nargout, varargout{j} = zeros(n,1); end [dgy,dlgpy] = g(warp,y,hyp(1:ng),i); % warping function derivative out = cell(nargout+1,1); % allocate memory [out{:}] = likGaussWarp(warp, hyp, y, mu, varargin{1:2}); % query lik % works only for homoscedastic likelihoods where y and mu can be swapped if nargout>0, varargout{1} = dlgpy - out{2}.*dgy; end % apply chain rule if nargout>1, varargout{2} = - out{3}.*dgy; end if nargout>2, varargout{3} = - out{4}.*dgy; end end end case 'infVB' % output does not depend on mu and following parameters end end % marshalling of parameters and available warping functions function varargout = g(warp,varargin) varargout = cell(nargout, 1); % allocate the right number of output arguments if strcmp(warp,'id') % indentity warping likGaussWarp = likGauss if nargin<2 if nargout>0, varargout{1} = 0; end elseif nargin<4 if nargout>0, varargout{1} = varargin{1}; end if nargout>1, varargout{2} = 0*varargin{1}; end end elseif numel(strfind(warp,'poly'))>0 m = str2double(warp(5:end)); if nargin<2 && nargout>0, varargout{1} = m-1; return, end [varargout{:}] = g_poly(varargin{:}); elseif numel(strfind(warp,'tanh'))>0 m = str2double(warp(5:end)); if nargin<2 && nargout>0, varargout{1} = 3*m; return, end [varargout{:}] = g_tanh(varargin{:}); end % invert g(y) = z <=> ig(z) = y via bisection search + Newton iterations function [y,n,d] = ig(warp,z,hyp) y = z; gy = g(warp,z,hyp)-z; dz = max(abs(z(:))); % lower bound search ylow while any(0<gy(:)), y(0<gy) = y(0<gy)-dz; gy = g(warp,y,hyp)-z; end, ylow = y; y = z; gy = g(warp,z,hyp)-z; dz = max(abs(z(:))); % upper bound search yupp while any(0>gy(:)), y(0>gy) = y(0>gy)+dz; gy = g(warp,y,hyp)-z; end, yupp = y; for n=1:12 % bisection search ylow<=y<=yupp d = max(abs(gy(:))); if d<sqrt(eps), break, end y = (ylow+yupp)/2; gy = g(warp,y,hyp)-z; ylow(gy<0) = y(gy<0); yupp(gy>0) = y(gy>0); end for n=1:12 % Newton iterations [gy,lgpy] = g(warp,y,hyp); gpy = exp(lgpy); y = y - (gy-z)./gpy; y(y<ylow) = ylow(y<ylow); y(y>yupp) = yupp(y>yupp); % keep brackets d = max( abs(gy(:)-z(:)) ); if d<sqrt(eps), break, end end if n==10 || d>sqrt(eps), fprintf('Not converged: res=%1.4e\n',d), end % poly warping function g(y) and log of the derivative log(g'(y))>0 % or derivatives of the latter w.r.t. ith hyperparameter function [gy,lgpy] = g_poly(y,hyp,i) m = numel(hyp)+1; c = exp(hyp); if nargin==2 % function values gy = y; gpy = 1; ay = abs(y); for j=2:m gy = gy + c(j-1)*ay.^j; gpy = gpy + c(j-1)*j*ay.^(j-1); end gy = sign(y).*gy; lgpy = log(gpy); else % derivatives gpy = 1; ay = abs(y); for j=2:m gpy = gpy + c(j-1)*j*ay.^(j-1); end gy = c(i)*ay.^j; lgpy = c(i)*j*ay.^(j-1)./gpy; end % tanh warping function g(y) and log of the derivative log(g'(y))>0 % or derivatives of the latter w.r.t. ith hyperparameter function [gy,lgpy] = g_tanh(y,hyp,i) m = numel(hyp)/3; a = exp(hyp(1:m)); b = exp(hyp(m+(1:m))); c = hyp(2*m+(1:m)); if nargin==2 % function values gy = y; gpy = 1; for j=1:m ai = a(j); bi = b(j); ci = c(j); ti = tanh(bi*(y+ci)); dti = 1-ti.^2; gy = gy + ai *ti; gpy = gpy + ai*bi*dti; end lgpy = log(gpy); else % derivatives gpy = 1; for j=1:m ai = a(j); bi = b(j); ci = c(j); ti = tanh(bi*(y+ci)); dti = 1-ti.^2; gpy = gpy + ai*bi*dti; end if i<=m j = i; ai = a(j); bi = b(j); ci = c(j); ti = tanh(bi*(y+ci)); dti = 1-ti.^2; gy = ai*ti; lgpy = ai*bi*dti./gpy; elseif i<=2*m j = i-m; ai = a(j); bi = b(j); ci = c(j); ti = tanh(bi*(y+ci)); dti = 1-ti.^2; gy = ai*bi*dti.*(y+ci); d2ti = -2*ti.*dti; lgpy = ai*bi*(dti+bi*d2ti.*(y+ci))./gpy; else j = i-2*m; ai = a(j); bi = b(j); ci = c(j); ti = tanh(bi*(y+ci)); dti = 1-ti.^2; gy = ai*bi*dti; d2ti = -2*ti.*dti; lgpy = ai*bi^2*d2ti./gpy; end end
github
kd383/GPML_SLD-master
likNegBinom.m
.m
GPML_SLD-master/gpml-matlab-v4.1-2017-10-19/lik/likNegBinom.m
4,884
utf_8
371431b58d1a1ee5317643cf4badc0a5
function [varargout] = likNegBinom(link, hyp, y, mu, s2, inf, i) % likNegBinom - Negative binomial likelihood function for count data y. % The expression for the likelihood is % likNegBinom(f) = 1/Z * mu^y / (r+mu)^(r+y), Z = G(y+1)*G(r)/(r^r*G(y+r)) % with G(t)=gamma(t)=(t-1)!, mean=mu and variance=mu*(mu+r)/r, where r is the % number of failures parameters, mu = g(f) is the negative binomial intensity, % f is a Gaussian process and y is the non-negative integer count data. % Hence, we have -- with log(Z)=r*log(r)+L(y+r)-L(y+1)-L(r), L(t)=gammaln(t) -- % llik(f) = log(likNegBinom(f)) = y*log(mu)-(r+y)*log(r+mu)-log(Z). % % We provide two inverse link functions 'exp' and 'logistic': % g(f) = exp(f) and g(f) = log(1+exp(f))). % The link functions are located at util/glm_invlink_*.m. % % Note that for neither link function the likelihood lik(f) is log concave. % % The hyperparameters are: % % hyp = [ log(r) ] % % Several modes are provided, for computing likelihoods, derivatives and moments % respectively, see likFunctions.m for the details. In general, care is taken % to avoid numerical issues when the arguments are extreme. % % See also LIKFUNCTIONS.M. % % Copyright (c) by Hannes Nickisch, 2016-12-09. if nargin<4, varargout = {'1'}; return; end % report number of hyperparameters if ~exist('psi'), mypsi = @digamma; else mypsi = @psi; end % no psi in Octave lr = hyp; r = exp(lr); if nargin<6 % prediction mode if inf is not present if numel(y)==0, y = zeros(size(mu)); end s2zero = 1; if nargin>4&&numel(s2)>0&&norm(s2)>eps, s2zero = 0; end % s2==0 ? if s2zero % log probability lZ = gammaln(y+1) + gammaln(r) - gammaln(y+r) - r*lr; lg = g(mu,link); mx = max(lg,lr); lgr = log(exp(lg-mx)+exp(lr-mx))+mx; % log(exp(lg)+r) lp = y.*lg - (y+r).*lgr - lZ; else lp = likNegBinom(link, hyp, y, mu, s2, 'infEP'); end ymu = {}; ys2 = {}; if nargout>1 % compute y moments by quadrature n = max([length(y),length(mu),length(s2)]); on = ones(n,1); N = 20; [t,w] = gauher(N); oN = ones(1,N); lw = ones(n,1)*log(w'); mu = mu(:).*on; sig = sqrt(s2(:)).*on; % vectors only lg = g(sig*t'+mu*oN,link); ymu = exp(logsumexp2(lg+lw)); % first moment using Gaussian-Hermite quad if nargout>2 elg = exp(lg); yv = elg.*(elg/r+1); % second y moment from negative binomial distribution ys2 = (yv+(elg-ymu*oN).^2)*w; end end varargout = {lp,ymu,ys2}; else switch inf case 'infLaplace' [lg,dlg,d2lg,d3lg] = g(mu,link); elg = exp(lg); lZ = gammaln(y+1) + gammaln(r) - gammaln(y+r) - r*lr; mx = max(lg,lr); lgr = log(exp(lg-mx)+exp(lr-mx))+mx; % log(exp(lg)+r) a = 1./(1+r./elg); da = a.*(1-a).*dlg; % auxiliary quantities if nargin<7 % no derivative mode lp = y.*lg - (y+r).*lgr - lZ; dlp = {}; d2lp = {}; d3lp = {}; % return arguments if nargout>1 dlp = y.*dlg - (y+r).*a.*dlg; % dlp, derivative of log likelihood if nargout>2 % d2lp, 2nd derivative of log likelihood d2lp = y.*d2lg - (y+r).*(a.*d2lg + da.*dlg); if nargout>3 % d3lp, 3rd derivative of log likelihood d3lp = y.*d3lg - (y+r).*(a.*d3lg + da.*(3*d2lg +(1-2*a).*dlg.*dlg)); end end end varargout = {lp,dlp,d2lp,d3lp}; else % derivative mode b = (y+r)./(elg+r); lp_dhyp = r*(1+log(r)-lgr-b-mypsi(r)+mypsi(y+r)); dlp_dhyp = r*dlg.*a.*(b-1); % first derivative d2lp_dhyp = r*((d2lg.*a+dlg.*da).*(b-1)-(dlg.*a).^2.*b); % and also second varargout = {lp_dhyp,dlp_dhyp,d2lp_dhyp}; end case 'infEP' if nargin<7 % no derivative mode % Since we are not aware of an analytical expression of the integral, % hence we use quadrature. varargout = cell(1,nargout); [varargout{:}] = lik_epquad({@likNegBinom,link},hyp,y,mu,s2); else % derivative mode varargout = {[]}; % deriv. wrt hyp.lik end case 'infVB' error('infVB not supported') end end % compute the log intensity using the inverse link function function varargout = g(f,link) varargout = cell(nargout, 1); % allocate the right number of output arguments if isequal(link,'exp') [varargout{:}] = glm_invlink_exp(f); elseif isequal(link,'logistic') [varargout{:}] = glm_invlink_logistic(f); else [varargout{:}] = glm_invlink_logistic2(link{2},f); end
github
kd383/GPML_SLD-master
likWeibull.m
.m
GPML_SLD-master/gpml-matlab-v4.1-2017-10-19/lik/likWeibull.m
4,638
utf_8
9dd3093ff8cf19d2b0aa38aa0d08f7da
function [varargout] = likWeibull(link, hyp, y, mu, s2, inf, i) % likWeibull - Weibull likelihood function for strictly positive data y. The % expression for the likelihood is % likWeibull(f) = g1*ka/mu * (g1*y/mu)^(ka-1) * exp(-(g1*y/mu)^ka) with % gj = gamma(1+j/ka), mean=mu and variance=mu^2*(g2/g1^2-1) where mu = g(f) is % the Weibull intensity, f is a Gaussian process, y is the positive data. % Hence, we have llik(f) = log(likWeibull(f)) = % log(g1*ka/mu) + (ka-1)*log(g1*y/mu) - (g1*y/mu)^ka. % % We provide two inverse link functions 'exp' and 'logistic': % g(f) = exp(f) and g(f) = log(1+exp(f))). % The link functions are located at util/glm_invlink_*.m. % % Note that for neither link function the likelihood lik(f) is log concave. % % The hyperparameters are: % % hyp = [ log(ka) ] % % Several modes are provided, for computing likelihoods, derivatives and moments % respectively, see likFunctions.m for the details. In general, care is taken % to avoid numerical issues when the arguments are extreme. % % See also LIKFUNCTIONS.M. % % Copyright (c) by Hannes Nickisch, 2016-10-04. if nargin<4, varargout = {'1'}; return; end % report number of hyperparameters ka = exp(hyp); lg1 = gammaln(1+1/ka); g1 = exp(lg1); dlg1 = -psi(1+1/ka)/ka; if nargin<6 % prediction mode if inf is not present if numel(y)==0, y = zeros(size(mu)); end s2zero = 1; if nargin>4&&numel(s2)>0&&norm(s2)>eps, s2zero = 0; end % s2==0 ? if s2zero % log probability lg = g(mu,link); lp = lg1 + log(ka) + (ka-1)*(lg1+log(y)) - ka*lg - exp(ka*(lg1+log(y)-lg)); else lp = likWeibull(link, hyp, y, mu, s2, 'infEP'); end ymu = {}; ys2 = {}; if nargout>1 % compute y moments by quadrature n = max([length(y),length(mu),length(s2)]); on = ones(n,1); N = 20; [t,w] = gauher(N); oN = ones(1,N); lw = ones(n,1)*log(w'); mu = mu(:).*on; sig = sqrt(s2(:)).*on; % vectors only lg = g(sig*t'+mu*oN,link); ymu = exp(logsumexp2(lg+lw)); % first moment using Gaussian-Hermite quad if nargout>2 elg = exp(lg); g2 = gamma(1+2/ka); yv = elg.^2*(g2/g1^2-1); % second y moment from Weibull distribution ys2 = (yv+(elg-ymu*oN).^2)*w; end end varargout = {lp,ymu,ys2}; else switch inf case 'infLaplace' [lg,dlg,d2lg,d3lg] = g(mu,link); elg = exp(-ka*lg); if nargin<7 % no derivative mode lp = lg1 + log(ka) + (ka-1)*(lg1+log(y)) -ka*lg - exp(ka*(lg1+log(y)-lg)); dlp = {}; d2lp = {}; d3lp = {}; % return arguments if nargout>1 dlp = -ka*dlg + ka*(g1*y).^ka .* elg.*dlg; % dlp, deriv of log lik if nargout>2 % d2lp, 2nd derivative of log likelihood d2lp = -ka*d2lg + ka*(g1*y).^ka .* ( -ka*elg.*dlg.^2 + elg.*d2lg ); if nargout>3 % d3lp, 3rd derivative of log likelihood a = ka^2*dlg.^3 -3*ka*dlg.*d2lg + d3lg; d3lp = - ka*d3lg + ka*(g1*y).^ka .* a .*elg; end end end varargout = {lp,dlp,d2lp,d3lp}; else % derivative mode v = ka*(lg1+log(y)-lg); ev = exp(v); % derivative of log lik w.r.t. ka w = v+ka*dlg1; dw = -ka*dlg; d2w = -ka*d2lg; lp_dhyp = 1 + w - ev.*w; dlp_dhyp = dw.*(1-ev.*(1+w)); % first derivative d2lp_dhyp = d2w.*(1-ev.*(1+w)) - dw.^2.*(ev.*(2+w)); % and also second varargout = {lp_dhyp,dlp_dhyp,d2lp_dhyp}; end case 'infEP' if nargin<7 % no derivative mode % Since we are not aware of an analytical expression of the integral, % we use quadrature. varargout = cell(1,nargout); [varargout{:}] = lik_epquad({@likWeibull,link},hyp,y,mu,s2); else % derivative mode varargout = {[]}; % deriv. wrt hyp.lik end case 'infVB' error('infVB not supported') end end % compute the log intensity using the inverse link function function varargout = g(f,link) varargout = cell(nargout, 1); % allocate the right number of output arguments if isequal(link,'exp') [varargout{:}] = glm_invlink_exp(f); elseif isequal(link,'logistic') [varargout{:}] = glm_invlink_logistic(f); else [varargout{:}] = glm_invlink_logistic2(link{2},f); end
github
kd383/GPML_SLD-master
likGamma.m
.m
GPML_SLD-master/gpml-matlab-v4.1-2017-10-19/lik/likGamma.m
4,663
utf_8
fd847e2de452088e865d5bf34fe3ed10
function [varargout] = likGamma(link, hyp, y, mu, s2, inf, i) % likGamma - Gamma likelihood function for strictly positive data y. The % expression for the likelihood is % likGamma(f) = al^al*y^(al-1)/gamma(al) * exp(-y*al/mu) / mu^al with % mean=mu and variance=mu^2/al where mu = g(f) is the Gamma intensity, f is a % Gaussian process, y is the strictly positive data. Hence, we have -- with % log(Zy) = log(gamma(al)) - al*log(al) + (1-al)*log(y) % llik(f) = log(likGamma(f)) = -al*( log(g(f)) + y/g(f) ) - log(Zy). % The larger one chooses al, the stronger the likelihood resembles a Gaussian % since skewness = 2/sqrt(al) and kurtosis = 6/al. % % We provide two inverse link functions 'exp' and 'logistic': % g(f) = exp(f) and g(f) = log(1+exp(f))). % The link functions are located at util/glm_invlink_*.m. % % Note that for neither link function the likelihood lik(f) is log concave. % % The hyperparameters are: % % hyp = [ log(al) ] % % Several modes are provided, for computing likelihoods, derivatives and moments % respectively, see likFunctions.m for the details. In general, care is taken % to avoid numerical issues when the arguments are extreme. % % See also LIKFUNCTIONS.M. % % Copyright (c) by Hannes Nickisch, 2016-10-04. if nargin<4, varargout = {'1'}; return; end % report number of hyperparameters al = exp(hyp); if nargin<6 % prediction mode if inf is not present if numel(y)==0, y = zeros(size(mu)); end s2zero = 1; if nargin>4&&numel(s2)>0&&norm(s2)>eps, s2zero = 0; end % s2==0 ? if s2zero % log probability lg = g(mu,link); lZy = gammaln(al) - al*log(al) + (1-al)*log(y); % normalisation constant lp = -al*(lg+y./exp(lg)) - lZy; else lp = likGamma(link, hyp, y, mu, s2, 'infEP'); end ymu = {}; ys2 = {}; if nargout>1 % compute y moments by quadrature n = max([length(y),length(mu),length(s2)]); on = ones(n,1); N = 20; [t,w] = gauher(N); oN = ones(1,N); lw = ones(n,1)*log(w'); mu = mu(:).*on; sig = sqrt(s2(:)).*on; % vectors only lg = g(sig*t'+mu*oN,link); ymu = exp(logsumexp2(lg+lw)); % first moment using Gaussian-Hermite quad if nargout>2 elg = exp(lg); yv = elg.^2/al; % second y moment from Gamma distribution ys2 = (yv+(elg-ymu*oN).^2)*w; end end varargout = {lp,ymu,ys2}; else switch inf case 'infLaplace' [lg,dlg,d2lg,d3lg] = g(mu,link); elg = exp(lg); if nargin<7 % no derivative mode lZy = gammaln(al) - al*log(al) + (1-al)*log(y); % normalisation constant lp = -al*(lg+y./elg) - lZy; dlp = {}; d2lp = {}; d3lp = {}; % return arguments if nargout>1 dlp = -al*dlg.*(1-y./elg); % dlp, derivative of log likelihood if nargout>2 % d2lp, 2nd derivative of log likelihood d2lp = -al*d2lg.*(1-y./elg) - al*dlg.*dlg.*y./elg; if nargout>3 % d3lp, 3rd derivative of log likelihood d3lp = -al*d3lg.*(1-y./elg) + al*dlg.*(dlg.*dlg-3*d2lg).*y./elg; end end end varargout = {lp,dlp,d2lp,d3lp}; else % derivative mode dlZy = al*psi(0,al) - al*(log(al) + 1 + log(y)); lp_dhyp = -al*(lg+y./elg) - dlZy; % derivative of log likelihood w.r.t. al dlp_dhyp = -al*dlg.*(1-y./elg); % first derivative d2lp_dhyp = -al*d2lg.*(1-y./elg) - al*dlg.*dlg.*y./elg; % and also second varargout = {lp_dhyp,dlp_dhyp,d2lp_dhyp}; end case 'infEP' if nargin<7 % no derivative mode % Since we are not aware of an analytical expression of the integral, % we use quadrature. varargout = cell(1,nargout); [varargout{:}] = lik_epquad({@likGamma,link},hyp,y,mu,s2); else % derivative mode varargout = {[]}; % deriv. wrt hyp.lik end case 'infVB' error('infVB not supported') end end % compute the log intensity using the inverse link function function varargout = g(f,link) varargout = cell(nargout, 1); % allocate the right number of output arguments if isequal(link,'exp') [varargout{:}] = glm_invlink_exp(f); elseif isequal(link,'logistic') [varargout{:}] = glm_invlink_logistic(f); else [varargout{:}] = glm_invlink_logistic2(link{2},f); end
github
kd383/GPML_SLD-master
likInvGauss.m
.m
GPML_SLD-master/gpml-matlab-v4.1-2017-10-19/lik/likInvGauss.m
4,769
utf_8
31cfacf6a5b3bb0a9b090dd6ef59bb57
function [varargout] = likInvGauss(link, hyp, y, mu, s2, inf, i) % likInvGauss - Inverse Gaussian likelihood function for strictly positive data % y. The expression for the likelihood is % likInvGauss(f) = sqrt(lam/(2*pi*y^3))*exp(-lam*(mu-y)^2/(2*mu^2*y)) with % mean=mu and variance=mu^3/lam where mu = g(f) is the Inverse Gaussian % intensity, f is a Gaussian process, y is the strictly positive data. % Hence, we have -- with log(Zy) = -(log(lam)-log(2*pi*y^3))/2 % llik(f) = log(likInvGauss(f)) = -lam*(y-mu)^2/(2*mu^2*y) - log(Zy). % The larger one chooses lam, the stronger the likelihood resembles a Gaussian % since skewness = 3*sqrt(mu/lam) and kurtosis = 15*mu/lam. % % We provide two inverse link functions 'exp' and 'logistic': % g(f) = exp(f) and g(f) = log(1+exp(f))). % The link functions are located at util/glm_invlink_*.m. % % Note that for neither link function the likelihood lik(f) is log concave. % % The hyperparameters are: % % hyp = [ log(lam) ] % % Several modes are provided, for computing likelihoods, derivatives and moments % respectively, see likFunctions.m for the details. In general, care is taken % to avoid numerical issues when the arguments are extreme. % % See also LIKFUNCTIONS.M. % % Copyright (c) by Hannes Nickisch, 2016-10-04. if nargin<4, varargout = {'1'}; return; end % report number of hyperparameters lam = exp(hyp); if nargin<6 % prediction mode if inf is not present if numel(y)==0, y = zeros(size(mu)); end s2zero = 1; if nargin>4&&numel(s2)>0&&norm(s2)>eps, s2zero = 0; end % s2==0 ? if s2zero % log probability lg = g(mu,link); elg = exp(lg); lZy = -(log(lam)-log(2*pi*y.^3))/2; % normalisation constant lp = -lam*(y./elg-1).^2 ./(2*y) - lZy; else lp = likInvGauss(link, hyp, y, mu, s2, 'infEP'); end ymu = {}; ys2 = {}; if nargout>1 % compute y moments by quadrature n = max([length(y),length(mu),length(s2)]); on = ones(n,1); N = 20; [t,w] = gauher(N); oN = ones(1,N); lw = ones(n,1)*log(w'); mu = mu(:).*on; sig = sqrt(s2(:)).*on; % vectors only lg = g(sig*t'+mu*oN,link); ymu = exp(logsumexp2(lg+lw)); % first moment using Gaussian-Hermite quad if nargout>2 elg = exp(lg); yv = elg.^3/lam; % second y moment from inverse Gaussian distribution ys2 = (yv+(elg-ymu*oN).^2)*w; end end varargout = {lp,ymu,ys2}; else switch inf case 'infLaplace' [lg,dlg,d2lg,d3lg] = g(mu,link); elg = exp(lg); if nargin<7 % no derivative mode lZy = -(log(lam)-log(2*pi*y.^3))/2; % normalisation constant lp = -lam*(y./elg-1).^2 ./(2*y) - lZy; dlp = {}; d2lp = {}; d3lp = {}; % return arguments if nargout>1 dlp = lam*(y./elg-1).*dlg./elg; % dlp, derivative of log likelihood if nargout>2 % d2lp, 2nd derivative of log likelihood d2lp = lam*( (y./elg-1).*(d2lg-dlg.^2) - y.*dlg.^2./elg )./elg; if nargout>3 % d3lp, 3rd derivative of log likelihood d3lp = lam*( (y./elg-1) .* (4*dlg.^3-6*dlg.*d2lg+d3lg) ... + (3*dlg.^3 - 3*dlg.*d2lg) )./ elg; end end end varargout = {lp,dlp,d2lp,d3lp}; else % derivative mode lp_dhyp = 1/2-lam*(y./elg-1).^2 ./(2*y); % deriv. of log lik w.r.t. lam dlp_dhyp = lam*(y./elg-1).*dlg./elg; % first derivative d2lp_dhyp = lam*( (y./elg-1).*(d2lg-dlg.^2) - y.*dlg.^2./elg )./elg; % 2nd varargout = {lp_dhyp,dlp_dhyp,d2lp_dhyp}; end case 'infEP' if nargin<7 % no derivative mode % Since we are not aware of an analytical expression of the integral, % we use quadrature. varargout = cell(1,nargout); [varargout{:}] = lik_epquad({@likInvGauss,link},hyp,y,mu,s2); else % derivative mode varargout = {[]}; % deriv. wrt hyp.lik end case 'infVB' error('infVB not supported') end end % compute the log intensity using the inverse link function function varargout = g(f,link) varargout = cell(nargout, 1); % allocate the right number of output arguments if isequal(link,'exp') [varargout{:}] = glm_invlink_exp(f); elseif isequal(link,'logistic') [varargout{:}] = glm_invlink_logistic(f); else [varargout{:}] = glm_invlink_logistic2(link{2},f); end
github
kd383/GPML_SLD-master
likPoisson.m
.m
GPML_SLD-master/gpml-matlab-v4.1-2017-10-19/lik/likPoisson.m
4,268
utf_8
b7d00b67bdb25ebd320b90fc7baac258
function [varargout] = likPoisson(link, hyp, y, mu, s2, inf, i) % likPoisson - Poisson likelihood function for count data y. The expression for % the likelihood is % likPoisson(f) = mu^y * exp(-mu) / y! with mean=variance=mu % where mu = g(f) is the Poisson intensity, f is a % Gaussian process, y is the non-negative integer count data and % y! = gamma(y+1) its factorial. Hence, we have -- with Zy = gamma(y+1) = y! -- % llik(f) = log(likPoisson(f)) = log(g(f))*y - g(f) - log(Zy). % The larger the intensity mu, the stronger the likelihood resembles a Gaussian % since skewness = 1/sqrt(mu) and kurtosis = 1/mu. % % We provide two inverse link functions 'exp' and 'logistic': % For g(f) = exp(f), we have lik(f) = exp(f*y-exp(f)) / Zy. % For g(f) = log(1+exp(f))), we have lik(f) = log^y(1+exp(f)))(1+exp(f)) / Zy. % The link functions are located at util/glm_invlink_*.m. % % Note that for both intensities g(f) the likelihood lik(f) is log concave. % % Several modes are provided, for computing likelihoods, derivatives and moments % respectively, see likFunctions.m for the details. In general, care is taken % to avoid numerical issues when the arguments are extreme. % % See also LIKFUNCTIONS.M. % % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-10-04. if nargin<4, varargout = {'0'}; return; end % report number of hyperparameters if nargin<6 % prediction mode if inf is not present if numel(y)==0, y = zeros(size(mu)); end s2zero = 1; if nargin>4&&numel(s2)>0&&norm(s2)>eps, s2zero = 0; end % s2==0 ? if s2zero % log probability lg = g(mu,link); lp = lg.*y - exp(lg) - gammaln(y+1); else lp = likPoisson(link, hyp, y, mu, s2, 'infEP'); end ymu = {}; ys2 = {}; if nargout>1 % compute y moments by quadrature n = max([length(y),length(mu),length(s2)]); on = ones(n,1); N = 20; [t,w] = gauher(N); oN = ones(1,N); lw = ones(n,1)*log(w'); mu = mu(:).*on; sig = sqrt(s2(:)).*on; % vectors only lg = g(sig*t'+mu*oN,link); ymu = exp(logsumexp2(lg+lw)); % first moment using Gaussian-Hermite quad if nargout>2 elg = exp(lg); yv = elg; % second y moment from Poisson distribution ys2 = (yv+(elg-ymu*oN).^2)*w; end end varargout = {lp,ymu,ys2}; else switch inf case 'infLaplace' if nargin<7 % no derivative mode [lg,dlg,d2lg,d3lg] = g(mu,link); elg = exp(lg); lp = lg.*y - elg - gammaln(y+1); dlp = {}; d2lp = {}; d3lp = {}; % return arguments if nargout>1 dlp = dlg.*(y-elg); % dlp, derivative of log likelihood if nargout>2 % d2lp, 2nd derivative of log likelihood d2lp = d2lg.*(y-elg) - dlg.*dlg.*elg; if nargout>3 % d3lp, 3rd derivative of log likelihood d3lp = d3lg.*(y-elg) - dlg.*(dlg.*dlg+3*d2lg).*elg; end end end varargout = {lp,dlp,d2lp,d3lp}; else % derivative mode varargout = {[],[],[]}; % derivative w.r.t. hypers end case 'infEP' if nargin<7 % no derivative mode % Since we are not aware of an analytical expression of the integral, % hence we use quadrature. varargout = cell(1,nargout); [varargout{:}] = lik_epquad({@likPoisson,link},hyp,y,mu,s2); else % derivative mode varargout = {[]}; % deriv. wrt hyp.lik end case 'infVB' error('infVB not supported') end end % compute the log intensity using the inverse link function function varargout = g(f,link) varargout = cell(nargout, 1); % allocate the right number of output arguments if isequal(link,'exp') [varargout{:}] = glm_invlink_exp(f); elseif isequal(link,'logistic') [varargout{:}] = glm_invlink_logistic(f); else [varargout{:}] = glm_invlink_logistic2(link{2},f); end
github
kd383/GPML_SLD-master
likLogistic.m
.m
GPML_SLD-master/gpml-matlab-v4.1-2017-10-19/lik/likLogistic.m
6,137
utf_8
527e5959fbb8bae3f9980e898ada4956
function [varargout] = likLogistic(hyp, y, mu, s2, inf, i) % likLogistic - logistic function for binary classification or logit regression. % The expression for the likelihood is % likLogistic(t) = 1./(1+exp(-t)). % % Several modes are provided, for computing likelihoods, derivatives and moments % respectively, see likFunctions.m for the details. In general, care is taken % to avoid numerical issues when the arguments are extreme. The moments % \int f^k likLogistic(y,f) N(f|mu,var) df are calculated via a cumulative % Gaussian scale mixture approximation. % % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2013-09-02. % % See also LIKFUNCTIONS.M. if nargin<3, varargout = {'0'}; return; end % report number of hyperparameters if nargin>1, y = sign(y); y(y==0) = 1; else y = 1; end % allow only +/- 1 values if numel(y)==0, y = 1; end if nargin<5 % prediction mode if inf is not present y = y.*ones(size(mu)); % make y a vector s2zero = 1; if nargin>3&&numel(s2)>0&&norm(s2)>eps, s2zero = 0; end % s2==0 ? if s2zero % log probability evaluation yf = y.*mu; % product latents and labels lp = yf; ok = -35<yf; lp(ok) = -log(1+exp(-yf(ok))); % log of likelihood else % prediction lp = likLogistic(hyp, y, mu, s2, 'infEP'); end ymu = {}; ys2 = {}; if nargout>1 p = exp(lp); ymu = 2*p-1; % first y moment if nargout>2 ys2 = 4*p.*(1-p); % second y moment end end varargout = {lp,ymu,ys2}; else % inference mode switch inf case 'infLaplace' if nargin<6 % no derivative mode f = mu; yf = y.*f; s = -yf; % product latents and labels dlp = {}; d2lp = {}; d3lp = {}; % return arguments ps = max(0,s); lp = -(ps+log(exp(-ps)+exp(s-ps))); % lp = -(log(1+exp(s))) if nargout>1 % first derivatives s = min(0,f); p = exp(s)./(exp(s)+exp(s-f)); % p = 1./(1+exp(-f)) dlp = (y+1)/2-p; % derivative of log likelihood if nargout>2 % 2nd derivative of log likelihood d2lp = -exp(2*s-f)./(exp(s)+exp(s-f)).^2; if nargout>3 % 3rd derivative of log likelihood d3lp = 2*d2lp.*(0.5-p); end end end varargout = {lp,dlp,d2lp,d3lp}; else % derivative mode varargout = {[],[],[]}; % derivative w.r.t. hypers end case 'infEP' if nargin<6 % no derivative mode y = y.*ones(size(mu)); % make y a vector % likLogistic(t) \approx 1/2 + \sum_{i=1}^5 (c_i/2) erf(lam_i/sqrt(2)t) lam = sqrt(2)*[0.44 0.41 0.40 0.39 0.36]; % approx coeffs lam_i and c_i c = [1.146480988574439e+02; -1.508871030070582e+03; 2.676085036831241e+03; -1.356294962039222e+03; 7.543285642111850e+01 ]; [lZc,dlZc,d2lZc] = likErf([], y*ones(1,5), mu*lam, s2*(lam.^2), inf); lZ = log_expA_x(lZc,c); % A=lZc, B=dlZc, d=c.*lam', lZ=log(exp(A)*c) dlZ = expABz_expAx(lZc, c, dlZc, c.*lam'); % ((exp(A).*B)*d)./(exp(A)*c) % d2lZ = ((exp(A).*Z)*e)./(exp(A)*c) - dlZ.^2 where e = c.*(lam.^2)' d2lZ = expABz_expAx(lZc, c, dlZc.^2+d2lZc, c.*(lam.^2)') - dlZ.^2; % The scale mixture approximation does not capture the correct asymptotic % behavior; we have linear decay instead of quadratic decay as suggested % by the scale mixture approximation. By observing that for large values % of -f*y ln(p(y|f)) for likLogistic is linear in f with slope y, we are % able to analytically integrate the tail region. val = abs(mu)-196/200*s2-4; % empirically determined bound at val==0 lam = 1./(1+exp(-10*val)); % interpolation weights lZtail = min(s2/2-abs(mu),-0.1); % apply the same to p(y|f) = 1 - p(-y|f) dlZtail = -sign(mu); d2lZtail = zeros(size(mu)); id = y.*mu>0; lZtail(id) = log(1-exp(lZtail(id))); % label and mean agree dlZtail(id) = 0; lZ = (1-lam).* lZ + lam.* lZtail; % interpolate between scale .. dlZ = (1-lam).* dlZ + lam.* dlZtail; % .. mixture and .. d2lZ = (1-lam).*d2lZ + lam.*d2lZtail; % .. tail approximation varargout = {lZ,dlZ,d2lZ}; else % derivative mode varargout = {[]}; % deriv. wrt hyp.lik end case 'infVB' % variational lower site bound % using -log(1+exp(-s)) = s/2 -log( 2*cosh(s/2) ); % the bound has the form: (b+z/ga)*f - f.^2/(2*ga) - h(ga)/2 n = numel(s2); b = (y/2).*ones(n,1); z = zeros(size(b)); varargout = {b,z}; end end % computes y = log( exp(A)*x ) in a numerically safe way by subtracting the % maximal value in each row to avoid cancelation after taking the exp function y = log_expA_x(A,x) N = size(A,2); maxA = max(A,[],2); % number of columns, max over columns y = log(exp(A-maxA*ones(1,N))*x) + maxA; % exp(A) = exp(A-max(A))*exp(max(A)) % computes y = ( (exp(A).*B)*z ) ./ ( exp(A)*x ) in a numerically safe way % The function is not general in the sense that it yields correct values for % all types of inputs. We assume that the values are close together. function y = expABz_expAx(A,x,B,z) N = size(A,2); maxA = max(A,[],2); % number of columns, max over columns A = A-maxA*ones(1,N); % subtract maximum value y = ( (exp(A).*B)*z ) ./ ( exp(A)*x );
github
kd383/GPML_SLD-master
likSech2.m
.m
GPML_SLD-master/gpml-matlab-v4.1-2017-10-19/lik/likSech2.m
8,514
utf_8
669db149fc7157ab5834a447ecfdc501
function [varargout] = likSech2(hyp, y, mu, s2, inf, i) % likSech2 - sech-square likelihood function for regression. Often, the sech- % square distribution is also referred to as the logistic distribution not to be % confused with the logistic function for classification. The expression for the % likelihood is % likSech2(t) = Z / cosh(tau*(y-t))^2 where % tau = pi/(2*sqrt(3)*sn) and Z = tau/2 % and y is the mean and sn^2 is the variance. % % hyp = [ log(sn) ] % % Several modes are provided, for computing likelihoods, derivatives and moments % respectively, see likFunctions.m for the details. In general, care is taken % to avoid numerical issues when the arguments are extreme. The moments % \int f^k likSech2(y,f) N(f|mu,var) df are calculated via a Gaussian % scale mixture approximation. % % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2013-09-02. % % See also LIKFUNCTIONS.M, LIKLOGISTIC.M. if nargin<3, varargout = {'1'}; return; end % report number of hyperparameters sn = exp(hyp); tau = pi/(2*sqrt(3)*sn); lZ = log(pi) - log(sn) - log(4*sqrt(3)); if nargin<5 % prediction mode if inf is not present if numel(y)==0, y = zeros(size(mu)); end s2zero = 1; if nargin>3&&numel(s2)>0&&norm(s2)>eps, s2zero = 0; end % s2==0 ? if s2zero % log probability evaluation lp = lZ - 2*logcosh(tau*(y-mu)); s2 = 0; else % prediction lp = likSech2(hyp, y, mu, s2, 'infEP'); end ymu = {}; ys2 = {}; if nargout>1 ymu = mu; % first y moment if nargout>2 ys2 = s2 + sn.^2; % second y moment end end varargout = {lp,ymu,ys2}; else % inference mode switch inf case 'infLaplace' r = y-mu; [g,dg,d2g,d3g] = logcosh(tau.*r); % precompute derivatives if nargin<6 % no derivative mode dlp = {}; d2lp = {}; d3lp = {}; lp = lZ - 2*g; if nargout>1 % first derivatives dlp = 2*tau.*dg; if nargout>2 % 2nd derivative of log likelihood d2lp = -2*tau.^2.*d2g; if nargout>3 % 3rd derivative of log likelihood d3lp = 2*tau.^3.*d3g; end end end varargout = {lp,dlp,d2lp,d3lp}; else % derivative mode lp_dhyp = 2*tau.*r.*dg - 1; % derivative w.r.t. sn dlp_dhyp = -2*tau.*(dg+tau.*r.*d2g); d2lp_dhyp = 2*tau.^2.*(2*d2g + tau.*r.*d3g); varargout = {lp_dhyp,dlp_dhyp,d2lp_dhyp}; end case 'infEP' n = max([length(y),length(mu),length(s2),length(sn)]); on = ones(n,1); y = y.*on; mu = mu.*on; s2 = s2.*on; sn = sn.*on; % vectors only fac = 1e3; % factor between the widths of the two distributions ... % ... from when one considered a delta peak, we use 3 orders of magnitude idlik = fac*sn<sqrt(s2); % Likelihood is a delta peak idgau = fac*sqrt(s2)<sn; % Gaussian is a delta peak id = ~idgau & ~idlik; % interesting case in between % likLogistic(t) \approx 1/2 + \sum_{i=1}^5 (c_i/2) erf(lam_i/sqrt(2)t) % likSech2(t|y,sn) \approx \sum_{i=1}^5 c_i likGauss(t|y,sn*rho_i) lam = sqrt(2)*[0.44 0.41 0.40 0.39 0.36]; % approx coeffs lam_i, c_i, rho_i c = [1.146480988574439e+02; -1.508871030070582e+03; 2.676085036831241e+03; -1.356294962039222e+03; 7.543285642111850e+01 ]; rho = sqrt(3)./(pi*lam); o5 = ones(1,5); if nargin<6 % no derivative mode lZ = zeros(n,1); dlZ = lZ; d2lZ = lZ; % allocate memory if any(idlik) [lZ(idlik),dlZ(idlik),d2lZ(idlik)] = ... likGauss(log(s2(idlik))/2, mu(idlik), y(idlik)); end if any(idgau) [lZ(idgau),dlZ(idgau),d2lZ(idgau)] = ... likSech2(log(sn(idgau)), mu(idgau), y(idgau)); end if any(id) [lZc,dlZc,d2lZc] = likGauss(log(sn(id)*rho), ... y(id)*o5, mu(id)*o5, s2(id)*o5, inf); lZ(id) = log_expA_x(lZc,c); % A=lZc, B=dlZc, lZ=log(exp(A)*c) dlZ(id) = expABz_expAx(lZc, c, dlZc, c); % ((exp(A).*B)*c)./(exp(A)*c) % d2lZ(id) = ((exp(A).*Z)*c)./(exp(A)*c) - dlZ.^2 d2lZ(id) = expABz_expAx(lZc, c, dlZc.^2+d2lZc, c) - dlZ(id).^2; % the tail asymptotics of likSech2 is the same as for likLaplace % which is not covered by the scale mixture approximation, so for % extreme values, we approximate likSech2 by a rescaled likLaplace tmu = (mu-y)./sn; tvar = s2./sn.^2; crit = 0.596*(abs(tmu)-5.38)-tvar; idl = -1<crit & id; % if 0<crit, Laplace is better if any(idl) % close to zero, we use a smooth .. lam = 1./(1+exp(-15*crit(idl))); % .. interpolation with weights lam thyp = log(sqrt(6)*sn(idl)/pi); [lZl,dlZl,d2lZl] = likLaplace(thyp, y(idl), mu(idl), s2(idl), inf); lZ(idl) = (1-lam).*lZ(idl) + lam.*lZl; dlZ(idl) = (1-lam).*dlZ(idl) + lam.*dlZl; d2lZ(idl) = (1-lam).*d2lZ(idl) + lam.*d2lZl; end end varargout = {lZ,dlZ,d2lZ}; else % derivative mode dlZhyp = zeros(n,1); if any(idlik) dlZhyp(idlik) = 0; end if any(idgau) dlZhyp(idgau) = ... likSech2(log(sn(idgau)), mu(idgau), y(idgau), 'infLaplace', 1); end if any(id) lZc = likGauss(log(sn(id)*rho),y(id)*o5,mu(id)*o5,s2(id)*o5,inf); dlZhypc = likGauss(log(sn(id)*rho),y(id)*o5,mu(id)*o5,s2(id)*o5,inf,1); % dlZhyp = ((exp(lZc).*dlZhypc)*c)./(exp(lZc)*c) dlZhyp(id) = expABz_expAx(lZc, c, dlZhypc, c); % the tail asymptotics of likSech2 is the same as for likLaplace % which is not covered by the scale mixture approximation, so for % extreme values, we approximate likLogistic by a rescaled likLaplace tmu = (mu-y)./sn; tvar = s2./sn.^2; crit = 0.596*(abs(tmu)-5.38)-tvar; idl = -1<crit & id; % if 0<crit, Laplace is better if any(idl) % close to zero, we use a smooth .. lam = 1./(1+exp(-15*crit(idl))); % .. interpolation with weights lam thyp = log(sqrt(6)*sn(idl)/pi); dlZhypl = likLaplace(thyp, y(idl), mu(idl), s2(idl), inf, i); dlZhyp(idl) = (1-lam).*dlZhyp(idl) + lam.*dlZhypl; end end varargout = {dlZhyp}; % derivative w.r.t. hypers end case 'infVB' % variational lower site bound % using -log( 2*cosh(s/2) ); % the bound has the form: (b+z/ga)*f - f.^2/(2*ga) - h(ga)/2 n = numel(s2); b = zeros(n,1); y = y.*ones(n,1); z = y; varargout = {b,z}; end end % numerically safe version of log(cosh(x)) = log(exp(x)+exp(-x))-log(2) function [f,df,d2f,d3f] = logcosh(x) a = exp(-2*abs(x)); % always between 0 and 1 and therefore safe to evaluate f = abs(x) + log(1+a) - log(2); df = sign(x).*( 1 - 2*a./(1+a) ); d2f = 4*a./(1+a).^2; d3f = -8*sign(x).*a.*(1-a)./(1+a).^3; % computes y = log( exp(A)*x ) in a numerically safe way by subtracting the % maximal value in each row to avoid cancelation after taking the exp function y = log_expA_x(A,x) N = size(A,2); maxA = max(A,[],2); % number of columns, max over columns y = log(exp(A-maxA*ones(1,N))*x) + maxA; % exp(A) = exp(A-max(A))*exp(max(A)) % computes y = ( (exp(A).*B)*z ) ./ ( exp(A)*x ) in a numerically safe way % The function is not general in the sense that it yields correct values for % all types of inputs. We assume that the values are close together. function y = expABz_expAx(A,x,B,z) N = size(A,2); maxA = max(A,[],2); % number of columns, max over columns A = A-maxA*ones(1,N); % subtract maximum value y = ( (exp(A).*B)*z ) ./ ( exp(A)*x );
github
kd383/GPML_SLD-master
likGumbel.m
.m
GPML_SLD-master/gpml-matlab-v4.1-2017-10-19/lik/likGumbel.m
3,976
utf_8
3ac9c17ecc01a2a501fb5eb5bafeea6c
function [varargout] = likGumbel(sign, hyp, y, mu, s2, inf, i) % likGumbel - Gumbel likelihood function for extremal value regression. % The expression for the likelihood is % likGumbel(t) = exp(-z-exp(-z))/be, z = ga+s*(y-t)/be, be = sn*sqrt(6)/pi % where s={+1,-1} is a sign switching between left and right skewed, ga is the % Euler-Mascheroni constant, y is the mean, sn^2 is the variance. % The skewness and kurtosis of likGumbel are 1.14*s and 2.4, respectively. % % The hyperparameters are: % % hyp = [ log(sn) ] % % Several modes are provided, for computing likelihoods, derivatives and moments % respectively, see likFunctions.m for the details. In general, care is taken % to avoid numerical issues when the arguments are extreme. % % Copyright (c) by Hannes Nickisch, 2013-11-01. % % See also LIKFUNCTIONS.M. if nargin<4, varargout = {'1'}; return; end % report number of hyperparameters if sign=='-', s = -1; else s = 1; end % extract sign of skewness sn2 = exp(2*hyp); % extract hyperparameters ga = 0.5772156649; % Euler-Mascheroni constant be = sqrt(6*sn2)/pi; lZ = -log(be); if nargin<6 % prediction mode if inf is not present if numel(y)==0, y = zeros(size(mu)); end s2zero = 1; if nargin>4&&numel(s2)>0&&norm(s2)>eps, s2zero = 0; end % s2==0 ? if s2zero % log probability evaluation lp = likGumbel(sign, hyp, y, mu, [], 'infLaplace'); s2 = 0; else % prediction lp = likGumbel(sign, hyp, y, mu, s2, 'infEP'); end ymu = {}; ys2 = {}; if nargout>1 ymu = mu; % first y moment if nargout>2 ys2 = s2 + sn2; % second y moment end end varargout = {lp,ymu,ys2}; else switch inf case 'infLaplace' z = ga+s*(y-mu)/be; emz = exp(-z); if nargin<7 % no derivative mode dlp = {}; d2lp = {}; d3lp = {}; lp = lZ -z -emz; if nargout>1 dz = -s/be; % dz/dmu dlp = dz*(emz-1); % dlp, derivative of log likelihood if nargout>2 % d2lp, 2nd derivative of log likelihood d2lp = -dz^2*emz; if nargout>3 % d3lp, 3rd derivative of log likelihood d3lp = dz^3*emz; end end end varargout = {lp,dlp,d2lp,d3lp}; else % derivative w.r.t. log(sn) dz = -s/be; % dz/dmu dzs = -s*(y-mu)/be; % dz/dlog(sn) lp_dhyp = dzs.*(emz-1) -1; dlp_dhyp = dz*(1-emz.*(1+dzs)); d2lp_dhyp = dz^2*emz.*(2+dzs); varargout = {lp_dhyp,dlp_dhyp,d2lp_dhyp}; end case 'infEP' if nargout>1 error('infEP not supported since likT is not log-concave') end n = max([length(y),length(mu),length(s2)]); on = ones(n,1); y = y(:).*on; mu = mu(:).*on; sig = sqrt(s2(:)).*on; % vectors only % since we are not aware of an analytical expression of the integral, % we use Gaussian-Hermite quadrature N = 20; [t,w] = gauher(N); oN = ones(1,N); lZ = likGumbel(sign, hyp, y*oN, sig*t'+mu*oN, []); lZ = log_expA_x(lZ,w); % log( exp(lZ)*w ) varargout = {lZ}; case 'infVB' error('infVB not supported') end end % computes y = log( exp(A)*x ) in a numerically safe way by subtracting the % maximal value in each row to avoid cancelation after taking the exp function y = log_expA_x(A,x) N = size(A,2); maxA = max(A,[],2); % number of columns, max over columns y = log(exp(A-maxA*ones(1,N))*x) + maxA; % exp(A) = exp(A-max(A))*exp(max(A))