5454#include " xls/common/status/matchers.h"
5555#include " xls/common/status/ret_check.h"
5656#include " xls/common/status/status_macros.h"
57- #include " xls/estimators/delay_model/delay_estimator.h"
5857#include " xls/interpreter/block_evaluator.h"
5958#include " xls/interpreter/block_interpreter.h"
6059#include " xls/ir/bits.h"
@@ -97,6 +96,7 @@ using ::testing::ElementsAre;
9796using ::testing::Eq;
9897using ::testing::Ge;
9998using ::testing::HasSubstr;
99+ using ::testing::IsEmpty;
100100using ::testing::Optional;
101101using ::testing::Pair;
102102using ::testing::SizeIs;
@@ -282,7 +282,7 @@ TEST_F(BlockConversionTest, SimpleFunction) {
282282 m::OutputPort (" out" , m::Add (m::InputPort (" x" ), m::InputPort (" y" ))));
283283}
284284
285- TEST_F (BlockConversionTest, DISABLED_SimpleFunctionWithNamedOutput ) {
285+ TEST_F (BlockConversionTest, SimpleFunctionWithNamedOutput ) {
286286 auto p = CreatePackage ();
287287 FunctionBuilder fb (TestName (), p.get ());
288288 BValue x = fb.Param (" x" , p->GetBitsType (32 ));
@@ -331,7 +331,7 @@ TEST_F(BlockConversionTest, ZeroWidthInputsAndOutput) {
331331 EXPECT_EQ (block->GetPorts ().size (), 4 );
332332}
333333
334- TEST_F (BlockConversionTest, DISABLED_SimplePipelinedFunction ) {
334+ TEST_F (BlockConversionTest, SimplePipelinedFunction ) {
335335 auto p = CreatePackage ();
336336 FunctionBuilder fb (TestName (), p.get ());
337337 BValue x = fb.Param (" x" , p->GetBitsType (32 ));
@@ -348,11 +348,13 @@ TEST_F(BlockConversionTest, DISABLED_SimplePipelinedFunction) {
348348 SchedulingOptions ().pipeline_stages (3 )));
349349
350350 EXPECT_THAT (GetOutputPort (block),
351- m::OutputPort (m::Neg (m::Register (m::Not (m::Register (
352- m::Add (m::InputPort (" x" ), m::InputPort (" y" ))))))));
351+ m::OutputPort (m::Neg (m::Register (m::Not (
352+ m::Register (m::Add (m::InputPort (" x" ), m::InputPort (" y" ))))))))
353+ << " \n\n IR:\n "
354+ << block->DumpIr ();
353355}
354356
355- TEST_F (BlockConversionTest, DISABLED_TrivialPipelinedFunctionNoFlopping ) {
357+ TEST_F (BlockConversionTest, TrivialPipelinedFunctionNoFlopping ) {
356358 auto p = CreatePackage ();
357359 FunctionBuilder fb (TestName (), p.get ());
358360 BValue x = fb.Param (" x" , p->GetBitsType (32 ));
@@ -373,7 +375,7 @@ TEST_F(BlockConversionTest, DISABLED_TrivialPipelinedFunctionNoFlopping) {
373375 m::Add (m::InputPort (" x" ), m::InputPort (" y" ))))))));
374376}
375377
376- TEST_F (BlockConversionTest, DISABLED_TrivialPipelinedFunctionFloppedInputs ) {
378+ TEST_F (BlockConversionTest, TrivialPipelinedFunctionFloppedInputs ) {
377379 auto p = CreatePackage ();
378380 FunctionBuilder fb (TestName (), p.get ());
379381 BValue x = fb.Param (" x" , p->GetBitsType (32 ));
@@ -395,7 +397,7 @@ TEST_F(BlockConversionTest, DISABLED_TrivialPipelinedFunctionFloppedInputs) {
395397 m::Register (m::InputPort (" x" )), m::Register (m::InputPort (" y" )))))))));
396398}
397399
398- TEST_F (BlockConversionTest, DISABLED_TrivialPipelinedFunctionFloppedOutputs ) {
400+ TEST_F (BlockConversionTest, TrivialPipelinedFunctionFloppedOutputs ) {
399401 auto p = CreatePackage ();
400402 FunctionBuilder fb (TestName (), p.get ());
401403 BValue x = fb.Param (" x" , p->GetBitsType (32 ));
@@ -416,7 +418,7 @@ TEST_F(BlockConversionTest, DISABLED_TrivialPipelinedFunctionFloppedOutputs) {
416418 m::Add (m::InputPort (" x" ), m::InputPort (" y" )))))))));
417419}
418420
419- TEST_F (BlockConversionTest, DISABLED_TrivialPipelinedFunctionFloppedIo ) {
421+ TEST_F (BlockConversionTest, TrivialPipelinedFunctionFloppedIo ) {
420422 auto p = CreatePackage ();
421423 FunctionBuilder fb (TestName (), p.get ());
422424 BValue x = fb.Param (" x" , p->GetBitsType (32 ));
@@ -438,7 +440,7 @@ TEST_F(BlockConversionTest, DISABLED_TrivialPipelinedFunctionFloppedIo) {
438440 m::Register (m::InputPort (" y" ))))))))));
439441}
440442
441- TEST_F (BlockConversionTest, DISABLED_ZeroWidthPipeline ) {
443+ TEST_F (BlockConversionTest, ZeroWidthPipeline ) {
442444 auto p = CreatePackage ();
443445 FunctionBuilder fb (TestName (), p.get ());
444446 BValue x = fb.Param (" x" , p->GetTupleType ({}));
@@ -454,7 +456,28 @@ TEST_F(BlockConversionTest, DISABLED_ZeroWidthPipeline) {
454456 " clk" ),
455457 SchedulingOptions ().pipeline_stages (3 )));
456458
457- EXPECT_EQ (block->GetRegisters ().size (), 4 );
459+ EXPECT_THAT (block->GetRegisters (), IsEmpty ());
460+ }
461+
462+ TEST_F (BlockConversionTest, ZeroWidthPipelineWithValidControl) {
463+ auto p = CreatePackage ();
464+ FunctionBuilder fb (TestName (), p.get ());
465+ BValue x = fb.Param (" x" , p->GetTupleType ({}));
466+ BValue y = fb.Param (" y" , p->GetBitsType (0 ));
467+ XLS_ASSERT_OK_AND_ASSIGN (Function * f,
468+ fb.BuildWithReturnValue (fb.Tuple ({x, y})));
469+
470+ XLS_ASSERT_OK_AND_ASSIGN (
471+ Block * block,
472+ ConvertToBlock (f,
473+ CodegenOptions ()
474+ .flop_inputs (false )
475+ .flop_outputs (false )
476+ .clock_name (" clk" )
477+ .valid_control (" inputs_valid" , " output_valid" ),
478+ SchedulingOptions ().pipeline_stages (3 )));
479+
480+ EXPECT_THAT (block->GetRegisters (), SizeIs (2 ));
458481}
459482
460483// Verifies that an implicit token, as generated by the DSLX IR converter, is
@@ -473,11 +496,10 @@ fn __itok__implicit_token__main(__token: token, __activated: bits[1]) ->
473496fn __implicit_token__main() -> () {
474497 after_all.9: token = after_all(id=9)
475498 literal.10: bits[1] = literal(value=1, id=10)
476- invoke.11: (token, ()) = invoke(after_all.9, literal.10,
477- to_apply=__itok__implicit_token__main, id=11) tuple_index.12: token =
478- tuple_index(invoke.11, index=0, id=12) invoke.13: (token, ()) =
479- invoke(tuple_index.12, literal.10, to_apply=__itok__implicit_token__main,
480- id=13) ret tuple_index.14: () = tuple_index(invoke.13, index=1, id=14)
499+ invoke.11: (token, ()) = invoke(after_all.9, literal.10, to_apply=__itok__implicit_token__main, id=11)
500+ tuple_index.12: token = tuple_index(invoke.11, index=0, id=12)
501+ invoke.13: (token, ()) = invoke(tuple_index.12, literal.10, to_apply=__itok__implicit_token__main, id=13)
502+ ret tuple_index.14: () = tuple_index(invoke.13, index=1, id=14)
481503}
482504 )" ;
483505 XLS_ASSERT_OK_AND_ASSIGN (auto p, Parser::ParsePackage (kIrText ));
@@ -489,7 +511,7 @@ fn __implicit_token__main() -> () {
489511 XLS_ASSERT_OK (VerifyBlock (block));
490512}
491513
492- TEST_F (BlockConversionTest, DISABLED_SimpleProc ) {
514+ TEST_F (BlockConversionTest, SimpleProc ) {
493515 const std::string ir_text = R"( package test
494516
495517chan in(bits[32], id=0, kind=single_value, ops=receive_only)
@@ -513,7 +535,9 @@ proc my_proc(my_state: (), init={()}) {
513535 Block * block,
514536 ConvertToBlock (proc, codegen_options ().generate_combinational (true )));
515537 EXPECT_THAT (FindNode (" out" , block),
516- m::OutputPort (" out" , m::Neg (m::InputPort (" in" ))));
538+ m::OutputPort (" out" , m::Neg (m::InputPort (" in" ))))
539+ << " \n\n IR:\n "
540+ << block->DumpIr ();
517541}
518542
519543TEST_F (BlockConversionTest, DISABLED_StreamingChannelMetadataForSimpleProc) {
@@ -6394,7 +6418,7 @@ TEST_F(ProcConversionTestFixture,
63946418 }
63956419}
63966420
6397- TEST_F (ProcConversionTestFixture, DISABLED_SimpleFunctionWithProcsPresent ) {
6421+ TEST_F (ProcConversionTestFixture, SimpleFunctionWithProcsPresent ) {
63986422 XLS_ASSERT_OK_AND_ASSIGN (std::unique_ptr<Package> p,
63996423 CreateMultiProcPackage (/* with_functions=*/ true ));
64006424 XLS_ASSERT_OK_AND_ASSIGN (Function * f0, p->GetFunction (" f0" ));
0 commit comments