Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding virtual TM1638 for tang_nano_20k_hdmi board #196

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 65 additions & 9 deletions boards/tang_nano_20k_hdmi_tm1638/board_specific_top.sv
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

`ifdef FORCE_NO_INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE
`undef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE
`ifdef INSTANTIATE_GRAPHICS_INTERFACE_MODULE
`ifndef FORCE_NO_VIRTUAL_TM1638_USING_GRAPHICS
`define INSTANTIATE_VIRTUAL_TM1638_USING_GRAPHICS
`endif
`endif
`endif

`define IMITATE_RESET_ON_POWER_UP_FOR_TWO_BUTTON_CONFIGURATION
Expand Down Expand Up @@ -150,9 +155,15 @@ module board_specific_top
wire [w_x - 1:0] x;
wire [w_y - 1:0] y;

wire [w_red - 1:0] red;
wire [w_green - 1:0] green;
wire [w_blue - 1:0] blue;
wire [w_red - 1:0] lab_red;
wire [w_green - 1:0] lab_green;
wire [w_blue - 1:0] lab_blue;

wire vtm_red, vtm_green, vtm_blue;

wire [w_red - 1:0] red = lab_red ^ { w_red { vtm_red } };
wire [w_green - 1:0] green = lab_green ^ { w_green { vtm_green } };
wire [w_blue - 1:0] blue = lab_blue ^ { w_blue { vtm_blue } };

wire [ 23:0] mic;
wire [ 15:0] sound;
Expand Down Expand Up @@ -188,13 +199,28 @@ module board_specific_top
`ifdef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE

assign lab_key = tm_key;
assign tm_led = lab_led;
assign tm_digit = lab_digit;

assign LED = w_led' (~ lab_led);

`elsif INSTANTIATE_VIRTUAL_TM1638_USING_GRAPHICS

// Virtual tm1638 - tm_keys are input, not output

`ifdef REVERSE_KEY
`SWAP_BITS (lab_key, ~ KEY);
`else
assign lab_key = ~ KEY;
`endif

assign tm_key = lab_key;
assign tm_led = lab_led;
assign tm_digit = lab_digit;

assign LED = w_led' (~ lab_led);

`else // `ifdef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE
`else // no any form of TM1638

`ifdef REVERSE_KEY
`SWAP_BITS (lab_key, KEY);
Expand Down Expand Up @@ -255,9 +281,9 @@ module board_specific_top
.x ( x ),
.y ( y ),

.red ( red ),
.green ( green ),
.blue ( blue ),
.red ( lab_red ),
.green ( lab_green ),
.blue ( lab_blue ),

.uart_rx ( UART_RX ),
.uart_tx ( UART_TX ),
Expand All @@ -269,10 +295,13 @@ module board_specific_top

//------------------------------------------------------------------------

wire [$left (abcdefgh):0] hgfedcba;
`SWAP_BITS (hgfedcba, abcdefgh);

//------------------------------------------------------------------------

`ifdef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE

wire [$left (abcdefgh):0] hgfedcba;
`SWAP_BITS (hgfedcba, abcdefgh);

tm1638_board_controller
# (
Expand All @@ -298,6 +327,33 @@ module board_specific_top

`ifdef INSTANTIATE_GRAPHICS_INTERFACE_MODULE

`ifdef INSTANTIATE_VIRTUAL_TM1638_USING_GRAPHICS

virtual_tm1638_using_graphics
# (
.w_digit ( w_tm_digit ),
.screen_width ( screen_width ),
.screen_height ( screen_height )
)
i_tm1638_virtual
(
.clk ( clk ),
.rst ( rst ),
.hgfedcba ( hgfedcba ),
.digit ( tm_digit ),
.ledr ( tm_led ),
.keys ( tm_key ),
.x ( x ),
.y ( y ),
.red ( vtm_red ),
.green ( vtm_green ),
.blue ( vtm_blue )
);

`endif

//--------------------------------------------------------------------

localparam serial_clk_mhz = 125;

wire serial_clk;
Expand Down