A man killed his neighbour in a "savage and sustained" attack by stabbing him 25 times, a court heard.
Jeffrey Barry, 56, attacked Kurdish refugee Kamil Ahmad in his Bristol flat on 6 July 2016.
Bristol Crown Court heard that Mr Barry had previously phoned police claiming Mr Ahmad was a rapist and a terrorist.
Mr Barry, who has paranoid schizophrenia, denies murder but admits manslaughter by diminished responsibility.
A post-mortem examination found Mr Ahmad's body had been severely mutilated during the attack, with his penis being cut off after he died.
Knocked on door
The court was told Mr Barry had been racist towards Mr Ahmad in the past and had previously assaulted him in December 2013.
The pair both lived in a supported housing unit for adults in Wells Road.
Adam Vaitilingam QC, prosecuting said the attack happened after Mr Barry knocked on Mr Ahmad's door.
"[Mr Ahmed] was immediately subjected to a savage and sustained attack by the defendant, who was carrying a knife," he said.
"The defendant had taken a dislike to Kamil Ahmad long before he killed him."
He said Mr Barry had written notes stating his intention to kill people in the shared accommodation block.
On 24 May last year, he is reported to have told support workers he wanted to be "notorious and murder a member of the public", allegedly adding: "Kamil would be top of my list."
On the night of the killing Mr Barry was seen on CCTV knocking on Mr Ahmad's door at 01:30 BST. Later footage showed him exiting the flat, covered in blood, at 02:15 BST.
He then dialled 999 saying he had killed Mr Ahmad. Psychiatrists disagree on whether Barry had paranoid schizophrenia when he killed Mr Ahmad, the court heard.
The trial continues.