File: wrapcell.ys

package info (click to toggle)
yosys 0.52-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 69,796 kB
  • sloc: ansic: 696,955; cpp: 239,736; python: 14,617; yacc: 3,529; sh: 2,175; makefile: 1,945; lex: 697; perl: 445; javascript: 323; tcl: 162; vhdl: 115
file content (57 lines) | stat: -rw-r--r-- 1,415 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
read_verilog <<EOF
module top(
	input [1:0] a,
	input [2:0] b,
	output [2:0] y,
	input [2:0] a2,
	input [3:0] b2,
	output [3:0] y2,
 	input [1:0] a3,
 	input [2:0] b3,
 	output [2:0] y3
);
	assign y = a | (*keep*) b;
	assign y2 = a2 | (*keep*) b2;
	assign y3 = a3 | (*keep*) b3;
endmodule
EOF

wreduce
wrapcell -setattr foo -formatattr bar w{Y_WIDTH} -name OR_{A_WIDTH}_{B_WIDTH}_{Y_WIDTH}
check -assert
select -assert-count 2 top/t:OR_2_3_3
select -assert-count 1 top/t:OR_3_4_4
select -assert-none top/t:OR_2_3_3 top/t:OR_3_4_4 %% top/t:* %D
select -assert-mod-count 2 OR_2_3_3 OR_3_4_4
select -assert-mod-count 2 A:bar=w3 A:bar=w4

design -reset
read_verilog <<EOF
module top(
	input [1:0] a,
	input [2:0] b,
	output [2:0] y,
	input [2:0] a2,
	input [3:0] b2,
	output [3:0] y2,
 	input [1:0] a3,
 	input [2:0] b3,
 	output [2:0] y3
);
	assign y = a | (*keep*) b;
	assign y2 = a2 | (*keep*) b2;
	wire [2:0] y3_ = a3 | (*keep*) b3;
	assign y3 = {y3_[2], y3_[0]};
endmodule
EOF

opt_clean
wreduce
wrapcell -setattr foo -formatattr bar w{Y_WIDTH} -name OR_{A_WIDTH}_{B_WIDTH}_{Y_WIDTH}{%unused}
check -assert
select -assert-count 1 top/t:OR_2_3_3
select -assert-count 1 top/t:OR_2_3_3_unused_Y[1]
select -assert-count 1 top/t:OR_3_4_4
select -assert-none top/t:OR_2_3_3 top/t:OR_3_4_4 top/t:OR_2_3_3_unused_Y[1] %% top/t:* %D
select -assert-mod-count 2 OR_2_3_3 OR_3_4_4
select -assert-mod-count 3 A:bar=w3 A:bar=w4