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


Groups > comp.lang.forth > #54699

Re: embedded forth

From rickman <gnuarm@gmail.com>
Newsgroups comp.lang.forth
Subject Re: embedded forth
Date 2017-02-07 21:59 -0500
Organization A noiseless patient Spider
Message-ID <o7e1fm$t9i$1@dont-email.me> (permalink)
References (15 earlier) <o6jl7s$dm6$1@dont-email.me> <4b343d40-7252-4919-8e0d-aeace01a87cd@googlegroups.com> <o746dg$mbj$1@dont-email.me> <5feb22db-9f9c-46df-bdc8-9ae4e14d275d@googlegroups.com> <o7844k$2a1$1@dont-email.me>

Show all headers | View raw


On 2/5/2017 4:08 PM, rickman wrote:
> On 2/4/2017 8:54 PM, Ilya Tarasov wrote:
>>> You mean I don't have a fully coded VHDL example at 32 bits word
>>> width to show you?  No, I don't.  But that is not needed.  The
>>> control logic would be trivial compared to thousands of LUTs.  The
>>> only extra logic required is on the order of a handful of adders
>>> and/or multiplexers.
>>
>> So you can't show me a code and utilization report, but still
>> claiming area will be small? How small? What about 'only extra logic'
>> and how you can estimate the size of adders/multiplexers for you
>> code?
>
> I don't need a weatherman to know which way the wind blows.
>
> I don't have to construct a design to have an estimate of how large it
> will be.  If I need a look up table with a 10 bit address and 32 bit
> words, I know that will take two 16 kbit blocks of memory.  If my design
> needs 5 - 32 bit adders, I know that will be about 160 - 4 input LUTs.
> If the design does a 32x32 bit multiply I know it will take 4 - 18 bit
> multipliers and 64 LUTs of adder (if it's using all 64 output bits
> otherwise fewer adder LUTs), etc., etc., etc...
>
>
>>> I took the time to do some calculations which show to get results
>>> accurate to all but the last bit of a 32 bit word would require a
>>> sin() table with a quarter of a million values.  That would put it
>>> outside the realm of most FPGAs and require external memory.
>>> However if external memory is used, this is not only feasible but
>>> simple.  The only issue is to get the step sizes small enough so
>>> the two approximations do apply, sin(b)=b and cos(b)=1.0 to within
>>> the required accuracy.
>>
>> Again, I don't see you 'required accuracy'. Can you list your results
>> and explain how you got it?
>
> How about a Forth program.  Good thing I wrote this.  I see I made an
> error in my manual calculations.  This program shows a need for a 16 bit
> address in the LUT, not 18.  Here is the code.
>
>
> \ calculates the number of bits needed to address the LUT
> \ in a DDS for a given number of output bits
> \ To preserve the assumption that COS(b) is ~= 1.0 the minimum step of
> \ COS in the LUT should be no more than one lsb.
> \ FPI/2 is not ANS standard, you may need to add it to your system.
>
> MARKER SINE
>
> : 2^F ( f1 -- f2 ) \ Raise 2 to a power, floating point
>   2.0e0 FLN F* FEXP ;
>
> : SinLUTSize ( n1 -- n2 ) \ n1 is number of bits out, n2 is LUT address
> bits
>   DUP S>F 2^F 1.0e0 FSWAP F/   \ Turn bit count into resolution
>   CR ." Required resolution " . ." bits or " FDUP F.
>   1.0e0 FSWAP F- FACOS FPI/2 F/ \ Resolution to phase angle step in 90
> deg LUT
>   CR ." Maximum phase angle step size in LUT " FDUP F.
>   1.0e0 FSWAP F/ FLN 2.0e0 FLN F/
>   0.5e0 F+ F>S   \ round to integer
>   CR ." Number of bits required in LUT address " DUP .
>   DUP S>F 2^F 1.0e0 FSWAP F/ FPI/2 F* FCOS 1.0e0 FSWAP F-
>   CR ." Resolution with " . ." bit address " FDUP F.
>   1.0e0 FSWAP F/
>   CR ." Accuracy of 1 part in " FDUP F. ." or " FLN 2.0E0 FLN F/ F. ."
> bits"
>   ;
>
> PRECISION 11 SET-PRECISION
>
> 32 SinLUTSize
>
> SET-PRECISION
>
>
>
> ****** results ******
> FLOAD 'C:\Arius\Projects\Forth\SinLUTSize.f'
> Required resolution 32 bits or .00000000023
> Maximum phase angle step size in LUT .00001373774
> Number of bits required in LUT address 16
> Resolution with 16 bit address .00000000029
> Accuracy of 1 part in 3481368790.7 or 31.697007505 bits ok
>
>
>>> I've never seen an application that needed 32 bits of sin/cos.  The
>>> DDS work I've done was related to real world signals which are
>>> limited to some 20 to 24 bits of SNR when converting between analog
>>> and digital at very best.  I was pretty happy when I showed myself
>>> I could get 20 bits without any real trouble.
>>
>> The fact you don't need it is not a fact nobody need it. ADC
>> resolution matters, but this is not the only factor to choose sin/cos
>> resolution. Results with single precision and double-precision floats
>> are not the same for given ADC. Again, I can write a piece of Forth
>> code to show the difference... but maybe you will switch from
>> thinking to coding?
>
> I'm not sure what you are saying here.  Single precision floats use
> either 24 or 25 bits of mantissa (with 1 bit hidden), I can't recall
> which.  Either one is as good or better than the cutting edge of any ADC
> technology I am aware of with the exception of very high resolution,
> very low speed ADCs used for weight scales and such.
>
> What are you using 32 bit sine calculations for?
>
> As for thinking vs. coding, I'll take an ounce of thinking for a pound
> of coding any day.
>
>
>>>> I have several designs. Now it is 7th generation of
>>>> microarchitecture, with hardware multithreading, targeting
>>>> Spartan-6 and 7-series Xilinx FPGAs.
>>>
>>> But that doesn't tell me what a Forth CPU is.  I assume you really
>>> mean a stack machine.  When you say "hardware multithreading", I
>>> expect this is using the pipeline to facilitate multiple threads
>>> rather than concurrent instructions in a single thread?
>>
>> Yes, I really mean a stack machine, i.e. words like DUP DROP + - AND
>> OR are executed in one clock cycle with all appropriate modifications
>> to stack pointers etc. Multiple threads are supported by time
>> multiplexing, so one data memory and one ALU are shared between all
>> threads, but each clock cycle belongs to its own thread.
>
> Ok, I just wanted to be clear.  I am familiar with the requirements of
> stack machines and have designed my own.  I believe  the multi-threading
> you refer to is implemented by using each stage in your pipeline for
> separate threads.  An 8 stage pipeline allows 8 threads.  Often this can
> be done without an appreciable lowering of the clock speed compared to a
> single thread machine.  It does limit one feature in CPUs, low power by
> stopping the clock.  All thread processors run until all threads are
> idle.  Only then can the clock be disabled. But no biggie.

