Recent
:: anonymous
3 hrs ago
:: anonymous
9 hrs ago
:: anonymous
18 hrs ago
:: igd-jojo
1 day ago
:: jteam
1 day ago
:: anonymous
1 day ago
:: jteam
1 day ago
:: jteam
1 day ago
:: jteam
1 day ago
:: jteam
1 day ago
:: anonymous
1 day ago
:: This post is secret anonymous
1 day ago
:: anonymous
3 days ago
:: jteam
3 days ago
:: This post is secret anonymous
3 days ago
rss 2.0 feed

Make New Post
Posts: 22308

Syntax:       Wrapping:  

   #19151 Posted by anonymous 2010-02-08 13:05:59
Formated by GeSHi
  1. library ieee;
  2.  
  3. use ieee.std_logic_1164.all;
  4.  
  5. use ieee.numeric_std.all;
  6.  
  7.  
  8.  
  9. entity timer64 is
  10.  
  11.  
  12.  
  13. generic (
  14.  
  15. D_WIDTH : integer := 64;
  16.  
  17. T_WIDTH : integer := 32);
  18.  
  19.  
  20.  
  21. port (
  22.  
  23. clk : in std_logic;
  24.  
  25. rst : in std_logic;
  26.  
  27. start_in : in std_logic;
  28.  
  29. timer_out : out std_logic_vector(D_WIDTH-1 downto 0));
  30.  
  31.  
  32.  
  33. end timer64;
  34.  
  35.  
  36.  
  37. architecture synth of timer64 is
  38.  
  39.  
  40.  
  41. constant MAX_T : unsigned(T_WIDTH-1 downto 0) := (others => '1');
  42. signal tovfl : unsigned(T_WIDTH-1 downto 0) := (others => '0');
  43.  
  44. signal tval : unsigned(T_WIDTH-1 downto 0) := (others => '0');
  45.  
  46.  
  47.  
  48. signal running : std_logic := '0';
  49.  
  50.  
  51.  
  52. begin
  53.  
  54.  
  55.  
  56. start : process (clk, rst)
  57.  
  58. begin
  59.  
  60. if rst = '1' then
  61.  
  62. running <= '0';
  63.  
  64. elsif clk'event and clk = '1' then
  65.  
  66. if start_in = '1' then
  67.  
  68. running <= not running;
  69.  
  70. end if;
  71.  
  72. end if; end process start;
  73.  
  74.  
  75.  
  76. count : process (clk, rst)
  77.  
  78. begin
  79.  
  80. if rst = '1' then
  81.  
  82. timer_out <= (others => '0');
  83.  
  84. tovfl <= (others => '0');
  85.  
  86. tval <= (others => '0');
  87.  
  88. elsif clk'event and clk = '1' then
  89.  
  90. if running = '1' then
  91.  
  92. tval <= tval + 1;
  93.  
  94. timer_out <= std_logic_vector(tovfl & tval);
  95.  
  96. if tval = MAX_T then
  97.  
  98. tovfl <= tovfl + 1;
  99.  
  100. tval <= (others => '0');
  101.  
  102. end if;
  103.  
  104. else
  105.  
  106. tovfl <= (others => '0');
  107.  
  108. tval <= (others => '0');
  109.  
  110. end if;
  111.  
  112. end if;
  113.  
  114. end process count;
  115.  
  116.  
  117.  
  118. end synth;
Parsed in 0.11765194 seconds
::  Inline view Inline view ::  Email this post Email  ::  Print Print   

:: Download   Download Text File19151.txt   Download Gziped text File19151.txt.gz   Download HTML File19151.html   Download PDF File19151.pdf
:: Print into    Print into HTML FileHTML document   Print into PDF FilePDF document

:: Make Diff

:: Erase Post

* Code:

To highlight particular lines, prefix each line with @@


Description:


Secret key (for later deletion)
Syntax:     


comments (0)


Copyright © 2006 Openpastebin