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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [verif/] [tb/] [tb_tasks.v] - Blame information for rev 37

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

Line No. Rev Author Line
1 2 dinesha
 
2
initial
3
begin
4
   reg_cs  = 0;
5
   reg_be  = 4'h0;
6 10 dinesha
   reg_id  = 0;
7 2 dinesha
end
8
 
9
task cpu_read;
10 10 dinesha
  input  [3:0]  block_id;
11 2 dinesha
  input  [15:0] address;
12
  output [31:0] read_data;
13
  begin
14
      @(posedge app_clk);
15 10 dinesha
      reg_id  = block_id;
16 11 dinesha
 
17
      // Byte-0
18 2 dinesha
      reg_cs = 1;
19
      reg_wr = 0;
20 11 dinesha
      reg_be = 1'h1;
21 2 dinesha
      reg_addr = address;
22
      @(posedge reg_ack);
23 11 dinesha
       #1 read_data[7:0] = reg_rdata[7:0];
24 2 dinesha
      @(posedge app_clk);
25 11 dinesha
       reg_cs  = 0;
26
 
27
      // Byte-1
28
      reg_cs = 1;
29
      reg_wr = 0;
30
      reg_be = 1'h1;
31
      reg_addr = address+1;
32
      @(posedge reg_ack);
33
       #1 read_data[15:8]= reg_rdata[7:0];
34
      @(posedge app_clk);
35
       reg_cs  = 0;
36
 
37
      // Byte-2
38
      reg_cs = 1;
39
      reg_wr = 0;
40
      reg_be = 1'h1;
41
      reg_addr = address+2;
42
      @(posedge reg_ack);
43
       #1 read_data[23:16]= reg_rdata[7:0];
44
      @(posedge app_clk);
45
       reg_cs  = 0;
46
 
47
      // Byte-3
48
      reg_cs = 1;
49
      reg_wr = 0;
50
      reg_be = 1'h1;
51
      reg_addr = address+3;
52
      @(posedge reg_ack);
53
       #1 read_data[31:24] = reg_rdata[7:0];
54
      @(posedge app_clk);
55
       reg_cs  = 0;
56 2 dinesha
      //$display ("Config-Read: Id: %h Addr = %h, Data = %h", block_id,address, read_data);
57
  end
58
endtask
59
 
60
task cpu_write;
61 10 dinesha
  input  [3:0] block_id; // 0/1/2 --> ram/spi/uart 
62 2 dinesha
  input  [15:0] address;
63
  input  [31:0] write_data;
64
  begin
65
      $display ("Config-Write: Id: %h Addr = %h, Cfg. Data = %h", block_id,address, write_data);
66 11 dinesha
      // Byte-0
67 2 dinesha
      @(posedge app_clk);
68 10 dinesha
      reg_id  = block_id;
69 2 dinesha
      reg_cs = 1;
70
      reg_wr = 1;
71 11 dinesha
      reg_be = 1'h1;
72 2 dinesha
      reg_addr = address;
73 11 dinesha
      reg_wdata = write_data[7:0];
74 2 dinesha
      @(posedge reg_ack);
75
      @(posedge app_clk);
76
      reg_cs  = 0;
77
      reg_wr = 0;
78 11 dinesha
 
79
      // Byte-1
80
      @(posedge app_clk);
81
      reg_id  = block_id;
82
      reg_cs = 1;
83
      reg_wr = 1;
84
      reg_be = 1'h1;
85
      reg_addr = address+1;
86
      reg_wdata = write_data[15:8];
87
      @(posedge reg_ack);
88
      @(posedge app_clk);
89
      reg_cs  = 0;
90
      reg_wr = 0;
91
 
92
      // Byte-2
93
      @(posedge app_clk);
94
      reg_id  = block_id;
95
      reg_cs = 1;
96
      reg_wr = 1;
97
      reg_be = 1'h1;
98
      reg_addr = address+2;
99
      reg_wdata = write_data[23:16];
100
      @(posedge reg_ack);
101
      @(posedge app_clk);
102
      reg_cs  = 0;
103
      reg_wr = 0;
104
 
105
      // Byte-2
106
      @(posedge app_clk);
107
      reg_id  = block_id;
108
      reg_cs = 1;
109
      reg_wr = 1;
110
      reg_be = 1'h1;
111
      reg_addr = address+3;
112
      reg_wdata = write_data[31:24];
113
      @(posedge reg_ack);
114
      @(posedge app_clk);
115
      reg_cs  = 0;
116
      reg_wr = 0;
117
 
118 2 dinesha
  end
119
endtask
120
 
121 11 dinesha
task cpu_byte_read;
122
  input  [3:0]  block_id;
123
  input  [15:0] address;
124
  output [7:0] read_data;
125
  begin
126
      @(posedge app_clk);
127
      reg_id  = block_id;
128
 
129
      // Byte-0
130
      reg_cs = 1;
131
      reg_wr = 0;
132
      reg_be = 1'h1;
133
      reg_addr = address;
134
      @(posedge reg_ack);
135
       #1 read_data[7:0] = reg_rdata[7:0];
136
      @(posedge app_clk);
137
       reg_cs  = 0;
138
 
139 29 dinesha
      $display ("Config-Read: Id: %h Addr = %h, Data = %h", block_id,address, read_data);
140 11 dinesha
  end
141
endtask
142
 
143 29 dinesha
task cpu_byte_read_cmp;
144
  input  [3:0]  block_id;
145
  input  [15:0] address;
146
  input [7:0]   exp_read_data;
147
  reg   [7:0]   read_data;
148
  begin
149
      @(posedge app_clk);
150
      reg_id  = block_id;
151
 
152
      // Byte-0
153
      reg_cs = 1;
154
      reg_wr = 0;
155
      reg_be = 1'h1;
156
      reg_addr = address;
157
      @(posedge reg_ack);
158
       #1 read_data[7:0] = reg_rdata[7:0];
159
      @(posedge app_clk);
160
       reg_cs  = 0;
161
 
162
      if(read_data !== exp_read_data) begin
163
          $display ("ERROR: REG READ : Id: %h Addr = %h, Data = %h", block_id,address, read_data);
164
          `TB_GLBL.test_err;
165
      end else
166
          $display ("Config-Read: Id: %h Addr = %h, Data = %h", block_id,address, read_data);
167
  end
168
endtask
169 11 dinesha
task cpu_byte_write;
170
  input  [3:0] block_id; // 0/1/2 --> ram/spi/uart 
171
  input  [15:0] address;
172
  input  [7:0] write_data;
173
  begin
174
      $display ("Config-Write: Id: %h Addr = %h, Cfg. Data = %h", block_id,address, write_data);
175
      // Byte-0
176
      @(posedge app_clk);
177
      reg_id  = block_id;
178
      reg_cs = 1;
179
      reg_wr = 1;
180
      reg_be = 1'h1;
181
      reg_addr = address;
182
      reg_wdata = write_data[7:0];
183
      @(posedge reg_ack);
184
      @(posedge app_clk);
185
      reg_cs  = 0;
186
      reg_wr = 0;
187
 
188
  end
189
endtask
190
 

powered by: WebSVN 2.1.0

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