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

Subversion Repositories eco32

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

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

Line No. Rev Author Line
1 118 hellwig
//
2
// rom.v -- parallel flash ROM interface
3 290 hellwig
//          512K x 32 bit = 2 MB
4 118 hellwig
//
5
 
6
 
7 290 hellwig
`timescale 1ns/10ps
8
`default_nettype none
9
 
10
 
11
module rom(clk, rst,
12
           stb, we, addr,
13
           data_out, ack,
14 27 hellwig
           ce_n, oe_n, we_n, rst_n, byte_n, a, d);
15
    // internal interface signals
16
    input clk;
17 290 hellwig
    input rst;
18
    input stb;
19
    input we;
20
    input [20:2] addr;
21 27 hellwig
    output reg [31:0] data_out;
22 290 hellwig
    output reg ack;
23 118 hellwig
    // flash ROM interface signals
24 27 hellwig
    output ce_n;
25
    output oe_n;
26
    output we_n;
27
    output rst_n;
28
    output byte_n;
29
    output [19:0] a;
30
    input [15:0] d;
31
 
32
  reg [3:0] state;
33 220 hellwig
  reg upper_half;
34 27 hellwig
 
35
  // the following control signals are all
36
  // either constantly asserted or deasserted
37
  assign ce_n = 0;
38
  assign oe_n = 0;
39
  assign we_n = 1;
40
  assign rst_n = 1;
41
  assign byte_n = 1;
42
 
43 118 hellwig
  // the flash ROM is organized in 16-bit halfwords
44 220 hellwig
  // address line a[0] is controlled by the state machine
45 290 hellwig
  // ("upper half" means "at higher address in ROM")
46 27 hellwig
  assign a[19:1] = addr[20:2];
47 220 hellwig
  assign a[0] = upper_half;
48 27 hellwig
 
49
  // the state machine
50
  always @(posedge clk) begin
51 290 hellwig
    if (rst) begin
52 27 hellwig
      state <= 0;
53 290 hellwig
      ack <= 0;
54 27 hellwig
    end else begin
55
      if (state == 0) begin
56
        // wait for start of access
57 290 hellwig
        if (stb & ~we) begin
58 27 hellwig
          state <= 1;
59 290 hellwig
          upper_half <= 0;
60 27 hellwig
        end
61
      end else
62
      if (state == 6) begin
63 290 hellwig
        // latch upper halfword
64
        data_out[31:24] <= d[7:0];
65
        data_out[23:16] <= d[15:8];
66
        state <= 7;
67
        upper_half <= 1;
68 27 hellwig
      end else
69
      if (state == 12) begin
70
        // latch lower halfword
71
        data_out[15:8] <= d[7:0];
72
        data_out[7:0] <= d[15:8];
73
        state <= 13;
74 290 hellwig
        ack <= 1;
75 27 hellwig
      end else
76
      if (state == 13) begin
77
        // end of access
78 290 hellwig
        ack <= 0;
79 27 hellwig
        state <= 0;
80
      end else begin
81 118 hellwig
        // wait for flash ROM access time to pass
82 27 hellwig
        state <= state + 1;
83
      end
84
    end
85
  end
86
 
87
endmodule

powered by: WebSVN 2.1.0

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