Exemplo n.º 1
0
//====================================================
SignalAnchor::SignalAnchor( char* instance_name,
                        PracSimModel* outer_model,
                        Signal<bit_t>* bit_signal,
                        Signal<byte_t>* byte_signal )
          :PracSimModel(instance_name,
                        outer_model)
{
  MODEL_NAME(SignalAnchor);
  int block_size;
  double samp_intvl;
  
  OPEN_PARM_BLOCK;
  
  GET_DOUBLE_PARM( samp_intvl );
  GET_INT_PARM( block_size );
  Bit_Signal = bit_signal;
  Byte_Signal = byte_signal;

  MAKE_INPUT(Bit_Signal);
  MAKE_INPUT(Byte_Signal);
  SET_SAMP_INTVL(Bit_Signal, samp_intvl);
  SET_BLOCK_SIZE(Bit_Signal, block_size);
  SET_SAMP_INTVL(Byte_Signal, samp_intvl);
  SET_BLOCK_SIZE(Byte_Signal, block_size);

}
Exemplo n.º 2
0
void buddyFree(void * ptr) {
	Address blockStart = (Address)(ptr - heap) - 4*sizeof(Address);
	size_t blockSize = GET_BLOCK_SIZE(blockStart);
	Address buddyAddress = _getBuddyAddress(blockStart, blockSize);
	int buddySide = _getBuddySide(blockStart, blockSize);
	TRACE_DUMP("Deallocating %s buddy (neighbour at %lu).", 
		(buddySide == BUDDY_SIDE_LEFT ? "left" : "right"), buddyAddress);
	
	// in all cases, mark as unused
	MARK_BLOCK_FREE(blockStart);
	
	
	// while buddy is free, merge them and go one level up
	while (IS_BLOCK_FREE(buddyAddress)) {
		TRACE_DUMP("Merging...");
		// deattach the buddy
		_removeBlockFromList(buddyAddress, blockSize);
		
		// find the new block start
		blockStart = buddyAddress < blockStart ? buddyAddress : blockStart;

		blockSize++;
		// look for parent one
		if (MAX_BLOCK_SIZE == blockSize) {
			// at the very top, heap is completely free
			break;
		}
		buddyAddress = _getBuddyAddress(blockStart, blockSize);
		TRACE_DUMP("New block start is %lu, buddy at %lu.", blockStart, buddyAddress);
	}
	
	SET_BLOCK_SIZE(blockStart, blockSize);
	_addBlockToList(blockStart, blockSize);
}
PolarFreqDomainFilter::PolarFreqDomainFilter( char* instance_name,
                                         PracSimModel* outer_model,
                                         Signal< std::complex<float> >* in_sig,
                                         Signal< std::complex<float> >* out_sig)
            :PracSimModel(instance_name,
                          outer_model)
{
   MODEL_NAME(PolarFreqDomainFilter);
   ENABLE_MULTIRATE;
   In_Sig = in_sig;
   Out_Sig = out_sig;

   OPEN_PARM_BLOCK;

   GET_INT_PARM(Fft_Size);
   GET_DOUBLE_PARM(Dt_For_Fft);
   GET_FLOAT_PARM(Overlap_Save_Mem);
   GET_BOOL_PARM(Bypass_Enabled);

   Magnitude_Data_Fname = new char[64];
   strcpy(Magnitude_Data_Fname, "\0");
   GET_STRING_PARM(Magnitude_Data_Fname);
   GET_DOUBLE_PARM(Mag_Freq_Scaling_Factor);

   Phase_Data_Fname = new char[64];
   strcpy(Phase_Data_Fname, "\0");
   GET_STRING_PARM(Phase_Data_Fname);
   GET_DOUBLE_PARM(Phase_Freq_Scaling_Factor);

   Num_Saved_Samps = int(Overlap_Save_Mem/Dt_For_Fft + 0.5);
   Block_Size = Fft_Size - Num_Saved_Samps;

   MAKE_OUTPUT(Out_Sig);
   MAKE_INPUT(In_Sig);

   SET_SAMP_INTVL(In_Sig, Dt_For_Fft);
   SET_BLOCK_SIZE(In_Sig, Block_Size);

   SET_SAMP_INTVL(Out_Sig, Dt_For_Fft);
   SET_BLOCK_SIZE(Out_Sig, Block_Size);

   //SET_DELAY( In_Sig, Out_Sig, Group_Delay_Offset);

}
Exemplo n.º 4
0
/*
 * Scan the heap until we find a block large enough to fulfill the
 * request.
 */
