Close

Linear Feedback Shift Registers and ALUs...?

A project log for Random Ridiculosities and Experiments

Sometimes yah's just gots tah try somethin', regardless of whether it'll become a full-fledged "project"...

eric-hertzEric Hertz 12/24/2015 at 09:360 Comments

Today's fixation: Can a Linear Feedback Shift Register be used to perform arithmetic...?

I can't seem to find anything on the matter via search-fu...

But here's a general idea: They're typically used for pseudo-random number generation... whose repeatability is quite low... They're also used for CRC generation/detection. So, if I understand correctly (and I *really* don't... these things are total black-magic to me), there're some cases where ... no I'm totally off, here.

I was thinking there might be some correlation with the idea that for any 4-bit number in, there might be a configuration such that a different 4-bit number would come out. Somehow I equated this to: any two 4-bit numbers in would result in a *different* 5-bit number coming out... and that's what addition does... But that's totally absurd. Then, if it wasn't absurd, the idea would be that it's only a small step from a 5-bit number to a lookup-table, which might save a couple instructions when performing such an operation on huge blocks of data.

Yeah, this whole venture seems utterly ridiculous right now... but it did make sense earlier today. I didn't plan on doing *addition,* I was contemplating using LFSRs to do something even simpler... *comparison*. And, yeah, that's pretty much exactly what they're used for, in the case of CRCs, right?

So, the *original* idea was: I have a memory-block filled with sample-data... And I want to use DMA to run through that entire data block and indicate all samples that equal a certain value, outputting (to a pin(s) on a port) a 0 for not-equal samples, and outputting a 1 for equal samples.

The *very* first idea was to output the raw sample-data, then just feed it through a simple bit of logic... I think @Yann Guidon / YGDES has a favorite 74-series chip for this purpose... And, for this case, I don't think the LUT flash-method we'd discussed would be fast enough.

Then I thought about the Configurable-logic blocks on PIC16's, but apparently they don't have 'em on PIC32's.

Then I started looking into the DMA controller (something I *barely* grasp) and noticed that there's a CRC-generator/LFSR block that can be injected into the process... And, yahknow, it's plausible simple comparisons could be handled via LFSR.

So, in reality, this actual mind-experiment, no matter how it turns out, probably won't be used for my original idea... I was thinking of ways to render stored samples on a raster-drawn screen using DMA without having to load points into a frame-buffer. Even if the LFSR block can be manipulated into giving 1 or 0 for whether the line being drawn corresponds to the value in the samples, I'd still have to do some processing for drawing e.g. two channels simultaneously, coloring, etc...

But, who knows... And it definitely seems to me that DMA with built-in LFSR could be useful for some sort of repeated-processing of huge blocks of data, besides CRC calculation or random-number generation...

Discussions