yosys/tests/opt/opt_expr_xor.ys

141 lines
3.2 KiB
Plaintext
Raw Normal View History

read_verilog <<EOT
module top(input a, output [3:0] y);
assign y[0] = a^1'b0;
assign y[1] = 1'b1^a;
assign y[2] = a~^1'b0;
assign y[3] = 1'b1^~a;
endmodule
EOT
design -save read
select -assert-count 2 t:$xor
select -assert-count 2 t:$xnor
2022-08-30 06:56:05 -05:00
equiv_opt -assert opt_expr
design -load postopt
select -assert-none t:$xor
select -assert-none t:$xnor
2020-03-20 16:38:50 -05:00
select -assert-count 2 t:$not
design -load read
simplemap
2022-08-30 06:56:05 -05:00
equiv_opt -assert opt_expr
design -load postopt
select -assert-none t:$_XOR_
select -assert-none t:$_XNOR_ # NB: simplemap does $xnor -> $_XOR_+$_NOT_
select -assert-count 3 t:$_NOT_
design -reset
read_verilog -icells <<EOT
module top(input a, output [1:0] y);
$_XNOR_ u0(.A(a), .B(1'b0), .Y(y[0]));
$_XNOR_ u1(.A(1'b1), .B(a), .Y(y[1]));
endmodule
EOT
select -assert-count 2 t:$_XNOR_
2022-08-30 06:56:05 -05:00
equiv_opt -assert opt_expr
design -load postopt
select -assert-none t:$_XNOR_ # NB: simplemap does $xnor -> $_XOR_+$_NOT_
select -assert-count 1 t:$_NOT_
2020-03-20 16:38:50 -05:00
design -reset
read_verilog <<EOT
module top(input a, output [1:0] w, x, y, z);
assign w = a^1'b0;
assign x = a^1'b1;
assign y = a~^1'b0;
assign z = a~^1'b1;
endmodule
EOT
2022-08-30 06:56:05 -05:00
equiv_opt -assert opt_expr
2020-04-23 17:58:36 -05:00
# Single-bit $xor
design -reset
read_verilog -noopt <<EOT
module gold(input i, output o);
assign o = 1'bx ^ i;
endmodule
EOT
select -assert-count 1 t:$xor
copy gold coarse
copy gold fine
copy gold coarse_keepdc
copy gold fine_keepdc
cd coarse
opt_expr
select -assert-none c:*
cd fine
simplemap
opt_expr
select -assert-none c:*
cd
miter -equiv -flatten -make_assert -make_outputs -ignore_gold_x gold coarse miter
sat -verify -prove-asserts -show-ports -enable_undef miter
miter -equiv -flatten -make_assert -make_outputs coarse fine miter2
sat -verify -prove-asserts -show-ports -enable_undef miter2
cd coarse_keepdc
opt_expr -keepdc
select -assert-count 1 c:*
cd fine_keepdc
simplemap
opt_expr -keepdc
select -assert-count 1 c:*
cd
miter -equiv -flatten -make_assert -make_outputs gold coarse_keepdc miter3
sat -verify -prove-asserts -show-ports -enable_undef miter3
miter -equiv -flatten -make_assert -make_outputs coarse_keepdc fine_keepdc miter4
sat -verify -prove-asserts -show-ports -enable_undef miter4
# Multi-bit $xor
design -reset
read_verilog -noopt <<EOT
module gold(input i, output [6:0] o);
assign o = {1'bx, 1'b0, 1'b0, 1'b1, 1'bx, 1'b1, i} ^ {7{i}};
endmodule
EOT
select -assert-count 1 t:$xor
copy gold coarse
copy gold fine
copy gold coarse_keepdc
copy gold fine_keepdc
cd coarse
opt_expr -fine
2020-04-24 13:16:25 -05:00
select -assert-count 0 t:$xor
2020-04-23 17:58:36 -05:00
cd fine
simplemap
opt_expr
select -assert-none t:$_XOR_
cd
miter -equiv -flatten -make_assert -make_outputs -ignore_gold_x gold coarse miter
sat -verify -prove-asserts -show-ports -enable_undef miter
miter -equiv -flatten -make_assert -make_outputs coarse fine miter2
sat -verify -prove-asserts -show-ports -enable_undef miter2
cd coarse_keepdc
opt_expr -keepdc -fine
2020-04-24 13:16:25 -05:00
select -assert-count 1 t:$xor
2020-04-23 17:58:36 -05:00
cd fine_keepdc
simplemap
opt_expr -keepdc
2020-04-24 13:16:25 -05:00
select -assert-count 3 t:$_XOR_
2020-04-23 17:58:36 -05:00
cd
miter -equiv -flatten -make_assert -make_outputs gold coarse_keepdc miter3
sat -verify -prove-asserts -show-ports -enable_undef miter3
2020-04-23 17:58:36 -05:00
miter -equiv -flatten -make_assert -make_outputs coarse_keepdc fine_keepdc miter4
sat -verify -prove-asserts -show-ports -enable_undef miter4