Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bool channels not supported? #3

Open
fhuemer opened this issue Jul 17, 2023 · 4 comments
Open

bool channels not supported? #3

fhuemer opened this issue Jul 17, 2023 · 4 comments

Comments

@fhuemer
Copy link

fhuemer commented Jul 17, 2023

I think there might be a bug when using bool channels:
Consider the following act code:

defproc test(chan?(bool) a; chan!(bool) b)
{
	dataflow {
		a -> [1] b
	}
}

This produces the following chp code:

defproc test (chan(bool)? a; chan(bool)! b)
{
chan(int<1>) b_bufIn;
func_0W1W1 b_bufIn_inst(a, b_bufIn);
lib::onebuf<1> b_inst(b_bufIn, b);
}

It keeps the bool channels for the interface, but then uses int<1> channels internally. Loading this code using interact's act:read command then yields:

ERROR: File `test_chp.act', line 9, col 31
	Typechecking failed on connection! (position: 0)
	Types `chan(int<1>)?' and `chan(bool)?' are not compatible
@rmanohar
Copy link
Member

Ah yes, thanks. I've known about this long-standing bug. I will work on getting this fixed shortly.

@rmanohar
Copy link
Member

I pushed an initial fix for this issue.

@fhuemer
Copy link
Author

fhuemer commented Aug 4, 2023

Thank you for the quick fix. I recompiled the new version and the CHP Code now seems to be correct. However, now I run into another issue, related to the conversion function int_to_bool, when using chp2prs on the generated CHP code.

CHP code:

defproc test (chan(bool)? a; chan(bool)! b)
{
chan(int<1>) _fromint_b;
chan(int<1>) _toint_a;
chan(int<1>) _fromint_b_bufIn;
func_0W1W1 _fromint_b_bufIn_inst(_toint_a, _fromint_b_bufIn);
lib::onebuf<1> _fromint_b_inst(_fromint_b_bufIn, _fromint_b);
lib::int_to_bool _xint2b(_fromint_b,b);
lib::bool_to_int _xinta(a,_toint_a);
}

When I then run chp2prs test_chp.act test test_prs.act and then try to load the generated design using act:read test_prs.act I run into the following issue:

interact> act:read test_prs.act
ERROR: File `test_prs.act', line 25, col 40
	The identifier `var_in' does not exist in the current scope

The portion of test_prs.act looks like that:

defproc sdt__0_0std_0_0dflow_0_0lib_0_0int_to_bool <: ::std::dflow::lib::int_to_bool ()
+{
  syn::sdtboolchan out;
  syn::sdtchan<1> in;
}
{
 refine {
   syn::mux_bool_outport<1> out_muxo(out);
   syn::muxinport<1,1> in_muxi(in);
   a1of1 c0;
   syn::expr::const<1,1> e0;
   a1of1 c1;
   a1of1 c2;
   syn::expr::const<1,1> e1;
 syn::sdtchan_to_probe<1> s_0(in);
 syn::probed_clause<1,{1},1> s_1({e1.out},{s_0.probe});
   a1of1 c3;
   syn::probed_select<1,1> s_2(c2,{e1.out},{s_1.out},{c3});
   a1of1 c4;
  syn::expr::nullint<1> e2(var_in.out[0]); /* >>>>>> LINE 25 <<<<<< */
   syn::expr::const<1,0> e3;
   syn::expr::blk0 e5(e3.out, e2.out);
   syn::transfer<1> s_3(c4, e5.out,out_muxo.m[0]);
   a1of1 c5;
   syn::recvport_drop<1> s_4(c5,in_muxi.m[1]);
   syn::semi<3> s_5(c1,{c2,c4,c5});
   syn::loop<1> s_6(c0,{e0.out},{c1});
/*--- connect reset to go signal ---*/
   a1of1 c6;
   syn::sinit s6 (c0);
 }
}

@rmanohar
Copy link
Member

Thanks for the detailed report. chp2prs is a relatively old tool, and we have added some CHP extensions since it was originally written... I will add a work-around to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants