9086/system/memory.v

48 lines
1.6 KiB
Coq
Raw Normal View History

/* memory.v - implementation of memory external to the 9086 CPU for testing purposes
This file is part of the 9086 project.
Copyright (c) 2023 Efthymios Kritikos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
2023-03-04 08:37:43 +00:00
// don't ask for the full 1MiB especially since we don't even have segmentation
/* verilator lint_off UNUSEDSIGNAL */
module doublemem(input [19:0] address,inout wire [15:0] data ,input rd,input wr,input BHE,input cs);
2023-03-04 08:37:43 +00:00
/* verilator lint_on UNUSEDSIGNAL */
reg [15:0] memory [0:32768];
2023-03-04 08:37:43 +00:00
initial begin
string boot_code;
if(!$value$plusargs("BOOT_CODE=%s",boot_code))begin
$display("No boot code specified. Please add +BOOT_CODE=<path> to your vvp args");
$finish;
end
$readmemh(boot_code, memory,0,32767);
end
2023-02-14 13:13:40 +00:00
2023-03-04 08:37:43 +00:00
assign data[7:0] = !address[0:0] & !rd & !cs ? memory[address[16:1]][15:8] : 8'hz;
2023-03-04 08:37:43 +00:00
assign data[15:8] = !BHE & !rd & !cs ? memory[address[16:1]][7:0] : 8'hz;
2023-02-14 13:13:40 +00:00
always @(negedge wr) begin
if(BHE==0)
2023-03-04 08:37:43 +00:00
memory[address[16:1]][7:0]<=data[15:8];
if(address[0]==0)
2023-03-04 08:37:43 +00:00
memory[address[16:1]][15:8]<=data[7:0];
2023-02-14 13:13:40 +00:00
end
endmodule