Rev 2528 Rev 2533
Line 1... Line 1...
1 ---------------------------------------------------------------------------------- 1 ----------------------------------------------------------------------------------
2 -- Company: www.mlab.cz 2 -- Company: www.mlab.cz
3 -- Engineer: miho, kakl 3 -- Based on code writen by MIHO.
4 -- 4 --
5 -- Create Date: 29/08/2011 5 -- Create Date: 29/08/2011
6 -- Design Name: S3AN01A Test Design 6 -- Design Name: S3AN01A Test Design
7 -- Module Name: PulseGen -  
8 -- Project Name: PulseGen 7 -- Project Name: PulseGen
9 -- Target Devices: XC3S50AN-4 8 -- Target Devices: XC3S50AN-4
10 -- Tool versions: ISE 13.3 9 -- Tool versions: ISE 13.3
11 -- Description: Sample of Pulse Generator at S3AN01A MLAB board. 10 -- Description: Sample of Pulse Generator at S3AN01A MLAB board.
12 -- 11 --
13 -- Dependencies: External PS/2 Keyboard has to be connected. 12 -- Dependencies: External PS/2 Keyboard has to be connected.
14 -- 13 --
15 -- Revision: 1.00 File Created 14 -- Version: $Id: PulseGen.vhd 2533 2012-09-02 13:36:25Z kakl $
16 -- 15 --
17 ---------------------------------------------------------------------------------- 16 ----------------------------------------------------------------------------------
18   17  
19 library IEEE; 18 library IEEE;
20 use IEEE.STD_LOGIC_1164.ALL; 19 use IEEE.STD_LOGIC_1164.ALL;
Line 156... Line 155...
156 signal T1: unsigned(15 downto 0) := X"000a"; -- Time t1 to Impuls at O2 155 signal T1: unsigned(15 downto 0) := X"000a"; -- Time t1 to Impuls at O2
157 signal T2: unsigned(15 downto 0) := X"0001"; -- Duration t2 of impuls at O2 156 signal T2: unsigned(15 downto 0) := X"0001"; -- Duration t2 of impuls at O2
158 signal CT0: unsigned(15 downto 0) := X"0000"; -- Timer 157 signal CT0: unsigned(15 downto 0) := X"0000"; -- Timer
159 signal O1: std_logic := '0'; -- Output 1 158 signal O1: std_logic := '0'; -- Output 1
160 signal O2: std_logic := '0'; -- Output 2 159 signal O2: std_logic := '0'; -- Output 2
-   160 signal CTburst: unsigned(15 downto 0) := X"0000"; -- Pulse counter
161 161
162 -- LED Demo Signals 162 -- LED Demo Signals
163 -- ---------------- 163 -- ----------------
164   164  
165 signal Counter: unsigned(31 downto 0) := X"00000000"; -- Main Counter (binary) 165 signal Counter: unsigned(31 downto 0) := X"00000000"; -- Main Counter (binary)
Line 350... Line 350...
350 PS2_Result( 7 downto 0) <= PS2_Code; 350 PS2_Result( 7 downto 0) <= PS2_Code;
351 PS2_Result(15 downto 8) <= PS2_Attribs; 351 PS2_Result(15 downto 8) <= PS2_Attribs;
352 end if; 352 end if;
353 353
354 if PS2_Valid and PS2_Attribs(7)='0' then 354 if PS2_Valid and PS2_Attribs(7)='0' then
355 if PS2_Code = X"74" and T1<200 then T1<=T1+1; end if; 355 if PS2_Code = X"74" and T1<2000 then T1<=T1+1; end if;
356 if PS2_Code = X"6b" and T1>0 then T1<=T1-1; end if; 356 if PS2_Code = X"6b" and T1>0 then T1<=T1-1; end if;
357 if PS2_Code = X"75" and T2<200 then T2<=T2+1; end if; 357 if PS2_Code = X"75" and T2<200 then T2<=T2+1; end if;
358 if PS2_Code = X"72" and T2>0 then T2<=T2-1; end if; 358 if PS2_Code = X"72" and T2>0 then T2<=T2-1; end if;
359 CT0<=X"0000"; 359 CT0<=X"0000";
360 O1<='0'; 360 O1<='0';
361 O2<='0'; 361 O2<='0';
-   362 CTburst<=X"0000";
362 end if; 363 end if;
363   364  
-   365 if PB(0)='1' then
-   366 T1<=X"0000";
-   367 T2<=X"0000";
-   368 end if;
-   369
-   370 if DIPSW(0)='1' then
364 if CT0=X"F000" then 371 if CT0>X"F000" then
-   372 CT0<=X"0000";
-   373 else
-   374 CT0<=CT0+1;
-   375 end if;
-   376 else
-   377 if CT0>X"0200" then
365 CT0<=X"0000"; 378 CT0<=X"0000";
366 else 379 else
367 CT0<=CT0+1; 380 CT0<=CT0+1;
368 end if; 381 end if;
-   382 end if;
-   383
-   384 if CTburst>2000 then
-   385 CTburst<=X"0000";
-   386 end if;
369 387  
-   388 if (CTburst<1000) or (DIPSW(1)='0') then
370 if CT0=X"0000" then 389 if CT0=X"0000" then
371 O1<='1'; 390 O1<='1';
372 end if; 391 end if;
373 392
374 if CT0=T1 then 393 if CT0=T1+X"0000" then
375 O2<='1'; 394 O2<='1';
376 end if; 395 end if;
-   396 end if;
377 397
378 if CT0=(T2+T1) then 398 if CT0=T2+T1+X"0000" then
379 O1<='0'; 399 O1<='0';
380 O2<='0'; 400 O2<='0';
-   401 CTburst<=CTburst+1;
381 end if; 402 end if;
382 403
383 end if; 404 end if;
384 405
385 end process; 406 end process;
Line 415... Line 436...
415 DIF2P <= O2; 436 DIF2P <= O2;
416 B(2) <= O2; 437 B(2) <= O2;
417 DIF2N <= not O2; 438 DIF2N <= not O2;
418 B(3) <= not O2; 439 B(3) <= not O2;
419   440
-   441 VGA_R(0) <= O1;
-   442 VGA_R(1) <= O2;
-   443  
420 -- Unused Signals 444 -- Unused Signals
421 -- ============== 445 -- ==============
422   446  
423 -- I2C Signals (on connector J30) 447 -- I2C Signals (on connector J30)
424 I2C_SCL <= 'Z'; 448 I2C_SCL <= 'Z';