Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > sci.electronics.design > #538329 > unrolled thread

a couple of LC filter progs

Started byJohn Larkin <jjlarkin@highlandtechnology.com>
First post2019-04-05 19:55 -0700
Last post2019-04-07 10:03 -0700
Articles 20 on this page of 32 — 11 participants

Back to article view | Back to sci.electronics.design


Contents

  a couple of LC filter progs John Larkin <jjlarkin@highlandtechnology.com> - 2019-04-05 19:55 -0700
    Re: a couple of LC filter progs "John Miles, KE5FX" <jmiles@gmail.com> - 2019-04-06 20:07 -0700
      Re: a couple of LC filter progs John Larkin <jjlarkin@highlandtechnology.com> - 2019-04-07 07:47 -0700
        Re: a couple of LC filter progs Winfield Hill <hill@rowland.harvard.edu> - 2019-04-07 08:46 -0700
          Re: a couple of LC filter progs John Larkin <jjlarkin@highlandtechnology.com> - 2019-04-07 09:40 -0700
            Re: a couple of LC filter progs Winfield Hill <hill@rowland.harvard.edu> - 2019-04-07 09:49 -0700
              Re: a couple of LC filter progs John Larkin <jjlarkin@highlandtechnology.com> - 2019-04-07 10:17 -0700
                Re: a couple of LC filter progs Joseph Gwinn <joegwinn@comcast.net> - 2019-04-07 15:07 -0400
                  Re: a couple of LC filter progs Winfield Hill <hill@rowland.harvard.edu> - 2019-04-07 12:21 -0700
                    Re: a couple of LC filter progs John Larkin <jjlarkin@highlandtechnology.com> - 2019-04-07 13:24 -0700
                      Re: a couple of LC filter progs Joseph Gwinn <joegwinn@comcast.net> - 2019-04-07 17:08 -0400
                        Re: a couple of LC filter progs John Larkin <jjlarkin@highlandtechnology.com> - 2019-04-07 14:53 -0700
                          Re: a couple of LC filter progs Joseph Gwinn <joegwinn@comcast.net> - 2019-04-08 22:37 -0400
                            Re: a couple of LC filter progs "Tim Williams" <tiwill@seventransistorlabs.com> - 2019-04-09 00:57 -0500
                              Re: a couple of LC filter progs Joseph Gwinn <joegwinn@comcast.net> - 2019-04-09 10:44 -0400
                            Re: a couple of LC filter progs "Tim Williams" <tiwill@seventransistorlabs.com> - 2019-04-09 14:50 -0500
                              Re: a couple of LC filter progs Gerhard Hoffmann <dk4xp@arcor.de> - 2019-04-09 23:02 +0200
                                Re: a couple of LC filter progs "Tim Williams" <tiwill@seventransistorlabs.com> - 2019-04-09 19:30 -0500
                                  Re: a couple of LC filter progs Gerhard Hoffmann <dk4xp@arcor.de> - 2019-04-10 02:55 +0200
                                  Re: a couple of LC filter progs upsidedown@downunder.com - 2019-04-10 07:40 +0300
                                    Re: a couple of LC filter progs Gerhard Hoffmann <dk4xp@arcor.de> - 2019-04-10 11:26 +0200
                                      Re: a couple of LC filter progs upsidedown@downunder.com - 2019-04-10 21:20 +0300
                                  Re: a couple of LC filter progs Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2019-04-10 11:50 +0300
                              Re: a couple of LC filter progs Joseph Gwinn <joegwinn@comcast.net> - 2019-04-11 09:15 -0400
      Re: a couple of LC filter progs Simon S Aysdie <gwhite@ti.com> - 2019-04-07 10:22 -0700
    Re: a couple of LC filter progs "Tim Williams" <tiwill@seventransistorlabs.com> - 2019-04-07 00:41 -0500
      Re: a couple of LC filter progs John Larkin <jjlarkin@highlandtechnology.com> - 2019-04-07 07:54 -0700
    Re: a couple of LC filter progs Clifford Heath <no.spam@please.net> - 2019-04-07 17:56 +1000
      Re: a couple of LC filter progs John Larkin <jjlarkin@highlandtechnology.com> - 2019-04-07 07:55 -0700
        Re: a couple of LC filter progs Clifford Heath <no.spam@please.net> - 2019-04-08 07:59 +1000
          Re: a couple of LC filter progs John Larkin <jjlarkin@highland_snip_technology.com> - 2019-04-08 10:58 -0700
    Re: a couple of LC filter progs Simon S Aysdie <gwhite@ti.com> - 2019-04-07 10:03 -0700

Page 1 of 2  [1] 2  Next page →


#538329 — a couple of LC filter progs

FromJohn Larkin <jjlarkin@highlandtechnology.com>
Date2019-04-05 19:55 -0700
Subjecta couple of LC filter progs
Message-ID<j05gaeh4rgqtsm8leoorc84nna492o7j2j@4ax.com>
BESSIE designs LC Bessel filters up to 5th order.

