Sort of Gray code to binary converter

In article , John B wrote: [...]

Since there's going to be a table involved anyway you could just have a

256 location table with most of them blank.

If you don't like that big of a table how about:

if ( X and $0F0 ) > 0 then Y := Table1[ X shr 3] else Y := Table2[X]

--
--
kensmith@rahul.net   forging knowledge
Reply to
Ken Smith
Loading thread data ...

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.

Definitely worth a try.

--
John B
Reply to
John B

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

maybe not.

(I prefer Speff's switch statment)

martin

Reply to
martin griffith

"John B" schreef in bericht news:439c5a1f$0$12562$ snipped-for-privacy@master.news.zetnet.net...

That is not so bad at all. It looks perhaps bad, but it isn't. It's the same as a switch statement.

--
Thanks, Frank.
(remove \'q\' and \'.invalid\' when replying by email)
Reply to
Frank Bemelman

Or even easier, a 22CV10.

John

Reply to
John Larkin

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...

Reply to
Fred Bloggs

16V8 PAL

Inputs = ABCDEFGH

0xxxxxx1 = 0 or 1 xxxxxx10 = 2 or 3 xxxxx10x = 4 or 5 xxxx10xx = 6 or 7 xxx10xxx = 8 or 9 xx10xxxx = 10 or 11 x10xxxxx = 12 or 13 10xxxxxx = 14 or 15

Output0 = AB + BC + CD + DE + EF + FG + GH + AH Output1 = A&/B + C&/D + E&/F + G&/H Output2 = A&/B + B&/C + E&/F + F&/G Output3 = A&/B + B&/C + C&/D + D&/E

Reply to
Andrew Holme

Whatever happened to doing an indirect jump through a table ( of addresses) indexed into by the argument?

Reply to
Fred Bloggs

Don't these "Small C" compilers allow them to mix assembly with high level? Seems dumb if they don't.

Reply to
Fred Bloggs

Using 74LS00 series logic I can do it with the following chips:

74LS00 x 4 74LS20 x 2 74LS30 x 1 74LS04 x 1

-Robert Scott Ypsilanti, Michigan

Reply to
Robert Scott

"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)
Reply to
Frank Bemelman

"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)
Reply to
Frank Bemelman

I've got you very beat on chip count but mine are higher level chips. See my post elsewhere in this thread.

Since this doesn't have to be fast, you could use open collector/drain gates to wire-or things. 8 chips seems like way too many for this job.

A SIP R-pack and a comparitor could do the LSB if the high levels are well known.

--
--
kensmith@rahul.net   forging knowledge
Reply to
Ken Smith

"Spehro Pefhany" schreef in bericht news: snipped-for-privacy@4ax.com...

Ugliness is in the eye of the beholder. The CPU couldn't care less ;)

[snip]
--
Thanks, Frank.
(remove \'q\' and \'.invalid\' when replying by email)
Reply to
Frank Bemelman

Ah, a straight LUT. That is how the AD DDS's do it, too.

Assembly isn't very portable, though. Sometimes that matters, and sometimes it doesn't.

Sounds like for you it usually doesn't. ;-)

--Mac

Reply to
Mac

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.)

-Robert Scott Ypsilanti, Michigan

Reply to
Robert Scott

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.
Reply to
Richard Henry

Can I do it all in 2N2222 ?:-)

...Jim Thompson

--
|  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.
Reply to
Jim Thompson

How about some mind-numbing array of diodes?

--
Luhan Monat
luhanxmonat \'at\' yahoo \'dot\' com
http://members.cox.net/berniekm
Reply to
Luhan Monat

Relays ?:-)

...Jim Thompson

--
|  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.
Reply to
Jim Thompson

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.