showing the same error
Error (10500): VHDL syntax error at req.vhd(556) near text "when";
expecting ")", or ","
Error (10500): VHDL syntax error at req.vhd(556) near text ")";
expecting ";"
I can only read VHDL, but not write it, therefore I can´t give you a code solution.
But the key is to think as a digital circuit, not as a software solution.
If you know how to draw your logic as a schematic with digital logic ICs, then you should be able to write the VHDL code.
Maybe a truth table can help.