LCNORM normalizes or scales filters for new frequencies or impedances.
That's always a nuisance to do by hand.

https://www.dropbox.com/s/syvu0wsx7s9rllk/Filter_Progs_1.zip?dl=0

I hope I got them right.



-- 

John Larkin         Highland Technology, Inc

lunatic fringe electronics 

[toc] | [next] | [standalone]


#538430

From"John Miles, KE5FX" <jmiles@gmail.com>
Date2019-04-06 20:07 -0700
Message-ID<c35494a9-e24d-42ad-8d45-7ce323ea4298@googlegroups.com>
In reply to#538329
On Friday, April 5, 2019 at 7:55:47 PM UTC-7, John Larkin wrote:
> BESSIE designs LC Bessel filters up to 5th order.
> 
> LCNORM normalizes or scales filters for new frequencies or impedances.
> That's always a nuisance to do by hand.
> 
> https://www.dropbox.com/s/syvu0wsx7s9rllk/Filter_Progs_1.zip?dl=0
> 
> I hope I got them right.
> 

I'll also put in a plug for this site, which I've been using quite a bit
lately to build elliptic BPFs at VHF:

https://rf-tools.com/lc-filter/

Results match those from the AADE program but this web-based program has the
ability to specify standard part values, which the AADE program doesn't.

-- john, KE5FX

[toc] | [prev] | [next] | [standalone]


#538485

FromJohn Larkin <jjlarkin@highlandtechnology.com>
Date2019-04-07 07:47 -0700
Message-ID<023kaedmlpnv5k17tm40f7363h1l2jkqph@4ax.com>
In reply to#538430
On Sat, 6 Apr 2019 20:07:03 -0700 (PDT), "John Miles, KE5FX"
<jmiles@gmail.com> wrote:

>On Friday, April 5, 2019 at 7:55:47 PM UTC-7, John Larkin wrote:
>> BESSIE designs LC Bessel filters up to 5th order.
>> 
>> LCNORM normalizes or scales filters for new frequencies or impedances.
>> That's always a nuisance to do by hand.
>> 
>> https://www.dropbox.com/s/syvu0wsx7s9rllk/Filter_Progs_1.zip?dl=0
>> 
>> I hope I got them right.
>> 
>
>I'll also put in a plug for this site, which I've been using quite a bit
>lately to build elliptic BPFs at VHF:
>
>https://rf-tools.com/lc-filter/
>
>Results match those from the AADE program but this web-based program has the
>ability to specify standard part values, which the AADE program doesn't.
>
>-- john, KE5FX

That's impressive. It looks competitive with the expensive NuHertz
software. NuHertz also does some rare filter forms, and finite-Q
designs.

I usually use a filter design program to get ideal values, then plug
into Spice and try values that we have in stock.

Here's my units conversion program:

https://www.dropbox.com/s/64rg7ko4rc7hhw7/U.zip?dl=0


-- 

John Larkin         Highland Technology, Inc

lunatic fringe electronics 

[toc] | [prev] | [next] | [standalone]


#538495

FromWinfield Hill <hill@rowland.harvard.edu>
Date2019-04-07 08:46 -0700
Message-ID<q8d60r0kuk@drn.newsguy.com>
In reply to#538485
John Larkin wrote...
>
> Here's my units conversion program:
>https://www.dropbox.com/s/64rg7ko4rc7hhw7/U.zip?dl=0

 John, you should provide the code.


-- 
 Thanks,
    - Win

[toc] | [prev] | [next] | [standalone]


#538503

FromJohn Larkin <jjlarkin@highlandtechnology.com>
Date2019-04-07 09:40 -0700
Message-ID<fm9kaep40mjdv7ilvnhqhv38dtuh871q9e@4ax.com>
In reply to#538495
On 7 Apr 2019 08:46:35 -0700, Winfield Hill <hill@rowland.harvard.edu>
wrote:

>John Larkin wrote...
>>
>> Here's my units conversion program:
>>https://www.dropbox.com/s/64rg7ko4rc7hhw7/U.zip?dl=0
>
> John, you should provide the code.

It's PowerBasic, which hardly anyone uses, and it's pretty hacked
looking. It just sort of happened.

OK, added to the zip file.




-- 

John Larkin         Highland Technology, Inc

lunatic fringe electronics 

[toc] | [prev] | [next] | [standalone]


#538507

FromWinfield Hill <hill@rowland.harvard.edu>
Date2019-04-07 09:49 -0700
Message-ID<q8d9lv0rok@drn.newsguy.com>
In reply to#538503
John Larkin wrote...
>
> On 7 Apr 2019, Winfield Hill wrote:
>> John Larkin wrote...
>>>
>>> Here's my units conversion program:
>>>https://www.dropbox.com/s/64rg7ko4rc7hhw7/U.zip?dl=0
>>
>> John, you should provide the code.
>
> It's PowerBasic, which hardly anyone uses, and it's
> pretty hacked looking. It just sort of happened.
> OK, added to the zip file.

 Hey, John, that's not so bad, thanks!


