Syntax error : System verilog keyword 'void' is not expected to b used in this context

The first error is that you are missing the ‘function’ keyword in the declaration of main().
Also I’m not sure if your assignment to mode1 is correct.