-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_strip_driver.template.v
126 lines (102 loc) · 3.13 KB
/
test_strip_driver.template.v
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
//
// LED Suit FPGA Implementation - Multi-output addressable LED driver HDL
// implementation for Kevin's LED suit controller.
// Copyright (C) 2019-2020 Kevin Balke
//
// This file is part of LED Suit FPGA Implementation.
//
// LED Suit FPGA Implementation 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.
//
// LED Suit FPGA Implementation 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 LED Suit FPGA Implementation. If not, see
// <http://www.gnu.org/licenses/>.
//
{% set num_channels = 8 %}
{% set indices = range(num_channels) %}
`timescale 10 ns / 1 ns
module test(
);
reg clk_50mhz, rst;
parameter NUM_LEDS = 20;
parameter NUM_DRIVERS = {{num_channels}};
parameter NUM_CHANNELS = NUM_LEDS * 3;
parameter ADDRESS_WIDTH = $clog2(NUM_CHANNELS * NUM_DRIVERS);
// Strip drivers.
{% for index in indices %}
wire data_req_{{index}};
wire data_rdy_{{index}};
wire[7:0] data_{{index}};
wire[ADDRESS_WIDTH - 1:0] data_addr_{{index}};
wire strip_out_{{index}};
assign PIN_{{index + 4}} = strip_out_{{index}};
strip_driver #(.INPUT_CLOCK_FREQ_MHZ(50),
.MAX_LEDS(NUM_LEDS),
.ADDRESS_WIDTH(ADDRESS_WIDTH),
.BASE_ADDRESS(NUM_CHANNELS*{{index}})) strip_driver_{{index}}(
.clk(clk_50mhz),
.rst(rst),
.mem_req(data_req_{{index}}),
.mem_rdy(data_rdy_{{index}}),
.mem_data(data_{{index}}),
.mem_addr(data_addr_{{index}}),
.strip_out(strip_out_{{index}})
);
{% endfor %}
// Memory
wire[ADDRESS_WIDTH - 1:0] mem_data_addr;
wire[7:0] mem_data;
wire[ADDRESS_WIDTH - 1:0] waddr;
assign waddr = 0;
bram #(.MEMORY_SIZE(NUM_CHANNELS * NUM_DRIVERS), .DATA_WIDTH(8)) bram(
.clk(clk_50mhz),
.wen(1'b0),
.wdata(8'b0),
.waddr(waddr),
.ren(1'b1),
.rdata(mem_data),
.raddr(mem_data_addr)
);
bus_arbiter #(.ADDRESS_WIDTH(ADDRESS_WIDTH), .DATA_WIDTH(8)) bus_arbiter(
.clk(clk_50mhz),
.rst(rst),
{% for index in indices %}
// CHANNEL {{index}}
.data_req_{{index}}(data_req_{{index}}),
.data_addr_{{index}}(data_addr_{{index}}),
.data_{{index}}(data_{{index}}),
.data_rdy_{{index}}(data_rdy_{{index}}),
{% endfor %}
.mem_data_addr(mem_data_addr),
.mem_data(mem_data)
);
integer i;
initial
begin
$display($time, "STARTING SIMULATION");
$dumpfile("test.vcd");
$dumpvars(0, test);
for(i=0; i<NUM_CHANNELS*NUM_DRIVERS; i+=1) begin
if (((i % NUM_CHANNELS) < 2) || ((i % NUM_CHANNELS) >= (NUM_CHANNELS - 2))) begin
bram.memory[i] = i;
end else begin
bram.memory[i] = 0;
end
end
clk_50mhz=1'b0;
rst=1'b1;
#20 rst=1'b0;
#2_000_000 $display($time, "STOPPING SIMULATION");
$finish;
end
always
#2 clk_50mhz=~clk_50mhz;
endmodule