Spehro Pefhany said:
"Spehro Pefhany" <
[email protected]> schreef in bericht
On 29 Nov 2005 06:12:56 -0800, the renowned "Davy"
Hi all,
reg[7:0] register;
The register contains data like
[0 0 0 1 0 1 0 1]
And I want to know the number of the zeros before the first 1
(in this example is 3 zeros).
How to do this in a combinational logic?
Best regards,
Davy
Pretty easy (a few minutes) if you can use a behavioral description.
A few minutes indeed.
It synthesized to 9 4-in LUTs on an FPGA, or 5 slices, with 6 levels
of logic.
Here's another nice puzzle I stumbled on
yesterday:
http://cgi.ebay.com/Magic-Switchboard_W0QQitemZ6581621863
Took me about 3 minutes to figure out half a solution. The problem
I have is the requirement:
"With this improved version, when the board is initially turned on
you are able to light the bulbs in any order.".
Spending another 30 minutes didn't bring me any luck
Heh. Nonvolatile memory? ;-)
I don't know. If you mount the bulbs and caps in random
order, you could "program" the board by flipping the switches
in the same sequence as the lamps are mounted. So, if the
bulbs are mounted as B-Y-G-R, flip the switches in B-Y-G-R
sequence, thus telling the board which switch belongs to
which bulb. Not many would notice that turning on the
switches in that sequence, is actually a learning cycle for
the controller. Only needed once after power-on reset, and
then the game can continue.
But then there is the claim that you can turn on the lamps
in any order, no matter in what sequence they are mounted.
It depends on the meaning of "initially"-- remember it's to their
advantage to obfuscate a bit. Note the distinctions in the description
between what *you* must do and what the "spectators" can be allowed to
do (they can flip the switches, but presumably not decide *which*
switches to initially flip).
If it's previously been programmed, then you can turn it on
"initially" and it will remember the previous programming (and the
lights can be turned on in any order-- but not re-ordered with the
power off). Their early model might not have done that.
Perhaps there is enough difference in resistance between the
colored bulbs to indentify them reliably. The controller
could then measure the cold resistance to find out which
bulb is in which socket.
I don't think there's anything fancy-schmancy like that going on. Just
switches and probably detection of bulbs removed. You're thinking way
too hard about the electronics and not hard enough about the
obfuscation. It's a kind of magic trick.
Reminds me of the flashing devil horns that I bought for a couple of
dollars on the street one Halloween:
http://server2.hostingplex.com/~zstoretr/horns.JPG
Ran off of AA cells in the black cylinders on the sides, with a light
in each horn. I postulated some kind of COB ASIC with a bipolar
transistor driving each lamp. Felt pretty silly when I found one
fractional-cent thermal flasher Xmas mini-light in each horn and no
active circuitry at all. ;-)
Sounds like a fun project, bit of shame I don't need a
fun project at this moment
Might be a fun project for a student. In VHDL, Verilog, with a
microcontroller or whatever.
Best regards,
Spehro Pefhany