SE-VGA/old/se-vga.sv

124 lines
3.5 KiB
Systemverilog
Raw Normal View History

2021-04-07 04:15:48 +00:00
/******************************************************************************
* SE-VGA
* Top-level module
* techav
* 2021-04-06
******************************************************************************
* Pulls together all the smaller modules to form the SE-VGA adapter
*****************************************************************************/
2021-04-12 04:46:29 +00:00
module sevga (
2021-04-07 04:15:48 +00:00
input wire nReset, // System reset signal
input wire pixClk, // 25.175MHz pixel clock
output wire nhSync, // HSync signal
output wire nvSync, // VSync signal
output wire vidOut, // 1-bit Monochrome video signal
2021-04-12 04:46:29 +00:00
output logic [14:0] vramAddr, // VRAM Address bus
2021-04-07 04:15:48 +00:00
inout logic [7:0] vramData, // VRAM Data bus
output wire nvramOE, // VRAM Read strobe
output wire nvramWE, // VRAM Write strobe
2021-04-20 01:45:11 +00:00
output wire nvramCE0, // VRAM Main chip select signal
output wire nvramCE1, // VRAM Alt chip select signal
2021-04-07 04:15:48 +00:00
input logic [23:1] cpuAddr, // CPU Address bus
input logic [15:0] cpuData, // CPU Data bus
input wire ncpuAS, // CPU Address Strobe signal
input wire ncpuUDS, // CPU Upper Data Strobe signal
input wire ncpuLDS, // CPU Lower Data Strobe signal
input wire cpuRnW, // CPU Read/Write select signal
2021-04-12 04:46:29 +00:00
input logic [2:0] ramSize // Select installed RAM size
2021-04-07 04:15:48 +00:00
);
logic [9:0] hCount;
logic [9:0] vCount;
wire hActive;
wire hSEActive;
2021-04-12 04:46:29 +00:00
wire vActive;
wire vSEActive;
2021-04-18 19:31:05 +00:00
wire nvramWEpre; // VRAM Write signal from cpu snoop
2021-04-20 01:45:11 +00:00
wire nvramCE0pre;
wire nvramCE1pre;
wire vidBufSel;
2021-04-07 04:15:48 +00:00
2021-04-12 04:46:29 +00:00
logic [14:0] vidVramAddr;
logic [14:0] cpuVramAddr;
logic [7:0] vidVramData;
wire [7:0] cpuVramData;
2021-04-07 04:15:48 +00:00
// link module that generates all our timing signals
2021-04-08 03:50:46 +00:00
vgagen vgatiming(
.nReset(nReset),
.pixClk(pixClk),
.hCount(hCount),
.hActive(hActive),
.hSEActive(hSEActive),
.nhSync(nhSync),
.vCount(vCount),
.vActive(vActive),
.vSEActive(vSEActive),
.nvSync(nvSync)
);
2021-04-07 04:15:48 +00:00
// link module that fetches & outputs video data
2021-04-08 03:50:46 +00:00
vgaout vidvram(
.pixClock(pixClk),
.nReset(nReset),
.hCount(hCount),
.vCount(vCount),
.hSEActive(hSEActive),
.vSEActive(vSEActive),
2021-04-12 04:46:29 +00:00
.vramData(vidVramData),
2021-04-08 03:50:46 +00:00
.vramAddr(vidVramAddr),
.nvramOE(nvramOE),
.vidOut(vidOut)
);
2021-04-18 17:07:42 +00:00
// link module that snoops cpu writes
2021-04-08 03:50:46 +00:00
cpusnoop cpusnp(
.nReset(nReset),
.pixClock(pixClk),
2021-04-12 04:46:29 +00:00
.seq(hCount[2:0]),
2021-04-08 03:50:46 +00:00
.cpuAddr(cpuAddr),
.cpuData(cpuData),
.ncpuAS(ncpuAS),
.ncpuUDS(ncpuUDS),
.ncpuLDS(ncpuLDS),
.cpuRnW(cpuRnW),
.cpuClk(cpuClk),
2021-04-12 04:46:29 +00:00
.vramAddr(cpuVramAddr),
.vramDataOut(cpuVramData),
2021-04-17 20:41:53 +00:00
.nvramWE(nvramWEpre),
2021-04-20 01:45:11 +00:00
.nvramCE0(nvramCE0pre),
.nvramCE1(nvramCE1pre),
.vidBufSelOut(vidBufSel),
2021-04-12 04:46:29 +00:00
.ramSize(ramSize)
2021-04-08 03:50:46 +00:00
);
2021-04-07 04:15:48 +00:00
2021-04-08 03:50:46 +00:00
always_comb begin
// vramAddr muxing
2021-04-17 20:41:53 +00:00
if(nvramWEpre == 1'b0) begin
2021-04-08 03:50:46 +00:00
vramAddr <= cpuVramAddr;
2021-04-18 17:07:42 +00:00
end else if(nvramOE == 0) begin
2021-04-12 04:46:29 +00:00
vramAddr <= vidVramAddr;
2021-04-18 17:07:42 +00:00
end else begin
vramAddr <= 0;
2021-04-12 04:46:29 +00:00
end
end
always_comb begin
2021-04-17 20:41:53 +00:00
if(nvramWEpre == 1'b0) begin
2021-04-12 04:46:29 +00:00
vramData <= cpuVramData;
end else begin
vramData <= 8'bZZZZZZZZ;
2021-04-08 03:50:46 +00:00
end
2021-04-12 04:46:29 +00:00
vidVramData <= vramData;
2021-04-08 03:50:46 +00:00
end
2021-04-07 04:15:48 +00:00
2021-04-20 01:45:11 +00:00
assign nvramCE0 = (nvramWEpre | nvramCE0pre) & (nvramOE | vidBufSel);
assign nvramCE1 = (nvramWEpre | nvramCE1pre) & (nvramOE | ~vidBufSel);
2021-04-20 01:45:11 +00:00
2021-05-16 17:22:28 +00:00
//assign nvramWE = nvramWEpre | pixClk;
assign nvramWE = nvramWEpre;
2021-04-17 20:41:53 +00:00
2021-04-07 04:15:48 +00:00
endmodule