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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [verif/] [testcase/] [i2cm_test1.v] - Blame information for rev 30

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

Line No. Rev Author Line
1 29 dinesha
/**********************************************************
2
             I2C Master Test
3
**********************************************************/
4
task i2cm_test1;
5
reg [7:0] rdata;
6
begin
7
 $display("############################################");
8
 $display("   Testing I2CM Read/Write Access           ");
9
 $display("############################################");
10
 
11
  @(posedge  app_clk);
12
  $display("---------- Initialize I2C Master ----------");
13
  //Wrire Prescale registers
14
   tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h0,8'hC7);
15
   tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h1,8'h00);
16
  // Core Enable
17
   tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h2,8'h80);
18
 
19
  // Writing Data
20
 
21
  $display("---------- Writing Data ----------");
22
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h3,8'h20); // Slave Addr + WR  
23
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h4,8'h90);
24
  rdata [1] = 1'b1;
25
  while(rdata[1]==1)
26
    tb_top.cpu_byte_read(`ADDR_SPACE_I2CM,8'h4,rdata);
27
 
28
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h3,8'h66);
29
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h4,8'h10);
30
 
31
  rdata [1] = 1'b1;
32
  while(rdata[1]==1)
33
    tb_top.cpu_byte_read(`ADDR_SPACE_I2CM,8'h4,rdata);
34
 
35
 /* Byte1: 12 */
36
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h3,8'h12);
37
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h4,8'h10); // No Stop + Write  
38
 
39
  rdata [1] = 1'b1;
40
  while(rdata[1]==1)
41
    tb_top.cpu_byte_read(`ADDR_SPACE_I2CM,8'h4,rdata);
42
 
43
 /* Byte1: 34 */
44
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h3,8'h34);
45
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h4,8'h10); // No Stop + Write 
46
 
47
  rdata [1] = 1'b1;
48
  while(rdata[1]==1)
49
    tb_top.cpu_byte_read(`ADDR_SPACE_I2CM,8'h4,rdata);
50
 
51
 /* Byte1: 56 */
52
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h3,8'h56);
53
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h4,8'h10); // No Stop + Write 
54
 
55
  rdata [1] = 1'b1;
56
  while(rdata[1]==1)
57
    tb_top.cpu_byte_read(`ADDR_SPACE_I2CM,8'h4,rdata);
58
 
59
 /* Byte1: 78 */
60
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h3,8'h78);
61
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h4,8'h50); // Stop + Write 
62
 
63
  rdata [1] = 1'b1;
64
  while(rdata[1]==1)
65
    tb_top.cpu_byte_read(`ADDR_SPACE_I2CM,8'h4,rdata);
66
 
67
  //Reading Data
68
 
69
  //Wrire Address
70
  $display("---------- Writing Data ----------");
71
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h3,8'h20);
72
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h4,8'h90);
73
  rdata [1] = 1'b1;
74
  while(rdata[1]==1)
75
    tb_top.cpu_byte_read(`ADDR_SPACE_I2CM,8'h4,rdata);
76
 
77
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h3,8'h66);
78
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h4,8'h50);
79
 
80
  rdata [1] = 1'b1;
81
  while(rdata[1]==1)
82
    tb_top.cpu_byte_read(`ADDR_SPACE_I2CM,8'h4,rdata);
83
 
84
  //Generate Read
85
  $display("---------- Writing Data ----------");
86
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h3,8'h21); // Slave Addr + RD  
87
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h4,8'h90);
88
  rdata [1] = 1'b1;
89
  while(rdata[1]==1)
90
    tb_top.cpu_byte_read(`ADDR_SPACE_I2CM,8'h4,rdata);
91
 
92
  /* BYTE-1 : 0x12  */
93
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h4,8'h20);  // RD + ACK
94
 
95
  rdata [1] = 1'b1;
96
  while(rdata[1]==1)
97
    tb_top.cpu_byte_read(`ADDR_SPACE_I2CM,8'h4,rdata);
98
 
99
  //Compare received data
100
  tb_top.cpu_byte_read_cmp(`ADDR_SPACE_I2CM,8'h3,8'h12);
101
 
102
  /* BYTE-2 : 0x34  */
103
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h4,8'h20);  // RD + ACK
104
 
105
  rdata [1] = 1'b1;
106
  while(rdata[1]==1)
107
    tb_top.cpu_byte_read(`ADDR_SPACE_I2CM,8'h4,rdata);
108
 
109
  //Compare received data
110
  tb_top.cpu_byte_read_cmp(`ADDR_SPACE_I2CM,8'h3,8'h34);
111
 
112
  /* BYTE-3 : 0x56  */
113
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h4,8'h20);  // RD + ACK
114
 
115
  rdata [1] = 1'b1;
116
  while(rdata[1]==1)
117
    tb_top.cpu_byte_read(`ADDR_SPACE_I2CM,8'h4,rdata);
118
 
119
  //Compare received data
120
  tb_top.cpu_byte_read_cmp(`ADDR_SPACE_I2CM,8'h3,8'h56);
121
 
122
  /* BYTE-4 : 0x78  */
123
  tb_top.cpu_byte_write(`ADDR_SPACE_I2CM,8'h4,8'h68);  // STOP + RD + NACK 
124
 
125
  rdata [1] = 1'b1;
126
  while(rdata[1]==1)
127
    tb_top.cpu_byte_read(`ADDR_SPACE_I2CM,8'h4,rdata);
128
 
129
  //Compare received data
130
  tb_top.cpu_byte_read_cmp(`ADDR_SPACE_I2CM,8'h3,8'h78);
131
 
132
  repeat(100)@(posedge app_clk);
133
end
134
endtask //}
135
 

powered by: WebSVN 2.1.0

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