Skip to content

Commit

Permalink
Set port attributes on exported blackboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
povik committed Jan 21, 2025
1 parent f6da8ac commit b1dded1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/blackboxes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void export_blackbox_to_rtlil(ast::Compilation &comp, const ast::InstanceSymbol
}

RTLIL::Module *mod = target->addModule(name);
transfer_attrs<ast::Symbol>((ast::Symbol&) inst.getDefinition(), mod);
transfer_attrs<const ast::Symbol>((ast::Symbol&) inst.getDefinition(), mod);

inst.body.visit(ast::makeVisitor([&](auto&, const ast::PortSymbol &port) {
if (!port.getSyntax() ||
Expand Down Expand Up @@ -299,6 +299,7 @@ void export_blackbox_to_rtlil(ast::Compilation &comp, const ast::InstanceSymbol

RTLIL::Wire *wire =
mod->addWire(RTLIL::escape_id(std::string{port.name}), port.getType().getBitstreamWidth());
transfer_attrs<const ast::Symbol>(port, wire);

switch (port.direction) {
case ast::ArgumentDirection::In:
Expand Down
2 changes: 1 addition & 1 deletion src/slang_frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void transfer_attrs(T &from, RTLIL::AttrObject *to)
}
}
}
template void transfer_attrs<ast::Symbol>(ast::Symbol &from, RTLIL::AttrObject *to);
template void transfer_attrs<const ast::Symbol>(const ast::Symbol &from, RTLIL::AttrObject *to);

#define assert_nonstatic_free(signal) \
for (auto bit : (signal)) \
Expand Down
18 changes: 18 additions & 0 deletions tests/various/stringattrs.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
logger -expect log "attribute \\foo1 \"bar1\"" 1
logger -expect log "attribute \\foo2 \"bar2\"" 1

read_slang --keep-hierarchy <<EOF
(* blackbox *)
module sm(
(* foo1="bar1" *)
input w
);
endmodule
module top(
(* foo2="bar2" *)
input y
);
sm sm1();
endmodule
EOF
dump

0 comments on commit b1dded1

Please sign in to comment.