-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
175 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* ws281x_conf.sv | ||
* | ||
* Created on: 2020-07-10 14:29 | ||
* Author: Jack Chen <redchenjs@live.com> | ||
*/ | ||
|
||
module ws281x_conf( | ||
input logic clk_in, | ||
input logic rst_n_in, | ||
|
||
input logic bit_rdy_in, | ||
input logic bit_data_in, | ||
|
||
input logic [7:0] t0h_cnt_in, | ||
input logic [7:0] t0l_cnt_in, | ||
input logic [7:0] t1h_cnt_in, | ||
input logic [7:0] t1l_cnt_in, | ||
|
||
output logic [7:0] tim_sum_out | ||
); | ||
|
||
logic [7:0] tim_sum; | ||
|
||
wire [7:0] t0_sum = t0h_cnt_in + t0l_cnt_in; | ||
wire [7:0] t1_sum = t1h_cnt_in + t1l_cnt_in; | ||
|
||
assign tim_sum_out = tim_sum; | ||
|
||
always_ff @(posedge clk_in or negedge rst_n_in) | ||
begin | ||
if (!rst_n_in) begin | ||
tim_sum <= 8'h00; | ||
end else begin | ||
tim_sum <= bit_rdy_in ? (bit_data_in ? t1_sum : t0_sum) : tim_sum; | ||
end | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* test_ws281x_conf.sv | ||
* | ||
* Created on: 2020-07-10 14:31 | ||
* Author: Jack Chen <redchenjs@live.com> | ||
*/ | ||
|
||
`timescale 1ns / 1ps | ||
|
||
module test_ws281x_conf; | ||
|
||
logic clk_in; | ||
logic rst_n_in; | ||
|
||
logic bit_rdy_in; | ||
logic bit_data_in; | ||
|
||
logic [7:0] t0h_cnt_in; | ||
logic [7:0] t0l_cnt_in; | ||
logic [7:0] t1h_cnt_in; | ||
logic [7:0] t1l_cnt_in; | ||
|
||
logic [7:0] tim_sum_out; | ||
|
||
ws281x_conf test_ws281x_conf( | ||
.clk_in(clk_in), | ||
.rst_n_in(rst_n_in), | ||
|
||
.bit_rdy_in(bit_rdy_in), | ||
.bit_data_in(bit_data_in), | ||
|
||
.t0h_cnt_in(t0h_cnt_in), | ||
.t0l_cnt_in(t0l_cnt_in), | ||
.t1h_cnt_in(t1h_cnt_in), | ||
.t1l_cnt_in(t1l_cnt_in), | ||
|
||
.tim_sum_out(tim_sum_out) | ||
); | ||
|
||
initial begin | ||
clk_in <= 1'b1; | ||
rst_n_in <= 1'b0; | ||
|
||
bit_rdy_in <= 1'b0; | ||
bit_data_in <= 1'b0; | ||
|
||
// Unit: 10 ns (2 clk) | ||
t0h_cnt_in <= 8'h01; | ||
t0l_cnt_in <= 8'h7f; | ||
t1h_cnt_in <= 8'hfe; | ||
t1l_cnt_in <= 8'h01; | ||
|
||
#2 rst_n_in <= 1'b1; | ||
end | ||
|
||
always begin | ||
#2.5 clk_in <= ~clk_in; | ||
end | ||
|
||
always begin | ||
#11 bit_rdy_in <= 1'b1; | ||
#5 bit_rdy_in <= 1'b0; | ||
|
||
#10 bit_data_in <= 1'b1; | ||
|
||
#10 bit_rdy_in <= 1'b1; | ||
#5 bit_rdy_in <= 1'b0; | ||
|
||
#75 rst_n_in <= 1'b0; | ||
#25 $stop; | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters