YosysHQ / yosys

Yosys Open SYnthesis Suite
https://yosyshq.net/yosys/
ISC License
3.5k stars 895 forks source link

add select option for write_json #4719

Closed AdamLee7 closed 4 days ago

AdamLee7 commented 2 weeks ago

there is already codes of select_module, but the write_json cmd don't receive the option. now we can use the cmd like this:

select -module top;
write_json -selected xxx.json
KrystalDelusion commented 2 weeks ago

Could you please add a test? Loading a test design, write_json, reset design, read_json, then asserting the unselected portion is not included would be good.

AdamLee7 commented 2 weeks ago

yosys_case.zip this is a simple case, if use the -selected option, write_json only output the top module like synth_only_top.json

KrystalDelusion commented 1 week ago

Sorry, I meant add a test to the tests directory with a commit on this PR. Something like tests/aiger/neg.ys:

...
write_aiger -map neg.out/neg.map neg.out/neg.aig

design -reset
read_aiger -wideports -map neg.out/neg.map neg.out/neg.aig
select -assert-count 1 i:a
select -assert-count 1 i:b
select -assert-count 1 o:c
select -assert-count 3 x:* s:64 %i
nakengelhardt commented 1 week ago

This functionality already exists, it is the command json -o xxx.json top. I believe the two were deliberately separated, though I'm not familiar with the details of why.

nakengelhardt commented 1 week ago

We discussed this in the dev meeting, the json command was for convenience (mostly for debugging) and by analogy with dump, but in general we do want -selected options on all backends (including this one), and we don't want pass variants like dump and json for other backends.

AdamLee7 commented 1 week ago

This functionality already exists, it is the command json -o xxx.json top. I believe the two were deliberately separated, though I'm not familiar with the details of why.

this works, thanks, i'll closed this pr

nakengelhardt commented 1 week ago

Nono, as I mentioned in my follow-up comment after asking around about the reasons for why it was this way, we do want to have this PR so that all the backends have the same consistent interface. It'll be easier for users to discover how to do this with -selected.