Libre RISC-V Mailing list Archives (accessible via public-inbox)
 help / color / Atom feed
From: bugzilla-daemon@libre-soc.org
To: libre-riscv-dev@lists.libre-riscv.org
Subject: [libre-riscv-dev] [Bug 333] investigate why CR pipeline code took 100% CPU and locked up generating ILANG
Date: Wed, 20 May 2020 18:16:31 +0000
Message-ID: <bug-333-13-CneeQ3vxPv@https.bugs.libre-soc.org/> (raw)
In-Reply-To: <bug-333-13@https.bugs.libre-soc.org/>

https://bugs.libre-soc.org/show_bug.cgi?id=333

Michael Nolan <mtnolan2640@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mtnolan2640@gmail.com

--- Comment #1 from Michael Nolan <mtnolan2640@gmail.com> ---
It seems we both stumbled on this issue at about the same time, and arrived at
similar solutions. I narrowed down the commit that introduced it to this one: 

commit 7638005f8577ba6545a65a0c6e31c5419f1f684e
Author: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
Date:   Sun May 17 17:15:58 2020 +0100

    use slightly more elegant way to access CR lookup table

diff --git a/src/soc/cr/main_stage.py b/src/soc/cr/main_stage.py
index e29d5ee..23eba32 100644
--- a/src/soc/cr/main_stage.py
+++ b/src/soc/cr/main_stage.py
@@ -67,9 +67,10 @@ class CRMainStage(PipeModBase):
         # the CR to determine what the resulting bit should be.

         # Grab the lookup table for cr_op type instructions
-        lut = Signal(4, reset_less=True)
+        lut = Array([Signal(name=f"lut{i}") for i in range(4)])
         # There's no field, just have to grab it directly from the insn
-        comb += lut.eq(self.i.ctx.op.insn[6:10])
+        for i in range(4):
+            comb += lut[i].eq(self.i.ctx.op.insn[6+i])

         # Generate the mask for mtcrf, mtocrf, and mfocrf
         fxm = Signal(xfx_fields['FXM'][0:-1].shape())
@@ -108,28 +109,15 @@ class CRMainStage(PipeModBase):
                 comb += ba.eq(xl_fields['BA'][0:-1])
                 comb += bb.eq(xl_fields['BB'][0:-1])

-                # Extract the two input bits from the CR
-                bit_a = Signal(reset_less=True)
-                bit_b = Signal(reset_less=True)
-                comb += bit_a.eq(cr_arr[ba])
-                comb += bit_b.eq(cr_arr[bb])
-
-                # Use the two input bits to look up the result in the
-                # lookup table
-                bit_out = Signal(reset_less=True)
-                comb += bit_out.eq(Mux(bit_b,
-                                       Mux(bit_a, lut[3], lut[1]),
-                                       Mux(bit_a, lut[2], lut[0])))
-                # Set the output to the result above
-                comb += cr_out_arr[bt].eq(bit_out)
+                # Use the two input bits to look up the result in the LUT
+                comb += cr_out_arr[bt].eq(lut[Cat(cr_arr[bb], cr_arr[ba])])

             ##### mtcrf #####
             with m.Case(InternalOp.OP_MTCRF):
                 # mtocrf and mtcrf are essentially identical
                 # put input (RA) - mask-selected - into output CR, leave
                 # rest of CR alone.
-                comb += cr_o.eq((self.i.a[0:32] & mask) |
-                                     (self.i.cr & ~mask))
+                comb += cr_o.eq((self.i.a[0:32] & mask) | (self.i.cr & ~mask))

             ##### mfcr #####
             with m.Case(InternalOp.OP_MFCR):


I think what happens is nmigen generates something really big for arr[index].
Since that gets used to index lut, and then gets assigned to cr_out_arr[idx],
it generates a gigantic expression. By assigning the temporary expressions to
signals, this doesn't happen. Just a guess

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

  reply index

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-20 17:55 [libre-riscv-dev] [Bug 333] New: " bugzilla-daemon
2020-05-20 18:16 ` bugzilla-daemon [this message]
2020-05-20 18:37 ` [libre-riscv-dev] [Bug 333] " bugzilla-daemon
2020-05-20 18:45 ` bugzilla-daemon
2020-05-20 18:52 ` bugzilla-daemon
2020-05-20 18:59 ` bugzilla-daemon
2020-05-20 18:59 ` bugzilla-daemon
2020-05-20 19:39 ` bugzilla-daemon
2020-05-20 19:42 ` bugzilla-daemon
2020-05-20 19:46 ` bugzilla-daemon
2020-05-21  2:05 ` bugzilla-daemon
2020-05-21 16:02 ` bugzilla-daemon
2020-05-21 17:23 ` bugzilla-daemon
2020-05-21 17:32 ` bugzilla-daemon
2020-05-21 17:39 ` bugzilla-daemon
2020-05-21 17:46 ` bugzilla-daemon
2020-05-21 17:50 ` bugzilla-daemon
2020-05-21 18:30 ` bugzilla-daemon
2020-05-21 18:34 ` bugzilla-daemon
2020-05-21 18:35 ` bugzilla-daemon
2020-05-21 18:43 ` bugzilla-daemon
2020-05-21 18:56 ` bugzilla-daemon
2020-05-21 18:59 ` bugzilla-daemon
2020-05-21 19:08 ` bugzilla-daemon
2020-05-21 19:09 ` bugzilla-daemon
2020-05-21 19:22 ` bugzilla-daemon
2020-05-21 19:23 ` bugzilla-daemon
2020-05-21 19:28 ` bugzilla-daemon
2020-05-21 19:37 ` bugzilla-daemon
2020-05-21 19:50 ` bugzilla-daemon
2020-05-21 19:59 ` bugzilla-daemon
2020-05-22 13:36 ` bugzilla-daemon
2020-05-22 13:49 ` bugzilla-daemon
2020-05-24 20:48 ` 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-333-13-CneeQ3vxPv@https.bugs.libre-soc.org/ \
    --to=bugzilla-daemon@libre-soc.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