Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

I THINK MAN INVENTED THE CAR by instinct. -- Jack Handey, The New Mexican, 1988.


devel / comp.lang.forth / Re: MAP[ words for FPGA4th

SubjectAuthor
* MAP[ words for FPGA4thJohn Hart
+* Re: MAP[ words for FPGA4thWolfgang Allinger
|`- Re: MAP[ words for FPGA4thdxforth
+- Re: MAP[ words for FPGA4thHugh Aguilar
`- Re: MAP[ words for FPGA4thHugh Aguilar

1
MAP[ words for FPGA4th

<f4010df6-9c20-4a89-8ee7-7043392e7188n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23544&group=comp.lang.forth#23544

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:17a6:b0:758:faa7:dc37 with SMTP id ay38-20020a05620a17a600b00758faa7dc37mr2950177qkb.9.1683932015522;
Fri, 12 May 2023 15:53:35 -0700 (PDT)
X-Received: by 2002:a05:622a:1a21:b0:3f4:e666:4586 with SMTP id
f33-20020a05622a1a2100b003f4e6664586mr2193783qtb.13.1683932015264; Fri, 12
May 2023 15:53:35 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 12 May 2023 15:53:35 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=75.204.101.146; posting-account=_dwjNwoAAAA4hFltKxWAwHSTsQHdOMuM
NNTP-Posting-Host: 75.204.101.146
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f4010df6-9c20-4a89-8ee7-7043392e7188n@googlegroups.com>
Subject: MAP[ words for FPGA4th
From: johnroge...@gmail.com (John Hart)
Injection-Date: Fri, 12 May 2023 22:53:35 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1850
 by: John Hart - Fri, 12 May 2023 22:53 UTC

Something more compact and efficient than a CASE statement was needed for defining logic equations in the FPGA4th system.
The solution was a set of words to build a look up table.
key MAP[ n \ begins the process of building the table.
a b MAP \ associates a with b
c d MAP \ associates c with d
e ]MAP \ ends the look up table process
note: n specifies the key size (2^n) 0 = 1 byte, 1 = 2 bytes, 2 = 4 bytes

At runtime, if the key = a, b is returned, if the key isn't found, e is returned

Two more words to complete the set.
a ]: starts compilation of code associated with a
;[ ends compilation

: ALU { a b cmd - - c } \ example
cmd MAP[ 1
O ]: a b + ;[ MAP \ add
1 ]: a b - ;[ MAP \ sub
2 ]: a b AND ;[ MAP \ and
3 ]: a b OR ;[ MAP \ or
]: 0 ;[ ]MAP
EXECUTE
;

jrh

Re: MAP[ words for FPGA4th

<GGmtNRqjQoB@allinger-307049.user.uni-berlin>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23547&group=comp.lang.forth#23547

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: all2...@spambog.com (Wolfgang Allinger)
Newsgroups: comp.lang.forth
Subject: Re: MAP[ words for FPGA4th
Date: Sat, 13 May 2023 07:13:00 -0400
Lines: 22
Message-ID: <GGmtNRqjQoB@allinger-307049.user.uni-berlin>
References: <f4010df6-9c20-4a89-8ee7-7043392e7188n@googlegroups.com>
Reply-To: all2001@gmx.de
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: individual.net 9639UDKmMLOZ86JADlxpcgsRKw2e6dKD9kid2roU5o7K45U+FZ
Cancel-Lock: sha1:la/tK2Ycr0ITQSycvQWMjJ22t84=
User-Agent: OpenXP/5.0.57 (Win32)
 by: Wolfgang Allinger - Sat, 13 May 2023 11:13 UTC

On 12 May 23 at group /comp/lang/forth in article f4010df6-9c20-4a89-8ee7-7043392e7188n@googlegroups.com
<johnrogerhart@gmail.com> (John Hart) wrote:

> Something more compact and efficient than a CASE statement was needed for
> defining logic equations in the FPGA4th system. The solution was a set of
> words to build a look up table.

> key MAP[ n \ begins the process of building the table.

Nice, I would like to have this idea earlier :)

Saludos (an alle Vernünftigen, Rest sh. sig)
Wolfgang

--
Ich bin in Paraguay lebender Trollallergiker :) reply Adresse gesetzt!
Ich diskutiere zukünftig weniger mit Idioten, denn sie ziehen mich auf
ihr Niveau herunter und schlagen mich dort mit ihrer Erfahrung! :p
(lt. alter usenet Weisheit) iPod, iPhone, iPad, iTunes, iRak, iDiot

Re: MAP[ words for FPGA4th

<a9224319-7b0a-4d57-8a2a-e8d42a967432n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23549&group=comp.lang.forth#23549

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5883:0:b0:3f5:99e:d7da with SMTP id t3-20020ac85883000000b003f5099ed7damr898640qta.5.1684010613516;
Sat, 13 May 2023 13:43:33 -0700 (PDT)
X-Received: by 2002:a05:622a:1899:b0:3f3:fae6:91c7 with SMTP id
v25-20020a05622a189900b003f3fae691c7mr4345489qtc.3.1684010613325; Sat, 13 May
2023 13:43:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sat, 13 May 2023 13:43:32 -0700 (PDT)
In-Reply-To: <f4010df6-9c20-4a89-8ee7-7043392e7188n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=63.158.165.131; posting-account=OxDKOgoAAADW0cxAqHqpN1zqeCoSsDap
NNTP-Posting-Host: 63.158.165.131
References: <f4010df6-9c20-4a89-8ee7-7043392e7188n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a9224319-7b0a-4d57-8a2a-e8d42a967432n@googlegroups.com>
Subject: Re: MAP[ words for FPGA4th
From: hughagui...@gmail.com (Hugh Aguilar)
Injection-Date: Sat, 13 May 2023 20:43:33 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3100
 by: Hugh Aguilar - Sat, 13 May 2023 20:43 UTC

On Friday, May 12, 2023 at 3:53:36 PM UTC-7, John Hart wrote:
> Something more compact and efficient than a CASE statement was needed for defining logic equations in the FPGA4th system.
> The solution was a set of words to build a look up table.
>
> key MAP[ n \ begins the process of building the table.
> a b MAP \ associates a with b
> c d MAP \ associates c with d
> e ]MAP \ ends the look up table process
> note: n specifies the key size (2^n) 0 = 1 byte, 1 = 2 bytes, 2 = 4 bytes
>
> At runtime, if the key = a, b is returned, if the key isn't found, e is returned
>
> Two more words to complete the set.
> a ]: starts compilation of code associated with a
> ;[ ends compilation
>
> : ALU { a b cmd - - c } \ example
> cmd MAP[ 1
> O ]: a b + ;[ MAP \ add
> 1 ]: a b - ;[ MAP \ sub
> 2 ]: a b AND ;[ MAP \ and
> 3 ]: a b OR ;[ MAP \ or
> ]: 0 ;[ ]MAP
> EXECUTE
> ;
>
> jrh

Way back in 1994 you told me that you had a super-fast jump-table look-up
that could be used for simulating a processor. You recommended that I use
this to simulate the MiniForth. You were using a sequential look-up!!!
I pointed out that a binary search would be much faster. You said that what
you had was "super fast" because the 8086 has an instruction that does
a sequential search on a 16-bit number. That was dumb! A binary search is
still going to be faster, except possibly for a very small array of numbers..

My FAST-SWITCH> (a jump table) and SLOW-SWITCH> (a sorted array and
a binary search) is posted here:
https://groups.google.com/g/comp.lang.forth/c/HwxAddZ54mg/m/Fmg5xT08AAAJ
I'm far ahead of you.
Your MAP[ mentioned above is what you had in 1994. It wasn't any good then either.

What is your point in posting on comp.lang.forth???
You don't have anything to offer.

Re: MAP[ words for FPGA4th

<u3pj3e$2grv3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23551&group=comp.lang.forth#23551

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: MAP[ words for FPGA4th
Date: Sun, 14 May 2023 13:04:13 +1000
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <u3pj3e$2grv3$1@dont-email.me>
References: <f4010df6-9c20-4a89-8ee7-7043392e7188n@googlegroups.com>
<GGmtNRqjQoB@allinger-307049.user.uni-berlin>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 14 May 2023 03:04:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="905b9135671c765bf56a4b55ea35ec7a";
logging-data="2650083"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+UO6l50+o83xGtKUXhWFXV"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.10.1
Cancel-Lock: sha1:uEIW9RSTQbBKSMWAfyBzzPeG9zk=
Content-Language: en-GB
In-Reply-To: <GGmtNRqjQoB@allinger-307049.user.uni-berlin>
 by: dxforth - Sun, 14 May 2023 03:04 UTC

On 13/05/2023 9:13 pm, Wolfgang Allinger wrote:
>
> On 12 May 23 at group /comp/lang/forth in article f4010df6-9c20-4a89-8ee7-7043392e7188n@googlegroups.com
> <johnrogerhart@gmail.com> (John Hart) wrote:
>
>> Something more compact and efficient than a CASE statement was needed for
>> defining logic equations in the FPGA4th system. The solution was a set of
>> words to build a look up table.
>
>> key MAP[ n \ begins the process of building the table.
>
> Nice, I would like to have this idea earlier :)

The devil is often in the detail :)

Re: MAP[ words for FPGA4th

<bd01e2b8-c92d-4aee-98d6-b9e196e30f48n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23592&group=comp.lang.forth#23592

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:18a1:b0:3f5:16af:17e4 with SMTP id v33-20020a05622a18a100b003f516af17e4mr85745qtc.2.1684451365438;
Thu, 18 May 2023 16:09:25 -0700 (PDT)
X-Received: by 2002:ad4:5908:0:b0:61b:68e0:53d6 with SMTP id
ez8-20020ad45908000000b0061b68e053d6mr108516qvb.1.1684451365236; Thu, 18 May
2023 16:09:25 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 18 May 2023 16:09:24 -0700 (PDT)
In-Reply-To: <f4010df6-9c20-4a89-8ee7-7043392e7188n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=63.158.165.131; posting-account=OxDKOgoAAADW0cxAqHqpN1zqeCoSsDap
NNTP-Posting-Host: 63.158.165.131
References: <f4010df6-9c20-4a89-8ee7-7043392e7188n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <bd01e2b8-c92d-4aee-98d6-b9e196e30f48n@googlegroups.com>
Subject: Re: MAP[ words for FPGA4th
From: hughagui...@gmail.com (Hugh Aguilar)
Injection-Date: Thu, 18 May 2023 23:09:25 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 134
 by: Hugh Aguilar - Thu, 18 May 2023 23:09 UTC

On Friday, May 12, 2023 at 3:53:36 PM UTC-7, John Hart wrote:
> Something more compact and efficient than a CASE statement was needed for defining logic equations in the FPGA4th system.
> The solution was a set of words to build a look up table.
>
> key MAP[ n \ begins the process of building the table.
> a b MAP \ associates a with b
> c d MAP \ associates c with d
> e ]MAP \ ends the look up table process
> note: n specifies the key size (2^n) 0 = 1 byte, 1 = 2 bytes, 2 = 4 bytes
>
> At runtime, if the key = a, b is returned, if the key isn't found, e is returned
>
> Two more words to complete the set.
> a ]: starts compilation of code associated with a
> ;[ ends compilation
>
> : ALU { a b cmd - - c } \ example
> cmd MAP[ 1
> O ]: a b + ;[ MAP \ add
> 1 ]: a b - ;[ MAP \ sub
> 2 ]: a b AND ;[ MAP \ and
> 3 ]: a b OR ;[ MAP \ or
> ]: 0 ;[ ]MAP
> EXECUTE
> ;
>
> jrh

This is a copy of my document file for the <SWITCH package:
-------------------------------------------------------------------------------------------------
Documentation for FAST-SWITCH> and SLOW-SWITCH> in LIST.4TH
of the novice package --- this is ANS-Forth --- (c) Hugh Aguilar

The basic operation is this:

<SWITCH
:NONAME drop ... ; targ CASE-OF
...
:NONAME drop ... ; FAST-SWITCH> xxx ( selector -- )

The XXX is the name of the function being created.
The DROP in the :NONAME function gets rid of the selector-value.
You might need this sometimes though.
The last :NONAME before FAST-SWITCH> is the default action done if
no match was found. In many applications this indicates a bug so this
:NONAME function will abort and will not DROP the value but will
display it so the user can know what invalid selector got used.

There can be thousands of CASE-OF statements.
They don't have to be in any particular order.
Building the table is faster if they are pretty much in reverse order.
I'm using an insertion sort which is slow. I did this so that I would
find any duplicates immediately and would be able to abort on the
offending line so the user would know exactly where the duplicate was.
Note that Michael Gassenenko's CHOOSE doesn't tell where the duplicate
was. The slowness is at compile-time, so it doesn't matter very much
(compiling the assembler/simulator for my processor takes 17 seconds).
Duplicates are illegal, although duplicates are allowed in ANS-Forth's
goofy CASE construct that just does a sequential search.

We have a VALUE called JT-LIMIT that sets the limit of the size of
a FAST-SWITCH> jump-table. Note that the FAST-SWITCH> jump-table is a
sparse array, so the number of selectors could be significantly less
than the size of the jump-table. JT-LIMIT is currently set at 2^16 to
allow simulation of a processor with 16-bit opcodes. The user can
change JT-LIMIT. If there are more selectors than JT-LIMIT allows or
the user just wants to use less memory, SLOW-SWITCH> can be used
instead of FAST-SWITCH>. This will build a packed sorted table and at
run-time will do a binary search. This packed table is usually smaller
than a FAST-SWITCH> sparse table, but if over half of the posible
selectors are represented, then the SLOW-SWITCH> table will not only
be slower but will also use more memory.

It is possible to assign a :NONAME action to multiple selectors:
:NONAME drop ... ; low-targ high-targ RANGE-OF
:NONAME drop ... ; ." xxx" CHARS-OF
:NONAME drop ... ; <WHEN ... WHEN>
:NONAME drop ... ; DIGIT-OF
:NONAME drop ... ; LOWER-OF
:NONAME drop ... ; UPPER-OF
:NONAME drop ... ; ALPHA-OF
:NONAME drop ... ; PUNCTUATION-OF
:NONAME drop ... ; BLANK-OF

RANGE-OF matches all of the values from LOW-TARG to HIGH-TARG
inclusive. CHARS-OF matches all of the chars in the string.
<WHEN ... WHEN> matches all of the values between <WHEN and WHEN>
(the ... means zero or more values)
DIGIT-OF is the numeric digits, LOWER-OF is the lowercase letters,
UPPER-OFis the upper-case letters, ALPHA-OF is all of the letters,
PUNCTUATION-OF is punctuation, BLANK-OF is blanks.
It is trivial for the user to define macros like this. For example:

: punctuation-of ( head xt -- new-head )
s| .,!?'";:[]()@#$%&| chars-of ;

: blank-of ( head xt -- new-head )
0 32 range-of ;

So far, we have been assuming that the :NONAME function would DROP the
selector. This isn't always done though. I have an assembler/simulator
for a custom processor with 16-bit opcodes. In many of the opcodes,
the lower 9 bits are an embedded literal. I use RANGE-OF so that all
$200 opcodes will execute the same :NONAME function. The :NONAME
function needs the selector (the opcode) so it can extract the
embedded literal with $1FF AND to use this literal in the simulation
of the opcode. RANGE-OF is hugely useful for similating opcodes
assuming that the embedded literal values are in the lower bits
(I designed the processor, so I can put there embedded literal there).
Note that, RANGE-OF has recently (for this processor) been upgraded to
insert the values in reverse order to help speed up the table build.

We also have CASE: ... ;; that was suggested by DXforth. Apparently he
wanted to loosely imitate the syntax of ANS-Forth's goofy CASE
construct, although I don't know why anybody would care about this.

Instead of this:
:NONAME drop ... ; targ CASE-OF
You do this:
targ CASE: ... ;;

I also have STRING-SWITCH> that is similar to SLOW-SWITCH> in that it
uses a binary search, but it is for strings rather than integers.
Instead of CASE-OF you use STRING-OF and your TARG value is not an
integer but is an ADR/CNT pair for a counted string (typically
provided by S" or S| or whatever).
This was written for supporting something similar to LEX, although I
have my STRING-STACK.4TH package now that would be better.
STRING-SWITCH> might still prove useful though.
-------------------------------------------------------------------------------------------------

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor