diff --git a/boards/tang_nano_20k_lcd_480_272_tm1638/README.md b/boards/tang_nano_20k_lcd_480_272_tm1638/README.md new file mode 100644 index 00000000..436cf4eb --- /dev/null +++ b/boards/tang_nano_20k_lcd_480_272_tm1638/README.md @@ -0,0 +1,51 @@ +# Tang Nano 20K Documentation + +The **Tang Nano 20K** is a compact FPGA development board designed by Sipeed. It is based on the GW2AR-18 FPGA chip and is suitable for a variety of applications, including digital signal processing, embedded systems, and hardware prototyping. + +## Key Features +- **FPGA Chip**: GW2AR-18 +- **Logic Cells**: 20,736 +- **Block RAM**: 864 Kbits +- **32-bit SDR SDRAM**: 64 Mbits +- **Onboard Resources**: + - **Debugger**: BL616 (JTAG, USB to UART, USB to SPI) + - **Clock Generator**: MS5351 (provides multiple clocks) + - **Display Interface**: 40-pin RGB LCD connector, HDMI interface + - **LEDs**: 6 user-controllable LEDs + - **RGB LED**: 1 WS2812 RGB LED for visual feedback + - **User Buttons**: 2 buttons for input purposes + - **TF Card Slot**: For external storage + - **PCM Amplifier**: MAX98357A for audio driving + - **Flash Storage**: 64 Mbits for saving bitstream + - **Size**: 22.55mm x 54.04mm + +## Pinout Diagram + +![Tang Nano 20K Pinout](./tang_nano_20k_pinlabel.png) + +See [IC -> Name mapping](./board_specific.cst) and [Name -> Use mapping](./board_specific_top.sv). + +| Use | Name | IC | Board | IC | Name | Use | +|----------------:|--------:|----:|:-----:|----:|-----------------|------------------| +| INMP441: i2s_lr | GPIO[1] | 73 | USB-C | 5V | | | +| INMP441: i2s_ws | GPIO[2] | 74 | S1 S2 | GND | | | +| INMP441: i2s_sck| GPIO[3] | 75 | 6xLED | 76 | | | +| INMP441: i2s_sd | SD_DAT1 | 85 | | 80 | | | +| | | 77 | Si | 42 | | | +| | | 15 | PEED | 41 | | | +| | | 16 | | 56 | | | +| | | 27 | | 54 | | | +| | | 28 | | 51 | | | +| | | 25 | TANG | 48 | | | +| | | 26 | | 55 | | | +| | | 29 | | 49 | | | +| | | 30 | NANO | 86 | GPIO[0] | TM1638: sio_data | +| | | 31 | | 79 | | | +| | | 17 | | GND | | Ground | +| | | 20 | [20K] | 3V3 | | Power: 3.3V | +| | | 19 | | 72 | JOYSTICK_CS2 | TM1638: sio_clk | +| | | 18 | HDMI | 71 | JOYSTICK_MISO2 | TM1638: sio_stb | +| | | 3V3 | | 53 | | | +| | | GND | | 52 | | | + +For more detailed information and tutorials, please visit the [Tang Nano 20K Wiki](https://wiki.sipeed.com/hardware/en/tang/tang-nano-20k/nano-20k.html). diff --git a/boards/tang_nano_20k_lcd_480_272_tm1638/board_specific.cst b/boards/tang_nano_20k_lcd_480_272_tm1638/board_specific.cst new file mode 100644 index 00000000..a9765c53 --- /dev/null +++ b/boards/tang_nano_20k_lcd_480_272_tm1638/board_specific.cst @@ -0,0 +1,154 @@ +// The pin assignments +// All I/O pins here are 3.3V compatible unless specified otherwise + + IO_LOC "CLK" 4; + + IO_LOC "KEY[0]" 88; + IO_LOC "KEY[1]" 87; + + //IO_LOC "LED[0]" 15; + //IO_LOC "LED[1]" 16; + //IO_LOC "LED[2]" 17; + //IO_LOC "LED[3]" 18; + //IO_LOC "LED[4]" 19; + //IO_LOC "LED[5]" 20; + +// Some LCD pins share bank with TMDS pins +// which have different voltage requirements. + + IO_LOC "LCD_CLK" 77; + IO_LOC "LCD_DEN" 48; + //IO_LOC "LCD_HS" 25; + //IO_LOC "LCD_VS" 26; + + IO_LOC "LCD_R[3]" 42; + IO_LOC "LCD_R[4]" 41; + IO_LOC "LCD_R[5]" 49; + IO_LOC "LCD_R[6]" 39; + IO_LOC "LCD_R[7]" 38; + + IO_LOC "LCD_G[2]" 37; + IO_LOC "LCD_G[3]" 36; + IO_LOC "LCD_G[4]" 35; + IO_LOC "LCD_G[5]" 34; + IO_LOC "LCD_G[6]" 33; + IO_LOC "LCD_G[7]" 32; + + IO_LOC "LCD_B[3]" 31; + IO_LOC "LCD_B[4]" 30; + IO_LOC "LCD_B[5]" 29; + IO_LOC "LCD_B[6]" 28; + IO_LOC "LCD_B[7]" 27; + +// TMDS pins conflict with LCD pins +// In this configuration they are commented out +// IO_LOC "O_TMDS_CLK_P" 33,34; +// IO_LOC "O_TMDS_DATA_P[0]" 35,36; +// IO_LOC "O_TMDS_DATA_P[1]" 37,38; +// IO_LOC "O_TMDS_DATA_P[2]" 39,40; + +// DVI I2C + //IO_LOC "EDID_CLK" 53; + //IO_LOC "EDID_DAT" 52; + +// UART to debugger + //IO_LOC "UART_TX" 70; + //IO_LOC "UART_RX" 69; + +// //IO_LOC "UART_RXD" 31; // Conflct with LCD_B[0] +// //IO_LOC "UART_TXD" 30; // Conflct with LCD_B[1] + +// SDIO pins for SD-cards + //IO_LOC "SD_CLK" 83; + //IO_LOC "SD_CMD" 82; + //IO_LOC "SD_DAT0" 84; + //IO_LOC "SD_DAT1" 85; // Used for inmp441 sd + //IO_LOC "SD_DAT2" 80; + //IO_LOC "SD_DAT3" 81; + +// Onboard I2S audio + //IO_LOC "HP_BCK" 56; // DAC_BCLK + //IO_LOC "HP_DIN" 54; // DAC_DIN + //IO_LOC "HP_WS" 55; // DAC_LRCK + //IO_LOC "PA_EN" 51; // For audio, should be assigned 1 + +// On-board WS2812 RGB LED with a serial interface + //IO_LOC "WS2812" 79; + +// GPIO for external modules + +// //IO_LOC "JOYSTICK_CLK" 17; // Conflict with LED[2] +// //IO_LOC "JOYSTICK_MOSI" 20; // Conflict with LED[5] +// //IO_LOC "JOYSTICK_MISO" 19; // Conflict with LED[4] +// //IO_LOC "JOYSTICK_CS" 18; // Conflict with LED[3] + +// //IO_LOC "JOYSTICK_CLK2" 52; // Conflicts with EDID_CLK +// //IO_LOC "JOYSTICK_MOSI2" 53; // Conflicts with EDID_DAT + //IO_LOC "JOYSTICK_MISO2" 71; // TM1638: sio_stb + //IO_LOC "JOYSTICK_CS2" 72; // TM1638: sio_clk + + //IO_LOC "GPIO[0]" 86; // TM1638: sio_data + //IO_LOC "GPIO[1]" 73; // INMP441: i2s_lr + //IO_LOC "GPIO[2]" 74; // INMP441: i2s_ws + //IO_LOC "GPIO[3]" 75; // INMP441: i2s_sck +// //IO_LOC "SD_DAT1" 85; // INMP441: i2s_sd + +// Extra GPIO for custom tasks + //IO_LOC "GPIO[4]" 76; +// //IO_LOC "SD_DAT2" 80; +// //IO_LOC "WS2812" 79; +// //IO_LOC "EDID_CLK" 53; +// //IO_LOC "EDID_DAT" 52; + + +// TM1638 occupy: +// +// 86 GPIO[0] - tm1638: sio_data +// 72 JOYSTICK_CS2 - tm1638: sio_clk +// 71 JOYSTICK_MISO2 - tm1638: sio_stb + +// INMP 441 occupy: +// +// 73 GPIO[1] - inmp441: lr +// 74 GPIO[2] - inmp441: ws +// 75 GPIO[3] - inmp441: sck +// 85 SD_DAT1 - inmp441: sd + +// Extra pins for GPIO: +// +// 76 GCLKC_1 - gpio[0] +// 80 SD_DAT2 - gpio[1] +// Consider 79 / 2812_DIN +// Consider 53 / EDID_CLK +// Consider 52 / EDID_DAT + +// Pin conflicts: +// +// 17; //IO_LOC "JOYSTICK_CLK" +// 17; //IO_LOC "LED[2]" +// +// 18; //IO_LOC "JOYSTICK_CS" +// 18; //IO_LOC "LED[3]" +// +// 19; //IO_LOC "JOYSTICK_MISO" +// 19; //IO_LOC "LED[4]" +// +// 20; //IO_LOC "JOYSTICK_MOSI" +// 20; //IO_LOC "LED[5]" +// +// 30; //IO_LOC "LCD_B[1]" +// 30; //IO_LOC "UART_TXD" +// +// 31; //IO_LOC "LCD_B[0]" +// 31; //IO_LOC "UART_RXD" +// +// 33,34; //IO_LOC "O_TMDS_CLK_P" +// 33; //IO_LOC "LCD_G[4]" +// +// 35,36; //IO_LOC "O_TMDS_DATA_P[0]" +// 35; //IO_LOC "LCD_G[2]" +// +// 37,38; //IO_LOC "O_TMDS_DATA_P[1]" +// 37; //IO_LOC "LCD_G[0]" +// +// 39,40; IO_LOC "O_TMDS_DATA_P[2]" diff --git a/boards/tang_nano_20k_lcd_480_272_tm1638/board_specific.sdc b/boards/tang_nano_20k_lcd_480_272_tm1638/board_specific.sdc new file mode 100644 index 00000000..56287490 --- /dev/null +++ b/boards/tang_nano_20k_lcd_480_272_tm1638/board_specific.sdc @@ -0,0 +1,5 @@ +// The timing constraints +// + +create_clock -name CLK -period 37.037 -waveform {0 18.518} [get_ports {CLK}] +//create_clock -name LCD_CLK -period 111.11 -waveform {0 55.555} [get_ports {LCD_CLK}] \ No newline at end of file diff --git a/boards/tang_nano_20k_lcd_480_272_tm1638/board_specific.tcl b/boards/tang_nano_20k_lcd_480_272_tm1638/board_specific.tcl new file mode 100644 index 00000000..25b1bca7 --- /dev/null +++ b/boards/tang_nano_20k_lcd_480_272_tm1638/board_specific.tcl @@ -0,0 +1,10 @@ +# The synthesis options + +set_device GW2AR-LV18QN88C8/I7 -name GW2AR-18 -device_version C +set_option -synthesis_tool gowinsynthesis +set_option -output_base_name fpga_project +set_option -top_module board_specific_top +set_option -verilog_std sysv2017 + +set_option -use_mspi_as_gpio 1 +set_option -use_sspi_as_gpio 1 diff --git a/boards/tang_nano_20k_lcd_480_272_tm1638/board_specific_top.sv b/boards/tang_nano_20k_lcd_480_272_tm1638/board_specific_top.sv new file mode 100644 index 00000000..28a0dcb7 --- /dev/null +++ b/boards/tang_nano_20k_lcd_480_272_tm1638/board_specific_top.sv @@ -0,0 +1,506 @@ +`include "config.svh" +`include "lab_specific_board_config.svh" +`include "swap_bits.svh" + +//---------------------------------------------------------------------------- + +`ifdef FORCE_NO_INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE + `undef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE +`endif + +`define IMITATE_RESET_ON_POWER_UP_FOR_TWO_BUTTON_CONFIGURATION +`define REVERSE_KEY +`define REVERSE_LED + +//---------------------------------------------------------------------------- + +module lcd_timing +( + input PixelClk, + input nRST, + + output LCD_DE, + + output [4:0] LCD_B, + output [5:0] LCD_G, + output [4:0] LCD_R +); + + // Horizen count to Hsync, then next Horizen line. + + parameter H_Pixel_Valid = 16'd480; + parameter H_FrontPorch = 16'd50; + parameter H_BackPorch = 16'd30; + + parameter PixelForHS = H_Pixel_Valid + H_FrontPorch + H_BackPorch; + + parameter V_Pixel_Valid = 16'd272; + parameter V_FrontPorch = 16'd20; + parameter V_BackPorch = 16'd5; + + parameter PixelForVS = V_Pixel_Valid + V_FrontPorch + V_BackPorch; + + // Horizen pixel count + + reg [15:0] H_PixelCount; + reg [15:0] V_PixelCount; + + always @( posedge PixelClk or negedge nRST )begin + if( !nRST ) begin + V_PixelCount <= 16'b0; + H_PixelCount <= 16'b0; + end + else if( H_PixelCount == PixelForHS ) begin + V_PixelCount <= V_PixelCount + 1'b1; + H_PixelCount <= 16'b0; + end + else if( V_PixelCount == PixelForVS ) begin + V_PixelCount <= 16'b0; + H_PixelCount <= 16'b0; + end + else begin + V_PixelCount <= V_PixelCount ; + H_PixelCount <= H_PixelCount + 1'b1; + end + end + + // SYNC-DE MODE + + assign LCD_DE = ( H_PixelCount >= H_BackPorch ) && ( H_PixelCount <= H_Pixel_Valid + H_BackPorch ) && + ( V_PixelCount >= V_BackPorch ) && ( V_PixelCount <= V_Pixel_Valid + V_BackPorch ) && PixelClk; + + // color bar + localparam Colorbar_width = H_Pixel_Valid / 16; + + assign LCD_R = ( H_PixelCount < ( H_BackPorch + Colorbar_width * 0 )) ? 5'b00000 : + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 1 )) ? 5'b00001 : + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 2 )) ? 5'b00010 : + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 3 )) ? 5'b00100 : + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 4 )) ? 5'b01000 : + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 5 )) ? 5'b10000 : 5'b00000; + + assign LCD_G = ( H_PixelCount < ( H_BackPorch + Colorbar_width * 6 )) ? 6'b000001: + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 7 )) ? 6'b000010: + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 8 )) ? 6'b000100: + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 9 )) ? 6'b001000: + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 10 )) ? 6'b010000: + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 11 )) ? 6'b100000: 6'b000000; + + assign LCD_B = ( H_PixelCount < ( H_BackPorch + Colorbar_width * 12 )) ? 5'b00001 : + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 13 )) ? 5'b00010 : + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 14 )) ? 5'b00100 : + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 15 )) ? 5'b01000 : + ( H_PixelCount < ( H_BackPorch + Colorbar_width * 16 )) ? 5'b10000 : 5'b00000; + +endmodule + + +module board_specific_top +# ( + parameter clk_mhz = 27, + pixel_mhz = 9, + + w_key = 2, // The last key is used for a reset + w_sw = 0, + w_led = 6, + w_digit = 0, + w_gpio = 5, + + `ifdef USE_LCD_800_480 + + screen_width = 800, + screen_height = 480, + + `else // USE_LCD_480_272 or USE_LCD_480_272_ML6485 + + screen_width = 480, + screen_height = 272, + + `endif + + w_red = 5, + w_green = 6, + w_blue = 5, + + w_x = $clog2 ( screen_width ), + w_y = $clog2 ( screen_height ) +) +( + input CLK, + + input [w_key - 1:0] KEY, + + //output [w_led - 1:0] LED, + + // Some LCD pins share bank with TMDS pins + // which have different voltage requirements. + // + // However we can use LCD_DEN, VS, HS, CK, + // because they are assigned to a different bank. + + output LCD_DEN, + //output LCD_VS, + //output LCD_HS, + output LCD_CLK, + + output [7:7 + 1 - w_red ] LCD_R, + output [7:7 + 1 - w_green ] LCD_G, + output [7:7 + 1 - w_blue ] LCD_B + //input UART_RX, + //output UART_TX, + + //inout [w_gpio - 1:0] GPIO, + + // DVI ports + // output O_TMDS_CLK_N, + // output O_TMDS_CLK_P, + // output [ 2:0] O_TMDS_DATA_N, + // output [ 2:0] O_TMDS_DATA_P, + + //inout EDID_CLK, + //inout EDID_DAT, + + // output JOYSTICK_CLK, + // output JOYSTICK_MOSI, + // output JOYSTICK_MISO, + // output JOYSTICK_CS, + + // output JOYSTICK_CLK2, + // output JOYSTICK_MOSI2, + //output JOYSTICK_MISO2, + //output JOYSTICK_CS2, + + // SD card ports + //output SD_CLK, + //output SD_CMD, + //inout SD_DAT0, + //inout SD_DAT1, + //inout SD_DAT2, + //inout SD_DAT3, + + // Ports for on-board I2S amplifier + //output HP_BCK, + //output HP_DIN, + //output HP_WS, + //output PA_EN, + + // On-board WS2812 RGB LED with a serial interface + //inout WS2812 +); + + + Gowin_rPLL Gowin_rPLL_9Mhz( + .clkout(LCD_CLK), // 9MHz + .clkin(CLK) //27MHz + ); + + lcd_timing lcd_timing_inst( + .PixelClk ( LCD_CLK ), + .nRST ( ~ KEY [0] ), + + .LCD_DE ( LCD_DEN ), + + .LCD_B ( LCD_B ), + .LCD_G ( LCD_G ), + .LCD_R ( LCD_R ) + ); + + +`ifdef UNDEFINED + + wire clk = CLK; + + //------------------------------------------------------------------------ + + localparam w_tm_key = 8, + w_tm_led = 8, + w_tm_digit = 8; + + //------------------------------------------------------------------------ + + `ifdef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE + + localparam w_lab_key = w_tm_key, + w_lab_led = w_tm_led, + w_lab_digit = w_tm_digit; + + `else // TM1638 module is not connected + + // We create a dummy seven-segment digit + // to avoid errors in the labs with seven-segment display + + localparam w_lab_key = w_key, + w_lab_led = w_led, + w_lab_digit = 1; // w_digit; + + `endif + + //------------------------------------------------------------------------ + + wire [w_tm_key - 1:0] tm_key; + wire [w_tm_led - 1:0] tm_led; + wire [w_tm_digit - 1:0] tm_digit; + + logic [w_lab_key - 1:0] lab_key; + wire [w_lab_led - 1:0] lab_led; + wire [w_lab_digit - 1:0] lab_digit; + + wire [ 7:0] abcdefgh; + + wire [w_x - 1:0] x; + wire [w_y - 1:0] y; + + wire [ 23:0] mic; + wire [ 15:0] sound; + + //------------------------------------------------------------------------ + + `ifdef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE + + wire rst_on_power_up; + imitate_reset_on_power_up i_reset_on_power_up (clk, rst_on_power_up); + + wire rst = rst_on_power_up | (| (~ KEY)); + + `elsif IMITATE_RESET_ON_POWER_UP_FOR_TWO_BUTTON_CONFIGURATION + + wire rst_on_power_up; + imitate_reset_on_power_up i_reset_on_power_up (clk, rst_on_power_up); + + wire rst = rst_on_power_up; + + `else // Reset using an on-board button + + `ifdef REVERSE_KEY + wire rst = ~ KEY [0]; + `else + wire rst = ~ KEY [w_key - 1]; + `endif + + `endif + + //------------------------------------------------------------------------ + + `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); + + `else // `ifdef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE + + `ifdef REVERSE_KEY + `SWAP_BITS (lab_key, ~ KEY); + `else + assign lab_key = ~ KEY; + `endif + + //-------------------------------------------------------------------- + + `ifdef REVERSE_LED + `SWAP_BITS (LED, ~ lab_led); + `else + assign LED = ~ lab_led; + `endif + + `endif // `ifdef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE + + //------------------------------------------------------------------------ + + wire slow_clk; + + slow_clk_gen # (.fast_clk_mhz (clk_mhz), .slow_clk_hz (1)) + i_slow_clk_gen (.slow_clk (slow_clk), .*); + + //------------------------------------------------------------------------ + + wire [w_x - 1:0] mirrored_x = w_x' (screen_width - 1 - x); + wire [w_y - 1:0] mirrored_y = w_y' (screen_height - 1 - y); + + //------------------------------------------------------------------------ + + lab_top + # ( + .clk_mhz ( clk_mhz ), + + .w_key ( w_lab_key ), + .w_sw ( w_lab_key ), + .w_led ( w_lab_led ), + .w_digit ( w_lab_digit ), + .w_gpio ( w_gpio ), + + .screen_width ( screen_width ), + .screen_height ( screen_height ), + + .w_red ( w_red ), + .w_green ( w_green ), + .w_blue ( w_blue ) + ) + i_lab_top + ( + .clk ( clk ), + .slow_clk ( slow_clk ), + .rst ( rst ), + + .key ( lab_key ), + .sw ( lab_key ), + + .led ( lab_led ), + + .abcdefgh ( abcdefgh ), + .digit ( lab_digit ), + + .x ( mirrored_x ), + .y ( mirrored_y ), + + .red ( LCD_R ), + .green ( LCD_G ), + .blue ( LCD_B ), + + .uart_rx ( UART_RX ), + .uart_tx ( UART_TX ), + + .mic ( mic ), + .sound ( sound ), + .gpio ( GPIO ) + ); + + //------------------------------------------------------------------------ + + `ifdef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE + + wire [$left (abcdefgh):0] hgfedcba; + `SWAP_BITS (hgfedcba, abcdefgh); + + `endif + + //------------------------------------------------------------------------ + + `ifdef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE + + tm1638_board_controller + # ( + .clk_mhz ( clk_mhz ), + .w_digit ( w_tm_digit ) + ) + i_tm1638 + ( + .clk ( clk ), + .rst ( rst ), + .hgfedcba ( hgfedcba ), + .digit ( tm_digit ), + .ledr ( tm_led ), + .keys ( tm_key ), + .sio_data ( GPIO [0] ), + .sio_clk ( JOYSTICK_CS2 ), + .sio_stb ( JOYSTICK_MISO2 ) + ); + + `endif + + //------------------------------------------------------------------------ + + `ifdef INSTANTIATE_GRAPHICS_INTERFACE_MODULE + + `ifdef USE_LCD_800_480 + + wire lcd_module_clk; + + Gowin_rPLL i_Gowin_rPLL + ( + .clkout ( lcd_module_clk ), // 200 MHz + .clkoutd ( LCD_CLK ), // 33.33 MHz + .clkin ( clk ) // 27 MHz + ); + + `else // Using 480x272 + + Gowin_rPLL Gowin_rPLL + ( + .clkout ( LCD_CLK ), // 9 MHz + .clkin ( clk ) // 27 MHz + ); + + `endif + + `ifdef USE_LCD_800_480 + lcd_800_480 + `else + lcd_480_272 + `endif + i_lcd + ( + `ifdef USE_LCD_800_480 + .CLK ( lcd_module_clk ), + `endif + + .PixelClk ( LCD_CLK ), + .nRST ( ~ rst ), + + .LCD_DE ( LCD_DEN ), + //.LCD_HSYNC ( LCD_HS ), + //.LCD_VSYNC ( LCD_VS ), + + .x ( x ), + .y ( y ) + ); + + assign LCD_INIT = 1'b0; + assign LCD_BL = 1'b0; + + `endif + + //------------------------------------------------------------------------ + + `ifdef INSTANTIATE_MICROPHONE_INTERFACE_MODULE + + inmp441_mic_i2s_receiver + # ( + .clk_mhz ( clk_mhz ) + ) + i_microphone + ( + .clk ( clk ), + .rst ( rst ), + .lr ( GPIO[1] ), + .ws ( GPIO[2] ), + .sck ( GPIO[3] ), + .sd ( SD_DAT1 ), + .value ( mic ) + ); + + `endif + + //------------------------------------------------------------------------ + + `ifdef INSTANTIATE_SOUND_OUTPUT_INTERFACE_MODULE + + // For tang_nano_20k DAC do not require mclk signal + // but it needs enable signal PA_EN + + i2s_audio_out + # ( + .clk_mhz ( clk_mhz ) + ) + inst_audio_out + ( + .clk ( clk ), + .reset ( rst ), + .data_in ( sound ), + .mclk ( ), + .bclk ( HP_BCK ), + .lrclk ( HP_WS ), + .sdata ( HP_DIN ) + ); + + // Enable DAC + assign PA_EN = 1'b1; + + `endif + +`endif + +endmodule diff --git a/boards/tang_nano_20k_lcd_480_272_tm1638/fpga_project_01.gprj b/boards/tang_nano_20k_lcd_480_272_tm1638/fpga_project_01.gprj new file mode 100644 index 00000000..b1dd66f3 --- /dev/null +++ b/boards/tang_nano_20k_lcd_480_272_tm1638/fpga_project_01.gprj @@ -0,0 +1,7 @@ + + + + + 5 + gw2ar18c-000 + diff --git a/boards/tang_nano_20k_lcd_480_272_tm1638/fpga_project_02.gprj b/boards/tang_nano_20k_lcd_480_272_tm1638/fpga_project_02.gprj new file mode 100644 index 00000000..8c6b9904 --- /dev/null +++ b/boards/tang_nano_20k_lcd_480_272_tm1638/fpga_project_02.gprj @@ -0,0 +1,2 @@ + + diff --git a/boards/tang_nano_20k_lcd_480_272_tm1638/gowin_rpll.ipc b/boards/tang_nano_20k_lcd_480_272_tm1638/gowin_rpll.ipc new file mode 100644 index 00000000..195a22b1 --- /dev/null +++ b/boards/tang_nano_20k_lcd_480_272_tm1638/gowin_rpll.ipc @@ -0,0 +1,24 @@ +[General] +ipc_version=4 +file=gowin_rpll +module=Gowin_rPLL +target_device=gw2ar18c-000 +type=clock_rpll +version=1.0 + +[Config] +CKLOUTD3=false +CLKFB_SOURCE=0 +CLKIN_FREQ=27 +CLKOUTD=false +CLKOUTP=false +CLKOUT_BYPASS=false +CLKOUT_DIVIDE_DYN=true +CLKOUT_FREQ=9 +CLKOUT_TOLERANCE=0 +DYNAMIC=true +LANG=0 +LOCK_EN=false +MODE_GENERAL=true +PLL_PWD=false +RESET_PLL=false diff --git a/boards/tang_nano_20k_lcd_480_272_tm1638/gowin_rpll.v b/boards/tang_nano_20k_lcd_480_272_tm1638/gowin_rpll.v new file mode 100644 index 00000000..144ad62d --- /dev/null +++ b/boards/tang_nano_20k_lcd_480_272_tm1638/gowin_rpll.v @@ -0,0 +1,64 @@ +//Copyright (C)2014-2022 Gowin Semiconductor Corporation. +//All rights reserved. +//File Title: IP file +//GOWIN Version: V1.9.8.10 +//Part Number: GW2AR-LV18QN88C8/I7 +//Device: GW2AR-18 +//Device Version: C +//Created Time: Mon Apr 03 23:07:49 2023 + +module Gowin_rPLL (clkout, clkin); + +output clkout; +input clkin; + +wire lock_o; +wire clkoutp_o; +wire clkoutd_o; +wire clkoutd3_o; +wire gw_gnd; + +assign gw_gnd = 1'b0; + +rPLL rpll_inst ( + .CLKOUT(clkout), + .LOCK(lock_o), + .CLKOUTP(clkoutp_o), + .CLKOUTD(clkoutd_o), + .CLKOUTD3(clkoutd3_o), + .RESET(gw_gnd), + .RESET_P(gw_gnd), + .CLKIN(clkin), + .CLKFB(gw_gnd), + .FBDSEL({gw_gnd,gw_gnd,gw_gnd,gw_gnd,gw_gnd,gw_gnd}), + .IDSEL({gw_gnd,gw_gnd,gw_gnd,gw_gnd,gw_gnd,gw_gnd}), + .ODSEL({gw_gnd,gw_gnd,gw_gnd,gw_gnd,gw_gnd,gw_gnd}), + .PSDA({gw_gnd,gw_gnd,gw_gnd,gw_gnd}), + .DUTYDA({gw_gnd,gw_gnd,gw_gnd,gw_gnd}), + .FDLY({gw_gnd,gw_gnd,gw_gnd,gw_gnd}) +); + +defparam rpll_inst.FCLKIN = "27"; +defparam rpll_inst.DYN_IDIV_SEL = "false"; +defparam rpll_inst.IDIV_SEL = 2; +defparam rpll_inst.DYN_FBDIV_SEL = "false"; +defparam rpll_inst.FBDIV_SEL = 0; +defparam rpll_inst.DYN_ODIV_SEL = "false"; +defparam rpll_inst.ODIV_SEL = 64; +defparam rpll_inst.PSDA_SEL = "0000"; +defparam rpll_inst.DYN_DA_EN = "true"; +defparam rpll_inst.DUTYDA_SEL = "1000"; +defparam rpll_inst.CLKOUT_FT_DIR = 1'b1; +defparam rpll_inst.CLKOUTP_FT_DIR = 1'b1; +defparam rpll_inst.CLKOUT_DLY_STEP = 0; +defparam rpll_inst.CLKOUTP_DLY_STEP = 0; +defparam rpll_inst.CLKFB_SEL = "internal"; +defparam rpll_inst.CLKOUT_BYPASS = "false"; +defparam rpll_inst.CLKOUTP_BYPASS = "false"; +defparam rpll_inst.CLKOUTD_BYPASS = "false"; +defparam rpll_inst.DYN_SDIV_SEL = 2; +defparam rpll_inst.CLKOUTD_SRC = "CLKOUT"; +defparam rpll_inst.CLKOUTD3_SRC = "CLKOUT"; +defparam rpll_inst.DEVICE = "GW2AR-18C"; + +endmodule //Gowin_rPLL diff --git a/boards/tang_nano_20k_lcd_480_272_tm1638/project_process_config_01.json b/boards/tang_nano_20k_lcd_480_272_tm1638/project_process_config_01.json new file mode 100644 index 00000000..5b289cc1 --- /dev/null +++ b/boards/tang_nano_20k_lcd_480_272_tm1638/project_process_config_01.json @@ -0,0 +1,43 @@ +{ + "Allow_Duplicate_Modules" : false, + "Annotated_Properties_for_Analyst" : true, + "BACKGROUND_PROGRAMMING" : "off", + "CMSER" : false, + "CMSER_CHECKSUM" : false, + "CMSER_MODE" : "auto", + "COMPRESS" : false, + "CPU" : false, + "CRC_CHECK" : true, + "Clock_Conversion" : true, + "Clock_Route_Order" : 0, + "Correct_Hold_Violation" : true, + "DONE" : false, + "DOWNLOAD_SPEED" : "default", + "Default_Enum_Encoding" : "default", + "Disable_Insert_Pad" : false, + "ENABLE_MERGE_MODE" : false, + "ENCRYPTION_KEY" : false, + "ENCRYPTION_KEY_TEXT" : "00000000000000000000000000000000", + "ERROR_DECTION_AND_CORRECTION" : false, + "ERROR_DECTION_ONLY" : false, + "ERROR_INJECTION" : false, + "EXTERNAL_MASTER_CONFIG_CLOCK" : false, + "FORMAT" : "txt", + "FREQUENCY_DIVIDER" : "", + "FSM Compiler" : true, + "Fanout_Guide" : 10000, + "Frequency" : "Auto", + "Generate_Constraint_File_of_Ports" : false, + "Generate_IBIS_File" : false, + "Generate_Plain_Text_Timing_Report" : false, + "Generate_Post_PNR_Simulation_Model_File" : false, + "Generate_Post_Place_File" : false, + "Generate_SDF_File" : false, + "Generate_VHDL_Post_PNR_Simulation_Model_File" : false, + "GwSyn_Loop_Limit" : 2000, + "HOTBOOT" : false, + "I2C" : false, + "I2C_SLAVE_ADDR" : "00", + "Implicit_Initial_Value_Support" : false, + "IncludePath" : [ + \ No newline at end of file diff --git a/boards/tang_nano_20k_lcd_480_272_tm1638/project_process_config_02.json b/boards/tang_nano_20k_lcd_480_272_tm1638/project_process_config_02.json new file mode 100644 index 00000000..6914a154 --- /dev/null +++ b/boards/tang_nano_20k_lcd_480_272_tm1638/project_process_config_02.json @@ -0,0 +1,62 @@ + ], + "Incremental_Compile" : "", + "Initialize_Primitives" : false, + "JTAG" : false, + "MODE_IO" : false, + "MSPI" : true, + "MSPI_JUMP" : false, + "MULTIBOOT_ADDRESS_WIDTH" : "24", + "MULTIBOOT_MODE" : "Normal", + "MULTIBOOT_SPI_FLASH_ADDRESS" : "00000000", + "MULTIJUMP_ADDRESS_WIDTH" : "24", + "MULTIJUMP_MODE" : "Normal", + "MULTIJUMP_SPI_FLASH_ADDRESS" : "000000", + "Multi_Boot" : true, + "Multiple_File_Compilation_Unit" : true, + "Number_of_Critical_Paths" : "", + "Number_of_Start/End_Points" : "", + "OSC_DIVIDER" : "8", + "OUTPUT_BASE_NAME" : "Tang_nano_20K_LCD", + "POWER_ON_RESET_MONITOR" : true, + "PRINT_BSRAM_VALUE" : true, + "PROGRAM_DONE_BYPASS" : false, + "Pipelining" : true, + "PlaceInRegToIob" : true, + "PlaceIoRegToIob" : true, + "PlaceOutRegToIob" : true, + "Place_Option" : "0", + "Process_Configuration_Verion" : "1.0", + "Promote_Physical_Constraint_Warning_to_Error" : false, + "Push_Tristates" : true, + "READY" : false, + "RECONFIG_N" : false, + "Ram_RW_Check" : true, + "Report_Auto-Placed_Io_Information" : false, + "Resolve_Mixed_Drivers" : false, + "Resource_Sharing" : true, + "Retiming" : false, + "Route_Maxfan" : 23, + "Route_Option" : "0", + "Run_Timing_Driven" : true, + "SECURE_MODE" : false, + "SECURITY_BIT" : true, + "SSPI" : true, + "STOP_CMSER" : false, + "Show_All_Warnings" : false, + "Synthesis On/Off Implemented as Translate On/Off" : false, + "Synthesize_tool" : "GowinSyn", + "TclPre" : "", + "TopModule" : "TOP", + "USERCODE" : "default", + "Unused_Pin" : "As_input_tri_stated_with_pull_up", + "Update_Compile_Point_Timing_Data" : false, + "Use_Clock_Period_for_Unconstrainted IO" : false, + "VCCAUX" : 3.3, + "VCCX" : "3.3", + "VHDL_Standard" : "VHDL_Std_1993", + "Verilog_Standard" : "Vlg_Std_Sysv2017", + "WAKE_UP" : "0", + "Write_Vendor_Constraint_File" : true, + "show_all_warnings" : false, + "turn_off_bg" : false + } \ No newline at end of file diff --git a/boards/tang_nano_20k_lcd_480_272_tm1638/tang_nano_20k_pinlabel.png b/boards/tang_nano_20k_lcd_480_272_tm1638/tang_nano_20k_pinlabel.png new file mode 100644 index 00000000..da05a7ed Binary files /dev/null and b/boards/tang_nano_20k_lcd_480_272_tm1638/tang_nano_20k_pinlabel.png differ