Skip to content

Commit 812177f

Browse files
committed
rtl: remove RST Time registers
1 parent 95af9fa commit 812177f

File tree

7 files changed

+38
-68
lines changed

7 files changed

+38
-68
lines changed

README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ WS281X Cube Controller based on MAX10 FPGA.
88
* 4-Wire SPI Interface
99
* High Refresh Rate (Up to 500fps@8x8x8)
1010
* 8 Data Lines in Parallel (64 LEDs per line)
11-
* Configurable Waveform Generator (T0H, T0L, T1H, T1L, RST)
11+
* Configurable Waveform Generator (T0H, T0L, T1H, T1L)
1212
* Configurable LED Serial Connection Sequence (Addr Linked List)
1313

1414
## Commands
@@ -22,21 +22,16 @@ WS281X Cube Controller based on MAX10 FPGA.
2222
| 2nd Param | 1 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | |
2323
| 3rd Param | 1 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | |
2424
| 4th Param | 1 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | |
25-
| 5th Param | 1 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | |
26-
| 6th Param | 1 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | |
2725

28-
* 1st Param: T0H Time, unit: 10 ns
29-
* 2nd Param: T0L Time, unit: 10 ns
30-
* 3rd Param: T1H Time, unit: 10 ns
31-
* 4th Param: T1L Time, unit: 10 ns
32-
* 5th Param: RST Time H, unit: 10 ns
33-
* 6th Param: RST Time L, unit: 10 ns
26+
* 1st Param: T0H Time, range: 1-255, unit: 10 ns
27+
* 2nd Param: T0L Time, range: 1-255, unit: 10 ns
28+
* 3rd Param: T1H Time, range: 1-255, unit: 10 ns
29+
* 4th Param: T1L Time, range: 1-255, unit: 10 ns
3430

3531
Limits:
3632

37-
* T0H + T0L <= 255 = 2550 ns = 2.55 us
38-
* T1H + T1L <= 255 = 2550 ns = 2.55 us
39-
* RST <= 65535 = 655350 ns = 655.35 us
33+
* T0H + T0L <= 257 = 2570 ns = 2.57 us
34+
* T1H + T1L <= 257 = 2570 ns = 2.57 us
4035

4136
### ADDR_WR
4237

