|
|
|
|
|
|
|
|
|
|
|
|
Single Port RAM Asynchronous Read/Write
|
|
|
|
|
|
1 //===========================================
2 // Function : Asynchronous read write RAM
3 // Coder : Deepak Kumar Tala
4 // Date : 1-Nov-2005
5 //===========================================
6 module ram_sp_ar_aw #(parameter DATA_WIDTH = 8,
7 parameter ADDR_WIDTH = 8,
8 parameter RAM_DEPTH = (1 << ADDR_WIDTH))(
9 input wire [ADDR_WIDTH-1:0] address , // Address Input
10 inout wire [DATA_WIDTH-1:0] data , // Data bi-directional
11 input wire cs , // Chip Select
12 input wire we , // Write Enable/Read Enable
13 input wire oe // Output Enable
14 );
15 //--------------Internal variables----------------
16 reg [DATA_WIDTH-1:0] data_out ;
17 // Use Associative array to save memory footprint
18 typedef reg [ADDR_WIDTH-1:0] mem_addr;
19 reg [DATA_WIDTH-1:0] mem [mem_addr];
20
21 //--------------Code Starts Here------------------
22 // Tri-State Buffer control
23 // output : When we = 0, oe = 1, cs = 1
24 assign data = (cs && oe && ! we) ? data_out : 8'bz;
25
26 // Memory Write Block
27 // Write Operation : When we = 1, cs = 1
28 always_latch
29 begin : MEM_WRITE
30 if ( cs && we ) begin
31 mem[address] = data;
32 end
33 end
34
35 // Memory Read Block
36 // Read Operation : When we = 0, oe = 1, cs = 1
37 always_latch
38 begin : MEM_READ
39 if (cs && ! we && oe) begin
40 data_out = mem[address];
41 end
42 end
43
44 endmodule // End of Module ram_sp_ar_aw
You could download file sv_examples here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|