-- 
 Thanks,
    - Win

[toc] | [prev] | [next] | [standalone]


#538521

FromJohn Larkin <jjlarkin@highlandtechnology.com>
Date2019-04-07 10:17 -0700
Message-ID<pnbkaehon75kiil4lngfot8t7i6ugcfajn@4ax.com>
In reply to#538507
On 7 Apr 2019 09:49:03 -0700, Winfield Hill <hill@rowland.harvard.edu>
wrote:

>John Larkin wrote...
>>
>> On 7 Apr 2019, Winfield Hill wrote:
>>> John Larkin wrote...
>>>>
>>>> Here's my units conversion program:
>>>>https://www.dropbox.com/s/64rg7ko4rc7hhw7/U.zip?dl=0
>>>
>>> John, you should provide the code.
>>
>> It's PowerBasic, which hardly anyone uses, and it's
>> pretty hacked looking. It just sort of happened.
>> OK, added to the zip file.
>
> Hey, John, that's not so bad, thanks!

People are down on Basic and especially GOTO, but they suit the way I
think.

U.EXE is 24 kilobytes. I once challenged a c program in a signal
averaging application. c used pointers, I used subscripts. PowerBasic
beat it on run speed by over 3:1.




-- 

John Larkin         Highland Technology, Inc

lunatic fringe electronics 

[toc] | [prev] | [next] | [standalone]


#538533

FromJoseph Gwinn <joegwinn@comcast.net>
Date2019-04-07 15:07 -0400
Message-ID<0001HW.225A81ED003A767D70000E6E32EF@news.giganews.com>
In reply to#538521
On Apr 7, 2019, John Larkin wrote
(in article<pnbkaehon75kiil4lngfot8t7i6ugcfajn@4ax.com>):

> On 7 Apr 2019 09:49:03 -0700, Winfield Hill<hill@rowland.harvard.edu>
> wrote:
>
> > John Larkin wrote...
> > >
> > > On 7 Apr 2019, Winfield Hill wrote:
> > > > John Larkin wrote...
> > > > >
> > > > > Here's my units conversion program:
> > > > > https://www.dropbox.com/s/64rg7ko4rc7hhw7/U.zip?dl=0
> > > >
> > > > John, you should provide the code.
> > >
> > > It's PowerBasic, which hardly anyone uses, and it's
> > > pretty hacked looking. It just sort of happened.
> > > OK, added to the zip file.
> >
> > Hey, John, that's not so bad, thanks!
>
> People are down on Basic and especially GOTO, but they suit the way I
> think.
>
> U.EXE is 24 kilobytes. I once challenged a c program in a signal
> averaging application. c used pointers, I used subscripts. PowerBasic
> beat it on run speed by over 3:1.

How´d you do that? Basic is an interpreted language, and for something like 
signal averaging, any reasonable C program should be a factor faster. 
Something is wrong.

Joe Gwinn

[toc] | [prev] | [next] | [standalone]


#538534

FromWinfield Hill <hill@rowland.harvard.edu>
Date2019-04-07 12:21 -0700
Message-ID<q8dijg01967@drn.newsguy.com>
In reply to#538533
Joseph Gwinn wrote...
>
> How did you do that? Basic is an interpreted language...

 Microsoft introduced QuickBasic, an excellent compiler
 version, with proper compiled-langauge features, in
 the mid 80s.  In the late 80s they brought out BC, a
 Basic Compiler, which was very advanced.  Not especially
 cheap, but well worth the money.  No line numbers and
 one would rarely use GOTOs, which went to labeled
 statementa if you did use them.

 The Windows version became VisualBasic, which then
 combined with the other Microsoft compilers.

 John can tell you about PowerBasic, which took things
 a few steps further.


-- 
 Thanks,
    - Win

[toc] | [prev] | [next] | [standalone]


#538542

FromJohn Larkin <jjlarkin@highlandtechnology.com>
Date2019-04-07 13:24 -0700
Message-ID<qhmkae1mkr8pfknv186ganulorjdbtti12@4ax.com>
In reply to#538534
On 7 Apr 2019 12:21:20 -0700, Winfield Hill <hill@rowland.harvard.edu>
wrote:

>Joseph Gwinn wrote...
>>
>> How did you do that? Basic is an interpreted language...
>
> Microsoft introduced QuickBasic, an excellent compiler
> version, with proper compiled-langauge features, in
> the mid 80s.  In the late 80s they brought out BC, a
> Basic Compiler, which was very advanced.  Not especially
> cheap, but well worth the money.  No line numbers and
> one would rarely use GOTOs, which went to labeled
> statementa if you did use them.
>
> The Windows version became VisualBasic, which then
> combined with the other Microsoft compilers.
>
> John can tell you about PowerBasic, which took things
> a few steps further.

