1
0
mirror of https://github.com/aolofsson/oh.git synced 2025-01-17 20:02:53 +08:00
oh/elink/hdl/eclocks.v

144 lines
4.1 KiB
Coq
Raw Normal View History

/*###########################################################################
2015-04-22 15:03:24 -04:00
# Function: High speed clock generator for elink
#
2015-04-22 15:03:24 -04:00
# cclk_p/n - Epiphany Output Clock (>600MHz)
#
2015-04-22 15:03:24 -04:00
# tx_lclk_div4 - Parallel data clock (125Mhz)
#
2015-04-22 15:03:24 -04:00
# tx_lclk - Serial DDR data clock (500MHz)
#
2015-04-22 15:03:24 -04:00
# tx_lclk90 - DDR "Clock" clock, to generate tx_lclk_p/n output
# Same as lclk, shifted by 90 degrees
#
############################################################################
*/
module eclocks (/*AUTOARG*/
// Outputs
2015-04-22 15:03:24 -04:00
cclk_p, cclk_n, tx_lclk, tx_lclk90, tx_lclk_div4,
// Inputs
clkin, hard_reset, clk_config, pll_bypass
);
// Parameters must be set as follows:
// PFD input frequency = 1/CLKIN1_PERIOD / DIVCLK_DIVIDE (10-450MHz)
// VCO frequency = PFD input frequency * CLKFBOUT_MULT (800-1600MHz)
// Output frequency = VCO frequency / CLKOUTn_DIVIDE
//Input clock, reset, config interface
2015-04-22 15:03:24 -04:00
input clkin; // primary input clock
input hard_reset; //
input [15:0] clk_config; // clock settings
input [3:0] pll_bypass; //[0]=cclk
//[1]=lclk
//[2]=lclk90
//[3]=lclk_div4
//Output Clocks
output cclk_p, cclk_n; // high speed Epiphany clock (up to 1GHz)
output tx_lclk; // elink tx serdes clock
2015-04-22 15:03:24 -04:00
output tx_lclk90; // center aligned output clock for elink tx
output tx_lclk_div4; // lclk/4 slow clock for tx parallel logic
// Wires
wire cclk_en;
wire lclk_en;
wire cclk_bp;
wire lclk_bp;
2015-04-22 15:03:24 -04:00
wire cclk;
wire lclk;
wire lclk90;
wire lclk_div4;
2015-04-22 15:03:24 -04:00
//Register decoding
assign cclk_en=clk_config[0];
assign lclk_en=clk_config[1];
assign cclk_bp=clk_config[2];
assign lclk_bp=clk_config[3];
2015-04-22 15:03:24 -04:00
`ifdef TARGET_XILINX
2015-04-22 15:03:24 -04:00
//instantiate MMCM
`elsif TARGET_CLEAN
2015-04-22 15:03:24 -04:00
clock_divider cclk_divider(
// Outputs
.clkout (cclk),
.clkout90 (),
// Inputs
.clkin (clkin),
2015-04-23 18:57:55 -04:00
.reset (hard_reset),
.divcfg (clk_config[7:4])
)
;
clock_divider lclk_divider(
// Outputs
.clkout (lclk),
.clkout90 (lclk90),
// Inputs
.clkin (clkin),
2015-04-23 18:57:55 -04:00
.reset (hard_reset),
.divcfg (clk_config[11:8])
);
//This clock is always on!
clock_divider lclk_par_divider(
// Outputs
.clkout (lclk_div4),
.clkout90 (),
// Inputs
.clkin (clkin),
2015-04-23 18:57:55 -04:00
.reset (hard_reset),
.divcfg (clk_config[11:8] + 4'd2)
);
//cclk (hack for sim)
assign cclk_p = hard_reset ? clkin :
cclk_bp ? pll_bypass[0] :
cclk;
2015-04-22 15:03:24 -04:00
assign cclk_n = ~cclk_p;
//lclk (hack for sim)
assign tx_lclk = hard_reset ? clkin :
lclk_bp ? pll_bypass[1] :
lclk;
assign tx_lclk90 = hard_reset ? clkin :
lclk_bp ? pll_bypass[2] :
lclk90;
assign tx_lclk_div4 = hard_reset ? clkin :
lclk_bp ? pll_bypass[3] :
lclk_div4;
2015-04-22 15:03:24 -04:00
`endif
2015-04-22 15:03:24 -04:00
endmodule // eclocks
// Local Variables:
// verilog-library-directories:("." "../../common/hdl")
// End:
/*
Copyright (C) 2014 Adapteva, Inc.
2015-04-22 15:03:24 -04:00
Contributed by Andreas Olofsson <andreas@adapteva.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.This program 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 General Public License for more details. You should have received a copy
of the GNU General Public License along with this program (see the file
COPYING). If not, see <http://www.gnu.org/licenses/>.
*/