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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [fpga/] [experiments/] [memdelay/] [memdelay.v] - Blame information for rev 314

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

Line No. Rev Author Line
1 297 hellwig
//
2
// memdelay.v -- test memory delay
3
//
4
 
5
 
6
`timescale 1ns/10ps
7
`default_nettype none
8
 
9
 
10
module memdelay;
11
 
12
  reg clk;
13
  reg rst_in;
14
  reg rst;
15
  reg stb;
16
  reg we;
17
  wire [22:0] addr;
18
  wire [31:0] data_in;
19
  wire [31:0] data_out;
20
  wire ack;
21
  reg [5:0] state;
22
  reg [5:0] next_state;
23
 
24
  initial begin
25
    #0     $dumpfile("dump.vcd");
26
           $dumpvars(0, memdelay);
27
           clk = 1;
28
           rst_in = 1;
29
    #25    rst_in = 0;
30
    #1000  $finish;
31
  end
32
 
33
  always begin
34
    #10 clk = ~ clk;
35
  end
36
 
37
  always @(posedge clk) begin
38
    rst <= rst_in;
39
  end
40
 
41
  assign addr[22:0] = 23'h123456;
42
  assign data_in[31:0] = 32'h12345678;
43
 
44
  ram ram_1(
45
    .clk(clk),
46
    .rst(rst),
47
    .stb(stb),
48
    .we(we),
49
    .addr(addr[22:0]),
50
    .data_in(data_in[31:0]),
51
    .data_out(data_out[31:0]),
52
    .ack(ack)
53
  );
54
 
55
  always @(posedge clk) begin
56
    if (rst) begin
57
      state <= 0;
58
    end else begin
59
      state <= next_state;
60
    end
61
  end
62
 
63
  always @(*) begin
64
    case (state[5:0])
65
      6'h0:
66
        begin
67
          stb = 0;
68
          we = 0;
69
          next_state = 6'h1;
70
        end
71
      6'h1:
72
        begin
73
          stb = 0;
74
          we = 0;
75
          next_state = 6'h2;
76
        end
77
      6'h2:
78
        begin
79
          stb = 1;
80
          we = 0;
81
          if (ack) begin
82
            next_state = 6'h3;
83
          end else begin
84
            next_state = 6'h2;
85
          end
86
        end
87
      6'h3:
88
        begin
89
          stb = 0;
90
          we = 0;
91
          next_state = 6'h4;
92
        end
93
      6'h4:
94
        begin
95
          stb = 0;
96
          we = 0;
97
          next_state = 6'h5;
98
        end
99
      6'h5:
100
        begin
101
          stb = 1;
102
          we = 1;
103
          if (ack) begin
104
            next_state = 6'h6;
105
          end else begin
106
            next_state = 6'h5;
107
          end
108
        end
109
      6'h6:
110
        begin
111
          stb = 0;
112
          we = 0;
113
          next_state = 6'h6;
114
        end
115
      default:
116
        begin
117
          stb = 0;
118
          we = 0;
119
          next_state = 6'h0;
120
        end
121
    endcase
122
  end
123
 
124
endmodule

powered by: WebSVN 2.1.0

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