3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-23 17:15:33 +00:00

Merge pull request #5000 from YosysHQ/krys/re_refactor_selections

This commit is contained in:
N. Engelhardt 2025-04-10 16:06:36 +00:00 committed by GitHub
commit 3410e10ed5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 1110 additions and 301 deletions

View file

@ -1,4 +1,5 @@
logger -nowarn "Yosys has only limited support for tri-state logic at the moment\. .*"
logger -nowarn "Ignoring boxed module .*\."
read_verilog <<EOT
module top(input C, D, output [7:0] Q);

View file

@ -1,4 +1,5 @@
logger -nowarn "Yosys has only limited support for tri-state logic at the moment\. .*"
logger -nowarn "Ignoring boxed module .*\."
read_verilog <<EOT
module top(input [24:0] A, input [17:0] B, output [47:0] P);

View file

@ -13,5 +13,5 @@ run_subtest value
run_subtest value_fuzz
# Compile-only test.
../../yosys -p "read_verilog test_unconnected_output.v; proc; clean; write_cxxrtl cxxrtl-test-unconnected_output.cc"
../../yosys -p "read_verilog test_unconnected_output.v; select =*; proc; clean; write_cxxrtl cxxrtl-test-unconnected_output.cc"
${CC:-gcc} -std=c++11 -c -o cxxrtl-test-unconnected_output -I../../backends/cxxrtl/runtime cxxrtl-test-unconnected_output.cc

View file

@ -1,4 +1,3 @@
read_verilog -specify <<EOT
module top(input a, b, output o);
assign o = a & b;
endmodule
@ -15,14 +14,3 @@ endmodule
module wb(input a, b, output o);
assign o = a ^ b;
endmodule
EOT
clean
select -assert-count 1 c:*
select -assert-none t:* t:$and %d
select -assert-count 3 w:*
select -assert-count 4 *
select -assert-count 3 =c:*
select -assert-count 10 =w:*
select -assert-count 13 =*

View file

@ -0,0 +1,7 @@
read_verilog -specify boxes.v
clean
select -set top top
select -assert-count 4 @top
select -set boxes =?b
select -assert-count 9 @boxes

View file

@ -0,0 +1,38 @@
read_verilog -specify boxes.v
clean
# wb = 4w1c, bb = 3w1c, top = 3w1c
select =wb
select -assert-count 5 %
select -add =bb
select -assert-count 9 %
select -del =wb
select -assert-count 4 %
# unions
select -assert-count 8 =bb * %u
select -assert-count 8 * =bb %u
select -assert-count 13 top =* %u
select -assert-count 8 =bb top %u
select -assert-count 8 top =bb %u
# intersections
select -assert-count 3 =w:* =bb %i
select -assert-count 4 =* * %i
select -assert-count 4 * =* %i
# inverses
select -assert-count 8 =wb %n
select -assert-none top %n
select -assert-none * %n
select -assert-none =* %n
select -assert-count 9 =top %n
# differences
select -assert-count 9 =* top %d
select -assert-count 0 top =* %d
select -assert-count 9 =* * %d
select -assert-count 0 * =* %d
# random
select -assert-any =?b %R

View file

@ -0,0 +1,7 @@
read_verilog -specify boxes.v
clean
select -assert-none ?b
select -assert-count 4 =bb
select -assert-count 5 =wb
select -assert-count 9 =?b

View file

@ -0,0 +1,6 @@
read_verilog -specify boxes.v
clean
select -assert-count 3 =c:*
select -assert-count 10 =w:*
select -assert-count 13 =*

View file

@ -0,0 +1,29 @@
read_verilog -specify boxes.v
design -save read
logger -expect-no-warnings
delete =bb %n
select -assert-mod-count 1 =*
design -stash just_bb
design -import just_bb
select -assert-mod-count 0 *
select -assert-mod-count 1 =*
design -reset
design -import just_bb -as new
select -assert-mod-count 0 *
select -assert-mod-count 1 =*
design -reset
design -import read -as new_top top
design -import read -as new_bb =bb
select -assert-mod-count 1 *
select -assert-mod-count 2 =*
logger -check-expected
logger -expect warning "Selection .wb. did not match any module\." 1
logger -expect error "No top module found in source design\." 1
design -import read -as new_wb wb

