OpenCores
URL https://opencores.org/ocsvn/sv_dir_tb/sv_dir_tb/trunk

Subversion Repositories sv_dir_tb

[/] [sv_dir_tb/] [trunk/] [examples/] [internal/] [sv/] [mem_mod.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sckoarn
 
2
 
3
module mem_mod (
4
  clk,   // input clock
5
  addr,  // address
6
  datai,  // data in
7
  datao,  // data out
8
  sel,   // select
9
  w_n   // Write  not
10
);
11
 
12
 
13
  //input         rst_n;
14
  input         clk;
15
  input  [31:0] addr;
16
  input  [31:0] datai;
17
  output [31:0] datao;
18
  input         w_n;
19
  input         sel;
20
 
21
  reg [31:0] mem[0:64];
22
  reg [31:0] dout;
23
  reg [6:0]  aidx;
24
 
25
  assign datao = dout;
26
 
27
  integer i;
28
 
29
  initial begin
30
    i = 0;
31
    while (i < 64) begin
32
      mem[i] = 0;
33
      i = i + 1;
34
    end
35
  end
36
 
37
 
38
  always @(posedge clk) begin
39
    if (addr[15:0] < 16'h0040 && sel == 1'b1) begin
40
      aidx = addr[6:0];
41
      if (w_n == 1'b1) begin
42
        dout <= mem[aidx];
43
      end else if (w_n == 1'b0) begin
44
        mem[aidx] <= datai;
45
      end
46
    end else if (sel == 1'b0) begin
47
      dout <= 32'hzzzzzzzz;
48
    end
49
  end
50
 
51
 
52
 
53
endmodule

powered by: WebSVN 2.1.0

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