rtl/layer_code.sv

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ module layer_code(
1515
input logic [7:0] wr_data_in,
1616
input logic [3:0] wr_byte_en_in,
1717

18-
input logic [ 7:0] t0h_cnt_in,
19-
input logic [ 7:0] t0l_cnt_in,
20-
input logic [ 7:0] t1h_cnt_in,
21-
input logic [ 7:0] t1l_cnt_in,
22-
input logic [15:0] rst_cnt_in,
18+
input logic [7:0] t0h_cnt_in,
19+
input logic [7:0] t0l_cnt_in,
20+
input logic [7:0] t1h_cnt_in,
21+
input logic [7:0] t1l_cnt_in,
2322

2423
output logic ws281x_code_out
2524
);
@@ -50,7 +49,6 @@ ws281x_ctrl ws281x_ctrl(
5049

5150
.wr_done_in(wr_done_in),
5251
.rd_data_in(rd_data),
53-
.rst_cnt_in(rst_cnt_in),
5452

5553
.bit_rdy_out(bit_rdy),
5654
.bit_data_out(bit_data),

rtl/layer_conf.sv

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,21 @@ module layer_conf(
1313
input logic [5:0] wr_addr_in,
1414
input logic [7:0] wr_data_in,
1515

16-
output logic [ 7:0] t0h_cnt_out,
17-
output logic [ 7:0] t0l_cnt_out,
18-
output logic [ 7:0] t1h_cnt_out,
19-
output logic [ 7:0] t1l_cnt_out,
20-
output logic [15:0] rst_cnt_out
16+
output logic [7:0] t0h_cnt_out,
17+
output logic [7:0] t0l_cnt_out,
18+
output logic [7:0] t1h_cnt_out,
19+
output logic [7:0] t1l_cnt_out
2120
);
2221

23-
logic [ 7:0] t0h_cnt;
24-
logic [ 7:0] t0l_cnt;
25-
logic [ 7:0] t1h_cnt;
26-
logic [ 7:0] t1l_cnt;
27-
logic [15:0] rst_cnt;
22+
logic [7:0] t0h_cnt;
23+
logic [7:0] t0l_cnt;
24+
logic [7:0] t1h_cnt;
25+
logic [7:0] t1l_cnt;
2826

2927
assign t0h_cnt_out = t0h_cnt;
3028
assign t0l_cnt_out = t0l_cnt;
3129
assign t1h_cnt_out = t1h_cnt;
3230
assign t1l_cnt_out = t1l_cnt;
33-
assign rst_cnt_out = rst_cnt;
3431

3532
always_ff @(posedge clk_in or negedge rst_n_in)
3633
begin
@@ -39,22 +36,17 @@ begin
3936
t0l_cnt <= 8'h00;
4037
t1h_cnt <= 8'h00;
4138
t1l_cnt <= 8'h00;
42-
rst_cnt <= 16'h0000;
4339
end else begin
4440
if (wr_en_in) begin
45-
case (wr_addr_in[2:0])
46-
3'h0:
41+
case (wr_addr_in[1:0])
42+
2'b00:
4743
t0h_cnt <= wr_data_in;
48-
3'h1:
44+
2'b01:
4945
t0l_cnt <= wr_data_in;
50-
3'h2:
46+
2'b10:
5147
t1h_cnt <= wr_data_in;
52-
3'h3:
48+
2'b11:
5349
t1l_cnt <= wr_data_in;
54-
3'h4:
55-
rst_cnt[15:8] <= wr_data_in;
56-
3'h5:
57-
rst_cnt[ 7:0] <= wr_data_in;
5850
endcase
5951
end
6052
end

rtl/layer_ctrl.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ logic [2:0] data_en;
3232

3333
logic [5:0] wr_addr;
3434

35-
wire conf_done = (wr_addr == 6'd5);
35+
wire conf_done = (wr_addr == 6'd3);
3636
wire code_done = code_wr[0];
3737

3838
wire addr_done = (wr_addr == 6'd63);

rtl/top.sv

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ logic wr_done;
3232
logic [5:0] wr_addr;
3333
logic [3:0] wr_byte_en;
3434

35-
logic [ 7:0] t0h_cnt;
36-
logic [ 7:0] t0l_cnt;
37-
logic [ 7:0] t1h_cnt;
38-
logic [ 7:0] t1l_cnt;
39-
logic [15:0] rst_cnt;
35+
logic [7:0] t0h_cnt;
36+
logic [7:0] t0l_cnt;
37+
logic [7:0] t1h_cnt;
38+
logic [7:0] t1l_cnt;
4039

4140
sys_ctrl sys_ctrl(
4241
.clk_in(clk_in),
@@ -84,8 +83,7 @@ layer_conf layer_conf(
8483
.t0h_cnt_out(t0h_cnt),
8584
.t0l_cnt_out(t0l_cnt),
8685
.t1h_cnt_out(t1h_cnt),
87-
.t1l_cnt_out(t1l_cnt),
88-
.rst_cnt_out(rst_cnt)
86+
.t1l_cnt_out(t1l_cnt)
8987
);
9088

9189
layer_code layer_code7(
@@ -102,7 +100,6 @@ layer_code layer_code7(
102100
.t0l_cnt_in(t0l_cnt),
103101
.t1h_cnt_in(t1h_cnt),
104102
.t1l_cnt_in(t1l_cnt),
105-
.rst_cnt_in(rst_cnt),
106103

107104
.ws281x_code_out(ws281x_code_out[7])
108105
);
@@ -121,7 +118,6 @@ layer_code layer_code6(
121118
.t0l_cnt_in(t0l_cnt),
122119
.t1h_cnt_in(t1h_cnt),
123120
.t1l_cnt_in(t1l_cnt),
124-
.rst_cnt_in(rst_cnt),
125121

126122
.ws281x_code_out(ws281x_code_out[6])
127123
);
@@ -140,7 +136,6 @@ layer_code layer_code5(
140136
.t0l_cnt_in(t0l_cnt),
141137
.t1h_cnt_in(t1h_cnt),
142138
.t1l_cnt_in(t1l_cnt),
143-
.rst_cnt_in(rst_cnt),
144139

145140
.ws281x_code_out(ws281x_code_out[5])
146141
);
@@ -159,7 +154,6 @@ layer_code layer_code4(
159154
.t0l_cnt_in(t0l_cnt),
160155
.t1h_cnt_in(t1h_cnt),
161156
.t1l_cnt_in(t1l_cnt),
162-
.rst_cnt_in(rst_cnt),
163157

164158
.ws281x_code_out(ws281x_code_out[4])
165159
);
@@ -178,7 +172,6 @@ layer_code layer_code3(
178172
.t0l_cnt_in(t0l_cnt),
179173
.t1h_cnt_in(t1h_cnt),
180174
.t1l_cnt_in(t1l_cnt),
181-
.rst_cnt_in(rst_cnt),
182175

183176
.ws281x_code_out(ws281x_code_out[3])
184177
);
@@ -197,7 +190,6 @@ layer_code layer_code2(
197190
.t0l_cnt_in(t0l_cnt),
198191
.t1h_cnt_in(t1h_cnt),
199192
.t1l_cnt_in(t1l_cnt),
200-
.rst_cnt_in(rst_cnt),
201193

202194
.ws281x_code_out(ws281x_code_out[2])
203195
);
@@ -216,7 +208,6 @@ layer_code layer_code1(
216208
.t0l_cnt_in(t0l_cnt),
217209
.t1h_cnt_in(t1h_cnt),
218210
.t1l_cnt_in(t1l_cnt),
219-
.rst_cnt_in(rst_cnt),
220211

221212
.ws281x_code_out(ws281x_code_out[1])
222213
);
@@ -235,7 +226,6 @@ layer_code layer_code0(
235226
.t0l_cnt_in(t0l_cnt),
236227
.t1h_cnt_in(t1h_cnt),
237228
.t1l_cnt_in(t1l_cnt),
238-
.rst_cnt_in(rst_cnt),
239229

240230
.ws281x_code_out(ws281x_code_out[0])
241231
);

rtl/ws281x_code.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ logic bit_done, bit_code;
3131
wire [7:0] t0_sum = t0h_cnt_in + t0l_cnt_in;
3232
wire [7:0] t1_sum = t1h_cnt_in + t1l_cnt_in;
3333

34-
wire cnt_done = (bit_cnt[8:1] == cnt_sum);
34+
wire cnt_done = (bit_cnt[8:0] == {cnt_sum, 1'b0} - 2'b11);
3535

3636
wire t0h_time = (bit_cnt[8:1] < t0h_cnt_in);
3737
wire t1h_time = (bit_cnt[8:1] < t1h_cnt_in);

rtl/ws281x_ctrl.sv

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module ws281x_ctrl(
1313

1414
input logic wr_done_in,
1515
input logic [31:0] rd_data_in,
16-
input logic [15:0] rst_cnt_in,
1716

1817
output logic bit_rdy_out,
1918
output logic bit_data_out,
@@ -25,26 +24,25 @@ module ws281x_ctrl(
2524
parameter [1:0] IDLE = 2'b00; // Idle
2625
parameter [1:0] READ_RAM = 2'b01; // Read RAM Data
2726
parameter [1:0] SEND_BIT = 2'b10; // Send Bit Code
28-
parameter [1:0] SEND_RST = 2'b11; // Send RST Code
27+
parameter [1:0] SYNC_BIT = 2'b11; // Sync Bit Code
2928

3029
logic [1:0] ctl_sta;
3130

3231
logic bit_st;
3332
logic [4:0] bit_sel;
33+
logic [8:0] bit_syn;
3434

3535
logic bit_rdy, bit_data;
3636

3737
logic rd_done;
3838
logic [ 5:0] rd_addr;
3939
logic [23:0] rd_data;
4040

41-
logic [16:0] rst_cnt;
42-
4341
wire ram_next = (bit_sel == 5'd23);
4442
wire ram_done = (rd_addr == 6'h00);
4543

4644
wire bit_next = bit_st | bit_done_in;
47-
wire rst_done = (rst_cnt[16:1] == rst_cnt_in);
45+
wire syn_done = (bit_syn[8:1] == 8'hfe);
4846

4947
assign bit_rdy_out = bit_rdy;
5048
assign bit_data_out = bit_data;
@@ -66,33 +64,30 @@ begin
6664
rd_done <= 1'b0;
6765
rd_addr <= 6'h00;
6866
rd_data <= 24'h00_0000;
69-
70-
rst_cnt <= 17'h0_0000;
7167
end else begin
7268
case (ctl_sta)
7369
IDLE:
7470
ctl_sta <= wr_done_in ? READ_RAM : ctl_sta;
7571
READ_RAM:
7672
ctl_sta <= rd_done ? SEND_BIT : ctl_sta;
7773
SEND_BIT:
78-
ctl_sta <= (bit_next & ram_next) ? (ram_done ? SEND_RST : READ_RAM) : ctl_sta;
79-
SEND_RST:
80-
ctl_sta <= rst_done ? IDLE : ctl_sta;
74+
ctl_sta <= (bit_next & ram_next) ? (ram_done ? SYNC_BIT : READ_RAM) : ctl_sta;
75+
SYNC_BIT:
76+
ctl_sta <= syn_done ? IDLE : ctl_sta;
8177
default:
8278
ctl_sta <= IDLE;
8379
endcase
8480

8581
bit_st <= (ctl_sta != SEND_BIT) & ((ctl_sta == IDLE) | bit_st);
8682
bit_sel <= (ctl_sta == SEND_BIT) ? bit_sel + bit_next : 5'h00;
83+
bit_syn <= (ctl_sta == SYNC_BIT) ? bit_syn + 1'b1 : 9'h000;
8784

8885
bit_rdy <= (ctl_sta == SEND_BIT) & bit_next;
8986
bit_data <= (ctl_sta == SEND_BIT) & bit_next ? rd_data[5'd23 - bit_sel] : bit_data;
9087

9188
rd_done <= rd_en_out;
9289
rd_addr <= rd_done ? rd_data_in[29:24] : rd_addr;
9390
rd_data <= rd_done ? rd_data_in[23:0] : rd_data;
94-
95-
rst_cnt <= (ctl_sta == SEND_RST) ? rst_cnt + 1'b1 : 17'h0_0000;
9691
end
9792
end
9893

0 commit comments

Comments
 (0)