function [x,y,typ]=Hopfield4(job,arg1,arg2)
    x=[];y=[];typ=[];
    select job
    case 'plot' then standard_draw(arg1)
    case 'getinputs' then [x,y,typ]=standard_inputs(arg1)
    case 'getoutputs' then [x,y,typ]=standard_outputs(arg1)
    case 'getorigin' then [x,y]=standard_origin(arg1)
    case 'set' then
        x=arg1;graphics=arg1.graphics;model=arg1.model;exprs=graphics.exprs;
        while %t do
            //[ok,num_of_blk,mblif_num,Hopfield4_W21p,Hopfield4_W31p,Hopfield4_W41p,Hopfield4_N1p,Hopfield4_W21n,Hopfield4_W31n,Hopfield4_W41n,Hopfield4_N1n,Hopfield4_W12p,Hopfield4_W32p,Hopfield4_W42p,Hopfield4_N2p,Hopfield4_W12n,Hopfield4_W32n,Hopfield4_W42n,Hopfield4_N2n,Hopfield4_W13p,Hopfield4_W23p,Hopfield4_W43p,Hopfield4_N3Gp,Hopfield4_N3p,Hopfield4_W13n,Hopfield4_W23n,Hopfield4_W43n,Hopfield4_N3Gn,Hopfield4_N3n,Hopfield4_W14p,Hopfield4_W24p,Hopfield4_W34p,Hopfield4_N4Gp,Hopfield4_N4p,Hopfield4_W14n,Hopfield4_W24n,Hopfield4_W34n,Hopfield4_N4Gn,Hopfield4_N4n,Hopfield4_In11p,Hopfield4_In13p,Hopfield4_In21p,Hopfield4_In11n,Hopfield4_In21n,Hopfield4_In12p,Hopfield4_In22p,Hopfield4_In12n,Hopfield4_In22n,Hopfield4_In13n,Hopfield4_In23n,Hopfield4_In14p,Hopfield4_In24p,Hopfield4_In14n,Hopfield4_In24n,Hopfield4_In23p,Hopfield4_ibias2,Hopfield4_pbias2,Hopfield4_nbias2,Hopfield4_ibias1,Hopfield4_pbias1,Hopfield4_nbias1,Hopfield4_ibias3,Hopfield4_ibias4,fix_loc,exprs]=scicos_getvalue('New Block Parameter',['num_of_blk';'mblif_num';'Hopfield4_W21p';'Hopfield4_W31p';'Hopfield4_W41p';'Hopfield4_N1p';'Hopfield4_W21n';'Hopfield4_W31n';'Hopfield4_W41n';'Hopfield4_N1n';'Hopfield4_W12p';'Hopfield4_W32p';'Hopfield4_W42p';'Hopfield4_N2p';'Hopfield4_W12n';'Hopfield4_W32n';'Hopfield4_W42n';'Hopfield4_N2n';'Hopfield4_W13p';'Hopfield4_W23p';'Hopfield4_W43p';'Hopfield4_N3Gp';'Hopfield4_N3p';'Hopfield4_W13n';'Hopfield4_W23n';'Hopfield4_W43n';'Hopfield4_N3Gn';'Hopfield4_N3n';'Hopfield4_W14p';'Hopfield4_W24p';'Hopfield4_W34p';'Hopfield4_N4Gp';'Hopfield4_N4p';'Hopfield4_W14n';'Hopfield4_W24n';'Hopfield4_W34n';'Hopfield4_N4Gn';'Hopfield4_N4n';'Hopfield4_In11p';'Hopfield4_In13p';'Hopfield4_In21p';'Hopfield4_In11n';'Hopfield4_In21n';'Hopfield4_In12p';'Hopfield4_In22p';'Hopfield4_In12n';'Hopfield4_In22n';'Hopfield4_In13n';'Hopfield4_In23n';'Hopfield4_In14p';'Hopfield4_In24p';'Hopfield4_In14n';'Hopfield4_In24n';'Hopfield4_In23p';'Hopfield4_ibias2';'Hopfield4_pbias2';'Hopfield4_nbias2';'Hopfield4_ibias1';'Hopfield4_pbias1';'Hopfield4_nbias1';'Hopfield4_ibias3';'Hopfield4_ibias4';'fix_loc'],list('vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1),exprs);
            
		[ok,num_of_blk,mblif_num,Ibiasp,Ibiasn,IbiasG,SigmoidBias,Weights,fix_loc,exprs] = scicos_getvalue('New Block Parameter',['num_of_blk';'mblif_num';'Ibiasp';'Ibiasn';'IbiasG';'SigmoidBias';'Weights';'fix_loc'],list('vec',-1,'vec',-1,'vec',-1','vec',-1,'vec',-1,'vec',-1,'mat',[-1,-2],'vec',-1),exprs);	


	    if ~ok then break,end
            if ok then


		//Biases
		Hopfield4_N1p = Ibiasp;
		Hopfield4_N2p = Ibiasp;
		Hopfield4_N3p = Ibiasp;
		Hopfield4_N4p = Ibiasp;


		Hopfield4_N1n = Ibiasn;
		Hopfield4_N2n = Ibiasn;
		Hopfield4_N3n = Ibiasn;
		Hopfield4_N4n = Ibiasn;

		Hopfield4_N3Gp=IbiasG;
		Hopfield4_N3Gn=IbiasG;
		Hopfield4_N4Gp=IbiasG;
		Hopfield4_N4Gn=IbiasG;

		Hopfield4_ibias1=SigmoidBias;
		Hopfield4_ibias2=SigmoidBias;
		Hopfield4_ibias3=SigmoidBias;
		Hopfield4_ibias4=SigmoidBias;
		Hopfield4_pbias1=SigmoidBias;
		Hopfield4_pbias2=SigmoidBias;
		Hopfield4_nbias1=SigmoidBias;
		Hopfield4_nbias2=SigmoidBias;

		//Input weights
		Hopfield4_In11p = Weights(1,1);
		Hopfield4_In11n = Weights(2,1);
		Hopfield4_In12p = Weights(3,1);
		Hopfield4_In12n = Weights(4,1);
		Hopfield4_In13p = Weights(5,1);
		Hopfield4_In13n = Weights(6,1);
		Hopfield4_In14p = Weights(7,1);
		Hopfield4_In14n = Weights(8,1);

		Hopfield4_In21p = Weights(1,2);
		Hopfield4_In21n = Weights(2,2);
		Hopfield4_In22p = Weights(3,2);
		Hopfield4_In22n = Weights(4,2);
		Hopfield4_In23p = Weights(5,2);
		Hopfield4_In23n = Weights(6,2);
		Hopfield4_In24p = Weights(7,2);
		Hopfield4_In24n = Weights(8,2);

		//Recurrent weights
		Hopfield4_W21p = Weights(1,4);
		Hopfield4_W21n = Weights(2,4);
		Hopfield4_W31p = Weights(1,5);
		Hopfield4_W31n = Weights(2,5);
		Hopfield4_W41p = Weights(1,6);
		Hopfield4_W41n = Weights(2,6);

		Hopfield4_W12p = Weights(3,3);
		Hopfield4_W12n = Weights(4,3);
		Hopfield4_W32p = Weights(3,5);
		Hopfield4_W32n = Weights(4,5);
		Hopfield4_W42p = Weights(3,6);
		Hopfield4_W42n = Weights(4,6);

		Hopfield4_W13p = Weights(5,3);
		Hopfield4_W13n = Weights(6,3);
		Hopfield4_W23p = Weights(5,4);
		Hopfield4_W23n = Weights(6,4);
		Hopfield4_W43p = Weights(5,6);
		Hopfield4_W43n = Weights(6,6);

		Hopfield4_W14p = Weights(7,3);
		Hopfield4_W14n = Weights(8,3);
		Hopfield4_W24p = Weights(7,4);
		Hopfield4_W24n = Weights(8,4);
		Hopfield4_W34p = Weights(7,5);
		Hopfield4_W34n = Weights(8,5);
		

                model.ipar=[num_of_blk,mblif_num];
                model.rpar=[Hopfield4_W21p,Hopfield4_W31p,Hopfield4_W41p,Hopfield4_N1p,Hopfield4_W21n,Hopfield4_W31n,Hopfield4_W41n,Hopfield4_N1n,Hopfield4_W12p,Hopfield4_W32p,Hopfield4_W42p,Hopfield4_N2p,Hopfield4_W12n,Hopfield4_W32n,Hopfield4_W42n,Hopfield4_N2n,Hopfield4_W13p,Hopfield4_W23p,Hopfield4_W43p,Hopfield4_N3Gp,Hopfield4_N3p,Hopfield4_W13n,Hopfield4_W23n,Hopfield4_W43n,Hopfield4_N3Gn,Hopfield4_N3n,Hopfield4_W14p,Hopfield4_W24p,Hopfield4_W34p,Hopfield4_N4Gp,Hopfield4_N4p,Hopfield4_W14n,Hopfield4_W24n,Hopfield4_W34n,Hopfield4_N4Gn,Hopfield4_N4n,Hopfield4_In11p,Hopfield4_In13p,Hopfield4_In21p,Hopfield4_In11n,Hopfield4_In21n,Hopfield4_In12p,Hopfield4_In22p,Hopfield4_In12n,Hopfield4_In22n,Hopfield4_In13n,Hopfield4_In23n,Hopfield4_In14p,Hopfield4_In24p,Hopfield4_In14n,Hopfield4_In24n,Hopfield4_In23p,Hopfield4_ibias2,Hopfield4_pbias2,Hopfield4_nbias2,Hopfield4_ibias1,Hopfield4_pbias1,Hopfield4_nbias1,Hopfield4_ibias3,Hopfield4_ibias4,fix_loc'];
                graphics.exprs=exprs;
                x.graphics=graphics;
                x.model=model
                break;
            end
        end
    case 'define' then

	Ibiasp = 2e-9;
	Ibiasn = 1e-9;
	IbiasG = 10e-6;
	SigmoidBias = 10e-6;

	Weights = 1e-12*ones(8,6);
	
        num_of_blk=1;
        mblif_num=0;
        //Biases
	Hopfield4_N1p = Ibiasp;
	Hopfield4_N2p = Ibiasp;
	Hopfield4_N3p = Ibiasp;
	Hopfield4_N4p = Ibiasp;

	Hopfield4_N1n = Ibiasn;
	Hopfield4_N2n = Ibiasn;
	Hopfield4_N3n = Ibiasn;
	Hopfield4_N4n = Ibiasn;

	Hopfield4_N3Gp=IbiasG;
	Hopfield4_N3Gn=IbiasG;
	Hopfield4_N4Gp=IbiasG;
	Hopfield4_N4Gn=IbiasG;

	Hopfield4_ibias1=SigmoidBias;
	Hopfield4_ibias2=SigmoidBias;
	Hopfield4_ibias3=SigmoidBias;
	Hopfield4_ibias4=SigmoidBias;
	Hopfield4_pbias1=SigmoidBias;
	Hopfield4_pbias2=SigmoidBias;
	Hopfield4_nbias1=SigmoidBias;
	Hopfield4_nbias2=SigmoidBias;

	//Input weights
	Hopfield4_In11p = Weights(1,1);
	Hopfield4_In11n = Weights(2,1);
	Hopfield4_In12p = Weights(3,1);
	Hopfield4_In12n = Weights(4,1);
	Hopfield4_In13p = Weights(5,1);
	Hopfield4_In13n = Weights(6,1);
	Hopfield4_In14p = Weights(7,1);
	Hopfield4_In14n = Weights(8,1);

	Hopfield4_In21p = Weights(1,2);
	Hopfield4_In21n = Weights(2,2);
	Hopfield4_In22p = Weights(3,2);
	Hopfield4_In22n = Weights(4,2);
	Hopfield4_In23p = Weights(5,2);
	Hopfield4_In23n = Weights(6,2);
	Hopfield4_In24p = Weights(7,2);
	Hopfield4_In24n = Weights(8,2);

	//Recurrent weights
	Hopfield4_W21p = Weights(1,4);
	Hopfield4_W21n = Weights(2,4);
	Hopfield4_W31p = Weights(1,5);
	Hopfield4_W31n = Weights(2,5);
	Hopfield4_W41p = Weights(1,6);
	Hopfield4_W41n = Weights(2,6);

	Hopfield4_W12p = Weights(3,3);
	Hopfield4_W12n = Weights(4,3);
	Hopfield4_W32p = Weights(3,5);
	Hopfield4_W32n = Weights(4,5);
	Hopfield4_W42p = Weights(3,6);
	Hopfield4_W42n = Weights(4,6);

	Hopfield4_W13p = Weights(5,3);
	Hopfield4_W13n = Weights(6,3);
	Hopfield4_W23p = Weights(5,4);
	Hopfield4_W23n = Weights(6,4);
	Hopfield4_W43p = Weights(5,6);
	Hopfield4_W43n = Weights(6,6);

	Hopfield4_W14p = Weights(7,3);
	Hopfield4_W14n = Weights(8,3);
	Hopfield4_W24p = Weights(7,4);
	Hopfield4_W24n = Weights(8,4);
	Hopfield4_W34p = Weights(7,5);
	Hopfield4_W34n = Weights(8,5);
        fix_loc=[0;0;0];
        model=scicos_model();
        model.sim=list('Hopfield4_c',5);
        model.in=[-1;-1];
        model.in2=[-1;-1];
        model.intyp=[-1;-1];
        model.out=[-1;-1;-1;-1];
        model.out2=[-1;-1;-1;-1];
        model.outtyp=[-1;-1;-1;-1];
        model.ipar=[num_of_blk,mblif_num];
        model.rpar=[Hopfield4_W21p,Hopfield4_W31p,Hopfield4_W41p,Hopfield4_N1p,Hopfield4_W21n,Hopfield4_W31n,Hopfield4_W41n,Hopfield4_N1n,Hopfield4_W12p,Hopfield4_W32p,Hopfield4_W42p,Hopfield4_N2p,Hopfield4_W12n,Hopfield4_W32n,Hopfield4_W42n,Hopfield4_N2n,Hopfield4_W13p,Hopfield4_W23p,Hopfield4_W43p,Hopfield4_N3Gp,Hopfield4_N3p,Hopfield4_W13n,Hopfield4_W23n,Hopfield4_W43n,Hopfield4_N3Gn,Hopfield4_N3n,Hopfield4_W14p,Hopfield4_W24p,Hopfield4_W34p,Hopfield4_N4Gp,Hopfield4_N4p,Hopfield4_W14n,Hopfield4_W24n,Hopfield4_W34n,Hopfield4_N4Gn,Hopfield4_N4n,Hopfield4_In11p,Hopfield4_In13p,Hopfield4_In21p,Hopfield4_In11n,Hopfield4_In21n,Hopfield4_In12p,Hopfield4_In22p,Hopfield4_In12n,Hopfield4_In22n,Hopfield4_In13n,Hopfield4_In23n,Hopfield4_In14p,Hopfield4_In24p,Hopfield4_In14n,Hopfield4_In24n,Hopfield4_In23p,Hopfield4_ibias2,Hopfield4_pbias2,Hopfield4_nbias2,Hopfield4_ibias1,Hopfield4_pbias1,Hopfield4_nbias1,Hopfield4_ibias3,Hopfield4_ibias4,fix_loc'];
        model.blocktype='d';
        model.dep_ut=[%f %t]; //[block input has direct feedthrough to output w/o ODE   block always active]
        
        //exprs=[sci2exp(num_of_blk);sci2exp(mblif_num);sci2exp(Hopfield4_W21p);sci2exp(Hopfield4_W31p);sci2exp(Hopfield4_W41p);sci2exp(Hopfield4_N1p);sci2exp(Hopfield4_W21n);sci2exp(Hopfield4_W31n);sci2exp(Hopfield4_W41n);sci2exp(Hopfield4_N1n);sci2exp(Hopfield4_W12p);sci2exp(Hopfield4_W32p);sci2exp(Hopfield4_W42p);sci2exp(Hopfield4_N2p);sci2exp(Hopfield4_W12n);sci2exp(Hopfield4_W32n);sci2exp(Hopfield4_W42n);sci2exp(Hopfield4_N2n);sci2exp(Hopfield4_W13p);sci2exp(Hopfield4_W23p);sci2exp(Hopfield4_W43p);sci2exp(Hopfield4_N3Gp);sci2exp(Hopfield4_N3p);sci2exp(Hopfield4_W13n);sci2exp(Hopfield4_W23n);sci2exp(Hopfield4_W43n);sci2exp(Hopfield4_N3Gn);sci2exp(Hopfield4_N3n);sci2exp(Hopfield4_W14p);sci2exp(Hopfield4_W24p);sci2exp(Hopfield4_W34p);sci2exp(Hopfield4_N4Gp);sci2exp(Hopfield4_N4p);sci2exp(Hopfield4_W14n);sci2exp(Hopfield4_W24n);sci2exp(Hopfield4_W34n);sci2exp(Hopfield4_N4Gn);sci2exp(Hopfield4_N4n);sci2exp(Hopfield4_In11p);sci2exp(Hopfield4_In13p);sci2exp(Hopfield4_In21p);sci2exp(Hopfield4_In11n);sci2exp(Hopfield4_In21n);sci2exp(Hopfield4_In12p);sci2exp(Hopfield4_In22p);sci2exp(Hopfield4_In12n);sci2exp(Hopfield4_In22n);sci2exp(Hopfield4_In13n);sci2exp(Hopfield4_In23n);sci2exp(Hopfield4_In14p);sci2exp(Hopfield4_In24p);sci2exp(Hopfield4_In14n);sci2exp(Hopfield4_In24n);sci2exp(Hopfield4_In23p);sci2exp(Hopfield4_ibias2);sci2exp(Hopfield4_pbias2);sci2exp(Hopfield4_nbias2);sci2exp(Hopfield4_ibias1);sci2exp(Hopfield4_pbias1);sci2exp(Hopfield4_nbias1);sci2exp(Hopfield4_ibias3);sci2exp(Hopfield4_ibias4);sci2exp(fix_loc)];

	exprs = [sci2exp(num_of_blk);sci2exp(mblif_num);sci2exp(Ibiasp);sci2exp(Ibiasn);sci2exp(IbiasG);sci2exp(SigmoidBias);sci2exp(Weights);sci2exp(fix_loc)];
        gr_i=['text=[''Hopfield4''];';'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');']
        x=standard_define([5 3],model, exprs,gr_i) //Numbers define the width and height of block
    end
endfunction
