@@ -1378,5 +1378,86 @@ TEST_F(TranslatorMemoryTest, Size) {
1378
1378
content);
1379
1379
}
1380
1380
1381
+ TEST_F (TranslatorMemoryTest, PassMemoryAliased) {
1382
+ const std::string content = R"(
1383
+ using StoreType = __xls_memory<int, 32>;
1384
+
1385
+ void sub(StoreType& memory,
1386
+ __xls_channel<int>& out,
1387
+ int addr) {
1388
+ const int val = memory[addr];
1389
+ out.write(3*val);
1390
+ }
1391
+
1392
+ #pragma hls_top
1393
+ void my_package(__xls_channel<int>& in,
1394
+ StoreType& memory,
1395
+ __xls_channel<int>& out) {
1396
+ const int addr = in.read();
1397
+ sub(memory, out, addr);
1398
+ })" ;
1399
+
1400
+ IOTest (
1401
+ content,
1402
+ /* inputs=*/ {IOOpTest (" in" , 7 , true ), IOOpTest (" memory__read" , 10 , true )},
1403
+ /* outputs=*/
1404
+ {IOOpTest (" memory__read" , xls::Value (xls::UBits (7 , 5 )), true ),
1405
+ IOOpTest (" out" , 30 , true )});
1406
+ }
1407
+
1408
+ TEST_F (TranslatorMemoryTest, PassMemoryTypedef) {
1409
+ const std::string content = R"(
1410
+ typedef __xls_memory<int, 32> StoreType;
1411
+
1412
+ void sub(StoreType& memory,
1413
+ __xls_channel<int>& out,
1414
+ int addr) {
1415
+ const int val = memory[addr];
1416
+ out.write(3*val);
1417
+ }
1418
+
1419
+ #pragma hls_top
1420
+ void my_package(__xls_channel<int>& in,
1421
+ StoreType& memory,
1422
+ __xls_channel<int>& out) {
1423
+ const int addr = in.read();
1424
+ sub(memory, out, addr);
1425
+ })" ;
1426
+
1427
+ IOTest (
1428
+ content,
1429
+ /* inputs=*/ {IOOpTest (" in" , 7 , true ), IOOpTest (" memory__read" , 10 , true )},
1430
+ /* outputs=*/
1431
+ {IOOpTest (" memory__read" , xls::Value (xls::UBits (7 , 5 )), true ),
1432
+ IOOpTest (" out" , 30 , true )});
1433
+ }
1434
+
1435
+ TEST_F (TranslatorMemoryTest, PassChannelAliased) {
1436
+ const std::string content = R"(
1437
+ using ChannelType = __xls_channel<int>;
1438
+
1439
+ void sub(__xls_memory<int, 32>& memory,
1440
+ ChannelType& out,
1441
+ int addr) {
1442
+ const int val = memory[addr];
1443
+ out.write(3*val);
1444
+ }
1445
+
1446
+ #pragma hls_top
1447
+ void my_package(__xls_channel<int>& in,
1448
+ __xls_memory<int, 32>& memory,
1449
+ ChannelType& out) {
1450
+ const int addr = in.read();
1451
+ sub(memory, out, addr);
1452
+ })" ;
1453
+
1454
+ IOTest (
1455
+ content,
1456
+ /* inputs=*/ {IOOpTest (" in" , 7 , true ), IOOpTest (" memory__read" , 10 , true )},
1457
+ /* outputs=*/
1458
+ {IOOpTest (" memory__read" , xls::Value (xls::UBits (7 , 5 )), true ),
1459
+ IOOpTest (" out" , 30 , true )});
1460
+ }
1461
+
1381
1462
} // namespace
1382
1463
} // namespace xlscc
0 commit comments