Bug 1127 - Generating a Libre-SOC Microwatt-compatible core with SVP64
Summary: Generating a Libre-SOC Microwatt-compatible core with SVP64
Status: CONFIRMED
Alias: None
Product: Libre-SOC's first SoC
Classification: Unclassified
Component: Source Code (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- enhancement
Assignee: Andrey Miroshnikov
URL: https://libre-soc.org/HDL_workflow/ge...
Depends on: 1086
Blocks: 961 1129
  Show dependency treegraph
 
Reported: 2023-08-01 12:45 BST by Andrey Miroshnikov
Modified: 2023-08-29 22:47 BST (History)
2 users (show)

See Also:
NLnet milestone: ---
total budget (EUR) for completion of task and all subtasks: 0
budget (EUR) for this task, excluding subtasks' budget: 0
parent task for budget allocation:
child tasks for budget allocation:
The table of payments (in EUR) for this task; TOML format:


Attachments
Diff of mw vs mw+svp64 core using yosys ls (1.60 KB, text/plain)
2023-08-01 12:45 BST, Andrey Miroshnikov
Details
Shows full log of ls2 synthesis (218.33 KB, text/plain)
2023-08-01 12:46 BST, Andrey Miroshnikov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Miroshnikov 2023-08-01 12:45:41 BST
Created attachment 195 [details]
Diff of mw vs mw+svp64 core using yosys ls

Last Thursday I started looking into generating an external Libre-SOC core containing SVP64 (no elwidth overrides, 64-bit element width only), while also retaining Microwatt compatibility (so that we could run the same binary).
https://libre-soc.org/irclog/%23libre-soc.2023-07-27.log.html#t2023-07-27T18:03:34

(I do apologise for not raising the bug report earlier and misusing the IRC. For anyone seeing this in the future, please see bug #1126 for how to properly report an issue.)

The core is generated from the soc repo, by calling the Makefile. I'm using the environment produced by following the ls2 setup on the wiki page.

I added a rule to the Makefile, and an argument to issuer_verilog.py, leaving all the parameters the same as 'microwatt_external_core', except setting 'svp64' to True.
https://git.libre-soc.org/?p=soc.git;a=commitdiff;h=7c41d80d9a1af94f8dacd808b822bee62a620811

When running 'make microwatt_external_core_svp64', I hit an AttributeError, with PowerDecode2 missing the signal 'use_svp64_ldst_dec'.

On Monday I looked at the commits in openpower-isa (that's where the power_decoder2.py is located). See: https://libre-soc.org/irclog/%23libre-soc.2023-07-31.log.html#t2023-07-31T13:44:10

This commit on 24th June 2021 shows the 'use_svp64_ldst_dec' signal being added): https://git.libre-soc.org/?p=openpower-isa.git;a=commitdiff;h=847075a69e38b96376b7db0d5df0cc125da0be7a

A commit on the 12th August 2022 then removes this signal: https://git.libre-soc.org/?p=openpower-isa.git;a=commitdiff;h=fdba782098076205d7740fc091d925d63b29a194

Using openpower-isa commit #1bbfcce929c9a1d6b1dc0fc68c84296bcc58eea1 (the one before the signal was removed), I was able to generate an external core with the SVP64 enabled.
https://git.libre-soc.org/?p=openpower-isa.git;a=commitdiff;h=1bbfcce929c9a1d6b1dc0fc68c84296bcc58eea1

To make sure the SVP64 related blocks are really there, I loaded the verilog file into yosys and listed the modules using ls. The diff comparing the Microwatt-compatible and MW+SVP64 is included as a text file.

Next step is to test the core within ls2.
Comment 1 Andrey Miroshnikov 2023-08-01 12:46:48 BST
Created attachment 196 [details]
Shows full log of ls2 synthesis

Next step was to place the generated core inside the ls2 peripheral framework and create an FPGA image.
During the yosys synthesis, I encountered many combinatorial loops, which caused the timing analysis to fail. The errors mostly occurred in dec2, specifically the sv blocks.
Full log is attached.
Comment 2 Luke Kenneth Casson Leighton 2023-08-01 14:06:27 BST
(In reply to Andrey Miroshnikov from comment #1)

> caused the timing analysis to fail. The errors mostly occurred in dec2,
> specifically the sv blocks.

ignore them 100%.

p.s now you know why we cannot use DDR3 and instead use HyperRAM
which can run as low as a 1 mhz clockrate.
Comment 3 Luke Kenneth Casson Leighton 2023-08-01 14:33:05 BST
ah: it's an error not a warning.  answer: i don't know. this code was written
18+ months ago.  you'll have to investigate step-by-step, first listing
actually what the loops are.
Comment 4 Andrey Miroshnikov 2023-08-03 14:19:13 BST
As you have suggested yesterday Luke, I tried running this mw+svp64 libre-soc core within microwatt repo's verilator, and it runs hello world!

Also started documenting the steps required to generate this core (still in progress): https://libre-soc.org/HDL_workflow/gen_core_with_svp64/

From the assembly file in hello world, I see that an instruction can be called by the machine code directly, https://git.libre-soc.org/?p=microwatt.git;a=blob;f=hello_world/head.S;h=63576063f040c707d307a6c0ea4216e16f3f2da9;hb=refs/heads/verilator_trace#l20

Now I'll need to play with pypowersim to make some svp64 machine code, which I could then insert into the hello world code and try running it.
Comment 5 Luke Kenneth Casson Leighton 2023-08-03 14:43:51 BST
(In reply to Andrey Miroshnikov from comment #4)
> As you have suggested yesterday Luke, I tried running this mw+svp64
> libre-soc core within microwatt repo's verilator, and it runs hello world!

hooray.  so now you know, there is a bug in the version of
yosys you used to do the nextpnr-routing.  verilator could
not do a simulation if there was *actually* a combinatorial loop.

> Also started documenting the steps required to generate this core (still in
> progress): https://libre-soc.org/HDL_workflow/gen_core_with_svp64/

awesome.
 
> From the assembly file in hello world, I see that an instruction can be
> called by the machine code directly,
> https://git.libre-soc.org/?p=microwatt.git;a=blob;f=hello_world/head.S;

of course it can. that is what has been done for nearly 3 years now,
back when lauri first did the a/v mp3 work.

> Now I'll need to play with pypowersim to make some svp64 machine code, which
> I could then insert into the hello world code and try running it.

link it as a single static .o exactly as is done in media/ and you
should be done in well under 2 hours.  not one month of failing because
you're not asking for guidance and think that the goal is "i have to
do this entirely by myself".

also examine konstantinos's crypto/ work as he combines assembly
functions with c functions.  this is the calling convention match
up the registers declare a static header file BAM job is done.

https://git.libre-soc.org/?p=openpower-isa.git;a=blob;f=media/calling-conv;hb=HEAD

this is all extremely straightforward been done multiple times you
just need to get on with it.