move the lil/csr conversion code into its own module