<commit_before>#include <stdio.h>

#include <spikehw.h>

SpikeHw *spikeHw;

int main(int argc, const char **argv)
{
    spikeHw = new SpikeHw();
    // not needed yet
    //spikeHw->setupDma(memfd);

    // query mmcm and interrupt status
    spikeHw->status();

    // read boot rom
    uint32_t firstword;
    spikeHw->read(0x000000 + 0x000, (uint8_t *)&firstword);
    fprintf(stderr, "First word of boot ROM %08x (expected %08x)\n", firstword, 0x00001137);

    // read ethernet identification register
    uint32_t id;
    spikeHw->read(0x180000 + 0x4f8, (uint8_t *)&id);
    fprintf(stderr, "AXI Ethernet Identification %08x (expected %08x)\n", id, 0x09000000);

    // put flash in query mode
    spikeHw->setFlashParameters(50); // divides clock by 50
    uint32_t values[4] = { 0x98 };
    spikeHw->writeFlash(0x00aa, (uint8_t *)&values[0]);
    spikeHw->readFlash(0x0020, (uint8_t *)&values[1]);
    spikeHw->readFlash(0x0022, (uint8_t *)&values[2]);
    spikeHw->readFlash(0x0024, (uint8_t *)&values[3]);
    fprintf(stderr, "Query flash %02x.%02x.%02x %c%c%c (expected QRY)\n", values[1], values[2], values[3], values[1], values[2], values[3]);

    return 0;
}
<commit_msg>read and verify 8 32-bit words of boot ROM<commit_after>#include <stdio.h>

#include <spikehw.h>

SpikeHw *spikeHw;

int main(int argc, const char **argv)
{
    spikeHw = new SpikeHw();
    // not needed yet
    //spikeHw->setupDma(memfd);

    // query mmcm and interrupt status
    spikeHw->status();

    // read boot rom
    uint32_t word = 0;
    uint32_t expected[] = {
	0x00001137,
	0x010000ef,
	0x20000513,
	0x00050067,
	0x0000006f,
	0x040007b7,
	0x40078793,
	0xfc0005b7
    };
    for (int i = 0; i < 8; i++){
	spikeHw->read(0x000000 + i*4, (uint8_t *)&word);
	fprintf(stderr, "word %04x of boot ROM %08x (expected %08x)\n", i*4, word, expected[i]);
    }

    // read ethernet identification register
    uint32_t id;
    spikeHw->read(0x180000 + 0x4f8, (uint8_t *)&id);
    fprintf(stderr, "AXI Ethernet Identification %08x (expected %08x)\n", id, 0x09000000);

    // put flash in query mode
    spikeHw->setFlashParameters(50); // divides clock by 50
    uint32_t values[4] = { 0x98 };
    spikeHw->writeFlash(0x00aa, (uint8_t *)&values[0]);
    spikeHw->readFlash(0x0020, (uint8_t *)&values[1]);
    spikeHw->readFlash(0x0022, (uint8_t *)&values[2]);
    spikeHw->readFlash(0x0024, (uint8_t *)&values[3]);
    fprintf(stderr, "Query flash %02x.%02x.%02x %c%c%c (expected QRY)\n", values[1], values[2], values[3], values[1], values[2], values[3]);

    return 0;
}

{'fraction_non_alphanumeric': 0.1626365054602184, 'fraction_numerical': 0.10452418096723869, 'mean_word_length': 3.7324723247232474, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5084884', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1034, 'n_words': 235}