lushaylabs / lushay-code

yosys, nextpnr, apicula and openFPGALoader in vscode using OSS-CAD-Suite
https://marketplace.visualstudio.com/items?itemName=lushay-labs.lushay-code&ssr=false
MIT License
20 stars 3 forks source link

100% memory/cpu usage #6

Closed Adivinedude closed 3 months ago

Adivinedude commented 3 months ago

IDE Visual Studio Code(1.87) w/ platformIO and the yosys extension As I was getting some code to pass formal verification with 'sby', the visual code "update complete" notification popped up. my IDE was updated to v1.88. the next time I ran 'sby', I received an error code

SBY 22:04:02 [counter] base: starting process "cd counter/src& yosys -ql ../model/design.log ../model/design.ys"
SBY 22:04:02 [counter] base: finished (returncode=3221225781)
SBY 22:04:02 [counter] base: task failed. ERROR.
SBY 22:04:02 [counter] summary: Elapsed clock time [H:MM:SS (secs)]: 0:00:00 (0)
SBY 22:04:02 [counter] summary: Elapsed process time unvailable on Windows
SBY 22:04:02 [counter] summary: engine_0 (smtbmc) did not return a status
SBY 22:04:02 [counter] summary: engine_0 did not produce any traces
SBY 22:04:02 [counter] DONE (ERROR, rc=16)

After restarting my pc, reinstalling visual code(1.87), platformio, oss-cad-suite, the error was still the only output I could get. even running sby -E did not help.

Running :\oss-cad-suite\enviroment.bat did not change is problem. But running :\oss-cad-suite\start.bat from the 'visual studio' terminal, got me back up and running. I have no idea what is going on, now if I start visual code, it starts yosys.exe which quickly consume all memory and page resources on my pc (32gig) One thing I have noticed, after uninstalling, then installing the IDE, none of the extensions where removed. I had to do that manually. The current working dir was also saved, opening back up when I started visual code after the fresh install. yosys.exe 100% cpu and 100% memory. on starting visual code. I managed to close the folder, then visual code, then 'task end' yosys.exe. But now if I open any folder containing *.v files, yosys.exe starts up and consumes all the ram and cpu

lushaylabs commented 3 months ago

Hi, I tried to replicate the setup with v1.88 and Lushay code 0.0.19 and platformIO and unfortunately, I have not been able to reproduce the issue yet.

from your description, I think this might be two separate issues, I see SBY is calling yosys without specifying a full path, which means it expects it to already be loaded, which would explain why after running start.bat it would work.

But I don't think this is related to the LushayCode extension issue you mentioned with the 100% since SBY I assume you are running manually and not via our plugin.

Our plugin gets instantiated whenever there is a project open with a .v file so it makes sense that it would be triggered by that and there are a few steps for things like the module debugger or the constraints editor which use yosys, but again I was still unable to pinpoint exactly what is causing the issue for you.

Does this happen for a specific verilog project or does it happen to all projects, for example if you open our examples repo https://github.com/lushaylabs/tangnano9k-series-examples does it happen as-well (this will help understand if it is project related or if I can reproduce using this repo)

Another thing that might help is to know the path to OSS CAD Suite and the version if you know, and the settings for the lushay code plugin (mainly Lushay.Oss Cad Suite: Path)

sorry for the inconvenience, hopefully together we can get to the bottom of this

Adivinedude commented 3 months ago

As you suggested, I opened the examples published, thank you btw, good stuff. and everything works as always. From what 'filemon' shows me, anytime I open, or tab to a file in visual code, yosys.exe opens and reads the entire file. yosys.exe keeps reading my counter.v file into memory, over and over. After taking a memory dump, I see my verilog text repeating in ram. a lot. I have been trying to edit a simple counter with a pipelined carrieover chain( for higher fmax) and I guess its so bad yosys is choking on it. Thank yall for making this plugin. Its fueled a passion.

Adivinedude commented 3 months ago
            // carry chain propagation, start with the second chunk and stop before the last
            for( idy = 1; idy != CHUNK_COUNT-1; idy = idy + 1 ) begin
                counter[ (idy*LUT_SIZE) + LUT_SIZE - 1 ] <= 0;  // clear the carry bit for this chunk
                if( counter[ (idy*LUT_SIZE) - 1 ] )             // if the previous chunk has the carry bit set, do the subtraction
                    counter[idy*LUT_SIZE+:LUT_SIZE] <= counter[idy*LUT_SIZE+:LUT_SIZE] - 1'b1;
                chunk_equal_zero[idy-1] <= counter[idy*LUT_SIZE+:REG_SIZE] != 0;   // Set the equal_zero flag if the register(without carry bit) == 0
            end

This loop, under default parameters, is never ending. by changing '!=' to '<' all is well and the stars can twinkle once again. Sorry for wasting your time

lushaylabs commented 3 months ago

Thank you, both for reporting this and the in-depth debugging to get to the root cause. I will try and see if there is a way to put a limit on the running process so that it can catch situations like this and provide an error message instead of running indefinitely and locking up.

Adivinedude commented 3 months ago

I was looking for a method to get yosys running with the -g switch.

-g
        globally enable debug log messages

It looks like src/stages/yosys-synth.ts line# 44 would be where to inject it. I wasn't sure if that would even help. so I used the tools I was familiar with instead of trying to learn the visual code extension api