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

Bug with DFG to MLIR HLS generation #12

Open
gcallanan opened this issue May 27, 2024 · 0 comments
Open

Bug with DFG to MLIR HLS generation #12

gcallanan opened this issue May 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@gcallanan
Copy link

I have a bug where the hls mlir file is not generating correctly under some conditions:

I have the following main.mlir file

dfg.process @Temp
	inputs(%In: i32)
	outputs(%Out: i32)
{
	dfg.loop inputs(%In: i32)
	{
		%l_t1__1_d0_0 = dfg.pull %In : i32
		%l_a__3_d0_0 = arith.constant 0 : i32
		dfg.push(%l_t1__1_d0_0) %Out : i32
	}

}

func.func @top(%In: i32) -> (i32)
{
	%queue_from_In, %queue_to_temp_In = dfg.channel(5) : i32
	%queue_from_temp_Out, %queue_to_Out = dfg.channel(5) : i32
	dfg.push(%In) %queue_from_In : i32
	dfg.instantiate @Temp // Instance name: temp
		inputs(%queue_to_temp_In)
		outputs(%queue_from_temp_Out) :
		(i32) -> (i32)
	%Out = dfg.pull %queue_to_Out : i32
	func.return %Out: i32
}

Which I build with the command: dfg-opt main.mlir --convert-std-to-circt --convert-dfg-to-circt --convert-fsm-to-sv --lower-seq-to-sv --export-split-verilog

This generates the following hls_Temp_calc.mlir:

"func.func"() <{function_type = (i32) -> (), sym_name = "hls_Temp_calc"}> ({
^bb0(%arg5: i32):
  %6 = "arith.constant"() <{value = 0 : i32}> : () -> i32
  "func.return"() : () -> ()
}) : () -> ()

and then throws an error: dfg-opt: /home/gareth/software-repos/mlir_related/dfg-mlir-240522/circt/llvm/llvm/include/llvm/ADT/ArrayRef.h:443: T &llvm::MutableArrayRef<mlir::BlockArgument>::operator[](size_t) const [T = mlir::BlockArgument]: Assertion Index < this->size() && "Invalid index!"' failed..

If I comment out the line: %l_a__3_d0_0 = arith.constant 0 : i32 then things seem to work. For context, I am default initializing a variable to 0 and then assigning a token from dfg.pull from that node, so the l_a__3_d0_0 operand ends up never getting used. Its not common but can happen depending on the code compiled. It seems strange that an unused operation would cause such a crash.

@HahaLan97 HahaLan97 added the bug Something isn't working label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants