Showing posts with label synthesizable. Show all posts
Showing posts with label synthesizable. Show all posts

Sunday, 23 January 2011

RTC on FPGA with manual set synthesizeble VHDL code.

Hey there, cheers to VHDL. I successfully added manual set feature in my previous RTC project. I am not going to copy whole code here. I am just adding the links of .vhd files. I also added the pre-compiled .sof file only for DE1 boards. There is a very small bug that while clicking the set button to enable min and hr set, it increments the hr or min value unintentionally. Else everything is working great.

(Input freq 24MHz., top-level entity DigiClock)

Video will be uploaded soon.

On DE1 board: Push button functions.
  • Key0: Reset
  • Key1: Hour set (Key3 kept pressed)
  • Key2: Minute set (Key3 kept pressed)
  • Key3: Set enable.
Download links:
Video : 
    Do test the codes. If you have any querries do comment or mail me at prasadp4009@gmail.com.

    Enjoy Programming..!!

    Wednesday, 10 November 2010

    Display on VGA Monitor by FPGA(VHDL code Synthesizable, 640X480 resol, 60Hz)

    This code is for displaying a simple ball bouncing on your monitor screen. As the monitor requires 60 Hz refresh rate i.e. to replace each pixel 60 times, it requires approx 40 ns. So to synchronize it with the FPGA processing speed, I used PLL with 50 MHz i/p clock dividing it to 25 MHz which scans each pixel in 40 ns.

    The Video Synchronization file I created is VGAS which has 5 o/ps viz.
    • red_out
    • green_out
    • blue_out
    • horiz_sync_out
    • vert_sync_out
    These are connected to the VGA controller which must have be present on your FPGA board (present on all DE series board of Altera, I dont know about Xilinx). For the pins check the your board manual.

    The VGAS.vhd file can be used as common file for all your FPGA projects(for dividing 50Hz clock as I have used PLL which is already present on DE1 board. So if you have DE1 board its well and good you can directly use the code with the syncclk.vhd included. If dont just a minor modification in i/p clock signal with 25MHz in VGAS.vhd and removing syncclk.vhd and its component in VGAS.vhd will work.)

    The Ballm.vhd is used to create display on Monitor. For DE1 users you can diretly program the SOF file i hav provided in download links.

    Post your replies and comments. For the projects or querries you have you can mail me on prasadp4009@gmail.com .

    Be the follower, if you like my posts.

    Enjoy programming.

    Video link: http://www.youtube.com/watch?v=QcCdkWG-rmM

    Download links for files:


    http://www.4shared.com/file/_7V3nyj9/Ballm.html
    http://www.4shared.com/file/8pE2Yhz2/Ballm.html
    http://www.4shared.com/file/mqnCQJs0/sycclk.html
    http://www.4shared.com/file/JsUb67B4/VGAS.html

    Sunday, 5 September 2010

    Synthesizable RTC in VHDL

    The code given is only for clock digit incrementation. For components in clock like min_clk and sec_clk, refer my previous codes.

    VHDL code:
    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.numeric_std.all;

    entity clk12 is
    port(
          clk: in std_logic;
          rst: in std_logic;
          op: out std_logic;
          op0,op1,op2,op3: out std_logic_vector(6 downto 0)
          );
         
    end clk12;

    architecture clock of clk12 is


    component sec_clk
    Port (
               clk : in std_logic;
               op  : out std_logic
         );
        end component;

    component min_clk
    Port (
               clk : in std_logic;
               rst : in std_logic;
               op  : out std_logic
         );
        end component;
       
       
    component seg7
    port(m: in integer range 0 to 10;
         num: out std_logic_vector(6 downto 0));
    end component;


    signal flag: std_logic;
    signal sflag: std_logic;

    signal a: integer range 0 to 10;
    signal b: integer range 0 to 6;
    signal c: integer range 0 to 10;
    signal d: integer range 0 to 3;


    begin

    c1: sec_clk port map(clk,sflag);
    c2: min_clk port map(sflag,rst,flag);
    op<=sflag;

    process(flag,rst)

    variable m0: integer range 0 to 10:=0;
    variable m1: integer range 0 to 6:=0;
    variable m2: integer range 0 to 10:=2;
    variable m3: integer range 0 to 3:=1;

    begin
         a<=m0;
         b<=m1;
         c<=m2;
         d<=m3;
         if rst='0' then
         m0:=0;
         m1:=0;
         m2:=2;
         m3:=1;    
         elsif rising_edge(flag) then
         if  m0/=9 then
             m0:= m0+1;
            elsif  m0=9 and  m1/=5  then
             m0:=0;
             m1:= m1+1;
            elsif  m0=9 and  m1=5 and  m2/=9 and  m3=0 then
             m0:=0;
             m1:=0;
             m2:= m2+1;
            elsif  m0=9 and  m1=5 and  m2=9 and  m3=0 then
             m0:=0;
             m1:=0;
             m2:=0;
             m3:=1;
            elsif  m3=1 and  m2/=2 and  m1=5 and  m0=9 then
             m2:= m2+1;
            elsif  m3=1 and  m2=2 and  m1=5 and  m0=9 then
             m0:=0;
             m1:=0;
             m2:=1;
             m3:=0;
            end if; 
            end if;   
       
        end process;
       
        z0: seg7 port map(a,op0);
        z1: seg7 port map(b,op1);
        z2: seg7 port map(c,op2);
        z3: seg7 port map(d,op3);

    end clock;



    Note: The clock cant be set manually. It starts from 12:00. I tried my best to add the manual set function but didnt succeed. But I assure that manual set will also be there in couple of time. Suggetions are most welcome.

    Video link: http://www.youtube.com/watch?v=1dbTi2PMgcU

    Quartus SOF file for DE1 board only: Digiclk(for DE1 board only).SOF

    Check the new code with hr and min manual set: RTC with maual set

    Enjoy Programming.