Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extract syntax #10

Merged
merged 4 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions yosys-plugin/churchroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ struct LakeroadWorker
// The let-bound ID string of the expression to extract from.
auto extract_from_expr = get_expression_for_signal(sigmap(sig.chunks()[0].wire), -1);
auto new_id = get_new_id_str();
auto extract_expr = stringf("(Extract %d %d %s)", (chunk.offset + chunk.width - 1) + chunk.wire->start_offset,
auto extract_expr = stringf("(Op1 (Extract %d %d) %s)", (chunk.offset + chunk.width - 1) + chunk.wire->start_offset,
chunk.offset + chunk.wire->start_offset, extract_from_expr.c_str());

auto let_expr = let(new_id, extract_expr);
Expand All @@ -1404,7 +1404,7 @@ struct LakeroadWorker
if (to_width < GetSize(sig))
{
auto new_id = get_new_id_str();
auto extend_expr = stringf("(Extract %d %d %s)", to_width - 1, 0, out_expr.c_str());
auto extend_expr = stringf("(Op1 (Extract %d %d) %s)", to_width - 1, 0, out_expr.c_str());
f << let(new_id, extend_expr) << "\n";
out_expr = new_id;
}
Expand Down
2 changes: 1 addition & 1 deletion yosys-plugin/tests/example.ys
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ EOF
write_lakeroad

# CHECK: (let v0 (Wire "v0" 2))
# CHECK: (let v1 (Extract 0 0 v0))
# CHECK: (let v1 (Op1 (Extract 0 0) v0))
# CHECK: (let v2 (Wire "v2" 1))
# CHECK: (let v3 (Wire "v3" 2))
# CHECK: (union v0 (Op2 (And) v3 v2))
Expand Down
12 changes: 6 additions & 6 deletions yosys-plugin/tests/permuter.sv
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ endmodule
// CHECK: (let v9 (Wire "v9" 16))
// CHECK: (let v10 (Wire "v10" 16))
// CHECK: (union v1 (Op2 (Or) v5 v4))
// CHECK: (let v11 (Extract 7 4 v9))
// CHECK: (let v12 (Extract 3 0 v9))
// CHECK: (let v13 (Extract 15 12 v9))
// CHECK: (let v14 (Extract 11 8 v9))
// CHECK: (let v11 (Op1 (Extract 7 4) v9))
// CHECK: (let v12 (Op1 (Extract 3 0) v9))
// CHECK: (let v13 (Op1 (Extract 15 12) v9))
// CHECK: (let v14 (Op1 (Extract 11 8) v9))
// CHECK: (let v15 (Concat v11 v12))
// CHECK: (let v16 (Concat v15 v13))
// CHECK: (let v17 (Concat v16 v14))
// CHECK: (union v2 (Op3 (Mux) v6 v9 v17))
// CHECK: (union v0 (Op3 (Mux) v1 v2 v3))
// CHECK: (let v18 (Extract 15 8 v9))
// CHECK: (let v19 (Extract 7 0 v9))
// CHECK: (let v18 (Op1 (Extract 15 8) v9))
// CHECK: (let v19 (Op1 (Extract 7 0) v9))
// CHECK: (let v20 (Concat v18 v19))
// CHECK: (let v21 (Concat v13 v14))
// CHECK: (let v22 (Concat v21 v11))
Expand Down