It's a serious super-optimized compiler, with many data types and
"modern" constructs, like CASE and WHILE and TRY...CATCH. The compiler
is written in PowerBasic. I can run non-trivial FOR loops at 100 MHz.

The guru was Bob Zale, who authored Turbo Basic but died in 2012. I
doubt it will last a lot longer.

Python is good (and looks a lot like Basic!) but most versions are
still interpreters. I think 1 MHz loops are possible. There are now
some Python compilers.

Python would be great for embedded systems. We use it in all our
automated test stands.



-- 

John Larkin         Highland Technology, Inc

lunatic fringe electronics 

[toc] | [prev] | [next] | [standalone]


#538548

FromJoseph Gwinn <joegwinn@comcast.net>
Date2019-04-07 17:08 -0400
Message-ID<0001HW.225A9E5400411EAC70000E6E32EF@news.giganews.com>
In reply to#538542
On Apr 7, 2019, John Larkin wrote
(in article<qhmkae1mkr8pfknv186ganulorjdbtti12@4ax.com>):

> On 7 Apr 2019 12:21:20 -0700, Winfield Hill<hill@rowland.harvard.edu>
> wrote:
>
> > Joseph Gwinn wrote...
> > >
> > > How did you do that? Basic is an interpreted language...
> >
> > Microsoft introduced QuickBasic, an excellent compiler
> > version, with proper compiled-langauge features, in
> > the mid 80s. In the late 80s they brought out BC, a
> > Basic Compiler, which was very advanced. Not especially
> > cheap, but well worth the money. No line numbers and
> > one would rarely use GOTOs, which went to labeled
> > statementa if you did use them.
> >
> > The Windows version became VisualBasic, which then
> > combined with the other Microsoft compilers.
> >
> > John can tell you about PowerBasic, which took things
> > a few steps further.
>
> It's a serious super-optimized compiler, with many data types and
> "modern" constructs, like CASE and WHILE and TRY...CATCH. The compiler
> is written in PowerBasic. I can run non-trivial FOR loops at 100 MHz.
>
> The guru was Bob Zale, who authored Turbo Basic but died in 2012. I
> doubt it will last a lot longer.
>
> Python is good (and looks a lot like Basic!) but most versions are
> still interpreters. I think 1 MHz loops are possible. There are now
> some Python compilers.
>
> Python would be great for embedded systems. We use it in all our
> automated test stands.

Ahh. Thanks. The Basic of my youth could not be compiled (because it had some 
dynamic syntax that required access to the executing runtime), but those 
awkward constructs seem to have withered away, and we now have compiled 
Basic.

This Basic seems to be evolving towards Fortran.

Hmm. One must be careful of that word "compiled". In this case, does it 
mean compiled down to machine code, or to some kind of bytecode that is 
executed by a runtime engine (like Java)?

> PowerBasic beat it on run speed by over 3:1.

3:1? Something is still amiss. For something as simple as averaging, the same 
algorithm programmed in a pair of compiled language, ought to yield roughly 
equal speeds. Unless the algorithm is biased toward one or the other 
language. In particular, algorithms developed on one language often prove 
awkward if transliterated into a different language.

For many algorithms, C is faster than Basic (and Fortran) because one can 
pass objects in by address, even if the C compiler has no knowledge of that 
object.

An inspection of the generated assembly code may prove surprising.

Joe Gwinn

[toc] | [prev] | [next] | [standalone]


#538553

FromJohn Larkin <jjlarkin@highlandtechnology.com>
Date2019-04-07 14:53 -0700
Message-ID<3srkaelmkd8brc6i1jbdm3eio9dlcbget6@4ax.com>
In reply to#538548
On Sun, 07 Apr 2019 17:08:36 -0400, Joseph Gwinn
<joegwinn@comcast.net> wrote:

>On Apr 7, 2019, John Larkin wrote
>(in article<qhmkae1mkr8pfknv186ganulorjdbtti12@4ax.com>):
>
>> On 7 Apr 2019 12:21:20 -0700, Winfield Hill<hill@rowland.harvard.edu>
>> wrote:
>>
>> > Joseph Gwinn wrote...
>> > >
>> > > How did you do that? Basic is an interpreted language...
>> >
>> > Microsoft introduced QuickBasic, an excellent compiler
>> > version, with proper compiled-langauge features, in
>> > the mid 80s. In the late 80s they brought out BC, a
>> > Basic Compiler, which was very advanced. Not especially
>> > cheap, but well worth the money. No line numbers and
>> > one would rarely use GOTOs, which went to labeled
>> > statementa if you did use them.
>> >
>> > The Windows version became VisualBasic, which then
>> > combined with the other Microsoft compilers.
>> >
>> > John can tell you about PowerBasic, which took things
>> > a few steps further.
>>
>> It's a serious super-optimized compiler, with many data types and
>> "modern" constructs, like CASE and WHILE and TRY...CATCH. The compiler
>> is written in PowerBasic. I can run non-trivial FOR loops at 100 MHz.
>>
>> The guru was Bob Zale, who authored Turbo Basic but died in 2012. I
>> doubt it will last a lot longer.
>>
>> Python is good (and looks a lot like Basic!) but most versions are
>> still interpreters. I think 1 MHz loops are possible. There are now
>> some Python compilers.
>>
>> Python would be great for embedded systems. We use it in all our
>> automated test stands.
>
>Ahh. Thanks. The Basic of my youth could not be compiled (because it had some 
>dynamic syntax that required access to the executing runtime), but those 
>awkward constructs seem to have withered away, and we now have compiled 
>Basic.
>
>This Basic seems to be evolving towards Fortran.
>
>Hmm. One must be careful of that word "compiled". In this case, does it 
>mean compiled down to machine code, or to some kind of bytecode that is 
>executed by a runtime engine (like Java)?