void *
malloc(unsigned sz)
{
    block_header_t *header, *next;

    /* Align the request. */
    sz += MIN_REQUEST - 1;
    sz &= ~(MIN_REQUEST - 1);

    /* First fit. */
    for (header = (block_header_t *) heap_start;
         (char *) header < heap_end;
         header = next) {
        next = (block_header_t *)
            ((char *) header
             + sizeof(block_header_t)
             + GET_BLOCK_SIZE(*header));

        if (GET_PREV_FREE(*next) && sz <= GET_BLOCK_SIZE(*header)) {
            /* We can fit the request in this block. */
            void *result = (void *)((char *) header + sizeof(block_header_t));

            if (GET_BLOCK_SIZE(*header) < sz + sizeof(block_header_t) + MIN_REQUEST) {
                /* We can't fit any other requests here, though. */
                CLEAR_PREV_FREE(*next);
            }
            else {
                /* Split the block. */
                struct block_footer *footer =
                    (struct block_footer *)
                    ((char *) next - sizeof(struct block_footer));

                unsigned remaining = GET_BLOCK_SIZE(*header) - sz - sizeof(block_header_t);

                SET_BLOCK_SIZE(*header, sz);

                header = (block_header_t *)
                    ((char *) header
                     + sizeof(block_header_t)
                     + sz);

                ASSERT(remaining % 2 == 0, ("odd block size"));
                INIT_BLOCK_HEADER(*header, remaining, 0);

                footer->header = header;
            }

            return result;
        }
    }

    /* Uh oh, couldn't allocate! */
    panic();
    return 0;
}
Exemplo n.º 5
0
//====================================================
// Dual integer signals
SignalAnchor::SignalAnchor( char* instance_name,
                        PracSimModel* outer_model,
                        Signal<int>* int_signal,
                        Signal<int>* int_signal_2,
                        double samp_intvl,
                        int block_size )
          :PracSimModel(instance_name,
                        outer_model)
{
  Int_Signal = int_signal;
  Int_Signal_2 = int_signal_2;

  MAKE_INPUT(Int_Signal);
  MAKE_INPUT(Int_Signal_2);
  SET_SAMP_INTVL(Int_Signal, samp_intvl);
  SET_BLOCK_SIZE(Int_Signal, block_size);
  SET_SAMP_INTVL(Int_Signal_2, samp_intvl);
  SET_BLOCK_SIZE(Int_Signal_2, block_size);

}
Exemplo n.º 6
0
//====================================================
// Dual float signal
SignalAnchor::SignalAnchor( char* instance_name,
                        PracSimModel* outer_model,
                        Signal<float>* float_signal,
                        Signal<float>* float_signal_2,
                        double samp_intvl,
                        int block_size )
          :PracSimModel(instance_name,
                        outer_model)
{
  MODEL_NAME(SignalAnchor);
  Float_Signal = float_signal;
  Float_Signal_2 = float_signal_2;

  MAKE_INPUT(Float_Signal);
  MAKE_INPUT(Float_Signal_2);
  SET_SAMP_INTVL(Float_Signal, samp_intvl);
  SET_BLOCK_SIZE(Float_Signal, block_size);
  SET_SAMP_INTVL(Float_Signal_2, samp_intvl);
  SET_BLOCK_SIZE(Float_Signal_2, block_size);

}
Exemplo n.º 7
0
//====================================================
SignalAnchor::SignalAnchor( char* instance_name,
                        PracSimModel* outer_model,
                        Signal<bit_t>* bit_signal,
                        double samp_intvl,
                        int block_size )
          :PracSimModel(instance_name,
                        outer_model)
{
  Bit_Signal = bit_signal;

  MAKE_INPUT(Bit_Signal);
  SET_SAMP_INTVL(Bit_Signal, samp_intvl);
  SET_BLOCK_SIZE(Bit_Signal, block_size);

}
Exemplo n.º 8
0
SignalAnchor::SignalAnchor( char* instance_name,
                        PracSimModel* outer_model,
                        Signal< std::complex<float> >* complex_signal,
                        double samp_intvl,
                        int block_size )
          :PracSimModel(instance_name,
                        outer_model)
{
  MODEL_NAME(SignalAnchor);
  Complex_Signal = complex_signal;

  MAKE_INPUT(Complex_Signal);
  SET_SAMP_INTVL(Complex_Signal, samp_intvl);
  SET_BLOCK_SIZE(Complex_Signal, block_size);

}
Exemplo n.º 9
0
/*
 * Free the block, coalescing with the previous and next blocks if
 * possible.
 */
void
free(void *ptr)
{
    block_header_t *header = (block_header_t *)
        ((char *) ptr - sizeof(block_header_t));

    block_header_t *next = (block_header_t *)
        ((char *) ptr + GET_BLOCK_SIZE(*header));

    block_header_t *next_next = (block_header_t *)
        ((char *) next + sizeof(block_header_t) + GET_BLOCK_SIZE(*next));

    struct block_footer *footer;
    unsigned size;

    if ((char *) next_next < heap_end && GET_PREV_FREE(*next_next)) {
        /* The block following us is free. */
        next = next_next;
    }

    if (GET_PREV_FREE(*header)) {
        /* The block prior to us is free. */
        footer = (struct block_footer *)
            ((char *) header - sizeof(struct block_footer));

        header = footer->header;
    }

    footer = (struct block_footer *)
        ((char *) next - sizeof(struct block_footer));

    footer->header = header;

    /* Expand the block to encompass the reclaimed space. */
    size = (char *) next - (char *) header - sizeof(block_header_t);
    ASSERT(size % 2 == 0, ("odd block size"));
    SET_BLOCK_SIZE(*header, size);

    /* Note in the header of the _next_ block that this block is free. */
    MARK_PREV_FREE(*next);
}