Debian Codegraph @

examples/pll-nanolcd/TOP.v

raw
1 (* top *)
2 module TOP
3 (
4 input rst_i,
5 input clk,
6
7 output LCD_CLK,
8 output LCD_HYNC,
9 output LCD_SYNC,
10 output LCD_DEN,
11 output [4:0] LCD_R,
12 output [5:0] LCD_G,
13 output [4:0] LCD_B,
14
15 output LED_R,
16 output LED_G,
17 output LED_B
18
19 );
20
21 wire rst = rst_i ^ `INV_BTN;
22 wire CLK_SYS;
23 wire CLK_PIX;
24
25 /* //使用内部时钟
26 Gowin_OSC chip_osc(
27 .oscout(oscout_o) //output oscout
28 );
29 */
30 rPLL pll(
31 .CLKOUT(CLK_PIX), // 9MHz
32 .CLKIN(clk),
33 .CLKFB(GND),
34 .RESET(GND),
35 .RESET_P(GND),
36 .FBDSEL({GND,GND,GND,GND,GND,GND}),
37 .IDSEL({GND,GND,GND,GND,GND,GND}),
38 .ODSEL({GND,GND,GND,GND,GND,GND}),
39 .DUTYDA({GND,GND,GND,GND}),
40 .PSDA({GND,GND,GND,GND}),
41 .FDLY({GND,GND,GND,GND})
42 );
43 defparam pll.DEVICE = `PLL_DEVICE;
44 defparam pll.FCLKIN = `PLL_FCLKIN;
45 defparam pll.FBDIV_SEL = `PLL_FBDIV_SEL_LCD;
46 defparam pll.IDIV_SEL = `PLL_IDIV_SEL_LCD;
47 defparam pll.ODIV_SEL = `PLL_ODIV_SEL;
48 defparam pll.CLKFB_SEL="internal";
49 defparam pll.CLKOUTD3_SRC="CLKOUT";
50 defparam pll.CLKOUTD_BYPASS="true";
51 defparam pll.CLKOUTD_SRC="CLKOUT";
52 defparam pll.CLKOUTP_BYPASS="false";
53 defparam pll.CLKOUTP_DLY_STEP=0;
54 defparam pll.CLKOUTP_FT_DIR=1'b1;
55 defparam pll.CLKOUT_BYPASS="false";
56 defparam pll.CLKOUT_DLY_STEP=0;
57 defparam pll.CLKOUT_FT_DIR=1'b1;
58 defparam pll.DUTYDA_SEL="1000";
59 defparam pll.DYN_DA_EN="false";
60 defparam pll.DYN_FBDIV_SEL="false";
61 defparam pll.DYN_IDIV_SEL="false";
62 defparam pll.DYN_ODIV_SEL="false";
63 defparam pll.DYN_SDIV_SEL=1; // 9MHz --- pixel clock
64 defparam pll.PSDA_SEL="0000";
65
66 VGAMod D1
67 (
68 .CLK ( CLK_SYS ),
69 .nRST ( rst ),
70
71 .PixelClk ( CLK_PIX ),
72 .LCD_DE ( LCD_DEN ),
73 .LCD_HSYNC ( LCD_HYNC ),
74 .LCD_VSYNC ( LCD_SYNC ),
75
76 .LCD_B ( LCD_B ),
77 .LCD_G ( LCD_G ),
78 .LCD_R ( LCD_R )
79 );
80
81 assign LCD_CLK = CLK_PIX;
82 assign CLK_SYS = CLK_PIX;
83
84
85 //RGB LED TEST
86 reg [24:0] Count;
87 reg [1:0] rgb_data;
88 always @( posedge CLK_SYS or negedge rst )
89 begin
90 if( !rst )
91 begin
92 Count <= 25'd0;
93 rgb_data <= 2'b00;
94 end
95 else if ( Count == 1200000 )
96 begin
97 Count <= 4'b0;
98 rgb_data <= rgb_data + 1'b1;
99 end
100 else
101 Count <= Count + 1'b1;
102 end
103 assign LED_R = ~(rgb_data == 2'b01);
104 assign LED_G = ~(rgb_data == 2'b10);
105 assign LED_B = ~(rgb_data == 2'b11);
106
107 endmodule