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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [fpga/] [mc-vl/] [src/] [rom/] [rom.v] - Blame information for rev 308

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 308 hellwig
//
2
// rom.v -- parallel flash ROM interface
3
//          16K x 32 bit = 64 KB
4
//
5
 
6
 
7
`timescale 1ns/10ps
8
`default_nettype none
9
 
10
 
11
//
12
// use this set of parameters for minimal access times
13
//
14
//`define RD_CYCLES     4'd2    // # cycles for read, min = 2
15
 
16
//
17
// use this set of parameters for realistic access times
18
//
19
`define RD_CYCLES       4'd14   // # cycles for read, min = 2
20
 
21
 
22
module rom(clk, rst,
23
           stb, we, addr,
24
           data_out, ack);
25
    input clk;
26
    input rst;
27
    input stb;
28
    input we;
29
    input [15:2] addr;
30
    output reg [31:0] data_out;
31
    output ack;
32
 
33
  reg [31:0] mem[0:16383];
34
  reg [3:0] counter;
35
 
36
  initial begin
37
    $readmemh("rom.dat", mem);
38
  end
39
 
40
  always @(posedge clk) begin
41
    if (stb) begin
42
      if (~we) begin
43
        // read cycle
44
        data_out <= mem[addr];
45
      end
46
    end
47
  end
48
 
49
  always @(posedge clk) begin
50
    if (rst) begin
51
      counter[3:0] <= 4'h0;
52
    end else begin
53
      if (counter[3:0] == 4'h0) begin
54
        if (stb & ~we) begin
55
          // a read may need some clock cycles
56
          counter[3:0] <= `RD_CYCLES - 1;
57
        end
58
      end else begin
59
        counter[3:0] <= counter[3:0] - 1;
60
      end
61
    end
62
  end
63
 
64
  assign ack = (counter[3:0] == 4'h1) ? 1 : 0;
65
 
66
endmodule

powered by: WebSVN 2.1.0

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