OpenCores
URL https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.accelerator/] [sig_gen/] [1.0/] [vhd/] [sig_gen.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : Signal generator
3
-- Project    : Funbase
4
-------------------------------------------------------------------------------
5
-- File       : sig_gen.vhd
6
-- Author     : Juha Arvio
7
-- Company    : TUT
8
-- Last update: 2011-12-05
9
-- Version    : 0.1
10
-- Platform   : 
11
-------------------------------------------------------------------------------
12
-- Description: Generates a constant value to the output bus and an enable
13
--              signal that can be toggled.
14
-------------------------------------------------------------------------------
15
-- Revisions  :
16
-- Date        Version  Author  Description
17
-- 20.10.2011   0.1     arvio     Created
18
-------------------------------------------------------------------------------
19
-- Funbase IP library Copyright (C) 2011 TUT Department of Computer Systems
20
--
21
-- This source file may be used and distributed without
22
-- restriction provided that this copyright statement is not
23
-- removed from the file and that any derivative work contains
24
-- the original copyright notice and the associated disclaimer.
25
--
26
-- This source file is free software; you can redistribute it
27
-- and/or modify it under the terms of the GNU Lesser General
28
-- Public License as published by the Free Software Foundation;
29
-- either version 2.1 of the License, or (at your option) any
30
-- later version.
31
--
32
-- This source is distributed in the hope that it will be
33
-- useful, but WITHOUT ANY WARRANTY; without even the implied
34
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
35
-- PURPOSE.  See the GNU Lesser General Public License for more
36
-- details.
37
--
38
-- You should have received a copy of the GNU Lesser General
39
-- Public License along with this source; if not, download it
40
-- from http://www.opencores.org/lgpl.shtml
41
-------------------------------------------------------------------------------
42
 
43
library ieee;
44
use ieee.std_logic_1164.all;
45
use ieee.std_logic_arith.all;
46
use ieee.std_logic_unsigned.all;
47
 
48
entity sig_gen is
49
  generic (
50
    SIGNAL_VAL   : integer := 5000000;  -- Constant value driven to the output
51
    SIGNAL_WIDTH : integer := 32        -- In bits
52
    );
53
  port (
54
    clk   : in std_logic;
55
    rst_n : in std_logic;
56
 
57
    toggle_in : in  std_logic;
58
    sig_out   : out std_logic_vector(SIGNAL_WIDTH-1 downto 0);
59
    ena_out   : out std_logic
60
    );
61
 
62
end sig_gen;
63
 
64
architecture rtl of sig_gen is
65
 
66
  function i2s(value : integer; width : integer) return std_logic_vector is
67
  begin
68
    return conv_std_logic_vector(value, width);
69
  end;
70
 
71
  function s2i(value : std_logic_vector) return integer is
72
  begin
73
    return conv_integer(value);
74
  end;
75
 
76
  signal toggle_d1_r : std_logic;
77
  signal ena_r       : std_logic;
78
begin
79
 
80
  sig_out <= i2s(SIGNAL_VAL, SIGNAL_WIDTH);
81
  ena_out <= ena_r;
82
 
83
  --
84
  -- Detects a rising edge in toggle-input 
85
  --
86
  process (clk, rst_n)
87
  begin
88
    if (rst_n = '0') then
89
      toggle_d1_r <= '0';
90
      ena_r       <= '0';
91
 
92
    elsif (clk'event and clk = '1') then
93
      toggle_d1_r <= toggle_in;
94
 
95
      if ((toggle_in = '1') and (toggle_d1_r = '0')) then
96
        ena_r <= not(ena_r);
97
      end if;
98
    end if;
99
  end process;
100
 
101
end rtl;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.