| 1 |
-- Copyright (c) 2013 Nuand LLC |
| 2 |
-- |
| 3 |
-- Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 |
-- of this software and associated documentation files (the "Software"), to deal |
| 5 |
-- in the Software without restriction, including without limitation the rights |
| 6 |
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 |
-- copies of the Software, and to permit persons to whom the Software is |
| 8 |
-- furnished to do so, subject to the following conditions: |
| 9 |
-- |
| 10 |
-- The above copyright notice and this permission notice shall be included in |
| 11 |
-- all copies or substantial portions of the Software. |
| 12 |
-- |
| 13 |
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 |
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 |
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 |
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 |
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 |
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 19 |
-- THE SOFTWARE. |
| 20 |
|
| 21 |
library ieee ; |
| 22 |
use ieee.std_logic_1164.all ; |
| 23 |
use ieee.numeric_std.all ; |
| 24 |
use ieee.math_real.all ; |
| 25 |
|
| 26 |
library work ; |
| 27 |
use work.nco_p.all ; |
| 28 |
|
| 29 |
entity fsk_modulator is |
| 30 |
port ( |
| 31 |
clock : in std_logic ; |
| 32 |
reset : in std_logic ; |
| 33 |
|
| 34 |
symbol : in std_logic ; |
| 35 |
symbol_valid : in std_logic ; |
| 36 |
|
| 37 |
out_real : out signed(15 downto 0) ; |
| 38 |
out_imag : out signed(15 downto 0) ; |
| 39 |
out_valid : out std_logic |
| 40 |
) ; |
| 41 |
end entity ; -- fsk_modulator |
| 42 |
|
| 43 |
architecture arch of fsk_modulator is |
| 44 |
|
| 45 |
-- Positive deviation for ZERO and negative deviation for ONE |
| 46 |
constant ZERO : signed(15 downto 0) := to_signed(integer(round(4096.0/19.2)),16) ; |
| 47 |
constant ONE : signed(15 downto 0) := -ZERO ; |
| 48 |
|
| 49 |
signal nco_input : nco_input_t ; |
| 50 |
signal nco_output : nco_output_t ; |
| 51 |
|
| 52 |
begin |
| 53 |
|
| 54 |
register_new_symbol : process(clock, reset) |
| 55 |
-- variable dir : std_logic ; |
| 56 |
-- variable dphase : signed(15 downto 0) ; |
| 57 |
begin |
| 58 |
if( reset = '1' ) then |
| 59 |
-- dir := '1' ; |
| 60 |
-- dphase := (others =>'0') ; |
| 61 |
nco_input.dphase <= ZERO ; |
| 62 |
nco_input.valid <= '0' ; |
| 63 |
elsif( rising_edge( clock ) ) then |
| 64 |
nco_input.valid <= '1' ; |
| 65 |
-- if( dir = '1' ) then |
| 66 |
-- if( dphase < 4094) then |
| 67 |
-- dphase := dphase + 1 ; |
| 68 |
-- else |
| 69 |
-- dphase := dphase - 1 ; |
| 70 |
-- dir := '0' ; |
| 71 |
-- end if ; |
| 72 |
-- else |
| 73 |
-- if( dphase > -4094) then |
| 74 |
-- dphase := dphase - 1 ; |
| 75 |
-- else |
| 76 |
-- dphase := dphase + 1 ; |
| 77 |
-- dir := '1' ; |
| 78 |
-- end if ; |
| 79 |
-- end if ; |
| 80 |
if( symbol_valid = '1' ) then |
| 81 |
-- nco_input.dphase <= dphase ; |
| 82 |
if( symbol = '0' ) then |
| 83 |
nco_input.dphase <= ZERO ; |
| 84 |
else |
| 85 |
nco_input.dphase <= ONE ; |
| 86 |
end if ; |
| 87 |
end if ; |
| 88 |
end if ; |
| 89 |
end process ; |
| 90 |
|
| 91 |
U_nco : entity work.nco |
| 92 |
port map ( |
| 93 |
clock => clock, |
| 94 |
reset => reset, |
| 95 |
inputs => nco_input, |
| 96 |
outputs => nco_output |
| 97 |
) ; |
| 98 |
|
| 99 |
out_real <= nco_output.re ; |
| 100 |
out_imag <= nco_output.im ; |
| 101 |
out_valid <= nco_output.valid ; |
| 102 |
|
| 103 |
end architecture ; -- arch |