Versuch 3 Software so halb

This commit is contained in:
brandlfl78731 2024-11-27 11:25:02 +01:00
parent de8d181dde
commit 45db9f89e2
3 changed files with 61 additions and 1 deletions

View File

@ -5,7 +5,66 @@
int task_crc_run( void * task ) {
// TODO
crc_config * config = ( crc_config *) task;
uint32_t value = config->start; // Startwert CRC vom gewaehlten Algorithmus (wird erst in der Funktion invertiert)
// Nachfolgende Antworten Lesen den FIFO der ersten Datenquelle aus und multiplizieren
// den jeweils gelesenen Wert mit 4 und speichern das Ergebnis in der Datensenke
for (uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i) {
float_word a;
data_channel_read(config->base.sources[0], (uint32_t * ) & a.word );
float_word c;
//c.value = 4*a; //Hier mit Werten aus CRC FIFO multiplizieren
c.value = 0;
for (uint32_t j = 0; j < 32; j++) {
if (a.word & (1<<31)) {
c.word = (c.word * 2 + ((a.word & (1<<j))>>j)) ^ CRC32POLY;
} else {
c.word = (c.word * 2 + ((a.word & (1<<j))>>j));
}
}
/*
for (uint32_t j = 0; j < 4; j++) {
if (a.word & (1<<31)) {
c.word = (c.word * 2 + ((a.word & (0xff<<j*8))>>j*8)) ^ CRC32POLY;
} else {
c.word = (c.word * 2 + ((a.word & (0xff<<j*8))>>j*8));
}
}
*/
data_channel_write( config->base.sink, c.word );
printf("a= %08x c= %08x\n", a.word, c.word);
}
return 0;
}
/*
crc := 0000 (Startwert)
für alle Bits b im Datenstrom:
wenn das am weitesten links stehende Bit von crc 1 ist:
crc := (crc * 2 + b) xor CRC-Polynom
sonst:
crc := crc * 2 + b
crc enthält das Ergebnis.
*/
/*
const uint8_t bitstream[] = { 1,0,0,0,1,1,0,0 };
const int bitcount = 8;
uint32_t crc32 = 0; // Schieberegister
int main ()
{
for (int i = 0; i < bitcount; i++)
{
if ( ((crc32 >> 31) & 1) != bitstream[i])
crc32 = (crc32 << 1) ^ CRC32POLY;
else
crc32 = (crc32 << 1);
}
printf ("0x%08X\n", crc32);
}
*/

View File

@ -9,7 +9,8 @@ extern "C" {
extern crc_config CRC_CONFIG;
#define CRC32POLY 0xEDB88320 /* CRC-32 Polynom (Invers)*/
//#define CRC32POLY 0xEDB88320 /* CRC-32 Polynom (Invers)*/
#define CRC32POLY 0x04C11DB7
int task_crc_run( void * task );

Binary file not shown.