Skip to content

Commit 3f1b2ad

Browse files
Sean Purser-Haskellcopybara-github
authored andcommitted
Add test case from old bug report.
PiperOrigin-RevId: 612918070
1 parent 59b150f commit 3f1b2ad

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

xls/contrib/xlscc/unit_tests/translator_logic_test.cc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,54 @@ TEST_F(TranslatorLogicTest, ForUnrollShortCircuitClass2) {
15941594
Run({{"a", 1}, {"b", 20}}, 4L * 20L, content);
15951595
}
15961596

1597+
TEST_F(TranslatorLogicTest, ForPipelinedConstantPropagation) {
1598+
const std::string content = R"(
1599+
#pragma hls_top
1600+
void foo(__xls_channel<int>& in,
1601+
__xls_channel<int>& out) {
1602+
int a = in.read();
1603+
1604+
const short max_iters = 5;
1605+
1606+
#pragma hls_pipeline_init_interval 1
1607+
for(long i=1;i<=4;++i) {
1608+
#pragma hls_unroll yes
1609+
for(int j=0;j<max_iters;++j) {
1610+
a += i;
1611+
}
1612+
}
1613+
1614+
out.write(a);
1615+
})";
1616+
1617+
HLSBlock block_spec;
1618+
{
1619+
block_spec.set_name("foo");
1620+
1621+
HLSChannel* ch_in = block_spec.add_channels();
1622+
ch_in->set_name("in");
1623+
ch_in->set_is_input(true);
1624+
ch_in->set_type(FIFO);
1625+
1626+
HLSChannel* ch_out1 = block_spec.add_channels();
1627+
ch_out1->set_name("out");
1628+
ch_out1->set_is_input(false);
1629+
ch_out1->set_type(FIFO);
1630+
}
1631+
1632+
absl::flat_hash_map<std::string, std::list<xls::Value>> inputs;
1633+
inputs["in"] = {xls::Value(xls::SBits(80, 32)),
1634+
xls::Value(xls::SBits(100, 32))};
1635+
1636+
{
1637+
absl::flat_hash_map<std::string, std::list<xls::Value>> outputs;
1638+
outputs["out"] = {xls::Value(xls::SBits(80 + 5 * 10, 32)),
1639+
xls::Value(xls::SBits(100 + 5 * 10, 32))};
1640+
1641+
ProcTest(content, block_spec, inputs, outputs, /* min_ticks = */ 8);
1642+
}
1643+
}
1644+
15971645
TEST_F(TranslatorLogicTest, ForUnrollMultiCondBreak) {
15981646
std::string_view content = R"(
15991647
long long my_package(long long a, long long b) {

0 commit comments

Comments
 (0)