x86 machine code. You can also insert inline ASM statements, which is
occasionally useful. In asm, you can refer to Basic variables or
labels by name.

>
>> PowerBasic beat it on run speed by over 3:1.
>
>3:1? Something is still amiss. For something as simple as averaging, the same 
>algorithm programmed in a pair of compiled language, ought to yield roughly 
>equal speeds. Unless the algorithm is biased toward one or the other 
>language. In particular, algorithms developed on one language often prove 
>awkward if transliterated into a different language.

The c guy played with code and compiler switches for a day and got
close.


-- 

John Larkin         Highland Technology, Inc

lunatic fringe electronics 

[toc] | [prev] | [next] | [standalone]


#538730

FromJoseph Gwinn <joegwinn@comcast.net>
Date2019-04-08 22:37 -0400
Message-ID<0001HW.225C3CD800A246FA70000E6E32EF@news.giganews.com>
In reply to#538553
On Apr 7, 2019, John Larkin wrote
(in article<3srkaelmkd8brc6i1jbdm3eio9dlcbget6@4ax.com>):

> On Sun, 07 Apr 2019 17:08:36 -0400, Joseph Gwinn
> <joegwinn@comcast.net>  wrote:
>
> > On Apr 7, 2019, John Larkin wrote
> > (in article<qhmkae1mkr8pfknv186ganulorjdbtti12@4ax.com>):
> >
> > > On 7 Apr 2019 12:21:20 -0700, Winfield Hill<hill@rowland.harvard.edu>
> > > wrote:
> > >
> > > > Joseph Gwinn wrote...
> > > > >
> > > > > How did you do that? Basic is an interpreted language...
> > > >
> > > > Microsoft introduced QuickBasic, an excellent compiler
> > > > version, with proper compiled-langauge features, in
> > > > the mid 80s. In the late 80s they brought out BC, a
> > > > Basic Compiler, which was very advanced. Not especially
> > > > cheap, but well worth the money. No line numbers and
> > > > one would rarely use GOTOs, which went to labeled
> > > > statementa if you did use them.
> > > >
> > > > The Windows version became VisualBasic, which then
> > > > combined with the other Microsoft compilers.
> > > >
> > > > John can tell you about PowerBasic, which took things
> > > > a few steps further.
> > >
> > > It's a serious super-optimized compiler, with many data types and
> > > "modern" constructs, like CASE and WHILE and TRY...CATCH. The compiler
> > > is written in PowerBasic. I can run non-trivial FOR loops at 100 MHz.
> > >
> > > The guru was Bob Zale, who authored Turbo Basic but died in 2012. I
> > > doubt it will last a lot longer.
> > >
> > > Python is good (and looks a lot like Basic!) but most versions are
> > > still interpreters. I think 1 MHz loops are possible. There are now
> > > some Python compilers.
> > >
> > > Python would be great for embedded systems. We use it in all our
> > > automated test stands.
> >
> > Ahh. Thanks. The Basic of my youth could not be compiled (because it had
> > some
> > dynamic syntax that required access to the executing runtime), but those
> > awkward constructs seem to have withered away, and we now have compiled
> > Basic.
> >
> > This Basic seems to be evolving towards Fortran.
> >
> > Hmm. One must be careful of that word "compiled". In this case, does it
> > mean compiled down to machine code, or to some kind of bytecode that is
> > executed by a runtime engine (like Java)?
>
> x86 machine code. You can also insert inline ASM statements, which is
> occasionally useful. In asm, you can refer to Basic variables or
> labels by name.

OK. No bytecode "compiler" marketing nonsense. I run into this all the 
time, so I always ask.

> >
> > > PowerBasic beat it on run speed by over 3:1.
> >
> > 3:1? Something is still amiss. For something as simple as averaging, the sam

> > algorithm programmed in a pair of compiled language, ought to yield roughly
> > equal speeds. Unless the algorithm is biased toward one or the other
> > language. In particular, algorithms developed on one language often prove
> > awkward if transliterated into a different language.
>
> The c guy played with code and compiler switches for a day and got
> close.

OK. That makes more sense.

The easy and hard directions in high-order programming languages (HOLs) are 
often surprising.

