-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathf_square.vhd
More file actions
35 lines (30 loc) · 739 Bytes
/
f_square.vhd
File metadata and controls
35 lines (30 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-- Square Function
-- See LICENSE file for copyright and license details.
library IEEE;
use IEEE.std_logic_1164.ALL;
-- f(x) = {
-- A if 0 ≤ x % T < T/2
-- -A if T/2 ≤ x % T < T
-- }
-- A: Amplitude of the wave
-- T: Period of the wave
entity f_square is
generic (
-- length of input word
N: positive := 8;
-- length of output word
M: positive := 8
);
port (
-- input of square
x: in std_logic_vector(N - 1 downto 0);
-- input compare of square
xc: in std_logic_vector(N - 1 downto 0);
-- output of square
f: out std_logic_vector(M - 1 downto 0)
);
end entity f_square;
architecture behav of f_square is
begin
f <= (others => '1') when x < xc else (others => '0');
end behav;