View file

@ -0,0 +1,7 @@
read_verilog -specify boxes.v
clean
select -assert-count 1 c:*
select -assert-none t:* t:$and %d
select -assert-count 3 w:*
select -assert-count 4 *

View file

@ -0,0 +1,18 @@
read_verilog -specify boxes.v
logger -expect warning "did not match any module" 2
clean wb
opt_clean wb
logger -check-expected
select -clear
logger -expect warning "did not match any module" 2
clean wb
opt_clean wb
logger -check-expected
select -none
logger -expect warning "did not match any module" 2
clean wb
opt_clean wb
logger -check-expected

View file

@ -0,0 +1,39 @@
read_verilog -specify boxes.v
design -save read
select -assert-none =a:test_attr
select -assert-none =A:test_attr
# setattr =* affects all modules
setattr -set test_attr 1 =*
select -assert-mod-count 3 =a:test_attr
select -assert-none =A:test_attr
design -load read
setattr -mod -set test_attr 1 =*
select -assert-none =a:test_attr
select -assert-mod-count 3 =A:test_attr
# setattr * doesn't affect boxed modules
design -load read
setattr -mod -set test_attr 1 *
select -assert-mod-count 1 =A:test_attr
# setattr can set and unset whitebox attr
design -load read
setattr -mod -unset whitebox =wb
select -assert-mod-count 2 *
setattr -mod -set whitebox 1 wb
select -assert-mod-count 1 *
# wbflip works on all non-bb in selection
design -load read
select -assert-mod-count 1 =A:whitebox
wbflip
select -assert-mod-count 2 =A:whitebox
wbflip
select -assert-mod-count 2 =A:whitebox
wbflip =wb
select -assert-mod-count 1 =A:whitebox
wbflip =bb
select -assert-mod-count 1 =A:whitebox

View file

@ -0,0 +1,29 @@
read_verilog -specify boxes.v
clean
# default selection == select *
select -assert-count 4 *
select -assert-count 4 %
# -none replaces default selection
select -none
select -assert-none %
select -assert-count 13 =*
# select replaces current selection
select =*
select -assert-count 13 %
# -module changes module
select -module wb
select -assert-none %
select -assert-count 5 =*
# -none maintains module
select -none
select -assert-count 5 =*
# -clear clears current selection and module
select -clear
select -assert-count 4 %
select -assert-count 13 =*

View file

