Commit 5f4383b9c2d5243a68eac209285fac15e3905541
1 parent
56eab79f
Ajout partie VGA
Showing
4 changed files
with
276 additions
and
72 deletions
Show diff stats
7Segment_display/README.md
... | ... | @@ -77,7 +77,7 @@ end display; |
77 | 77 | |
78 | 78 | Les signaux |
79 | 79 | |
80 | - les signaux utilisés vont nous permettre d'avoir un code clean et plus ou moins factorié. | |
80 | + les signaux utilisés vont nous permettre d'avoir un code propre et plus ou moins factorisé. | |
81 | 81 | |
82 | 82 | ``` |
83 | 83 | architecture Behavioral of display is |
... | ... | @@ -160,7 +160,7 @@ end display; |
160 | 160 | |
161 | 161 | > le diviseur (clk_enable) ralentit la cadence de switch entre afficheur. Si l'on ne divise du fait de la vitesse les chiffres ne s'affichent pas correctement. |
162 | 162 | |
163 | - Ainsi la logique et l'électronique étant ici très rapide devant la fréquence de percepetion de l'oeil humain, l'utilisateur à l'impression que l'affichage et statique et que rien ne clignote. | |
163 | + Ainsi la logique et l'électronique étant ici très rapide devant la fréquence de perception de l'oeil humain, l'utilisateur à l'impression que l'affichage et statique et que rien ne clignote. | |
164 | 164 | |
165 | 165 | - 2ème processus : |
166 | 166 | |
... | ... | @@ -221,4 +221,4 @@ end display; |
221 | 221 | |
222 | 222 | - Enfin il a fallu implémanter un simple algorithme pour le compteur. |
223 | 223 | |
224 | -![counter](counter.gif) | |
225 | 224 | \ No newline at end of file |
225 | +![counter](counter.gif) | ... | ... |
Vga_display/Basys-3-Master.xdc
... | ... | @@ -113,20 +113,20 @@ set_property -dict { PACKAGE_PIN R2 IOSTANDARD LVCMOS33 } [get_ports {sw[14]} |
113 | 113 | |
114 | 114 | |
115 | 115 | ##VGA Connector |
116 | -#set_property -dict { PACKAGE_PIN G19 IOSTANDARD LVCMOS33 } [get_ports {vgaRed[0]}] | |
117 | -#set_property -dict { PACKAGE_PIN H19 IOSTANDARD LVCMOS33 } [get_ports {vgaRed[1]}] | |
118 | -#set_property -dict { PACKAGE_PIN J19 IOSTANDARD LVCMOS33 } [get_ports {vgaRed[2]}] | |
119 | -#set_property -dict { PACKAGE_PIN N19 IOSTANDARD LVCMOS33 } [get_ports {vgaRed[3]}] | |
120 | -#set_property -dict { PACKAGE_PIN N18 IOSTANDARD LVCMOS33 } [get_ports {vgaBlue[0]}] | |
121 | -#set_property -dict { PACKAGE_PIN L18 IOSTANDARD LVCMOS33 } [get_ports {vgaBlue[1]}] | |
122 | -#set_property -dict { PACKAGE_PIN K18 IOSTANDARD LVCMOS33 } [get_ports {vgaBlue[2]}] | |
123 | -#set_property -dict { PACKAGE_PIN J18 IOSTANDARD LVCMOS33 } [get_ports {vgaBlue[3]}] | |
124 | -#set_property -dict { PACKAGE_PIN J17 IOSTANDARD LVCMOS33 } [get_ports {vgaGreen[0]}] | |
125 | -#set_property -dict { PACKAGE_PIN H17 IOSTANDARD LVCMOS33 } [get_ports {vgaGreen[1]}] | |
126 | -#set_property -dict { PACKAGE_PIN G17 IOSTANDARD LVCMOS33 } [get_ports {vgaGreen[2]}] | |
127 | -#set_property -dict { PACKAGE_PIN D17 IOSTANDARD LVCMOS33 } [get_ports {vgaGreen[3]}] | |
128 | -#set_property -dict { PACKAGE_PIN P19 IOSTANDARD LVCMOS33 } [get_ports Hsync] | |
129 | -#set_property -dict { PACKAGE_PIN R19 IOSTANDARD LVCMOS33 } [get_ports Vsync] | |
116 | +set_property -dict { PACKAGE_PIN G19 IOSTANDARD LVCMOS33 } [get_ports {vgaRed[0]}] | |
117 | +set_property -dict { PACKAGE_PIN H19 IOSTANDARD LVCMOS33 } [get_ports {vgaRed[1]}] | |
118 | +set_property -dict { PACKAGE_PIN J19 IOSTANDARD LVCMOS33 } [get_ports {vgaRed[2]}] | |
119 | +set_property -dict { PACKAGE_PIN N19 IOSTANDARD LVCMOS33 } [get_ports {vgaRed[3]}] | |
120 | +set_property -dict { PACKAGE_PIN N18 IOSTANDARD LVCMOS33 } [get_ports {vgaBlue[0]}] | |
121 | +set_property -dict { PACKAGE_PIN L18 IOSTANDARD LVCMOS33 } [get_ports {vgaBlue[1]}] | |
122 | +set_property -dict { PACKAGE_PIN K18 IOSTANDARD LVCMOS33 } [get_ports {vgaBlue[2]}] | |
123 | +set_property -dict { PACKAGE_PIN J18 IOSTANDARD LVCMOS33 } [get_ports {vgaBlue[3]}] | |
124 | +set_property -dict { PACKAGE_PIN J17 IOSTANDARD LVCMOS33 } [get_ports {vgaGreen[0]}] | |
125 | +set_property -dict { PACKAGE_PIN H17 IOSTANDARD LVCMOS33 } [get_ports {vgaGreen[1]}] | |
126 | +set_property -dict { PACKAGE_PIN G17 IOSTANDARD LVCMOS33 } [get_ports {vgaGreen[2]}] | |
127 | +set_property -dict { PACKAGE_PIN D17 IOSTANDARD LVCMOS33 } [get_ports {vgaGreen[3]}] | |
128 | +set_property -dict { PACKAGE_PIN P19 IOSTANDARD LVCMOS33 } [get_ports Hsync] | |
129 | +set_property -dict { PACKAGE_PIN R19 IOSTANDARD LVCMOS33 } [get_ports Vsync] | |
130 | 130 | |
131 | 131 | |
132 | 132 | ##USB-RS232 Interface |
... | ... | @@ -156,4 +156,4 @@ set_property CFGBVS VCCO [current_design] |
156 | 156 | ## SPI configuration mode options for QSPI boot, can be used for all designs |
157 | 157 | set_property BITSTREAM.GENERAL.COMPRESS TRUE [current_design] |
158 | 158 | set_property BITSTREAM.CONFIG.CONFIGRATE 33 [current_design] |
159 | -set_property CONFIG_MODE SPIx4 [current_design] | |
160 | 159 | \ No newline at end of file |
160 | +set_property CONFIG_MODE SPIx4 [current_design] | ... | ... |
Vga_display/README.md
... | ... | @@ -8,21 +8,221 @@ |
8 | 8 | > L'ensemble des codes, images et vidéos sont compris dans ce répertoire. |
9 | 9 | |
10 | 10 | ## But du projet |
11 | - | |
11 | +Nous avons eu comme projet d'afficher différentes choses sur un écran en passant par son port VGA. | |
12 | 12 | ## I/O utilisées |
13 | - | |
13 | +Tout d'abord, voyons les entrées/sortie que nous avons utilisées. | |
14 | +``` | |
15 | +entity vga_controller is | |
16 | + Port (clk_fpga : in std_logic; | |
17 | + sw : in std_logic_vector(15 downto 0); | |
18 | + vgaRed : out std_logic_vector(3 downto 0); | |
19 | + vgaGreen : out std_logic_vector(3 downto 0); | |
20 | + vgaBlue : out std_logic_vector(3 downto 0); | |
21 | + Hsync : out std_logic; | |
22 | + Vsync : out std_logic); | |
23 | +end vga_controller; | |
24 | +- clk_fpga : le signal de clock du fpga | |
25 | +- sw : interrupteurs pour commander les couleurs | |
26 | +- vgaRed/Green/Blue : permet de commander la couleur à afficher | |
27 | +- Hsyn : synchronisation horizontale | |
28 | +- Vsyn : synchronisation verticale | |
29 | +``` | |
30 | +Dans le fichier de contrainte : | |
31 | +``` | |
32 | +set_property -dict { PACKAGE_PIN V17 IOSTANDARD LVCMOS33 } [get_ports {sw[0]}] | |
33 | +set_property -dict { PACKAGE_PIN V16 IOSTANDARD LVCMOS33 } [get_ports {sw[1]}] | |
34 | +set_property -dict { PACKAGE_PIN W16 IOSTANDARD LVCMOS33 } [get_ports {sw[2]}] | |
35 | +set_property -dict { PACKAGE_PIN W17 IOSTANDARD LVCMOS33 } [get_ports {sw[3]}] | |
36 | +set_property -dict { PACKAGE_PIN W15 IOSTANDARD LVCMOS33 } [get_ports {sw[4]}] | |
37 | +set_property -dict { PACKAGE_PIN V15 IOSTANDARD LVCMOS33 } [get_ports {sw[5]}] | |
38 | +set_property -dict { PACKAGE_PIN W14 IOSTANDARD LVCMOS33 } [get_ports {sw[6]}] | |
39 | +set_property -dict { PACKAGE_PIN W13 IOSTANDARD LVCMOS33 } [get_ports {sw[7]}] | |
40 | +set_property -dict { PACKAGE_PIN V2 IOSTANDARD LVCMOS33 } [get_ports {sw[8]}] | |
41 | +set_property -dict { PACKAGE_PIN T3 IOSTANDARD LVCMOS33 } [get_ports {sw[9]}] | |
42 | +set_property -dict { PACKAGE_PIN T2 IOSTANDARD LVCMOS33 } [get_ports {sw[10]}] | |
43 | +set_property -dict { PACKAGE_PIN R3 IOSTANDARD LVCMOS33 } [get_ports {sw[11]}] | |
44 | +set_property -dict { PACKAGE_PIN W2 IOSTANDARD LVCMOS33 } [get_ports {sw[12]}] | |
45 | +set_property -dict { PACKAGE_PIN U1 IOSTANDARD LVCMOS33 } [get_ports {sw[13]}] | |
46 | +set_property -dict { PACKAGE_PIN T1 IOSTANDARD LVCMOS33 } [get_ports {sw[14]}] | |
47 | +set_property -dict { PACKAGE_PIN R2 IOSTANDARD LVCMOS33 } [get_ports {sw[14]}] | |
48 | +``` | |
49 | +Cela permet associer les interrupteurs au tableau sw. | |
50 | +Dans le fichier de contrainte : | |
51 | +``` | |
52 | +set_property -dict { PACKAGE_PIN G19 IOSTANDARD LVCMOS33 } [get_ports {vgaRed[0]}] | |
53 | +set_property -dict { PACKAGE_PIN H19 IOSTANDARD LVCMOS33 } [get_ports {vgaRed[1]}] | |
54 | +set_property -dict { PACKAGE_PIN J19 IOSTANDARD LVCMOS33 } [get_ports {vgaRed[2]}] | |
55 | +set_property -dict { PACKAGE_PIN N19 IOSTANDARD LVCMOS33 } [get_ports {vgaRed[3]}] | |
56 | +set_property -dict { PACKAGE_PIN N18 IOSTANDARD LVCMOS33 } [get_ports {vgaBlue[0]}] | |
57 | +set_property -dict { PACKAGE_PIN L18 IOSTANDARD LVCMOS33 } [get_ports {vgaBlue[1]}] | |
58 | +set_property -dict { PACKAGE_PIN K18 IOSTANDARD LVCMOS33 } [get_ports {vgaBlue[2]}] | |
59 | +set_property -dict { PACKAGE_PIN J18 IOSTANDARD LVCMOS33 } [get_ports {vgaBlue[3]}] | |
60 | +set_property -dict { PACKAGE_PIN J17 IOSTANDARD LVCMOS33 } [get_ports {vgaGreen[0]}] | |
61 | +set_property -dict { PACKAGE_PIN H17 IOSTANDARD LVCMOS33 } [get_ports {vgaGreen[1]}] | |
62 | +set_property -dict { PACKAGE_PIN G17 IOSTANDARD LVCMOS33 } [get_ports {vgaGreen[2]}] | |
63 | +set_property -dict { PACKAGE_PIN D17 IOSTANDARD LVCMOS33 } [get_ports {vgaGreen[3]}] | |
64 | +set_property -dict { PACKAGE_PIN P19 IOSTANDARD LVCMOS33 } [get_ports Hsync] | |
65 | +set_property -dict { PACKAGE_PIN R19 IOSTANDARD LVCMOS33 } [get_ports Vsync] | |
66 | +``` | |
67 | +On associe tout les pins du connecteur VGA avec nos signaux | |
14 | 68 | ## Explication de l'algorithme |
69 | +Pour que le code soit compréhensible facilement, nous avons crée plusieurs process pour les différentes utilités. | |
70 | +### Les signaux | |
71 | +``` | |
72 | +signal clk_65MHz : std_logic; | |
73 | +signal Hcount : integer range 1344 downto 1 := 1; | |
74 | +signal Vcount : integer range 1083264 downto 1 := 1; | |
75 | +signal myRed: std_logic_vector(3 downto 0); | |
76 | +signal myBlue: std_logic_vector(3 downto 0); | |
77 | +signal myGreen: std_logic_vector(3 downto 0); | |
78 | + | |
79 | +signal leftLimit: integer range 1025 downto 0:= 0; | |
80 | +signal rightLimit: integer range 1025 downto 0:= 100; | |
81 | +signal upLimit: integer range 768 downto 0:= 0; | |
82 | +signal downLimit: integer range 768 downto 0:= 100; | |
83 | +signal pixelX: integer range 1344 downto 1:= 1; | |
84 | +signal pixelY: integer range 768 downto 1; | |
85 | +``` | |
86 | +- *Limit : Permet de délimiter les coordonnées du carré | |
87 | +- pixel* : Désigne la coordonnée du pixel que nous affichons | |
88 | +### Les process | |
89 | +#### 1er process | |
90 | +``` | |
91 | +process(clk_65MHz) | |
92 | +begin | |
93 | +if clk_65MHz'event and clk_65MHz = '1' then | |
94 | + | |
95 | +-- Gestion du vga | |
96 | + | |
97 | + -- Syncro horizontale | |
98 | + if Hcount < 1025 then | |
99 | + -- affichage | |
100 | + Hsync <= '1'; | |
101 | + Hcount <= Hcount + 1; | |
102 | + elsif Hcount < 1049 then | |
103 | + -- Fp | |
104 | + Hsync <= '1'; | |
105 | + Hcount <= Hcount + 1; | |
106 | + elsif Hcount < 1185 then | |
107 | + -- Pw | |
108 | + Hsync <= '0'; | |
109 | + Hcount <= Hcount + 1; | |
110 | + elsif Hcount < 1344 then | |
111 | + -- Bp | |
112 | + Hsync <= '1'; | |
113 | + Hcount <= Hcount + 1; | |
114 | + else | |
115 | + Hcount <= 1; | |
116 | + end if; | |
117 | + | |
118 | + -- Synchro vertical | |
119 | + if Vcount < 1032193 then | |
120 | + -- Affichage de toutes les lignes | |
121 | + Vsync <= '1'; | |
122 | + Vcount <= Vcount + 1; | |
123 | + elsif Vcount < (1032193 + 4032) then | |
124 | + --Fp | |
125 | + Vsync <= '1'; | |
126 | + Vcount <= Vcount + 1; | |
127 | + elsif Vcount < (1032193 + 4032 + 8064) then | |
128 | + --Pw | |
129 | + Vsync <= '0'; | |
130 | + Vcount <= Vcount + 1; | |
131 | + elsif Vcount < (1032192 + 4032 + 8064 + 38976) then | |
132 | + --Bp | |
133 | + Vsync <= '1'; | |
134 | + Vcount <= Vcount + 1; | |
135 | + else | |
136 | + Vcount <= 1; | |
137 | + end if; | |
138 | +end if; | |
139 | +end process; | |
140 | +``` | |
141 | +Ce process permet de suivre les différents signaux de synchronisation verticale et horizontale grâce à une horologe 65MHz. | |
142 | +#### 2eme process | |
143 | +``` | |
144 | +process(clk_65MHz) | |
145 | +-- Gestion de l'affichage | |
146 | +begin | |
147 | +if clk_65MHz'event and clk_65MHz = '1' then | |
148 | + if pixelX > leftLimit and pixelX < rightLimit and pixelY > upLimit and pixelY < downLimit then | |
149 | + -- Carré | |
150 | + vgaRed <= myRed; | |
151 | + vgaBlue <= myBlue; | |
152 | + vgaGreen <= myGreen; | |
153 | + elsif Hcount < 1025 and pixelY < 769 then | |
154 | + -- Background | |
155 | + vgaRed <= (others => '1'); | |
156 | + vgaBlue <= (others => '1'); | |
157 | + vgaGreen <= (others => '1'); | |
158 | + else | |
159 | + -- Hors pixel | |
160 | + vgaRed <= (others => '0'); | |
161 | + vgaBlue <= (others => '0'); | |
162 | + vgaGreen <= (others => '0'); | |
163 | + end if; | |
164 | +end if; | |
165 | +end process; | |
166 | +``` | |
167 | +Ce process prends en charge l'affichage du fond de l'écran et ainsi que l'affichage du carré. | |
168 | + | |
169 | + | |
170 | +#### 3eme process | |
171 | +``` | |
172 | +process(clk_65MHz) | |
173 | +begin | |
174 | +if clk_65MHz'event and clk_65MHz = '1' then | |
175 | + if Vcount = 1032193 then | |
176 | + if rightLimit > 1024 and downLimit > 768 then | |
177 | + leftLimit <= 0; | |
178 | + rightLimit <= 100; | |
179 | + upLimit <= 0; | |
180 | + downLimit <= 100; | |
181 | + elsif rightLimit > 1024 then | |
182 | + leftLimit <= 0; | |
183 | + rightLimit <= 100; | |
184 | + upLimit <= upLimit + 1; | |
185 | + downLimit <= downLimit + 1; | |
186 | + else | |
187 | + leftLimit <= leftLimit + 1; | |
188 | + rightLimit <= rightLimit +1; | |
189 | + end if; | |
190 | + end if; | |
191 | +end if; | |
192 | +end process; | |
193 | +``` | |
194 | +Ce process permet de gerer le mouvement de notre carré grâce à ces coordonnées. | |
195 | + | |
196 | +#### 4eme process | |
197 | +``` | |
198 | +process(clk_65MHz) | |
199 | +-- Simplification des valeurs d'écran | |
200 | +begin | |
201 | +if clk_65MHz'event and clk_65MHz = '1' then | |
202 | + if Vcount = 1 then | |
203 | + pixelY <= 1; | |
204 | + elsif Hcount = 1025 then | |
205 | + pixelY <= pixelY + 1; | |
206 | + end if; | |
207 | +end if; | |
208 | +end process; | |
209 | +``` | |
15 | 210 | |
16 | 211 | ## Résultats |
17 | 212 | |
18 | -- | |
213 | +-Nous avons dans un premier temps réussi à afficher un écran dont la couleur est commandée par 12 interrupteurs (4 interrupteurs par couleurs) | |
19 | 214 | |
20 | 215 | ![gif1](gif1.gif) |
21 | 216 | |
22 | -- | |
217 | +-Puis nous avons reussi à afficher un carré dans un coin de l'écran (toujours commandé en couleurs par les interrupteurs) | |
23 | 218 | |
24 | 219 | ![img](img.jpg) |
25 | 220 | |
26 | -- | |
221 | +-Finalement avec la separation du code en process et en ajoutant des fonctionnalités, nous avons réussi à animer le carré qui se déplace de droite à gauche et revient à gauche dès qu'il touche le coin droit tout en descendant. | |
222 | + | |
223 | +![gif2](gif2.gif) | |
224 | + | |
225 | + | |
226 | + | |
227 | + | |
27 | 228 | |
28 | -![gif2](gif2.gif) | |
29 | 229 | \ No newline at end of file | ... | ... |
Vga_display/vga_controller.vhd
... | ... | @@ -84,6 +84,58 @@ myGreen(3) <= sw(11); |
84 | 84 | |
85 | 85 | pixelX <= Hcount; |
86 | 86 | |
87 | + | |
88 | +process(clk_65MHz) | |
89 | +begin | |
90 | +if clk_65MHz'event and clk_65MHz = '1' then | |
91 | + | |
92 | +-- Gestion du vga | |
93 | + | |
94 | + -- Syncro horizontale | |
95 | + if Hcount < 1025 then | |
96 | + -- affichage | |
97 | + Hsync <= '1'; | |
98 | + Hcount <= Hcount + 1; | |
99 | + elsif Hcount < 1049 then | |
100 | + -- Fp | |
101 | + Hsync <= '1'; | |
102 | + Hcount <= Hcount + 1; | |
103 | + elsif Hcount < 1185 then | |
104 | + -- Pw | |
105 | + Hsync <= '0'; | |
106 | + Hcount <= Hcount + 1; | |
107 | + elsif Hcount < 1344 then | |
108 | + -- Bp | |
109 | + Hsync <= '1'; | |
110 | + Hcount <= Hcount + 1; | |
111 | + else | |
112 | + Hcount <= 1; | |
113 | + end if; | |
114 | + | |
115 | + -- Synchro vertical | |
116 | + if Vcount < 1032193 then | |
117 | + -- Affichage de toutes les lignes | |
118 | + Vsync <= '1'; | |
119 | + Vcount <= Vcount + 1; | |
120 | + elsif Vcount < (1032193 + 4032) then | |
121 | + --Fp | |
122 | + Vsync <= '1'; | |
123 | + Vcount <= Vcount + 1; | |
124 | + elsif Vcount < (1032193 + 4032 + 8064) then | |
125 | + --Pw | |
126 | + Vsync <= '0'; | |
127 | + Vcount <= Vcount + 1; | |
128 | + elsif Vcount < (1032192 + 4032 + 8064 + 38976) then | |
129 | + --Bp | |
130 | + Vsync <= '1'; | |
131 | + Vcount <= Vcount + 1; | |
132 | + else | |
133 | + Vcount <= 1; | |
134 | + end if; | |
135 | +end if; | |
136 | +end process; | |
137 | + | |
138 | + | |
87 | 139 | process(clk_65MHz) |
88 | 140 | begin |
89 | 141 | if clk_65MHz'event and clk_65MHz = '1' then |
... | ... | @@ -141,53 +193,5 @@ if clk_65MHz'event and clk_65MHz = '1' then |
141 | 193 | end if; |
142 | 194 | end process; |
143 | 195 | |
144 | -process(clk_65MHz) | |
145 | -begin | |
146 | -if clk_65MHz'event and clk_65MHz = '1' then | |
147 | 196 | |
148 | --- Gestion du vga | |
149 | - | |
150 | - -- Syncro horizontale | |
151 | - if Hcount < 1025 then | |
152 | - -- affichage | |
153 | - Hsync <= '1'; | |
154 | - Hcount <= Hcount + 1; | |
155 | - elsif Hcount < 1049 then | |
156 | - -- Fp | |
157 | - Hsync <= '1'; | |
158 | - Hcount <= Hcount + 1; | |
159 | - elsif Hcount < 1185 then | |
160 | - -- Pw | |
161 | - Hsync <= '0'; | |
162 | - Hcount <= Hcount + 1; | |
163 | - elsif Hcount < 1344 then | |
164 | - -- Bp | |
165 | - Hsync <= '1'; | |
166 | - Hcount <= Hcount + 1; | |
167 | - else | |
168 | - Hcount <= 1; | |
169 | - end if; | |
170 | - | |
171 | - -- Synchro vertical | |
172 | - if Vcount < 1032193 then | |
173 | - -- Affichage de toutes les lignes | |
174 | - Vsync <= '1'; | |
175 | - Vcount <= Vcount + 1; | |
176 | - elsif Vcount < (1032193 + 4032) then | |
177 | - --Fp | |
178 | - Vsync <= '1'; | |
179 | - Vcount <= Vcount + 1; | |
180 | - elsif Vcount < (1032193 + 4032 + 8064) then | |
181 | - --Pw | |
182 | - Vsync <= '0'; | |
183 | - Vcount <= Vcount + 1; | |
184 | - elsif Vcount < (1032192 + 4032 + 8064 + 38976) then | |
185 | - --Bp | |
186 | - Vsync <= '1'; | |
187 | - Vcount <= Vcount + 1; | |
188 | - else | |
189 | - Vcount <= 1; | |
190 | - end if; | |
191 | -end if; | |
192 | -end process; | |
193 | 197 | end Behavioral; | ... | ... |