Example #1
0
int main(void)
{
#ifdef _ENABLE_OUTPUT_
  printf("C main(void) function\n");
#endif

  struct Hardware hardware;
  struct Hardware* hw = &hardware;

  struct Firmware firmware;
  struct Firmware* fw = &firmware;

  // burn firmware on chip
  firmware.hw = hw;
  hardware.fw = fw;

  // start hardware
  turn_on(hw);

  // start firmware
#ifdef _ENABLE_POSIX_
  pthread_t firmware_thread;
  pthread_create(&firmware_thread, NULL, poll, (void *) fw);
#else
  ASYNC(poll((void *) fw));
#endif

#ifdef _EXPOSE_BUG_
  sleep(SHORT_DELAY);
#endif

  // environment stimulus
#ifdef _ENABLE_POSIX_
  pthread_t stimulus_thread;
  pthread_create(&stimulus_thread, NULL, stimulus, (void *) hw);
#else
  ASYNC(stimulus((void *) hw));
#endif

#ifdef _EXPOSE_BUG_
  sleep(SHORT_DELAY);
#endif

  // stop hardware
  turn_off(hw);

  // check verification condition:
  //
  // the firmware must have reacted to every environment
  // stimulus that triggered the hardware functionality.
  assert(hardware.regs[SIGNAL_REG_ID] == 0);

#ifdef _ENABLE_POSIX_
  pthread_join(firmware_thread, NULL);
  pthread_join(stimulus_thread, NULL);
  pthread_mutex_destroy(&hw->lock);
#endif

  return 0;
}
Example #2
0
fsyni() {
	int i;
	double cur, g;
	
	i = chkarg(1, 0., (double)(maxstim-1));
	if ((cur = stimulus(i, &g)) != 0.) {
		cur *= pstim[i].mag / pstim[i].mag_seg;
	}
	ret(cur);
}
bool PauseDynamicStimulus::execute() {
    DynamicStimulusDriverPtr stimulus(getDynamicStimulus());
    
    if (!stimulus) {
        merror(M_PARADIGM_MESSAGE_DOMAIN, "Attempted to pause a non-dynamic stimulus.  Doing nothing.");
        return false;
    }
    
    stimulus->pause();
    return true;
}
Example #4
0
fsyng() {
	int i;
	double g;
	
	i = chkarg(1, 0., (double)(maxstim-1));
	IGNORE(stimulus(i, &g));
	if (g != 0.) {
		g *= pstim[i].mag / pstim[i].mag_seg;
	}
	ret(g);
}
Example #5
0
void
testStdp(backend_t backend, bool noiseConnections, float reward)
{
	nemo::Network net;
	unsigned m = construct(net, noiseConnections);
	nemo::Configuration conf = configuration(backend);

	boost::scoped_ptr<nemo::Simulation> sim(nemo::simulation(net, conf));

	verifyWeightChange(0, sim.get(), m, reward);

	for(unsigned epoch = 1; epoch <= nepochs; ++epoch) {
		for(unsigned ms = 0; ms < 100; ++ms) {
			std::vector<unsigned> fstim;
			sim->step(stimulus(ms, fstim));
		}
		/* During the preceding epoch each synapse should have
		 * been updated according to the STDP rule exactly
		 * once. The magnitude of the weight change will vary
		 * between synapses according to their delay */
		sim->applyStdp(reward);
		verifyWeightChange(epoch, sim.get(), m, reward);
	}
}
int sc_main (int argc , char *argv[])
{
	/*
	int	quantization[64] = { 8,  6,  6,  7,  6,  5,  8,  7,
							 7,  7,  9,  9,  8, 10, 12, 20,
							13, 12, 11, 11, 12, 25, 18, 19,
							15, 20, 29, 26, 31, 30, 29, 26,
							28, 28, 32, 36, 46, 39, 32, 34,
							44, 35, 28, 28, 40, 55, 41, 44,
							48, 49, 52, 52, 52, 31, 39, 57,
							61, 56, 50, 60, 46, 51, 52, 50 };
	 */

	int	quantization[64] = {16, 11, 10, 16, 24, 40, 51, 61,
							12, 12, 14, 19, 26, 58, 60, 55,
							14, 13, 16, 24, 40, 57, 69, 56,
							14, 17, 22, 29, 51, 87, 80, 62,
							18, 22, 37, 56, 68,109,103, 77,
							24, 35, 55, 64, 81,104,113, 92,
							49, 64, 78, 87,103,121,120,101,
							72, 92, 95, 98,112,100,103, 99};


	sc_ufixed<14,-2,SC_TRN,SC_WRAP> quantization_i[64] = {
			0.0625000000000000, 0.0909090909090909, 0.100000000000000, 0.0625000000000000, 0.0416666666666667, 0.0250000000000000, 0.0196078431372549, 0.0163934426229508,
			0.0833333333333333, 0.0833333333333333, 0.0714285714285714, 0.0526315789473684, 0.0384615384615385, 0.0172413793103448, 0.0166666666666667, 0.0181818181818182,
			0.0714285714285710, 0.0769230769230769, 0.0625000000000000, 0.0416666666666667, 0.0250000000000000, 0.0175438596491228, 0.0144927536231884, 0.0178571428571429,
			0.0714285714285714, 0.0588235294117647, 0.0454545454545455, 0.0344827586206897, 0.0196078431372549, 0.0114942528735632, 0.0125000000000000, 0.0161290322580645,
			0.0555555555555560, 0.0454545454545455, 0.0270270270270270, 0.0178571428571429, 0.0147058823529412, 0.00917431192660551, 0.00970873786407767, 0.0129870129870130,
			0.0416666666666667, 0.0285714285714286, 0.0181818181818182, 0.0156250000000000, 0.0123456790123457, 0.00961538461538462, 0.00884955752212389, 0.0108695652173913,
			0.0204081632653060, 0.0156250000000000, 0.0128205128205128, 0.0114942528735632, 0.00970873786407767, 0.00826446280991736, 0.00833333333333333, 0.00990099009900990,
			0.0138888888888889, 0.0108695652173913, 0.0105263157894737, 0.0102040816326531, 0.00892857142857143, 0.0100000000000000, 0.00970873786407767, 0.0101010101010101
	};

	// definition of default files
	const char*	inputfile		= "datain.pgm";
	const char*	outputfile		= "dataout.pgm";
	const char* typefile 		= "types.txt";

	// definition of FIFO queues
	fifo_stat<int>	stimulus("stimulus",1);
	fifo_stat<int>	parameters("parameters",3);
	fifo_stat<int>	stimulus_dup1("stimulus_dup1",1);
	fifo_stat<int>	stimulus_dup2("stimulus_dup2",MAXWIDTH8*8+64+64+64+64+64);
	fifo_stat<int>	parameters_dup1("parameters_dup1",3);
	fifo_stat<int>	parameters_dup2("parameters_dup2",3);
	fifo_stat<int>	parameters_dup3("parameters_dup3",3);
	fifo_stat<int>	jpeg_dec_in("jpeg_dec_in",1);
	fifo_stat<int>	result("result",1);
	fifo_stat<int>	result_dup1("result_dup1",1);
	fifo_stat<int>	result_dup2("result_dup2",1);

	// definition of signals
	sc_clock 				clk("clock", 12, SC_NS);
	sc_signal<bool> 		ask;
	sc_signal<bool>			ready;
	sc_signal< sc_uint<8> > data;

	// processing of command-line arguments
	bool	detected;
	for(int i=3; i<=argc; i+=2) {
		cout << argv[i-2] << " " << argv[i-1] << endl;
		detected = 0;
		if (strcmp(argv[i-2],"-i")==0) {
			inputfile = argv[i-1];
			detected = 1;
		}
		if (strcmp(argv[i-2],"-o")==0) {
			outputfile = argv[i-1];
			detected = 1;
		}
		if (strcmp(argv[i-2],"-t")==0) {
			typefile = argv[i-1];
			detected = 1;
		}
		if (detected == 0) {
			cout << "option " << argv[i-2] << " not known " << endl;
		}
	}

	//	definition of modules
	src src1("src1", inputfile, MAXWIDTH);
	src1.output(stimulus);
	src1.parameters(parameters);

	df_fork<int,2> fork1("fork1");
	fork1.in(stimulus);
	fork1.out[0](stimulus_dup1);
	fork1.out[1](stimulus_dup2);

	df_fork<int,3> fork_param("fork_param");
	fork_param.in(parameters);
	fork_param.out[0](parameters_dup1);
	fork_param.out[1](parameters_dup2);
	fork_param.out[2](parameters_dup3);

//	jpeg_enc jpeg_enc_1("jpeg_enc_1", quantization, MAXWIDTH);
//	jpeg_enc_1.input(stimulus_dup1);
//	jpeg_enc_1.clk(clk);
//	jpeg_enc_1.parameters(parameters_dup1);
//	jpeg_enc_1.output(data);
//	jpeg_enc_1.ready(ready);
//	jpeg_enc_1.ask(ask);

	jpeg_enc_float jpeg_enc_1("jpeg_enc_1", quantization_i, MAXWIDTH);
	jpeg_enc_1.input(stimulus_dup1);
	jpeg_enc_1.clk(clk);
	jpeg_enc_1.parameters(parameters_dup1);
	jpeg_enc_1.output(data);
	jpeg_enc_1.ready(ready);
	jpeg_enc_1.ask(ask);

	jpeg_dec jpeg_dec_1("jpeg_dec_1", quantization, MAXWIDTH, typefile);
	jpeg_dec_1.input(data);
	jpeg_dec_1.clk(clk);
	jpeg_dec_1.ready(ready);
	jpeg_dec_1.ask(ask);
	jpeg_dec_1.parameters(parameters_dup2);
	jpeg_dec_1.output(result);

	df_fork<int,2> fork2("fork2");
	fork2.in(result);
	fork2.out[0](result_dup1);
	fork2.out[1](result_dup2);

	snk snk1("snk1", outputfile);
	snk1.input(result_dup1);
	snk1.parameters(parameters_dup3);

	test test1("test1");
	test1.reference(stimulus_dup2);
	test1.data(result_dup2);

	sc_start();

	return 0;
}
    void TestSMCmodelModified(void) throw (Exception)
    {
        // Set stimulus (no stimulus in this case)
        double magnitude_stimulus = 0.0;   // dimensionless
        double duration_stimulus = 0.05;  // ms
        double start_stimulus = 0.01;   // ms
        double period=1;//
        boost::shared_ptr<RegularStimulus> stimulus(new RegularStimulus(magnitude_stimulus,
                                                                        duration_stimulus,
                                                                        period,
                                                                        start_stimulus));

        boost::shared_ptr<EulerIvpOdeSolver> solver(new EulerIvpOdeSolver); //define the solver

        HeartConfig::Instance()->SetOdePdeAndPrintingTimeSteps(0.1,0.1,1);
        CorriasBuistSMCModified smc_ode_system(solver, stimulus);

        TS_ASSERT_EQUALS(smc_ode_system.GetCarbonMonoxideScaleFactor(), 1.0); //coverage
        smc_ode_system.SetCarbonMonoxideScaleFactor(1.0);//coverage
        // Solve and write to file
        RunOdeSolverWithIonicModel(&smc_ode_system,
                                   60000,/*end time, in milliseconds*/
                                   "SMCmodel_modified",
                                   1000);

        // Calculate APDs and compare with hardcoded values
        ColumnDataReader data_reader1("TestIonicModels", "SMCmodel_modified");
        std::vector<double> voltages = data_reader1.GetValues("Vm_SM");
        //create the times vector
        double k =0;
        std::vector<double> times;
        for (unsigned i=0; i<voltages.size(); i++)
        {
          times.push_back(k);
          k=k+100;
        }

        CellProperties cell_properties(voltages, times, -45.0);//note the lower threshold for SMC calculation of 'AP');

        TS_ASSERT_DELTA(cell_properties.GetLastActionPotentialDuration(50), 8331.3835, 0.1);
        TS_ASSERT_DELTA(cell_properties.GetLastActionPotentialDuration(70), 8571.1671, 0.1);
        TS_ASSERT_DELTA(cell_properties.GetLastActionPotentialDuration(80), 8722.6543, 0.1);
        TS_ASSERT_DELTA(cell_properties.GetLastActionPotentialDuration(90), 8955.8126, 0.1);

        CorriasBuistSMCModified smc_ode_system_no_stim(solver, stimulus);

        //check the default value of the presence of ICC stimulus
        TS_ASSERT_EQUALS(smc_ode_system_no_stim.GetFakeIccStimulusPresent(), true);
        //Switch off ICC stimulus and check the voltage is almost flat
        smc_ode_system_no_stim.SetFakeIccStimulusPresent(false);
        //check member variable was switched correctly
        TS_ASSERT_EQUALS(smc_ode_system_no_stim.GetFakeIccStimulusPresent(), false);
        // Solve and write to file
        RunOdeSolverWithIonicModel(&smc_ode_system_no_stim,
                                   60000,/*end time, in milliseconds*/
                                   "SMCmodel_modified_nostim",
                                   1000);

        // Calculate APDs and compare with hardcoded values
        ColumnDataReader data_reader2("TestIonicModels", "SMCmodel_modified_nostim");
        std::vector<double> voltages_flat = data_reader2.GetValues("Vm_SM");

        CellProperties  cell_properties_2(voltages_flat, times, -45.0);

        //it should be flat now, no AP and cell properties should throw
        TS_ASSERT_THROWS_THIS(cell_properties_2.GetLastActionPotentialDuration(90),
                            "AP did not occur, never exceeded threshold voltage.");

     }
