|
45 | 45 | #include "xls/ir/bits.h" |
46 | 46 | #include "xls/ir/channel.h" |
47 | 47 | #include "xls/ir/fileno.h" |
| 48 | +#include "xls/ir/channel.h" |
48 | 49 | #include "xls/ir/function.h" |
49 | 50 | #include "xls/ir/function_base.h" |
50 | 51 | #include "xls/ir/lsb_or_msb.h" |
@@ -1600,15 +1601,50 @@ absl::StatusOr<Operation*> translateProc(::xls::Proc& xls_proc, |
1600 | 1601 | // Channel Translation |
1601 | 1602 | //===----------------------------------------------------------------------===// |
1602 | 1603 |
|
| 1604 | +FlopKind convertFlopKind(::xls::FlopKind kind) { |
| 1605 | + switch (kind) { |
| 1606 | + case ::xls::FlopKind::kNone: |
| 1607 | + return FlopKind::kNone; |
| 1608 | + case ::xls::FlopKind::kFlop: |
| 1609 | + return FlopKind::kFlop; |
| 1610 | + case ::xls::FlopKind::kSkid: |
| 1611 | + return FlopKind::kSkid; |
| 1612 | + case ::xls::FlopKind::kZeroLatency: |
| 1613 | + return FlopKind::kZeroLatency; |
| 1614 | + } |
| 1615 | +} |
| 1616 | + |
1603 | 1617 | absl::Status translateChannel(::xls::Channel& xls_chn, OpBuilder& builder, |
1604 | 1618 | MLIRContext* ctx, TranslationState& state) { |
1605 | 1619 | auto chn = builder.create<xls::ChanOp>( |
1606 | 1620 | builder.getUnknownLoc(), |
1607 | 1621 | /*name=*/builder.getStringAttr(xls_chn.name()), |
1608 | 1622 | /*type=*/TypeAttr::get(translateType(xls_chn.type(), builder, ctx)), |
| 1623 | + /*fifo_config=*/nullptr, |
| 1624 | + /*input_flop_kind=*/nullptr, |
| 1625 | + /*output_flop_kind=*/nullptr, |
1609 | 1626 | /*send_supported=*/builder.getBoolAttr(xls_chn.CanSend()), |
1610 | 1627 | /*recv_supported=*/builder.getBoolAttr(xls_chn.CanReceive())); |
1611 | 1628 |
|
| 1629 | + if (auto xls_streaming_chn = |
| 1630 | + dynamic_cast<::xls::StreamingChannel*>(&xls_chn)) { |
| 1631 | + auto xls_ch_config = xls_streaming_chn->channel_config(); |
| 1632 | + if (auto xls_fifo_config = xls_ch_config.fifo_config()) { |
| 1633 | + chn.setFifoConfigAttr(FifoConfig::get( |
| 1634 | + ctx, xls_fifo_config->depth(), xls_fifo_config->bypass(), |
| 1635 | + xls_fifo_config->register_push_outputs(), |
| 1636 | + xls_fifo_config->register_pop_outputs())); |
| 1637 | + } |
| 1638 | + |
| 1639 | + if (auto xls_input_flop = xls_ch_config.input_flop_kind()) { |
| 1640 | + chn.setInputFlopKind(convertFlopKind(*xls_input_flop)); |
| 1641 | + } |
| 1642 | + |
| 1643 | + if (auto xls_output_flop = xls_ch_config.output_flop_kind()) { |
| 1644 | + chn.setOutputFlopKind(convertFlopKind(*xls_output_flop)); |
| 1645 | + } |
| 1646 | + } |
| 1647 | + |
1612 | 1648 | return state.setChannel(std::string(xls_chn.name()), |
1613 | 1649 | SymbolRefAttr::get(chn.getNameAttr())); |
1614 | 1650 | } |
|
0 commit comments