Пример #1
0
static uint32_t derive_interval(uint32_t num)
{
    uint32_t interval;
    if ((DETAILED_STATS) && (LOG2_STATS)) {
        /* Use a logarithmic method to generate geometric variates in order to
         * populate the result table evenly across all buckets */

        /* Static exponent mask, picking the mask as tightly as possible reduces the
         * probability of discarded values, which reduces the computing overhead
         * between test iterations */

        static uint32_t exp_mask = 0;
        if (exp_mask == 0) {
            /* non-constant initializer */
            exp_mask = (2 << bitarithm_msb(TEST_LOG2NUM)) - 1;
            print_str("exp_mask = ");
            print_u32_hex(exp_mask);
            print("\n", 1);
            print_str("max interval = ");
            print_u32_dec((2 << exp_mask) - 1);
            print("\n", 1);
        }

        /* Pick an exponent based on the top bits of the number */
        /* exponent will be a number in the interval [0, log2(TEST_NUM) + 1] */
        unsigned int exponent = ((num >> (32 - 8)) & exp_mask);
        if (exponent == 0) {
            /* Special handling to avoid the situation where we never see a zero */
            /* We could also have used an extra right shift in the else case,
             * but the state grouping also groups 0 and 1 in the same bucket, which means that they are twice as likely  */
            interval = bitarithm_bits_set(num) & 1;
        }
        else {
            interval = (1 << exponent);
            interval |= (num & (interval - 1));
        }
    }
    else {
Пример #2
0
int main()
{
    init_platform();

    XIOModule_Initialize(&iomod_inst, 0);

    wait_ms(&iomod_inst,1000);

    codec_init(&iomod_inst);

    wait_ms(&iomod_inst,1000);
    print("Codec Initialized\r\n");
    print("Reading back registers\r\n");

    int i;
    uint8_t regData;
    for(i = 1; i < 9; i++)
    {
    	regData = codec_read(&iomod_inst,i);
    	print("Address ");
    	print_u32_hex((u32)i);
    	print(" ");
    	print_u32_hex((u32)regData);
    	print("\r\n");
    }

    print("Waiting 5 seconds for codec HPF to stabilize...\r\n");

    wait_ms(&iomod_inst,5000);

    u8 numCharsRet;

    clearInpBuffer();

    while(1)
    {
    	print("Please select the channel (L/R)\r\n> ");
    	numCharsRet = serial_read_line(serialInputBuffer,SERIAL_INPUT_BUFFER_LEN);

    	if(numCharsRet > 0)
    	{
    		if((serialInputBuffer[0] == 'l') || (serialInputBuffer[0] == 'L'))
    		{
    			selectedChannel = Left;
    			break;
    		}
    		else if((serialInputBuffer[0] == 'r') || (serialInputBuffer[0] == 'R'))
    		{
    			selectedChannel = Right;
    			break;
    		}
    	}

    	print("Invalid channel selection.\r\n");
    }
    clearInpBuffer();

    RunSineTest();


    for(i = 0; i < MAX_INPUT_LEN; i++)
    {
    	xil_printf("%d\r\n",input_buffer[i]);
    }

    print("End of samples\r\n");


    return 0;
}