What may be a dead-simple but relevant example is looping over a two 
dimensional array "Data[i, j]. In all HOLs, it matters which index 
increments faster, i or j, and in a big array the difference can be dramatic 
because of how caches and virtual memory work. A common problem when 
comparing the Fortran family and the C family is that with order is best 
differs between those two families. It all depends on how arrays are stored 
in memory, column-first or row-first. Whichever is first needs the faster 
index. So a full translation involves reversing how those indexes are used.

Twenty years ago, when I was involved with developing what is now called 
Middleware for a radar fire-control system for ship self defense against 
cruise missiles (no-kidding realtime - the final exam arrived at Mach 2, and 
fumbling was bad for your health), our main vendor had an interesting 
approach. They coded in plain C, inspected the generated assembly code, and 
tweaked the C code until the assembly code was clean and fast. It turned out 
that the resulting code was largely portable in that all C compilers 
generated clean, fast code from the same tweaked C source code, after the 
source code was tweaked to the first two compilers.

Joe Gwinn

[toc] | [prev] | [next] | [standalone]


#538749

From"Tim Williams" <tiwill@seventransistorlabs.com>
Date2019-04-09 00:57 -0500
Message-ID<q8hc77$nr7$1@dont-email.me>
In reply to#538730
"Joseph Gwinn" <joegwinn@comcast.net> wrote in message 
news:0001HW.225C3CD800A246FA70000E6E32EF@news.giganews.com...
> Twenty years ago, when I was involved with developing what is now called 
> Middleware for a radar fire-control system for ship self defense against
cruise missiles (no-kidding realtime - the final exam arrived at Mach 2, and
fumbling was bad for your health), our main vendor had an interesting
approach. They coded in plain C, inspected the generated assembly code, and
tweaked the C code until the assembly code was clean and fast. It turned out
that the resulting code was largely portable in that all C compilers
generated clean, fast code from the same tweaked C source code, after the
source code was tweaked to the first two compilers.
>

Schools need to teach this [more often?].  If you're working in a low level 
language* like C, you need to think about the end product: ultimately, 
you're telling the compiler how to write a program.  C is not exactly a 
specification or description language, but that's not an invalid perspective 
to take.

(Personally, I've seen VHDL taught that way, as describing instances of 
logic gates through semantic structures, but not C.  I did get ASM and then 
C from the same prof as did many other students on the same track, but 
without the explicit call to inspect ones' machine code, I doubt anyone made 
the connection.)

*Face it, C is low.  Well, "medium" would be more charitable.  It's 
assembler, cleaned up with richer macros and an optimizer.  If it were a 
high level language, it would know better than to give mere /developers/ the 
pointers^Hkeys to the missile silos!


As for the matter of writing mission-critical software in C, I will withold 
judgement on that... :^)

Tim

-- 
Seven Transistor Labs, LLC
Electrical Engineering Consultation and Design
Website: https://www.seventransistorlabs.com/ 

[toc] | [prev] | [next] | [standalone]


#538786

FromJoseph Gwinn <joegwinn@comcast.net>
Date2019-04-09 10:44 -0400
Message-ID<0001HW.225CE74500CA391870000E6E32EF@news.giganews.com>
In reply to#538749
On Apr 9, 2019, Tim Williams wrote
(in article <q8hc77$nr7$1@dont-email.me>):

> "Joseph Gwinn" <joegwinn@comcast.net> wrote in message
> news:0001HW.225C3CD800A246FA70000E6E32EF@news.giganews.com...
> > Twenty years ago, when I was involved with developing what is now called
> > Middleware for a radar fire-control system for ship self defense against
> cruise missiles (no-kidding realtime - the final exam arrived at Mach 2, and
> fumbling was bad for your health), our main vendor had an interesting
> approach. They coded in plain C, inspected the generated assembly code, and
> tweaked the C code until the assembly code was clean and fast. It turned out
> that the resulting code was largely portable in that all C compilers
> generated clean, fast code from the same tweaked C source code, after the
> source code was tweaked to the first two compilers.

I should mention that the mission code was written in Ada83, but the 
infrastructure was in C. It´s a long story, but Ada was a major cause of 
many problems. This was the last Ada project in that area - the Ada mandate 
was rescinded during the project.

.
> Schools need to teach this [more often?]. If you're working in a low level
> language* like C, you need to think about the end product: ultimately,
> you're telling the compiler how to write a program. C is not exactly a
> specification or description language, but that's not an invalid perspective
> to take.

The original intent of C was to develop a portable equivalent to assembly 
language, so UNIX could be ported from computer type to computer type. This 
is documented in K&R.

But whatever the language level, C won the language wars hands down. Ada83 
was an early casualty.

.
> (Personally, I've seen VHDL taught that way, as describing instances of
> logic gates through semantic structures, but not C. I did get ASM and then
> C from the same prof as did many other students on the same track, but
> without the explicit call to inspect ones' machine code, I doubt anyone made
> the connection.)
>
> *Face it, C is low. Well, "medium" would be more charitable. It's
> assembler, cleaned up with richer macros and an optimizer. If it were a
> high level language, it would know better than to give mere /developers/ the
> pointers^Hkeys to the missile silos!

