Author |
Message |
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Thu Oct 30, 2014 1:04 pm Post subject:
bit shuffler Subject description: Any ideas how to generate bit permutations? |
|
|
Sometimes I have to generate sequences to control part of a circuit that are more interesting than what you get from a simple counter. For example, instead of generating the outputs 0 1 2 3 4 5 6 7 from a 3-bit counter, I want something like 0 2 4 6 1 3 5 7. What I did so far is using a 4053 to switch the bits, like in the first schematic. Any input is switched to two outputs BUT the corresponding one. So you will never get 0 1 2 3 4 5 6 7 as the output, which is ok. This approach has a significant drawback however. For some permutations, bits are not mixed but duplicated. Many of the resulting sequences have repetitions because of that. For example, when using S1,2,3 = 000 you get the sequence 0 6 1 7 0 6 1 7. The part 0 6 1 7 repeats, and the values 2,3,4,5 are missing.
Because I am using all possible 3-bit numbers as input, I can improve that a bit by inverting some of the bits before switching them. In the second circuit I use 3 XORs for that. This gives me 3 more controls to select the sequence and should results in a total of 64 possible output sequences. Haven't tried that yet however.
To really mix bits without duplication you could use a 4053 like in the third schematic, here for two bits only. You would need several of them to mix the inputs values to any sequence. But I wonder if there are simpler ways to do this, even if not all possible permutations are generated. So I am sharing this to get some feedback about your ideas.
Description: |
|
Filesize: |
21.61 KB |
Viewed: |
246 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
|
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Fri Oct 31, 2014 12:44 pm Post subject:
|
|
|
Thinking a bit longer about this, I realized that you cannot get any sequence by just mixing the bits. When you only swap bits, there are only 6 possible combinations:
Quote: | A B C
B A C
A C B
B C A
C B A
C A B |
Those will produce exactly 6 sequences.
Quote: | 0 1 2 3 4 5 6 7
0 1 4 5 2 3 6 7
0 2 1 3 4 6 5 7
0 4 1 5 2 6 3 7
0 4 2 6 1 5 3 7
0 2 4 6 1 3 5 7
0 4 1 5 2 6 3 7
0 2 1 3 4 6 5 7 |
So It will take a bit more than just bit swapping. |
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Fri Oct 31, 2014 1:37 pm Post subject:
|
|
|
Combining the XOR idea and the bit swap using two switches from a 4053 results in this. First bits are selectively inverted, then the two lower ones are mixed, then the two upper ones, and finally the two outer ones. That results in the following 64 sequences without repetitions:
Quote: | 0 1 2 3 4 5 6 7 , 1 0 3 2 5 4 7 6 , 2 3 0 1 6 7 4 5 , 3 2 1 0 7 6 5 4 , 4 5 6 7 0 1 2 3 , 5 4 7 6 1 0 3 2 , 6 7 4 5 2 3 0 1 , 7 6 5 4 3 2 1 0 ,
0 1 4 5 2 3 6 7 , 1 0 5 4 3 2 7 6 , 4 5 0 1 6 7 2 3 , 5 4 1 0 7 6 3 2 , 2 3 6 7 0 1 4 5 , 3 2 7 6 1 0 5 4 , 6 7 2 3 4 5 0 1 , 7 6 3 2 5 4 1 0 ,
0 2 1 3 4 6 5 7 , 2 0 3 1 6 4 7 5 , 1 3 0 2 5 7 4 6 , 3 1 2 0 7 5 6 4 , 4 6 5 7 0 2 1 3 , 6 4 7 5 2 0 3 1 , 5 7 4 6 1 3 0 2 , 7 5 6 4 3 1 2 0 ,
0 4 1 5 2 6 3 7 , 4 0 5 1 6 2 7 3 , 1 5 0 4 3 7 2 6 , 5 1 4 0 7 3 6 2 , 2 6 3 7 0 4 1 5 , 6 2 7 3 4 0 5 1 , 3 7 2 6 1 5 0 4 , 7 3 6 2 5 1 4 0 ,
0 4 2 6 1 5 3 7 , 4 0 6 2 5 1 7 3 , 2 6 0 4 3 7 1 5 , 6 2 4 0 7 3 5 1 , 1 5 3 7 0 4 2 6 , 5 1 7 3 4 0 6 2 , 3 7 1 5 2 6 0 4 , 7 3 5 1 6 2 4 0 ,
0 2 4 6 1 3 5 7 , 2 0 6 4 3 1 7 5 , 4 6 0 2 5 7 1 3 , 6 4 2 0 7 5 3 1 , 1 3 5 7 0 2 4 6 , 3 1 7 5 2 0 6 4 , 5 7 1 3 4 6 0 2 , 7 5 3 1 6 4 2 0 ,
0 4 1 5 2 6 3 7 , 4 0 5 1 6 2 7 3 , 1 5 0 4 3 7 2 6 , 5 1 4 0 7 3 6 2 , 2 6 3 7 0 4 1 5 , 6 2 7 3 4 0 5 1 , 3 7 2 6 1 5 0 4 , 7 3 6 2 5 1 4 0 ,
0 2 1 3 4 6 5 7 , 2 0 3 1 6 4 7 5 , 1 3 0 2 5 7 4 6 , 3 1 2 0 7 5 6 4 , 4 6 5 7 0 2 1 3 , 6 4 7 5 2 0 3 1 , 5 7 4 6 1 3 0 2 , 7 5 6 4 3 1 2 0 |
Bit shuffler isn't a good name for this. It is about generating sequences and could be used in two ways:
Feed a high frequency to a 3-bit counter and the outputs to IN, and another frequency to a 6-bit counter and the outputs to S. Then you would have an interesting waveform modifier, although with a pretty small resolution.
Or feed IN and S with a 9-bit counter and use the OUT signals for a melody generator that repeats after 512 notes.
Description: |
|
Filesize: |
33.23 KB |
Viewed: |
244 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5581 Location: Moon Base
Audio files: 705
|
Posted: Sat Nov 01, 2014 6:30 am Post subject:
Re: bit shuffler Subject description: Any ideas how to generate bit permutations? |
|
|
synaesthesia wrote: | To really mix bits without duplication you could use a 4053 like in the third schematic, here for two bits only. You would need several of them to mix the inputs values to any sequence. |
That was my initial idea, having a bunch of muxes with all inputs attached to all of them and some extra control logic.
That was before I found out that the CD4053 actually has seperate control for all 3 muxes. And then you posted the first version
synaesthesia wrote: | Thinking a bit longer about this, I realized that you cannot get any sequence by just mixing the bits. When you only swap bits, there are only 6 possible combinations: |
I was thinking about a 4 bit version so that would give 24 permutation, but you're correct there are more possibilities.
synaesthesia wrote: | Combining the XOR idea and the bit swap using two switches from a 4053 results in this. First bits are selectively inverted, then the two lower ones are mixed, then the two upper ones, and finally the two outer ones. That results in the following 64 sequences without repetitions |
that's brilliant I gotta do some tests with that setup.
I wonder if the CD4035 can be useful somehow, it's a 4 bit shiftregister with parallel inputs. _________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube |
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5581 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5581 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
|