Techmap blackbox port direction #5067
-
I'm working on a project. I'm trying to use Yosys to compile verilog to coarse cells which I then simulate. Here I want to extract 32-bit multiplications and perform them in an optimized way. Looking at the json the port names and directions are wrong. I see a suspect "module_not_derived," but I dont quite understand how to address that hint. Am I even using the right tool? Ideally I want to replace $mul with a blackbox that my simulator can quickly identify and then do different transformations for non-conforming multiplications. Heres my script, read_verilog test1.v
#read_verilog -lib ../techmap/v2f_techmap.v
hierarchy -check -top top
flatten
proc
opt
techmap -map ../techmap/v2f_techmap.v;;
write_json -selected ./output/test1.json
show -lib ../techmap/v2f_techmap.v
module top(
input signed [31:0] signal_0,
input signed [31:0] signal_1,
output reg [31:0] signal_2
);
always @(*) begin
signal_2 = signal_0*signal_1;
end
endmodule
(* blackbox, keep *)
module v2f_mul (A,B,Y);
parameter A_WIDTH = 32; parameter B_WIDTH = 32; parameter Y_WIDTH = 32;
parameter A_SIGNED = 0;
parameter B_SIGNED = 0;
input [A_WIDTH-1:0] A;
input [B_WIDTH-1:0] B;
output [Y_WIDTH-1:0] Y;
//assign Y = A*B;
endmodule
(* techmap_celltype = "$mul" *)
module v2f_rule_mul (A, B, Y);
parameter A_SIGNED = 0;
parameter B_SIGNED = 0;
parameter A_WIDTH = 1;
parameter B_WIDTH = 1;
parameter Y_WIDTH = 1;
input [A_WIDTH-1:0] A;
input [B_WIDTH-1:0] B;
output [Y_WIDTH-1:0] Y;
wire _TECHMAP_FAIL_ = A_WIDTH > 32 || B_WIDTH > 32 || Y_WIDTH > 32;
(*keep*) v2f_mul #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .B_SIGNED(B_SIGNED), .B_WIDTH(B_WIDTH), .Y_WIDTH(Y_WIDTH)) _TECHMAP_REPLACE_(A, B, Y);
endmodule
// Omitted irrelevant rules Relevant json section: "top": {
"cells": {
"$mul$test1.v:7$2": {
"hide_name": 1,
"type": "v2f_mul",
"parameters": {
"A_SIGNED": "00000000000000000000000000000001",
"A_WIDTH": "00000000000000000000000000100000",
"B_SIGNED": "00000000000000000000000000000001",
"B_WIDTH": "00000000000000000000000000100000",
"Y_WIDTH": "00000000000000000000000000100000"
},
"attributes": {
"keep": "00000000000000000000000000000001",
"module_not_derived": "00000000000000000000000000000001",
"src": "test1.v:7.14-7.31|../techmap/v2f_techmap.v:79.120-79.146"
},
"connections": {
"$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 ],
"$2": [ 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65 ],
"$3": [ 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97 ]
}
}
},
} executing
Thanks in advance for any help you can provide! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The The unnamed ports is because You also typically want to provide the cell model and the techmap rules in separate files, i.e. module v2f_mul (A,B,Y);
parameter A_WIDTH = 32; parameter B_WIDTH = 32; parameter Y_WIDTH = 32;
parameter A_SIGNED = 0;
parameter B_SIGNED = 0;
input [A_WIDTH-1:0] A;
input [B_WIDTH-1:0] B;
output [Y_WIDTH-1:0] Y;
assign Y = A*B;
endmodule which lets you drop the v2f_techmap.v (* techmap_celltype = "$mul" *)
module v2f_rule_mul (A, B, Y);
parameter A_SIGNED = 0;
parameter B_SIGNED = 0;
parameter A_WIDTH = 1;
parameter B_WIDTH = 1;
parameter Y_WIDTH = 1;
input [A_WIDTH-1:0] A;
input [B_WIDTH-1:0] B;
output [Y_WIDTH-1:0] Y;
wire _TECHMAP_FAIL_ = A_WIDTH > 32 || B_WIDTH > 32 || Y_WIDTH > 32;
(*keep*) v2f_mul #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .B_SIGNED(B_SIGNED), .B_WIDTH(B_WIDTH), .Y_WIDTH(Y_WIDTH)) _TECHMAP_REPLACE_(.A(A), .B(B), .Y(Y));
endmodule And then in your script:
note that if you don't provide the |
Beta Was this translation helpful? Give feedback.
The
module_not_derived
attribute is because thev2f_mul
module is a blackbox.which I think is also related to the missing port directions(sidenote that theshow
output connects them all on the left not because they're all inputs, but just because that's the default side when the direction isn't known).The unnamed ports is because
_TECHMAP_REPLACE_
doesn't work with positional arguments.You also typically want to provide the cell model and the techmap rules in separate files, i.e.
v2f_model.v