[chbot] New chocolate fish challenge

hamster hamster at snap.net.nz
Wed Nov 19 20:12:33 GMT 2014


 

Hi Volker, 

I couldn't be bothererd to learn the math so the tap
positions (the constant of 0x30) was found trail and error - it isn't
that hard as knowing that a 5-bit two-tap design is possible the are
only 4 options (0x30, 0x28, 0x24, 0x22 and 0x21). Once I had a maximal
LFSR (it goes through all 63 possible states), it was just a case of
running it forward a few states to get the 0x22 constant for the
start/reset value. 

As to what application? Well, I've been getting a
bit pain for putting up FPGA designs that that people are handing in as
answers to their coursework, and I am going to put my digital clock up
on my wiki. As a digital clock is a common course assignment, so I am
including a few Easter Eggs to upset the lazy student . 

To divide the
32MHz XTAL signal to get a pulse per second signal (pps) rather than a
simple counter that goes from 0-31999999 I'm doing this: 

 if
rising_edge(clk) then
 if lfsr = "1111111111111111111111111" then
 lfsr
<= "0111110111010111001000000";
 pps <= '1';
 else
 lfsr <= (lfsr(0) xor
lfsr(3)) & lfsr(lfsr'high downto 1);
 pps <= '0';
 end if;
 end
if;

Likewise, to count minutes and seconds I'm using 6-bit LFSRs rather
than regular counters, and for the minute set and clock set
buttons.

The high level structure is just the same, the output is just
the same, but good luck explaining that one to your teacher if you hand
it in as homework.

Mike

On 20.11.2014 07:41, Volker Kuhlmann wrote:


> On Wed 19 Nov 2014 22:07:12 NZDT +1300, Michael Field wrote:
> 
>>
static int chocolate_fish_challenge(void) { static unsigned char reg =
0x22; if(reg) { reg = (reg >> 1) ^ ((reg & 1) ? 0 : 0x30); return 0; }
reg = 0x22; return 1; }
> 
> Interesting!
> How did you find the start
value, early exit condition and tap positions?
> 
> What application do
you have requiring this? Incrementing a counter to
> 60 gives shorter
code, faster execution, and a lot less maintenance
> headache for the
same memory requirements.
> 
> Thanks,
> 
> Volker

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20141120/551c798e/attachment.html>


More information about the Chchrobotics mailing list