Skip to content

Commit 5f14b60

Browse files
committed
Doesn't matter if path is abs or rel
1 parent 3ad30eb commit 5f14b60

7 files changed

Lines changed: 140 additions & 11 deletions

File tree

src/synth_fpga.cc

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,23 +2386,31 @@ struct SynthFpgaPass : public ScriptPass {
23862386
// Get the parent cad directory path
23872387
std::filesystem::path cad_directory = config_path.parent_path();
23882388

2389-
log("Loading cell models from config");
2389+
log("Loading cell models from config\n");
23902390

23912391
if(G_config.dff_techmap != "") {
2392-
if(std::filesystem::path(G_config.dff_techmap).is_absolute()) {
2393-
log_warning("dff techmap file path '%s' is absolute.\n", G_config.dff_techmap.c_str()); // Path is expected to be relative, in same dir as .*config.json
2392+
std::filesystem::path dff_techmap_path(G_config.dff_techmap);
2393+
if(dff_techmap_path.is_absolute()) {
2394+
dff_techmap_path = cad_directory / dff_techmap_path.relative_path();
2395+
log_warning("dff techmap file path '%s' is absolute, but treating as relative to config file directory.\n", G_config.dff_techmap.c_str()); // Path is expected to be relative, in same dir as .*config.json
23942396
}
2395-
2396-
std::filesystem::path dff_techmap_path = cad_directory / G_config.dff_techmap;
2397+
else {
2398+
dff_techmap_path = cad_directory / dff_techmap_path;
2399+
}
2400+
log("Reading dff techmap from %s\n", dff_techmap_path.string().c_str());
23972401
run("read_verilog " + dff_techmap_path.string());
23982402
}
23992403

24002404
if(G_config.dsps_techmap != ""){
2401-
if(std::filesystem::path(G_config.dsps_techmap).is_absolute()) {
2402-
log_warning("dff techmap file path '%s' is absolute.\n", G_config.dsps_techmap.c_str()); // Path is expected to be relative, in same dir as .*config.json
2405+
std::filesystem::path dsp_techmap_path(G_config.dsps_techmap);
2406+
if(dsp_techmap_path.is_absolute()) {
2407+
dsp_techmap_path = cad_directory / dsp_techmap_path.relative_path();
2408+
log_warning("dsp techmap file path '%s' is absolute, but treating as relative to config file directory.\n", G_config.dsps_techmap.c_str()); // Path is expected to be relative, in same dir as .*config.json
24032409
}
2404-
2405-
std::filesystem::path dsp_techmap_path = cad_directory / G_config.dsps_techmap;
2410+
else {
2411+
dsp_techmap_path = cad_directory / dsp_techmap_path;
2412+
}
2413+
log("Reading dsp techmap from %s\n", dsp_techmap_path.string().c_str());
24062414
run("read_verilog " + dsp_techmap_path.string());
24072415
}
24082416
}

tests/unit/data/z1000/z1000.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@
33
"partname": "z1000",
44
"lut_size": 4,
55
"flipflops": {
6-
"features": ["async_reset", "async_set", "flop_enable"],
7-
"legalize_list": ["$_DFF_PN0_", "$_DFF_P_", "$_DFFE_PP_", "$_DFFE_PN0P_"],
6+
"features": [
7+
"async_reset",
8+
"flop_enable"
9+
],
10+
"models": {
11+
},
12+
"legalize_list": [
13+
"$_DFF_PN0_",
14+
"$_DFF_P_",
15+
"$_DFFE_PP_",
16+
"$_DFFE_PN0P_"
17+
],
818
"techmap": "tech_flops.v"
919
}
1020
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": 1,
3+
"partname": "z1000",
4+
"lut_size": 4,
5+
"flipflops": {
6+
"features": [
7+
"async_reset",
8+
"flop_enable"
9+
],
10+
"models": {
11+
},
12+
"legalize_list": [
13+
"$_DFF_PN0_",
14+
"$_DFF_P_",
15+
"$_DFFE_PP_",
16+
"$_DFFE_PN0P_"
17+
],
18+
"techmap": "/tech_flops.v"
19+
}
20+
}

tests/unit/data/z1010/z1010.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"lut_size": 4,
55
"flipflops": {
66
"features": ["async_reset", "async_set", "flop_enable"],
7+
"models": {
8+
},
79
"legalize_list": ["$_DFF_PN0_", "$_DFF_P_", "$_DFFE_PP_", "$_DFFE_PN0P_"],
810
"techmap": "tech_flops.v"
911
},
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": 1,
3+
"partname": "z1010",
4+
"lut_size": 4,
5+
"flipflops": {
6+
"features": ["async_reset", "async_set", "flop_enable"],
7+
"models": {
8+
},
9+
"legalize_list": ["$_DFF_PN0_", "$_DFF_P_", "$_DFFE_PP_", "$_DFFE_PN0P_"],
10+
"techmap": "/tech_flops.v"
11+
},
12+
"brams": {
13+
"memory_libmap": ["/bram_memory_map.txt"],
14+
"techmap": ["/tech_bram.v"]
15+
},
16+
"dsps": {
17+
"family": "DSP48",
18+
"techmap": "/mult18x18_DSP48.v",
19+
"techmap_parameters": {
20+
"DSP_A_MAXWIDTH": 18,
21+
"DSP_B_MAXWIDTH": 18,
22+
"DSP_A_MINWIDTH": 2,
23+
"DSP_B_MINWIDTH": 2,
24+
"DSP_Y_MINWIDTH": 9,
25+
"DSP_SIGNEDONLY": 1,
26+
"DSP_NAME": "$__MUL18X18"
27+
}
28+
}
29+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# yosys -m wildebeest -s heartbeat-z1000-config-abspath.ys
2+
read_verilog <<EOF
3+
module heartbeat #(
4+
parameter N = 8
5+
) (
6+
//inputs
7+
input clk, // clock
8+
input nreset, //async active low reset
9+
//outputs
10+
output reg out //heartbeat
11+
);
12+
13+
reg [N-1:0] counter_reg;
14+
15+
always @(posedge clk or negedge nreset) begin
16+
if (!nreset) begin
17+
counter_reg <= {(N) {1'b0}};
18+
out <= 1'b0;
19+
end else begin
20+
counter_reg <= counter_reg + 1'b1;
21+
out <= (counter_reg == {(N) {1'b1}});
22+
end
23+
end
24+
25+
endmodule
26+
EOF
27+
28+
synth_fpga -config data/z1000/z1000_abspath.json -show_config
29+
select -assert-count 9 */t:dffr
30+
select -assert-count 11 */t:$lut
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# yosys -m wildebeest -s heartbeat-z1000-hardcode.ys
2+
read_verilog <<EOF
3+
module heartbeat #(
4+
parameter N = 8
5+
) (
6+
//inputs
7+
input clk, // clock
8+
input nreset, //async active low reset
9+
//outputs
10+
output reg out //heartbeat
11+
);
12+
13+
reg [N-1:0] counter_reg;
14+
15+
always @(posedge clk or negedge nreset) begin
16+
if (!nreset) begin
17+
counter_reg <= {(N) {1'b0}};
18+
out <= 1'b0;
19+
end else begin
20+
counter_reg <= counter_reg + 1'b1;
21+
out <= (counter_reg == {(N) {1'b1}});
22+
end
23+
end
24+
25+
endmodule
26+
EOF
27+
28+
synth_fpga -config data/z1010/z1010_abspath.json -show_config
29+
select -assert-count 9 */t:dffr
30+
select -assert-count 11 */t:$lut

0 commit comments

Comments
 (0)