On 11/12/2005 the venerable Spehro Pefhany etched in runes:
. . .
Oh, what a pedant you are.
OK, in this case 'best' means least amount of 'C' code or smallest amount of external hardware. Cost of components can be ignored since this has become an academic exercise and academics tend to ignore costs.
The unspecified 93.75% of cases can only happen in a situation where the external sensor has failed in some way. Let's assume that this wont happen and all unspecified cases can return any random value. That makes it easy for you.
As a pagan I personally have no Christmas so the closing date of the competition will be three days after the winter solstice. Just for the pedants, that will be the winter solstice in the Northern hemisphere!
Oh no, another pagan who drinks his red wine cool. Red wine should be drunk at room temperature and allowed to breathe for some time before drinking. That's always the hardest part.
If you could input active lows, use a priority encoder, hc157 to get the high bit sorted, but with the ouputs shifted up by one use diodes and resistors as a 2bit detector into a comparitor to see if the next bit down is set.This would be the lsb
The direct approaches are uninteresting- like the dumb C stuff that presumably uses 16 I/O which seems burdensome on the embedded flea power hardware. The answer in terms of an efficient solution is not only pat but also obvious if you can recognize the analogy with another well-known method...
"Spehro Pefhany" schreef in bericht news: snipped-for-privacy@4ax.com...
Right. If a large enough switch statement where an 8 bit switch argument is used, a binary tree comes to mind, but with smaller switches it all boils down to series of if/else cases. Writing it in if/else form, it allows you to optimize for the situation at hand, put the most likely possibilities at the top, things like that. This is all very understandable, as there exists no assembly equivalent for a switch statement, so any cleverness, if any, has to come from the compiler if you depend on the switch statement. I have yet to see a compiler that uses anything else than if/else approach, but perhaps I haven't used large enough switches to see a different behaviour.
--
Thanks, Frank.
(remove \'q\' and \'.invalid\' when replying by email)
"Fred Bloggs" schreef in bericht news: snipped-for-privacy@nospam.com...
That's nice if you have some control over the argument, like being restricted to 8 bit etc. In this case, only 16 different argument values exist. You can sacrifice a table of 256 vectors to gain some speed, if you must, and if you have the room for it.
--
Thanks, Frank.
(remove \'q\' and \'.invalid\' when replying by email)
How about comparing solutions on the basis of equivalent number of gates? Obviously an ASIC could be built to do this job, but the puzzle, as an intellectual exercise, is more interesting if you place complexity limitations on the solution.
(For a practical solution I would just program a PIC.)
Only for sufficiently-liberal definition of "gate". Or do you consider the
8-input nand-gate to be the equivalent of an '04 inverter? If so, I propose to program a PAL16CV8 with the solution and relabel it as an AG3927 Weathervane Gate.
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC\'s and Discrete Systems | manus |
| Phoenix, Arizona Voice:(480)460-2350 | |
| E-mail Address at Website Fax:(480)460-2142 | Brass Rat |
| http://www.analog-innovations.com | 1962 |
I love to cook with wine. Sometimes I even put it in the food.
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC\'s and Discrete Systems | manus |
| Phoenix, Arizona Voice:(480)460-2350 | |
| E-mail Address at Website Fax:(480)460-2142 | Brass Rat |
| http://www.analog-innovations.com | 1962 |
I love to cook with wine. Sometimes I even put it in the food.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.