One of the problems with Ada was precisely that it attempted to prevent 
errors by constraining the programmers. Having right hand tied to left foot 
does prevent mistakes, but it turns out that the price was too high.

Ada83 enforced a 1970s academic theory of how programs ought to be 
structured, from people who had zero experience of embedded realtime 
programming. There was zero support for hardware interfaces (no shared 
memory, no volatile variables, etc). The whole issue of priority inversion 
was simply missed - priority inversion was in the embedded-realtime lore, but 
had neither a name nor a literature, and so was invisible to academics. And 
Ada83 was locked down, and could not be changed to fix any of the many 
problems. So, we fixed such problems in the C-coded runtime, where Lady Ada 
could neither see nor touch - she lived in an artificial space designed to 
never surprise her.

.
> As for the matter of writing mission-critical software in C, I will withold
> judgement on that... :^)
Too late. Most military mission-critical code is written in C++ these days, 
with direct hardware control in ANSI C. The operating system is some form of 
Linux.

Ada retains a niche in safety-critical code, where DO-178 is implemented. But 
DO-178 is so heavy that it actually does not matter what language one uses, 
and one can argue that assembler is safer than any HOL, because with 
assembler nothing is hidden.

Joe Gwinn

[toc] | [prev] | [next] | [standalone]


#538809

From"Tim Williams" <tiwill@seventransistorlabs.com>
Date2019-04-09 14:50 -0500
Message-ID<q8it1k$3qi$1@dont-email.me>
In reply to#538730
"Joseph Gwinn" <joegwinn@comcast.net> wrote in message 
news:0001HW.225C3CD800A246FA70000E6E32EF@news.giganews.com...
> They coded in plain C, inspected the generated assembly code, and
tweaked the C code until the assembly code was clean and fast. It turned out
that the resulting code was largely portable in that all C compilers
generated clean, fast code from the same tweaked C source code, after the
source code was tweaked to the first two compilers.
>

Expanding on this some more --

Just in my humble experience alone, your writing style can massively affect 
code generation.

The optimizer is terribly, terribly far from exhaustive.  (It /could/ be 
exhaustive -- but then users would complain of hours or years of compilation 
time for almost no benefit, and that's no good!)  If it doesn't figure out 
any simple tricks, it's just going to pick the best, mediocre solution and 
let that be that.

And mind this affects execution time about as much as it does code size. 
Often, compact code runs faster, especially on simpler embedded platforms. 
(Yeah, when pipelines and caches get involved, unrolled and inlined 
operations get more attractive, and the discrepancy between compact and fast 
code can grow.)

Things the optimizer is likely to check, can range from modestly unrolling 
or reordering loops, to factoring numerical expressions, to inlining 
functions and operating on the resulting mega-function, and more.  All of 
these grow quickly in complexity, however, and the pursuit can become 
self-defeating.

A recent example was a bit-packing function, on an 8-bit platform with 
hardware multiply.  I wrote this a few different ways.  By far, the worst 
was a mega-expression: between macros and carefully indented and inspected 
sub-expressions, the whole operation can be expressed entirely numerically. 
That's technically fine, but the compiler really throws up its proverbial 
hands and basically ends up writing out the expression long-form without any 
reuse of sub-expressions, or registers even(!).

The next best was using a bunch of variables (which are allocated on the 
stack normally, but these are optimized out quickly when there are enough 
free registers to put them there instead, which was the case here) to hold 
intermediate steps, and repeating common steps in a short loop.  But keep in 
mind that, if the variables are allocated in registers... you can't loop 
over them.  Doing it with a loop, forces it to allocate stack, get the 
pointer, and index the variables.  Plus the memory accesses themselves, 
which are slower.  It is not without overhead!  (This is a much better deal 
on, say, classic 16-bit machines (x86, 68k), and most everything since.)  It 
might even try it with the loop and array, then try it unrolled with 
registers, and keep the unrolled version because it's simply better!

I forget what I ended up with; I think I sliced the bit pattern differently, 
still using a loop but getting better reuse.  It's still ugly, like hundreds 
of bytes for something nearly trivial if the data were byte aligned.

All of this optimizing is subject to the constrains of the functions 
executed within each expression or statement.  C functions can do literally 
anything.  Side effects are the bane of optimization.  If the optimizer 
can't reason about being able to move a function up or down the expression 
tree, it's simply forced to treat that as a sequence point.  (Sure, it could 
reason about the function's contents as if inlining it, but that would be 
extremely costly.)

As far as I know, the optimizer is bad at guessing what functions do, in 
terms of side effects, so it can help greatly (and this is why they put the 
features in there) to add hints about the nature of the function (e.g., 
using const with parameters, writing pure functions when possible, etc.).

