File: serial_settings_tasks.v

package info (click to toggle)
uhd 3.7.3-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 456,376 kB
  • ctags: 89,637
  • sloc: ansic: 51,090; cpp: 42,755; xml: 19,627; vhdl: 12,678; tcl: 5,944; python: 5,870; ada: 2,760; sh: 2,175; makefile: 615; pascal: 230; csh: 224; perl: 11
file content (59 lines) | stat: -rw-r--r-- 1,233 bytes parent folder | download | duplicates (4)
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

   task serial_settings_transaction;
      input [7:0] address;
      input [31:0] data;

      integer x;
      
      begin
	 scl_r <= 1'b1;
	 sda_r <= 1'b1;
	 @(negedge clk);
	 @(negedge clk);
	 // Drive SDA low whilst SCL high to signal START
	 sda_r <= 1'b0;
	 @(negedge clk);
	 @(negedge clk);
	 // Send 8 Address bits MSB first on falling edge of SCL clocks
	 for (x = 7; x >= 0; x = x - 1)
	   serial_settings_bit(address[x]);
	 // Send 32 Data bits MSB first on falling edge of SCL clocks
	 for (x = 31; x >= 0; x = x - 1)
	   serial_settings_bit(data[x]);
	 // Send STOP.
	 scl_r <= 1'b0;
	 sda_r <= 1'b0;
	  @(negedge clk);
	 @(negedge clk);
	 @(negedge clk);
	 @(negedge clk);
	 scl_r <= 1'b1;
	 @(negedge clk);	 
	 @(negedge clk);
	 @(negedge clk);	
	 @(negedge clk);
	 sda_r <= 1'b1;
	 @(negedge clk);	 
	 @(negedge clk);
	 @(negedge clk);	
	 @(negedge clk);
      end
   endtask // serial_settings_transaction

   task serial_settings_bit;
      input one_bit;

      begin
	 scl_r <= 1'b0;
	 sda_r <= one_bit;
	 @(negedge clk);
	 @(negedge clk);
	 @(negedge clk);
	 @(negedge clk);
	 scl_r <= 1'b1;
	 @(negedge clk);	 
	 @(negedge clk);
	 @(negedge clk);	
	 @(negedge clk);
      end
   endtask // send_settings_bit