OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [cpu/] [toplevel/] [tb_ram.sv] - Blame information for rev 7

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 gdevic
//--------------------------------------------------------------
2
// Implements RAM Model for simulation
3
// Loads in a file "ram.hexdump" before execution.
4
//--------------------------------------------------------------
5
module ram (Address, Data, CS, WE, OE);
6
 
7
// Set this to 1 if you want debug printout on each RAM access
8
int debug = 0;
9
 
10
input [15:0] Address;
11
inout [7:0] Data;
12
input CS, WE, OE;
13
 
14
reg [7:0] Mem [0:1<<16];
15
 
16
// Return data at the specified memory address; return 0x76 for non-initialized memory
17
assign Data = (!CS && !OE) ? (Mem[Address]===8'hxx) ? 8'h76 : Mem[Address] : {8{1'bz}};
18
 
19
// Read the initial content of the RAM memory from a file
20
initial begin : init
21
    // Read the CPU code (address 0) to simulate
22
    $readmemh("ram.hexdump", Mem, 0);
23
end : init
24
 
25
always @(!CS && !OE) begin
26
    if (debug)
27
        $strobe("[ram] RD A=%H, D=%H", Address, Data);
28
end
29
 
30
always @(CS or WE)
31
    if (!CS && !WE) begin
32
        if (debug)
33
            $strobe("[ram] WR A=%H, D=%H", Address, Data);
34
        Mem[Address] = Data;
35
    end
36
 
37
always @(WE or OE)
38
    if (!WE && !OE)
39
        $display("[ram] error: OE and WE both active!");
40
 
41
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.