(FYI, most of my experience centers around GCC.  Most of this is motivated 
by my own observations, illuminated by some of the official documentation 
about the optimizing step.)

Tim

-- 
Seven Transistor Labs, LLC
Electrical Engineering Consultation and Design
Website: https://www.seventransistorlabs.com/ 

[toc] | [prev] | [next] | [standalone]


#538816

FromGerhard Hoffmann <dk4xp@arcor.de>
Date2019-04-09 23:02 +0200
Message-ID<q8j19j$nld$1@solani.org>
In reply to#538809
Am 09.04.19 um 21:50 schrieb Tim Williams:

> The next best was using a bunch of variables (which are allocated on the 
> stack normally, but these are optimized out quickly when there are 
> enough free registers to put them there instead, which was the case 
> here) to hold intermediate steps, and repeating common steps in a short 
> loop.  But keep in mind that, if the variables are allocated in 
> registers... you can't loop over them.  Doing it with a loop, forces it 
> to allocate stack, get the pointer, and index the variables.  Plus the 
> memory accesses themselves, which are slower.  It is not without 

National tried to implement indexing over registers in their 16032 /
32032 processors. They didn't get it to work. Also, it was a bad idea.
When the array is small, then there is no real advantage. When it is
large, it will not fit into the registers.

regards, Gerhard

[toc] | [prev] | [next] | [standalone]


#538833

From"Tim Williams" <tiwill@seventransistorlabs.com>
Date2019-04-09 19:30 -0500
Message-ID<q8jddi$ai1$1@dont-email.me>
In reply to#538816
"Gerhard Hoffmann" <dk4xp@arcor.de> wrote in message 
news:q8j19j$nld$1@solani.org...
> National tried to implement indexing over registers in their 16032 /
> 32032 processors. They didn't get it to work. Also, it was a bad idea.
> When the array is small, then there is no real advantage. When it is
> large, it will not fit into the registers.

Cool.  In that, it was something to try, that didn't work out, but now we 
know.

There's been a number of architectures with memory mapped registers (not 
including memory-as-register architectures, which are worse :^) ), but they 
never really seem to stick around.  IIRC, AVR for example was introduced 
with it, but most examples today have dropped it.

In some cases, you can still hack it (self modifying code), but that's 
almost always worse (due to instruction pipelines and caches).  Other times, 
it's specifically forbidden (physical ROM, Harvard architecture, 
execute-only memory spaces, etc.).

Perhaps ironically, the feature still lives on, but in a more limited way, 
as register renaming is a well established feature in more advanced 
hardware.

Tim

-- 
Seven Transistor Labs, LLC
Electrical Engineering Consultation and Design
Website: https://www.seventransistorlabs.com/ 

[toc] | [prev] | [next] | [standalone]


#538839

FromGerhard Hoffmann <dk4xp@arcor.de>
Date2019-04-10 02:55 +0200
Message-ID<q8jett$vas$1@solani.org>
In reply to#538833
Am 10.04.19 um 02:30 schrieb Tim Williams:
> "Gerhard Hoffmann" <dk4xp@arcor.de> wrote in message 
> news:q8j19j$nld$1@solani.org...
>> National tried to implement indexing over registers in their 16032 /
>> 32032 processors. They didn't get it to work. Also, it was a bad idea.
>> When the array is small, then there is no real advantage. When it is
>> large, it will not fit into the registers.
> 
> Cool.  In that, it was something to try, that didn't work out, but now 
> we know.

The whole family was quite buggy. Some friends of mine tried to port
Andy Tanenbaum's p-code machine to it.


> There's been a number of architectures with memory mapped registers 

DEC system 10. That wasn't bad.

(not
> including memory-as-register architectures, which are worse :^) ), but 
> they never really seem to stick around.  

OMG!   TMS9900.  What a turd.


regards,
Gerhard

[toc] | [prev] | [next] | [standalone]


#538873

Fromupsidedown@downunder.com
Date2019-04-10 07:40 +0300
Message-ID<3jsqaelfpbkgb02hh11sensiv04h106p82@4ax.com>
In reply to#538833
On Tue, 9 Apr 2019 19:30:18 -0500, "Tim Williams"
<tiwill@seventransistorlabs.com> wrote:

>"Gerhard Hoffmann" <dk4xp@arcor.de> wrote in message 
>news:q8j19j$nld$1@solani.org...
>> National tried to implement indexing over registers in their 16032 /
>> 32032 processors. They didn't get it to work. Also, it was a bad idea.
>> When the array is small, then there is no real advantage. When it is
>> large, it will not fit into the registers.
>
>Cool.  In that, it was something to try, that didn't work out, but now we 
>know.
>
>There's been a number of architectures with memory mapped registers (not 
>including memory-as-register architectures, which are worse :^) ), but they 
>never really seem to stick around.  

Yes, TMS 9900 was interesting, but with  main memory cycle times in
the order of one microsecond  it was s_l_o_w. However, these days with
modern caches and cache management it would make sense.

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | sci.electronics.design


csiph-web