From e4ef199b8332ad19dfd468ee5ba28eff381cf9f2 Mon Sep 17 00:00:00 2001 From: "(Tim) Efthimis Kritikos" Date: Wed, 10 May 2023 08:35:14 +0100 Subject: [PATCH] Fixed a memory corruption bug --- system/memory.v | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/system/memory.v b/system/memory.v index b941eaf..dfbee72 100644 --- a/system/memory.v +++ b/system/memory.v @@ -38,10 +38,12 @@ assign data[7:0] = !address[0:0] & !rd & !cs ? memory[address[16:1]][15:8] : 8' assign data[15:8] = !BHE & !rd & !cs ? memory[address[16:1]][7:0] : 8'hz; always @(negedge wr) begin - if(BHE==0) - memory[address[16:1]][7:0]<=data[15:8]; - if(address[0]==0) - memory[address[16:1]][15:8]<=data[7:0]; + if( cs == 0 ) begin + if(BHE==0) + memory[address[16:1]][7:0]<=data[15:8]; + if(address[0]==0) + memory[address[16:1]][15:8]<=data[7:0]; + end end endmodule