Debian Codegraph @

hdl/fpga/ip/nuand/synthesis/signal_generator.vhd

raw
1 library ieee;
2 use ieee.std_logic_1164.all ;
3 use ieee.numeric_std.all ;
4
5 entity signal_generator is
6 port (
7 clock : in std_logic ;
8 reset : in std_logic ;
9 enable : in std_logic ;
10
11 mode : in std_logic ;
12 eightbit_en : in std_logic := '0';
13
14 sample_i : out signed(15 downto 0) ;
15 sample_q : out signed(15 downto 0) ;
16 sample_valid : buffer std_logic
17 ) ;
18 end entity ;
19
20 architecture arch of signal_generator is
21
22 begin
23
24 counter : process(clock, reset)
25 constant COUNT_RESET : natural := 256 ;
26 variable count12 : integer range -2047 to 2047 := COUNT_RESET ;
27 variable count32 : unsigned(31 downto 0) ;
28 begin
29 if( reset = '1' ) then
30 count12 := COUNT_RESET ;
31 count32 := (others =>'0') ;
32 sample_i <= (others =>'0') ;
33 sample_q <= (others =>'0') ;
34 sample_valid <= '0' ;
35 elsif( rising_edge(clock) ) then
36 if( mode = '0' ) then
37 sample_i <= to_signed( count12, sample_i'length) ;
38 sample_q <= to_signed(-count12, sample_q'length) ;
39 else
40 sample_i <= signed(std_logic_vector(count32(15 downto 0))) ;
41 sample_q <= signed(std_logic_vector(count32(31 downto 16))) ;
42
43 if eightbit_en = '1' then
44 sample_i <= signed(std_logic_vector(shift_left(resize(count32(8 downto 0), 16), 4)));
45 sample_q <= signed(std_logic_vector(shift_left(resize(count32(15 downto 8), 16), 4)));
46 end if;
47 end if ;
48
49 if( enable = '0' ) then
50 count12 := COUNT_RESET ;
51 count32 := (others =>'0') ;
52 sample_i <= (others =>'0') ;
53 sample_q <= (others =>'0') ;
54 sample_valid <= '0' ;
55 else
56 sample_valid <= not sample_valid ;
57 if( sample_valid = '1' ) then
58 if( count12 < 2047 ) then
59 count12 := count12 + 1 ;
60 else
61 count12 := -2047 ;
62 end if ;
63 count32 := count32 + 1 ;
64 end if ;
65 end if ;
66
67 end if ;
68 end process ;
69
70 end architecture ;