File: ssram.v

package info (click to toggle)
uhd 3.13.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 207,120 kB
  • sloc: cpp: 167,245; ansic: 86,841; vhdl: 53,420; python: 40,839; xml: 13,167; tcl: 5,688; makefile: 2,167; sh: 1,719; pascal: 230; csh: 94; asm: 20; perl: 11
file content (38 lines) | stat: -rw-r--r-- 844 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

// Model of Pipelined [ZBT] Synchronous SRAM

module ssram(clock,addr,data,wen,ce);
   parameter addrbits = 19;
   parameter depth = 524288;

   input clock;
   input [addrbits-1:0] addr;
   inout [35:0] data;
   input wen;
   input ce;

   reg [35:0] ram [0:depth-1];
   
   reg read_d1,read_d2;
   reg write_d1,write_d2;
   reg [addrbits-1:0] addr_d1,addr_d2;
   
   always @(posedge clock)
     begin
	read_d1 <= #1 ce & ~wen;
	write_d1 <= #1 ce & wen;
	addr_d1 <= #1 addr;
	read_d2 <= #1 read_d1;
	write_d2 <= #1 write_d1;
	addr_d2 <= #1 addr_d1;
	if(write_d2)
	  ram[addr_d2] = data;
     end // always @ (posedge clock)

   data = (ce & read_d2) ? ram[addr_d2] : 36'bz;

   always @(posedge clock)
     if(~ce & (write_d2 | write_d1 | wen))
       $display("$time ERROR:  RAM CE not asserted during write cycle");
   
endmodule // ssram