Libre RISC-V Mailing list Archives (accessible via public-inbox)
 help / color / Atom feed
From: bugzilla-daemon@libre-riscv.org
To: libre-riscv-dev@lists.libre-riscv.org
Subject: [libre-riscv-dev] [Bug 269] auto-conversion / parser of POWER ISA Spec v3.0B
Date: Fri, 03 Apr 2020 19:11:26 +0000
Message-ID: <bug-269-13-FLSN3w1a3s@http.bugs.libre-riscv.org/> (raw)
In-Reply-To: <bug-269-13@http.bugs.libre-riscv.org/>

http://bugs.libre-riscv.org/show_bug.cgi?id=269

--- Comment #9 from Luke Kenneth Casson Leighton <lkcl@lkcl.net> ---
(In reply to Michael Nolan from comment #8)
> (In reply to Luke Kenneth Casson Leighton from comment #7)
> 
> > can you take a look, see what the code "actually" would need to
> > look like?  i'd like to keep it really clean and simple.
> 
> What do you mean? I'm looking at the code in fixedarith.py and it looks
> pretty good...

i know, right! :)

ok so take a look at... mmm... where is it...  power_pseudo.py
and do this:

diff --git a/src/soc/decoder/power_pseudo.py b/src/soc/decoder/power_pseudo.py
index 86306b0..d05ca25 100644
--- a/src/soc/decoder/power_pseudo.py
+++ b/src/soc/decoder/power_pseudo.py
@@ -96,10 +96,10 @@ D <- d0||d1||d2
 """

 #code = testreg
-#code = cnttzd
+code = cnttzd
 #code = cmpi
 #code = cmpeqb
-code = addpcis
+#code = addpcis
 #code = bpermd

 def tolist(num):


then that should modify register 17 to be an (incorrect *sigh*) value
except, arse, right now it doesn't work :)

oh i know why.  forgot to add __bool__.  sorted.  working now.

ok so, if you look at the bits that go round the "exec (code, d)",
you see that the registers are "pre-prepared" (pre-read) into
variables that are dropped into the dictionary (d).

this creates *local* variables (in d) named RA, RT, RB, RS, which can
end up being modified in the code-fragment.

following code-execution, the *modified* variables have to be "extracted"
for storage into the register file.  if they're in fact registers.

when *not* using exec() but instead writing out the code-fragments to
an actual file, we need some pre- and post- functions which are called
before and after each function, that do the exact same thing.

several ways to do that:

1) pass in a dictionary of variables that are
to be added to locals():

https://www.pythondoeswhat.com/2017/03/when-you-can-update-locals.html

then *return* a copy of locals() from the function.


2) make everything class-based (yuk) self.RA, self.RT, blah blah.

this one i feel looks messy.


3) use exec() treating the code as a string

   however using exec() means that if you get a syntax error it's
   impossible to work out where the hell it was.  it's also really slow.


4) do everything as modules (!) yes really.  modules can be executed on-demand

   https://docs.python.org/2/library/runpy.html

   it then becomes possible to drop the global variables into the module
   and also "extract" them afterwards.  will need investigation.

   also might need an __main__submodule.  maybe.   have to test it.


5) other

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
libre-riscv-dev mailing list
libre-riscv-dev@lists.libre-riscv.org
http://lists.libre-riscv.org/mailman/listinfo/libre-riscv-dev

  parent reply index

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-28 11:12 [libre-riscv-dev] [Bug 269] New: " bugzilla-daemon
2020-03-28 17:35 ` [libre-riscv-dev] [Bug 269] " bugzilla-daemon
2020-03-30 15:16 ` bugzilla-daemon
2020-03-31 13:21 ` bugzilla-daemon
2020-04-01 13:42 ` bugzilla-daemon
2020-04-01 13:48 ` bugzilla-daemon
2020-04-02 15:06 ` bugzilla-daemon
2020-04-03 18:37 ` bugzilla-daemon
2020-04-03 18:45 ` bugzilla-daemon
2020-04-03 19:11 ` bugzilla-daemon [this message]
2020-04-03 19:45 ` bugzilla-daemon
2020-04-03 20:34 ` bugzilla-daemon
2020-04-03 20:55 ` bugzilla-daemon
2020-04-03 21:41 ` bugzilla-daemon
2020-04-03 22:55 ` bugzilla-daemon
2020-04-04  3:04 ` bugzilla-daemon
2020-04-04 16:45 ` bugzilla-daemon
2020-04-04 19:27 ` bugzilla-daemon
2020-04-04 19:38 ` bugzilla-daemon
2020-04-04 19:39 ` bugzilla-daemon
2020-04-04 20:28 ` bugzilla-daemon
2020-04-04 20:37 ` bugzilla-daemon
2020-04-04 20:39 ` bugzilla-daemon
2020-04-04 20:46 ` bugzilla-daemon
2020-04-04 21:36 ` bugzilla-daemon
2020-04-04 22:25 ` bugzilla-daemon
2020-04-05  4:28 ` bugzilla-daemon
2020-04-05 18:23 ` bugzilla-daemon
2020-04-05 18:55 ` bugzilla-daemon
2020-04-05 19:05 ` bugzilla-daemon
2020-04-05 19:52 ` bugzilla-daemon
2020-04-05 20:03 ` bugzilla-daemon
2020-04-05 23:27 ` bugzilla-daemon
2020-04-06  2:28 ` bugzilla-daemon
2020-04-06  2:35 ` bugzilla-daemon
2020-04-06  2:39 ` bugzilla-daemon
2020-04-06  3:07 ` bugzilla-daemon
2020-04-06 10:29 ` bugzilla-daemon
2020-04-06 11:18 ` bugzilla-daemon
2020-04-07  0:16 ` bugzilla-daemon
     [not found] <bug-269-13@https.bugs.libre-soc.org/>
2020-04-07 15:55 ` bugzilla-daemon
2020-04-07 16:57 ` bugzilla-daemon
2020-04-27 20:26 ` bugzilla-daemon
2020-04-27 20:28 ` bugzilla-daemon
2020-04-27 20:29 ` bugzilla-daemon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-269-13-FLSN3w1a3s@http.bugs.libre-riscv.org/ \
    --to=bugzilla-daemon@libre-riscv.org \
    --cc=libre-riscv-dev@lists.libre-riscv.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Libre RISC-V Mailing list Archives (accessible via public-inbox)

Archives are clonable: git clone --mirror https://inbox.libre-soc.org/libre-riscv-dev

Example config snippet for mirrors


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git