Enabling FPGAs for scientific programming
"As a computational scientist, I am used to thinking in terms of multiple processes communicating with each other. And I am used to developing software in C. However, I am not used to thinking in terms of hardware design. Impulse C provides the necessary abstraction of hardware and enables me to develop hardware accelerated software using familiar concepts."

Peter Messmer, Research Scientist, Tech-X Corporation

Mersenne Twister sample source code

// Mersenne twister sample code
//
// Uses streaming interface for seed and outputs
//
void genrand(co_stream p_in, co_stream out)
{
        co_uint16 i,kk;
        co_uint32 mm;

        co_uint32 mtA[MT_N];
        co_uint32 mtB[MT_N];
        co_uint32 u32;
        co_uint32 mt_kk,mt_kkp1,mt_kkpM;
        co_uint32 y,z;
        co_uint32 mag01[2] = {0x0UL, MATRIX_A};

        // The following will allow a soft reset to reset the RNGs.
        co_stream_open(p_in, O_RDONLY, UINT_TYPE(STREAMWIDTH));
        for(i=0;i<MT_N;i++) {
            co_stream_read(p_in, &u32, sizeof(co_uint32) );
            mtA[i]=mtB[i]=u32;
        }
        co_stream_close(p_in);

        co_stream_open(out, O_WRONLY, UINT_TYPE(STREAMWIDTH));

        do {
            mt_kk = mtA[0];
            for (kk=0;kk<227;kk++) {
                #pragma CO PIPELINE
                mt_kkp1 = mtA[kk+1]; // range 1 to 227
                mt_kkpM = mtB[kk+397]; // range 397 to 623
                y = (mt_kk&UPPER_MASK)|(mt_kkp1&LOWER_MASK);
                mt_kk = mt_kkp1;
                z = mt_kkpM ^ (y >> 1) ^ mag01[y & 0x1UL];
                mtA[kk] = z;
                mtB[kk] = z;
                co_stream_write(out, &z, sizeof(co_uint32));
            }
            mt_kk = mtA[227];
            for (kk=227;kk<623;kk++) {
                #pragma CO PIPELINE
                mt_kkp1 = mtA[kk+1]; // range 228 to 623
                mt_kkpM = mtB[kk-227]; // range 0 to 395
                y = (mt_kk&UPPER_MASK)|(mt_kkp1&LOWER_MASK);
                mt_kk = mt_kkp1;
                z = mt_kkpM ^ (y >> 1) ^ mag01[y & 0x1UL];
                mtA[kk] = z;
                mtB[kk] = z;
                co_stream_write(out, &z, sizeof(co_uint32));
            }
            y = (mtA[MT_N-1]&UPPER_MASK)|(mtB[0]&LOWER_MASK);
            mtA[MT_N-1] = mtA[MT_M-1] ^ (y >> 1) ^ mag01[y & 0x1UL];
            z = mtB[MT_N-1] = mtA[MT_N-1];
            co_stream_write(out, &z, sizeof(co_uint32));
        } while ( 1 );
}

Contact us to learn more.