vram: move VRAM to VRAMCore, in prep for arbitrated VRAM

This commit is contained in:
David Anderson 2024-09-08 09:26:59 -07:00
parent 69b7ce7f9e
commit 2760bad965
2 changed files with 17 additions and 15 deletions

View File

@ -1,12 +1,12 @@
package Top;
import VRAM::*;
import VRAMCore::*;
import ECP5_RAM::*;
import TriState::*;
(* synthesize *)
module mkTop(VRAM);
let _ret <- mkVRAM(112);
module mkTop(VRAMCore);
let _ret <- mkVRAMCore(112);
return _ret;
endmodule

View File

@ -1,5 +1,6 @@
package VRAM;
package VRAMCore;
import Connectable::*;
import GetPut::*;
import ClientServer::*;
import DReg::*;
@ -15,11 +16,12 @@ import ECP5_RAM::*;
export VRAMAddr;
export VRAMData;
export mkVRAM;
export VRAMRequest;
export VRAMResponse;
export VRAMClient;
export VRAMServer;
export VRAM;
export VRAMCore;
export mkVRAMCore;
typedef Bit#(8) VRAMData;
@ -133,30 +135,30 @@ typedef struct {
typedef Server#(VRAMRequest, VRAMResponse) VRAMServer;
typedef Client#(VRAMRequest, VRAMResponse) VRAMClient;
interface VRAM;
interface VRAMCore;
interface VRAMServer portA;
interface VRAMServer portB;
endinterface
// mkVRAM creates a dual port VRAM of the specified size, using ECP5
// EBR memory primitives. The memory size must be a multiple of 4KiB,
// with a maximum of 128KiB.
// mkVRAMCore creates a dual port VRAM of the specified size, using
// ECP5 EBR memory primitives. The memory size must be a multiple of
// 4KiB, with a maximum of 128KiB.
//
// The returned VRAM servers implement flow control. As long as
// The returned VRAMCore servers implement flow control. As long as
// responses are processed as soon as they're available, each port can
// process one memory operation per cycle.
//
// The VRAM does not prevent write-write or write-read conflicts
// The VRAMCore does not prevent write-write or write-read conflicts
// between the ports. The outcome of a simultaneous write to the same
// address is unspecified, as is the read output in a simultaneous
// read and write of the same address. The caller must use external
// arbitration to avoid such accesses.
module mkVRAM(Integer num_kilobytes, VRAM ifc);
module mkVRAMCore(Integer num_kilobytes, VRAMCore ifc);
if (num_kilobytes > 128)
error("maximum VRAM size is 128KiB");
error("maximum VRAMCore size is 128KiB");
let num_bytes = num_kilobytes*1024;
if (num_bytes % 4096 != 0)
error("VRAM must be a multiple of 4096b");
error("VRAMCore must be a multiple of 4096b");
let num_byterams = num_bytes/4096;
let num_arrays = ceil(fromInteger(num_byterams) / 8);