aboutsummaryrefslogtreecommitdiffstats
path: root/usrp2/models/gpmc_model_async.v
blob: 22b3cdf9f061f23e351084ddf72851f0d8754e83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//
// Copyright 2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//

`timescale 1ps/1ps

module gpmc_model_async
  (output EM_CLK, inout [15:0] EM_D, output reg [10:1] EM_A, output reg [1:0] EM_NBE,
   output reg EM_WAIT0, output reg EM_NCS4, output reg EM_NCS6, 
   output reg EM_NWE, output reg EM_NOE );

   assign EM_CLK = 0;
   reg [15:0] EM_D_int;
   assign EM_D = EM_D_int;
   
   initial
     begin
	EM_A <= 10'bz;
	EM_NBE <= 2'b11;
	EM_NWE <= 1;
	EM_NOE <= 1;
	EM_NCS4 <= 1;
	EM_NCS6 <= 1;
	EM_D_int <= 16'bz;
 	EM_WAIT0 <= 0;  // FIXME this is actually an input
     end
   
   task GPMC_Write;
      input ctrl;
      input [10:0] addr;
      input [15:0] data;
      begin
	 #23000;
	 EM_A <= addr[10:1];
	 EM_D_int <= data;
	 #20100;
	 if(ctrl)
	   EM_NCS6 <= 0;
	 else
	   EM_NCS4 <= 0;
	 #14000;
	 EM_NWE <= 0;
	 #77500;
	 EM_NCS4 <= 1;
	 EM_NCS6 <= 1;
	 //#1.5;
	 EM_NWE <= 1;
	 #60000;
	 EM_A <= 10'bz;
	 EM_D_int <= 16'bz;
      end
   endtask // GPMC_Write

   task GPMC_Read;
      input ctrl;
      input [10:0] addr;
      begin
	 #13000;
	 EM_A <= addr[10:1];
	 #3000;
	 if(ctrl)
	   EM_NCS6 <= 0;
	 else
	   EM_NCS4 <= 0;
	 #14000;
	 EM_NOE <= 0;
	 #77500;
	 EM_NCS4 <= 1;
	 EM_NCS6 <= 1;
	 //#1.5;
	 $display("Data Read from GPMC: %X",EM_D);
	 EM_NOE <= 1;
	 #254000;
	 EM_A <= 10'bz;
      end
   endtask // GPMC_Read
   
   initial
     begin
	#1000000;
	GPMC_Write(1,36,16'hF00D);
	#1000000;
	GPMC_Read(1,36);
	#1000000;
	GPMC_Write(0,0,16'h1234);
	GPMC_Write(0,0,16'h5678);
	GPMC_Write(0,0,16'h9abc);
	GPMC_Write(0,0,16'hF00D);
	GPMC_Write(0,0,16'hDEAD);
	GPMC_Write(0,0,16'hDEAD);
	GPMC_Write(0,0,16'hDEAD);
	GPMC_Write(0,0,16'hDEAD);
	GPMC_Write(0,0,16'hDEAD);
	GPMC_Write(0,0,16'hDEAD);
	#1000000;
	GPMC_Write(0,0,16'h1234);
	GPMC_Write(0,0,16'h5678);
	GPMC_Write(0,0,16'h9abc);
	GPMC_Write(0,0,16'hF00D);
	GPMC_Write(0,0,16'hDEAD);
	GPMC_Write(0,0,16'hDEAD);
	GPMC_Write(0,0,16'hDEAD);
	GPMC_Write(0,0,16'hDEAD);
	GPMC_Write(0,0,16'hDEAD);
	GPMC_Write(0,0,16'h9876);
	#1000000;
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	#1000000;
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	GPMC_Read(0,0);
	#1000000;
	GPMC_Read(0,0);
	#100000000;
	$finish;
     end
   
endmodule // gpmc_model_async