\qquad 下面是GPS L1信号跟踪通道的Verilog代码:
// -*- Mode: Verilog -*-
// Original filename : tracking_channel.v
// Filename : gps_tracking_channel.v
// Description : Wire the correlator block together.
// 2 gps_carrier_mixers
// 1 gps_carrier_nco
// 1 gps_code_nco
// 1 gps_code_gen
// 1 gps_epoch_counter
// 6 gps_accumulators
// Author : Peter Mumford, UNSW 2005
// Author : Cheng Huaide, turing321.com, 2015 (BDS & 1PPS - processing upgrade)
/*
Copyright (C) 2007 Peter Mumford
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
`include "namuro_gnss_setup.v"
module gps_tracking_channel (
clk, rstn, accum_sample_enable,
if_sign, if_mag,
pre_tic_enable, tic_enable,
carr_nco_fc,
code_nco_fc,
prn_key,
prn_key_enable,
code_slew, slew_enable, epoch_enable,
dump,
i_early,q_early,i_prompt,q_prompt,i_late,q_late,
`ifdef ENABLE_CARRIER_PHASE_MEASUREMENT
carrier_val,
`endif // ENABLE_CARRIER_PHASE_MEASUREMENT
code_val,epoch_load,epoch,epoch_check);
input clk, rstn, accum_sample_enable, if_sign, if_mag, pre_tic_enable, tic_enable, prn_key_enable, slew_enable, epoch_enable;
input [28:0] carr_nco_fc;
input [27:0] code_nco_fc;
input [9:0] prn_key;
input [10:0] code_slew;
input [10:0] epoch_load;
`ifdef ENABLE_32BIT_ACCUMULATOR
output [31:0] i_early,q_early,i_prompt,q_prompt,i_late,q_late;
`else
output [15:0] i_early,q_early,i_prompt,q_prompt,i_late,q_late;
`endif
`ifdef ENABLE_CARRIER_PHASE_MEASUREMENT
output [31:0] carrier_val;
`endif // ENABLE_CARRIER_PHASE_MEASUREMENT
output [10:0] epoch, epoch_check;
output [20:0] code_val;
output dump; // pulse generated (from code_gen) at the begining/end of the prompt C/A code cycle
wire carrier_i_sign, carrier_q_sign;
wire carrier_i_mag, carrier_q_mag;
wire mix_i_sign, mix_q_sign;
wire [2:0] mix_i_mag, mix_q_mag;
wire hc_enable, dump_enable;
wire early_code, prompt_code, late_code;
assign dump = dump_enable;
// carrier mixers -----------------------------------------------------------
gps_carrier_mixer i_cos (
.if_sign(if_sign), .if_mag(if_mag), // raw data input
.carrier_sign(carrier_i_sign), .carrier_mag(carrier_i_mag), // carrier nco inputs
.mix_sign(mix_i_sign), .mix_mag(mix_i_mag) // outputs
);
gps_carrier_mixer q_sin (
.if_sign(if_sign), .if_mag(if_mag), // raw data input
.carrier_sign(carrier_q_sign), .carrier_mag(carrier_q_mag), // carrier nco inputs
.mix_sign(mix_q_sign), .mix_mag(mix_q_mag) // outputs
);
// carrier nco --------------------------------------------------------------
gps_carrier_nco carrnco (
.clk(clk), .rstn(rstn),
.f_control(carr_nco_fc),
`ifdef ENABLE_CARRIER_PHASE_MEASUREMENT
.tic_enable(tic_enable),
.carrier_val(carrier_val),
`endif // ENABLE_CARRIER_PHASE_MEASUREMENT
.i_sign(carrier_i_sign), .i_mag(carrier_i_mag),
.q_sign(carrier_q_sign), .q_mag(carrier_q_mag)
);
// code nco -----------------------------------------------------------------
gps_code_nco codenco (
.clk(clk), .rstn(rstn), .tic_enable(pre_tic_enable),
.f_control(code_nco_fc),
.hc_enable(hc_enable), .code_nco_phase(code_val[9:0])
);
// code gen -----------------------------------------------------------------
gps_code_gen codegen (
.clk(clk), .rstn(rstn), .tic_enable(tic_enable),
.hc_enable(hc_enable), .prn_key_enable(prn_key_enable),
.prn_key(prn_key), .code_slew(code_slew), .slew_enable(slew_enable),
.dump_enable(dump_enable), .code_phase(code_val[20:10]),
.early(early_code), .prompt(prompt_code), .late(late_code)
);
// epoch counter ------------------------------------------------------------
gps_epoch_counter epc (
.clk(clk), .rstn(rstn),
.tic_enable(tic_enable), .dump_enable(dump_enable),
.epoch_enable(epoch_enable), .epoch_load(epoch_load),
.epoch(epoch), .epoch_check(epoch_check)
);
// accumulators -------------------------------------------------------------
// in-phase early
gps_accumulator ie (
.clk(clk), .rstn(rstn), .sample_enable(accum_sample_enable), .code(early_code),
.carrier_mix_sign(mix_i_sign), .carrier_mix_mag(mix_i_mag),
.dump_enable(dump_enable), .accumulation(i_early)
);
// in-phase prompt
gps_accumulator ip (
.clk(clk), .rstn(rstn), .sample_enable(accum_sample_enable), .code(prompt_code),
.carrier_mix_sign(mix_i_sign), .carrier_mix_mag(mix_i_mag),
.dump_enable(dump_enable), .accumulation(i_prompt)
);
// in-phase late
gps_accumulator il (
.clk(clk), .rstn(rstn), .sample_enable(accum_sample_enable), .code(late_code),
.carrier_mix_sign(mix_i_sign), .carrier_mix_mag(mix_i_mag),
.dump_enable(dump_enable), .accumulation(i_late)
);
// quadrature-phase early
gps_accumulator qe (
.clk(clk), .rstn(rstn), .sample_enable(accum_sample_enable), .code(early_code),
.carrier_mix_sign(mix_q_sign), .carrier_mix_mag(mix_q_mag),
.dump_enable(dump_enable), .accumulation(q_early)
);
// quadrature-phase prompt
gps_accumulator qp (
.clk(clk), .rstn(rstn), .sample_enable(accum_sample_enable), .code(prompt_code),
.carrier_mix_sign(mix_q_sign), .carrier_mix_mag(mix_q_mag),
.dump_enable(dump_enable), .accumulation(q_prompt)
);
// quadrature-phase late
gps_accumulator ql (
.clk(clk), .rstn(rstn), .sample_enable(accum_sample_enable), .code(late_code),
.carrier_mix_sign(mix_q_sign), .carrier_mix_mag(mix_q_mag),
.dump_enable(dump_enable), .accumulation(q_late)
);
//-------------------------------------------------------------------------
endmodule // gps_tracking_channel