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

Subversion Repositories neopixel_fpga

[/] [neopixel_fpga/] [trunk/] [rtl/] [ws2812_ctl_tb.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 splinedriv
/*
2
 *  FpgaNeoPixel - A spi to ws2812 machine
3
 *
4
 *  Copyright (C) 2020  Hirosh Dabui <hirosh@dabui.de>
5
 *
6
 *  Permission to use, copy, modify, and/or distribute this software for any
7
 *  purpose with or without fee is hereby granted, provided that the above
8
 *  copyright notice and this permission notice appear in all copies.
9
 *
10
 *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
 *  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
 *  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
 *  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
 *  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
 *  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
 *  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
 *
18
 */
19
`include "ws2812_sequence.v"
20
module testbench;
21
localparam CLK_HZ = 12_000_000;
22
reg clk;
23
reg resetn;
24
wire dout;
25
 
26
reg cs;
27
reg sck;
28
reg mosi;
29
wire miso;
30
wire ready;
31
 
32
 
33
reg [4095:0] vcdfile;
34
always #5 clk = (clk === 1'b0);
35
 
36
always #40 sck = (sck === 1'b0);
37
 
38
ws2812_ctl uut(
39
                .clk(clk),
40
                .resetn(reset),
41
                .dout(dout),
42
                .sck(sck),
43
                .mosi(mosi),
44
                .miso(miso),
45
                .cs(cs),
46
                .ready(ready),
47
                   );
48
 
49
        initial begin
50
                if ($value$plusargs("vcd=%s", vcdfile)) begin
51
                        $dumpfile(vcdfile);
52
                        $dumpvars(0, testbench);
53
                end
54
        end
55
 
56
  integer i = 0;
57
  integer j = 0;
58
  reg [31:0] data = 0;
59
  initial begin
60
    cs = 1;
61
    sck = 1;
62
    resetn = 0;
63
    #200 resetn = 1;
64
    repeat(5)@(posedge sck);
65
 
66
    for (i = 0; i < 10; i = i + 1)
67
    begin
68
/*
69
      cs = 0;
70
      data = 32'hdeadbeaf;
71
      for (j = 0; j < 32; j = j+1)
72
      begin
73
        mosi = data[31-j];
74
        repeat(1)@(posedge sck);
75
      end
76
      cs = 1;
77
      repeat(2)@(posedge sck);
78
*/
79
      cs = 0;
80
      data = 32'h80_000001;
81
      for (j = 0; j < 32; j = j+1)
82
      begin
83
        mosi = data[31-j];
84
        repeat(1)@(negedge sck);
85
      end
86
      cs = 1;
87
 
88
      repeat(2)@(posedge sck);
89
 
90
      /*
91
      cs = 0;
92
      data = 32'h00_000002;
93
      for (j = 0; j < 32; j = j+1)
94
      begin
95
        mosi = data[31-j];
96
        repeat(1)@(posedge sck);
97
      end
98
      cs = 1;
99
 
100
      repeat(2)@(posedge sck);
101
 
102
      cs = 0;
103
      data = 32'h00_000003;
104
      for (j = 0; j < 32; j = j+1)
105
      begin
106
        mosi = data[31-j];
107
        repeat(1)@(posedge sck);
108
      end
109
      cs = 1;
110
*/
111
 
112
      repeat(2)@(posedge sck);
113
 
114
      cs = 0;
115
      data = 32'hdeadbeaf;
116
      for (j = 0; j < 32; j = j+1)
117
      begin
118
        mosi = data[31-j];
119
        repeat(1)@(negedge sck);
120
      end
121
      cs = 1;
122
    repeat(1000)@(posedge sck);
123
    end
124
 
125
 
126
                $finish;
127
        end
128
endmodule

powered by: WebSVN 2.1.0

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