Example #8
0
int main( void ) {
  struct mint_image *image; /* used to image the weights */
  FILE *file;               /* to read and write from files */ 
  struct mint_network *net; /* the network */
  mint_nodes 
    in,                     /* pointer to input layer */
    hid;                    /* pointer to hidden layer */
  int t1, t2, size, x;   /* various counters and helpers */   

  mint_random_seed( time(0) );

  /* load network from file */
  file = fopen( "competitive.arc", "r" );
  net = mint_network_load( file );
  fclose( file );

  /* useful shortcuts */
  in = mint_network_nodes(net,0);
  hid = mint_network_nodes(net,1);
  size = mint_nodes_size(in);
  
  file = fopen( "output/time.dat", "w" );
  for( t1=0; t1<64; t1++ ) { /* loop over 64 stimulus presentations */

    /* choose a stimulus at random */ 
    stimulus( in, mint_random_int(0,size) );

    /* each stimulus is presented for 50 time steps to allow the
       recurrent network to settle */
    for( t2=0; t2<50; t2++ ) {

      mint_network_operate( net );

      /* save hidden layer output to file */ 
      fprintf( file, "%d ", t1*50+t2 );
      mint_nodes_save_var( hid, 1, file );
      fprintf( file, "\n" );
    }
  }
  fclose( file );

  /* save network architecture in dot format */ 
  file = fopen( "output/competitive.dot", "w" );
  mint_network_graph( net, file );
  fclose( file );

  /* save trained network for analysis */
  file = fopen( "output/end.arc", "w" );
  mint_network_save( net, file );
  fclose( file );

  /* create an image of the final feed-forward weights. we scale the
     image up 20 times because the original is only 8x8 pixels given
     the weight matrix is 8x8. */ 
  image = mint_image_weights( mint_network_weights(net,0), 0, 0 );
  mint_image_scale( image, 20 );
  mint_image_save( image, "output/weights-end.jpg", FIF_JPEG );

  /* make tuning curves */
  mint_network_freeze( net, -1, 1 ); /* prevents weight updates */
  file = fopen( "output/tuning.dat", "w" );
  for( x=0; x<mint_nodes_size(in); x++ ) { /* loop over all stimuli */

    stimulus( in, x ); /* set a specific stimulus */

    /* present stimulus for 50 time steps */
    for( t2=0; t2<50; t2++ )
      mint_network_operate( net );

    /* save output of each hidden node */
    mint_nodes_save_var( hid, 1, file );
    fprintf( file, "\n" );
  }
  fclose( file );

  mint_network_del( net ); /* release memory */

  return 0;
}
int sc_main (int argc , char *argv[]) {

/*
	int	quantization[64] = { 8,  6,  6,  7,  6,  5,  8,  7,
								 7,  7,  9,  9,  8, 10, 12, 20,
								13, 12, 11, 11, 12, 25, 18, 19,
								15, 20, 29, 26, 31, 30, 29, 26,
								28, 28, 32, 36, 46, 39, 32, 34,
								44, 35, 28, 28, 40, 55, 41, 44,
								48, 49, 52, 52, 52, 31, 39, 57,
								61, 56, 50, 60, 46, 51, 52, 50 };
*/

	int	quantization[64] = { 16, 11, 10, 16, 24, 40, 51, 61,
								 12, 12, 14, 19, 26, 58, 60, 55,
								 14, 13, 16, 24, 40, 57, 69, 56,
								 14, 17, 22, 29, 51, 87, 80, 62,
								 18, 22, 37, 56, 68,109,103, 77,
								 24, 35, 55, 64, 81,104,113, 92,
								 49, 64, 78, 87,103,121,120,101,
								 72, 92, 95, 98,112,100,103, 99};

// definition of default files
	const char*	inputfile		= "datain.pgm";
	const char*	outputfile		= "dataout.pgm";
	const char* typefile 		= "types.txt";

//	definition of FIFO queues
	fifo_stat<int>	stimulus("stimulus",1);
	fifo_stat<int>	parameters("parameters",3);
	fifo_stat<int>	stimulus_dup1("stimulus_dup1",1);
	fifo_stat<int>	stimulus_dup2("stimulus_dup2",MAXWIDTH8*8+64+64+64+64+64);
	fifo_stat<int>	parameters_dup1("parameters_dup1",3);
	fifo_stat<int>	parameters_dup2("parameters_dup2",3);
	fifo_stat<int>	parameters_dup3("parameters_dup3",3);
	// fifo_stat<int>	jpeg_enc_out("jpeg_enc_out",1);
	fifo_stat<int>	jpeg_dec_in("jpeg_dec_in",1);
	fifo_stat<int>	result("result",1);
	fifo_stat<int>	result_dup1("result_dup1",1);
	fifo_stat<int>	result_dup2("result_dup2",1);

  sc_signal<bool> ask,ready;
  sc_signal<sc_int<9> > data;

// processing of command-line arguments
	bool	detected;
	for(int i=3; i<=argc; i+=2) {
		cout << argv[i-2] << " " << argv[i-1] << endl;
		detected = 0;
		if (strcmp(argv[i-2],"-i")==0) {
			inputfile = argv[i-1];
			detected = 1;
		}
		if (strcmp(argv[i-2],"-o")==0) {
			outputfile = argv[i-1];
			detected = 1;
		}
		if (strcmp(argv[i-2],"-t")==0) {
			typefile = argv[i-1];
			detected = 1;
		}
		if (detected == 0) {
			cout << "option " << argv[i-2] << " not known " << endl;
		}
	}

//	definition of modules

  sc_clock clk ( "clock",10, SC_NS ) ;

	src src1("src1", inputfile, MAXWIDTH);
	src1.output(stimulus);
	src1.parameters(parameters);

	df_fork<int,2> fork1("fork1");
	fork1.in(stimulus);
	fork1.out[0](stimulus_dup1);
	fork1.out[1](stimulus_dup2);

	df_fork<int,3> fork_param("fork_param");
	fork_param.in(parameters);
	fork_param.out[0](parameters_dup1);
	fork_param.out[1](parameters_dup2);
	fork_param.out[2](parameters_dup3);

	jpeg_enc jpeg_enc_1("jpeg_enc_1", quantization, MAXWIDTH);
	jpeg_enc_1.input(stimulus_dup1);
	jpeg_enc_1.clk(clk);
	jpeg_enc_1.parameters(parameters_dup1);
	jpeg_enc_1.output(data);
	jpeg_enc_1.ready(ready);
	jpeg_enc_1.ask(ask);
  
  // FF2P<int> FF2P_1("FF2P_1");
  // FF2P_1.input(jpeg_enc_out);
  // FF2P_1.clk(clk);
  // FF2P_1.ask(ask);
  // FF2P_1.ready(ready);
  // FF2P_1.output(data);
  
  // P2FF<int> P2FF_1("P2FF_1");
  // P2FF_1.input(data);
  // P2FF_1.clk(clk);
  // P2FF_1.ask(ask);
  // P2FF_1.ready(ready);
  // P2FF_1.output(jpeg_dec_in);

	jpeg_dec jpeg_dec_1("jpeg_dec_1", quantization, MAXWIDTH, typefile);
	jpeg_dec_1.input(data);
	jpeg_dec_1.clk(clk);
	jpeg_dec_1.ready(ready);
	jpeg_dec_1.ask(ask);
	jpeg_dec_1.parameters(parameters_dup2);
	jpeg_dec_1.output(result);

	df_fork<int,2> fork2("fork2");
	fork2.in(result);
	fork2.out[0](result_dup1);
	fork2.out[1](result_dup2);

	snk snk1("snk1", outputfile);
	snk1.input(result_dup1);
	snk1.parameters(parameters_dup3);

	test test1("test1");
	test1.reference(stimulus_dup2);
	test1.data(result_dup2);

	// sc_start();
	sc_start(200000,SC_NS);

	return 0;
}
Example #10
0
int sc_main (int argc , char *argv[]) {

/*
	int	quantization[64] = { 8,  6,  6,  7,  6,  5,  8,  7,
								 7,  7,  9,  9,  8, 10, 12, 20,
								13, 12, 11, 11, 12, 25, 18, 19,
								15, 20, 29, 26, 31, 30, 29, 26,
								28, 28, 32, 36, 46, 39, 32, 34,
								44, 35, 28, 28, 40, 55, 41, 44,
								48, 49, 52, 52, 52, 31, 39, 57,
								61, 56, 50, 60, 46, 51, 52, 50 };
*/

	int	quantization[64] = { 16, 11, 10, 16, 24, 40, 51, 61,
								 12, 12, 14, 19, 26, 58, 60, 55,
								 14, 13, 16, 24, 40, 57, 69, 56,
								 14, 17, 22, 29, 51, 87, 80, 62,
								 18, 22, 37, 56, 68,109,103, 77,
								 24, 35, 55, 64, 81,104,113, 92,
								 49, 64, 78, 87,103,121,120,101,
								 72, 92, 95, 98,112,100,103, 99};

// definition of default files
	const char*	inputfile		= "datain.pgm";
	const char*	outputfile		= "dataout.pgm";
	const char* typefile 		= "types.txt";
	const char* costfilename;
	bool outputcost = false;

//	definition of FIFO queues
	fifo_stat<int>	stimulus("stimulus",1);
	fifo_stat<int>	parameters("parameters",3);
	fifo_stat<int>	stimulus_dup1("stimulus_dup1",1);
	fifo_stat<int>	stimulus_dup2("stimulus_dup2",MAXWIDTH8*8+64+64+64+64+64);
	fifo_stat<int>	parameters_dup1("parameters_dup1",3);
	fifo_stat<int>	parameters_dup2("parameters_dup2",3);
	fifo_stat<int>	parameters_dup3("parameters_dup3",3);
	fifo_stat<int>	jpeg_enc_out("jpeg_enc_out",1);
	fifo_stat<int>	result("result",1);
	fifo_stat<int>	result_dup1("result_dup1",1);
	fifo_stat<int>	result_dup2("result_dup2",1);


// processing of command-line arguments
	bool	detected;
	for(int i=3; i<=argc; i+=2) {
		cout << argv[i-2] << " " << argv[i-1] << endl;
		detected = 0;
		if (strcmp(argv[i-2],"-i")==0) {
			inputfile = argv[i-1];
			detected = 1;
		}
		if (strcmp(argv[i-2],"-o")==0) {
			outputfile = argv[i-1];
			detected = 1;
		}
		if (strcmp(argv[i-2],"-t")==0) {
			typefile = argv[i-1];
			detected = 1;
		}
		if (strcmp(argv[i-2],"-c")==0) {
			costfilename = argv[i-1];
			outputcost = true;
			detected = 1;
		}
		if (detected == 0) {
			cout << "option " << argv[i-2] << " not known " << endl;
		}
	}

//	definition of modules

	src src1("src1", inputfile, MAXWIDTH);
	src1.output(stimulus);
//	src1.output(stimulus_dup1);
//	src1.output(stimulus_dup2);
	src1.parameters(parameters);

	df_fork<int,2> fork1("fork1");
	fork1.in(stimulus);
	fork1.out[0](stimulus_dup1);
	fork1.out[1](stimulus_dup2);

	df_fork<int,3> fork_param("fork_param");
	fork_param.in(parameters);
	fork_param.out[0](parameters_dup1);
	fork_param.out[1](parameters_dup2);
	fork_param.out[2](parameters_dup3);

	jpeg_enc jpeg_enc_1("jpeg_enc_1", quantization, MAXWIDTH);
	jpeg_enc_1.input(stimulus_dup1);
	jpeg_enc_1.parameters(parameters_dup1);
	jpeg_enc_1.output(jpeg_enc_out);

	jpeg_dec jpeg_dec_1("jpeg_dec_1", quantization, MAXWIDTH, typefile);
	jpeg_dec_1.input(jpeg_enc_out);
	jpeg_dec_1.parameters(parameters_dup2);
	jpeg_dec_1.output(result);

	df_fork<int,2> fork2("fork2");
	fork2.in(result);
	fork2.out[0](result_dup1);
	fork2.out[1](result_dup2);

	snk snk1("snk1", outputfile);
	snk1.input(result_dup1);
	snk1.parameters(parameters_dup3);

	test test1("test1");
	test1.reference(stimulus_dup2);
	test1.data(result_dup2);

	sc_start();

	if (outputcost == true) {
		int cost = jpeg_dec_1.idct_1->hardware_cost();
		float snr = test1.snr();
		float psnr = test1.psnr();
		cout << "hardware cost IDCT 2nd " << cost << endl;
		ofstream *costfile;
		costfile = new ofstream(costfilename);
		if (!costfile->is_open()) cout << "Error opening file " << costfilename << endl;
		*costfile << cost << " " << snr << " " << psnr << endl;
		costfile->close();
	}
	return 0;
}