LOL... I was discussing this in another group and I had completely 
forgotten what I learned about this when I did the same exercise a 
couple/few years ago.

The determinant of the resolution is the approximation cos(b) = 1.0.  In 
the region of zero degrees the cosine function approaches a quadratic. 
The slope of the curve is -x^2.  So changing the required resolution by 
two bits requires one extra address bit.  The LUT address bits will 
*always* be half the total phase word bits for optimum accuracy.  I 
can't believe I forgot that.

Also, the accuracy will be twice what is calculated by the program (half 
the error).  The value out of the sine table is unsigned and a sign bit 
is added depending on the quadrant indicated by the phase word.  So you 
get an extra bit and twice the accuracy compared to what my program 
calculated.

-- 

Rick C

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

embedded forth Dale Scott <dalescottnet@gmail.com> - 2017-01-21 11:27 -0800
  Re: embedded forth Paul Rubin <no.email@nospam.invalid> - 2017-01-21 11:31 -0800
  Re: embedded forth stephen@mpeforth.com - 2017-01-22 00:52 -0800
  Re: embedded forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-22 17:09 +0000
    Re: embedded Forth Dale Scott <dalescottnet@gmail.com> - 2017-01-22 09:43 -0800
      Re: embedded Forth stephen@mpeforth.com - 2017-01-22 12:19 -0800
      Re: embedded Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-22 21:25 +0100
      Re: embedded Forth john <anon@example.com> - 2017-01-22 21:04 +0000
        Re: embedded Forth "Elizabeth D. Rather" <erather@forth.com> - 2017-01-22 12:30 -1000
        Re: embedded Forth hughaguilar96@gmail.com - 2017-01-22 20:45 -0800
      Re: embedded Forth stephen@mpeforth.com - 2017-01-22 14:08 -0800
        Re: embedded Forth Paul Rubin <no.email@nospam.invalid> - 2017-01-22 14:55 -0800
          Re: embedded Forth Dale Scott <dalescottnet@gmail.com> - 2017-01-22 20:41 -0800
            Re: embedded Forth Paul Rubin <no.email@nospam.invalid> - 2017-01-22 21:19 -0800
      Re: embedded Forth hughaguilar96@gmail.com - 2017-01-22 21:36 -0800
        Re: embedded Forth Dale Scott <dalescottnet@gmail.com> - 2017-01-22 22:09 -0800
          Re: embedded Forth rickman <gnuarm@gmail.com> - 2017-01-23 04:15 -0500
            Re: embedded Forth Dale Scott <dalescottnet@gmail.com> - 2017-01-23 08:41 -0800
              Re: embedded Forth rickman <gnuarm@gmail.com> - 2017-01-23 14:32 -0500
                Re: embedded Forth Dale Scott <dalescottnet@gmail.com> - 2017-01-23 11:53 -0800
                Re: embedded Forth rickman <gnuarm@gmail.com> - 2017-01-23 15:10 -0500
              Re: embedded Forth Paul Rubin <no.email@nospam.invalid> - 2017-01-23 14:34 -0800
                Re: embedded Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-24 03:14 -0600
        Re: embedded Forth rickman <gnuarm@gmail.com> - 2017-01-23 03:43 -0500
          Re: embedded Forth john <anon@example.com> - 2017-01-23 10:32 +0000
          keep secrets (was Re: embedded Forth) "Wolfgang Allinger" <all2001@spambog.com> - 2017-01-23 08:58 -0300
            Re: keep secrets (was Re: embedded Forth) Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-01-23 07:47 -0500
              Re: keep secrets (was Re: embedded Forth) "Wolfgang Allinger" <all2001@spambog.com> - 2017-01-23 18:18 -0300
                Re: keep secrets (was Re: embedded Forth) rickman <gnuarm@gmail.com> - 2017-01-23 19:15 -0500
            Re: keep secrets (was Re: embedded Forth) rickman <gnuarm@gmail.com> - 2017-01-23 14:38 -0500
              Re: keep secrets (was Re: embedded Forth) "Wolfgang Allinger" <all2001@spambog.com> - 2017-01-23 18:43 -0300
                Re: keep secrets (was Re: embedded Forth) rickman <gnuarm@gmail.com> - 2017-01-23 19:48 -0500
                Re: keep secrets (was Re: embedded Forth) "Elizabeth D. Rather" <erather@forth.com> - 2017-01-23 16:30 -1000
                Re: keep secrets (was Re: embedded Forth) rickman <gnuarm@gmail.com> - 2017-01-23 22:23 -0500
  Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-22 13:44 -0500
    Re: embedded forth Paul Rubin <no.email@nospam.invalid> - 2017-01-22 13:38 -0800
      Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-23 00:45 -0500
        Re: embedded forth Dale Scott <dalescottnet@gmail.com> - 2017-01-22 22:44 -0800
          Re: embedded forth Paul Rubin <no.email@nospam.invalid> - 2017-01-23 00:48 -0800
          Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-23 03:51 -0500
      Re: embedded forth john <anon@example.com> - 2017-01-23 10:02 +0000
    Re: embedded forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-23 09:01 +0000
      Re: embedded forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-23 13:05 +0100
        Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-23 14:40 -0500
          Re: embedded forth Mark Wills <markwills1970@gmail.com> - 2017-01-24 01:12 -0800
          Re: embedded forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-24 14:38 +0100
            Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-24 19:51 -0500
              Re: embedded forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-25 11:34 +0100
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-25 22:13 -0500
                Re: embedded forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-26 11:36 +0100
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-26 14:07 -0500
              Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-26 00:19 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-26 14:15 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-27 13:08 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-27 17:54 -0500
                Re: embedded forth Paul Rubin <no.email@nospam.invalid> - 2017-01-27 15:29 -0800
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-27 16:28 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-27 23:58 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-28 11:58 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-28 15:36 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-28 15:05 -0800
                Re: embedded forth Paul Rubin <no.email@nospam.invalid> - 2017-01-28 15:57 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-28 21:51 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-29 09:53 -0800
                Re: embedded forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-29 19:32 +0100
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-29 11:53 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-30 01:10 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-29 23:11 -0800
                Re: embedded forth Paul Rubin <no.email@nospam.invalid> - 2017-01-29 23:34 -0800
                Re: embedded forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-30 12:42 +0100
                Re: embedded forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-30 12:36 +0100
                Re: embedded forth ctmalan@gmail.com - 2017-01-30 11:02 -0800
                Re: embedded forth Paul Rubin <no.email@nospam.invalid> - 2017-01-30 11:04 -0800
                Re: embedded forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-31 04:34 -0600
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-30 12:15 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-30 10:15 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-30 12:20 -0800
                Re: embedded forth Paul Rubin <no.email@nospam.invalid> - 2017-01-30 14:09 -0800
                Re: embedded forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-31 03:04 +0100
                Re: embedded forth Paul Rubin <no.email@nospam.invalid> - 2017-01-30 20:19 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-30 17:10 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-30 14:38 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-30 23:09 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-31 09:32 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-02-08 18:22 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-02-09 01:46 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-02-09 05:11 -0500
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-02-12 01:30 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-02-12 10:21 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-02-12 19:37 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-02-14 13:26 -0800
                Re: embedded forth Gary Bergstrom <forthprgrmr@gmail.com> - 2017-02-14 11:36 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-02-14 18:13 -0500
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-28 21:51 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-29 10:20 -0800
                Re: embedded forth Cecil Bayona <cbayona@cbayona.com> - 2017-01-29 12:38 -0600
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-01-29 11:49 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-02-04 04:22 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-02-04 17:54 -0800
                Re: embedded forth hughaguilar96@gmail.com - 2017-02-04 20:26 -0800
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-02-05 07:53 -0800
                Re: embedded forth hughaguilar96@gmail.com - 2017-02-05 11:08 -0800
                Re: embedded forth hughaguilar96@gmail.com - 2017-02-05 11:39 -0800
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-02-08 06:46 -0800
                Re: embedded forth luser droog <mijoryx@yahoo.com> - 2017-02-13 19:17 -0800
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-02-15 06:23 -0800
                Re: embedded forth hughaguilar96@gmail.com - 2017-02-15 11:09 -0800
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-02-15 15:24 -0800
                Re: embedded forth jkn_gg@nicorp.f9.co.uk - 2017-02-16 09:49 -0800
                Re: embedded forth hughaguilar96@gmail.com - 2017-02-17 09:12 -0800
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-02-17 12:47 -0800
                Re: embedded forth hughaguilar96@gmail.com - 2017-02-17 16:18 -0800
                Re: embedded forth luser droog <mijoryx@yahoo.com> - 2017-02-16 08:43 -0800
                Re: embedded forth Alex <alex@rivadpm.com> - 2017-02-05 20:47 +0000
                Re: embedded forth hughaguilar96@gmail.com - 2017-02-05 13:36 -0800
                Re: embedded forth Alex <alex@rivadpm.com> - 2017-02-05 23:18 +0000
                Re: embedded forth hughaguilar96@gmail.com - 2017-02-05 21:10 -0800
                Re: embedded forth Alex <alex@rivadpm.com> - 2017-02-06 11:12 +0000
                Re: embedded forth hughaguilar96@gmail.com - 2017-02-05 21:15 -0800
                Re: embedded forth hughaguilar96@gmail.com - 2017-02-05 22:45 -0800
                Re: embedded forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-02-06 12:04 +0100
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-02-08 03:08 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-02-08 06:39 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-02-08 07:15 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-02-08 15:49 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-02-09 01:14 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-02-09 05:19 -0500
                Re: embedded forth Ilya Tarasov <ilya74.tarasov@gmail.com> - 2017-02-09 03:48 -0800
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-02-05 16:08 -0500
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-02-07 21:59 -0500
                Re: embedded forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-28 11:10 +0100
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-28 06:15 -0500
                Re: embedded forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-28 19:48 +0100
                Re: embedded forth rickman <gnuarm@gmail.com> - 2017-01-28 14:37 -0500
                Re: embedded forth mhx@iae.nl - 2017-01-28 07:48 -0800
                Re: embedded forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-28 19:53 +0100
                Re: embedded forth mhx@iae.nl - 2017-01-28 15:49 -0800
        Re: embedded forth "Wolfgang Allinger" <all2001@spambog.com> - 2017-01-23 18:46 -0300

csiph-web