@ -0,0 +1,165 @@
read_verilog boxes.v
## base case, no warnings ##
logger -expect-no-warnings
select =*
select -assert-count 13 %
select -assert-mod-count 3 %
test_select # SELECT_ALL && SB_ALL
select -assert-count 13 %
select -assert-mod-count 3 %
select =*
select -assert-mod-count 3 %
test_select -whole_only # SELECT_WHOLE_ONLY
select -assert-mod-count 3 %
select =*
select -assert-count 13 %
test_select -unboxed_only -include_wb # SB_EXCL_BB_ONLY
select -assert-count 10 %
select =*
select -assert-count 13 %
test_select -unboxed_only # SB_UNBOXED_ONLY
select -assert-count 5 %
logger -check-expected
## don't add to selection ##
select *
select -assert-count 5 %
select -assert-mod-count 1 %
test_select # SELECT_ALL && SB_ALL
select -assert-count 5 %
select -assert-mod-count 1 %
select =wb/a %n
select -assert-mod-count 3 %
test_select -whole_only # SELECT_WHOLE_ONLY
select -assert-mod-count 2 %
select =w:*
select -assert-mod-count 3 %
test_select -whole_only # SELECT_WHOLE_ONLY
select -assert-mod-count 1 %
select =w:*
select -assert-mod-count 3 %
test_select -whole_only -unboxed_only # SELECT_WHOLE_ONLY && SB_UNBOXED_ONLY
select -assert-none %
select =w:* %n
select -assert-mod-count 2 %
test_select -whole_only # SELECT_WHOLE_ONLY
select -assert-none %
select =?b
select -assert-count 8 %
test_select -unboxed_only -include_wb # SB_EXCL_BB_ONLY
select -assert-count 5 %
select =?b
select -assert-count 8 %
test_select -unboxed_only # SB_UNBOXED_ONLY
select -assert-none %
select =wb %n
select -assert-count 8 %
test_select -unboxed_only -include_wb # SB_EXCL_BB_ONLY
select -assert-count 5 %
select =top/a %n
select -assert-count 12 %
select -assert-mod-count 3 %
test_select -whole_only -unboxed_only -include_wb # SELECT_WHOLE_ONLY && SB_EXCL_BB_ONLY
select -assert-count 5 %
select -assert-mod-count 1 %
## warnings work ##
logger -expect warning "Ignoring blackbox module bb." 1
select =*
test_select -unboxed_only -include_wb -warn_boxes # SB_EXCL_BB_WARN
logger -check-expected
logger -expect warning "Ignoring boxed module .b." 2
select =*
test_select -unboxed_only -warn_boxes # SB_UNBOXED_WARN
logger -check-expected
logger -expect warning "Ignoring partially selected module [wb|top]." 2
select =w:*
test_select -whole_warn # SELECT_WHOLE_WARN
logger -check-expected
logger -expect warning "Ignoring partially selected module [wb|top]." 2
logger -expect warning "Ignoring blackbox module bb." 1
select =w:*
test_select -whole_warn -unboxed_only -include_wb -warn_boxes # SELECT_WHOLE_WARN && SB_EXCL_BB_WARN
logger -check-expected
logger -expect warning "Ignoring partially selected module [wb|top]." 2
logger -expect warning "Ignoring boxed module bb." 1
select =w:*
test_select -whole_warn -unboxed_only -warn_boxes # SELECT_WHOLE_WARN && SB_UNBOXED_WARN
logger -check-expected
## partials warn before boxes ##
logger -expect warning "Ignoring partially selected module wb." 1
select =wb/a
test_select -whole_warn -unboxed_only -warn_boxes # SELECT_WHOLE_WARN && SB_UNBOXED_WARN
logger -check-expected
## boxes won't warn if they've been removed because of partial selection ##
logger -expect-no-warnings
select =wb/a
test_select -whole_only -unboxed_only -warn_boxes # SELECT_WHOLE_ONLY && SB_UNBOXED_WARN
logger -check-expected
## boxes still warn if they're not partially selected
logger -expect warning "Ignoring boxed module wb." 1
select =bb %n
test_select -whole_only -unboxed_only -warn_boxes # SELECT_WHOLE_ONLY && SB_UNBOXED_WARN
logger -check-expected
## don't warn if it's not selected ##
logger -expect-no-warnings
select =bb %n
test_select -unboxed_only -include_wb -warn_boxes # SB_EXCL_BB_WARN
logger -check-expected
logger -expect-no-warnings
select *
test_select -unboxed_only -warn_boxes # SB_UNBOXED_WARN
logger -check-expected
logger -expect warning "Ignoring boxed module bb." 1
select =wb %n
test_select -unboxed_only -warn_boxes # SB_UNBOXED_WARN
logger -check-expected
## don't error if it's not selected ##
logger -expect-no-warnings
select =bb %n
test_select -unboxed_only -include_wb -err_boxes # SB_EXCL_BB_ERR
select =bb %n
test_select -unboxed_only -include_wb -cmderr_boxes # SB_EXCL_BB_CMDERR
select *
test_select -unboxed_only -err_boxes # SB_UNBOXED_ERR
select *
test_select -unboxed_only -cmderr_boxes # SB_UNBOXED_CMDERR
select *
test_select -whole_err # SELECT_WHOLE_ERR
select *
test_select -whole_cmderr # SELECT_WHOLE_CMDERR
logger -check-expected
##

View file

@ -49,6 +49,6 @@ exec ${MAKE:-make} -f ../tools/autotest.mk $seed *.v *.sv EXTRA_FLAGS="-f \"veri
clean; \
check -assert * abc9_test037 %d; \
select -assert-none t:${DOLLAR}_NOT_ t:${DOLLAR}_AND_ %%; \
setattr -mod -unset blackbox -unset whitebox'"
setattr -mod -unset blackbox -unset whitebox =*'"
# NOTE: Skip 'check -assert' on abc9_test037 because it intentionally has a combinatorial loop