353 lines
12 KiB
Scala
353 lines
12 KiB
Scala
// See LICENSE for license details.
|
|
package sifive.fpgashells.ip.xilinx
|
|
|
|
import Chisel._
|
|
import chisel3.core.{Input, Output, attach}
|
|
import chisel3.experimental.{Analog}
|
|
import freechips.rocketchip.util.{ElaborationArtefacts}
|
|
|
|
import sifive.blocks.devices.pinctrl.{BasePin}
|
|
|
|
//========================================================================
|
|
// This file contains common devices used by our Xilinx FPGA flows and some
|
|
// BlackBox modules used in the Xilinx FPGA flows
|
|
//========================================================================
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
// mmcm
|
|
//-------------------------------------------------------------------------
|
|
/** mmcm: This is generated by the Xilinx IP Generation Scripts */
|
|
|
|
class mmcm extends BlackBox {
|
|
val io = new Bundle {
|
|
val clk_in1 = Input(Clock())
|
|
val clk_out1 = Output(Clock())
|
|
val clk_out2 = Output(Clock())
|
|
val clk_out3 = Output(Clock())
|
|
val resetn = Input(Bool())
|
|
val locked = Output(Bool())
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
// reset_sys
|
|
//-------------------------------------------------------------------------
|
|
/** reset_sys: This is generated by the Xilinx IP Generation Scripts */
|
|
|
|
class reset_sys extends BlackBox {
|
|
val io = new Bundle {
|
|
val slowest_sync_clk = Input(Clock())
|
|
val ext_reset_in = Input(Bool())
|
|
val aux_reset_in = Input(Bool())
|
|
val mb_debug_sys_rst = Input(Bool())
|
|
val dcm_locked = Input(Bool())
|
|
val mb_reset = Output(Bool())
|
|
val bus_struct_reset = Output(Bool())
|
|
val peripheral_reset = Output(Bool())
|
|
val interconnect_aresetn = Output(Bool())
|
|
val peripheral_aresetn = Output(Bool())
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
// reset_mig
|
|
//-------------------------------------------------------------------------
|
|
/** reset_mig: This is generated by the Xilinx IP Generation Scripts */
|
|
|
|
class reset_mig extends BlackBox {
|
|
val io = new Bundle {
|
|
val slowest_sync_clk = Input(Clock())
|
|
val ext_reset_in = Input(Bool())
|
|
val aux_reset_in = Input(Bool())
|
|
val mb_debug_sys_rst = Input(Bool())
|
|
val dcm_locked = Input(Bool())
|
|
val mb_reset = Output(Bool())
|
|
val bus_struct_reset = Output(Bool())
|
|
val peripheral_reset = Output(Bool())
|
|
val interconnect_aresetn = Output(Bool())
|
|
val peripheral_aresetn = Output(Bool())
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
// PowerOnResetFPGAOnly
|
|
//-------------------------------------------------------------------------
|
|
/** PowerOnResetFPGAOnly -- this generates a power_on_reset signal using
|
|
* initial blocks. It is synthesizable on FPGA flows only.
|
|
*/
|
|
|
|
// This is a FPGA-Only construct, which uses
|
|
// 'initial' constructions
|
|
class PowerOnResetFPGAOnly extends BlackBox {
|
|
val io = new Bundle {
|
|
val clock = Input(Clock())
|
|
val power_on_reset = Output(Bool())
|
|
}
|
|
}
|
|
|
|
object PowerOnResetFPGAOnly {
|
|
def apply (clk: Clock): Bool = {
|
|
val por = Module(new PowerOnResetFPGAOnly())
|
|
por.io.clock := clk
|
|
por.io.power_on_reset
|
|
}
|
|
}
|
|
|
|
// ML507 clock generation
|
|
class ml507_sys_clock extends BlackBox {
|
|
val io = new Bundle {
|
|
val CLKIN_IN = Bool(INPUT)
|
|
val CLKFX_OUT = Clock(OUTPUT)
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
// vc707_sys_clock_mmcm
|
|
//-------------------------------------------------------------------------
|
|
//IP : xilinx mmcm with "NO_BUFFER" input clock
|
|
|
|
class vc707_sys_clock_mmcm0 extends BlackBox {
|
|
val io = new Bundle {
|
|
val clk_in1 = Bool(INPUT)
|
|
val clk_out1 = Clock(OUTPUT)
|
|
val clk_out2 = Clock(OUTPUT)
|
|
val clk_out3 = Clock(OUTPUT)
|
|
val clk_out4 = Clock(OUTPUT)
|
|
val clk_out5 = Clock(OUTPUT)
|
|
val clk_out6 = Clock(OUTPUT)
|
|
val clk_out7 = Clock(OUTPUT)
|
|
val reset = Bool(INPUT)
|
|
val locked = Bool(OUTPUT)
|
|
}
|
|
|
|
ElaborationArtefacts.add(
|
|
"vc707_sys_clock_mmcm0.vivado.tcl",
|
|
"""create_ip -name clk_wiz -vendor xilinx.com -library ip -module_name vc707_sys_clock_mmcm0 -dir $ipdir -force
|
|
set_property -dict [list \
|
|
CONFIG.CLK_IN1_BOARD_INTERFACE {Custom} \
|
|
CONFIG.PRIM_SOURCE {No_buffer} \
|
|
CONFIG.CLKOUT2_USED {true} \
|
|
CONFIG.CLKOUT3_USED {true} \
|
|
CONFIG.CLKOUT4_USED {true} \
|
|
CONFIG.CLKOUT5_USED {true} \
|
|
CONFIG.CLKOUT6_USED {true} \
|
|
CONFIG.CLKOUT7_USED {true} \
|
|
CONFIG.CLKOUT1_REQUESTED_OUT_FREQ {12.5} \
|
|
CONFIG.CLKOUT2_REQUESTED_OUT_FREQ {25} \
|
|
CONFIG.CLKOUT3_REQUESTED_OUT_FREQ {37.5} \
|
|
CONFIG.CLKOUT4_REQUESTED_OUT_FREQ {50} \
|
|
CONFIG.CLKOUT5_REQUESTED_OUT_FREQ {100} \
|
|
CONFIG.CLKOUT6_REQUESTED_OUT_FREQ {150.000} \
|
|
CONFIG.CLKOUT7_REQUESTED_OUT_FREQ {75} \
|
|
CONFIG.CLK_IN1_BOARD_INTERFACE {Custom} \
|
|
CONFIG.PRIM_IN_FREQ {200.000} \
|
|
CONFIG.CLKIN1_JITTER_PS {50.0} \
|
|
CONFIG.MMCM_DIVCLK_DIVIDE {1} \
|
|
CONFIG.MMCM_CLKFBOUT_MULT_F {4.500} \
|
|
CONFIG.MMCM_CLKIN1_PERIOD {5.0} \
|
|
CONFIG.MMCM_CLKOUT0_DIVIDE_F {72.000} \
|
|
CONFIG.MMCM_CLKOUT1_DIVIDE {36} \
|
|
CONFIG.MMCM_CLKOUT2_DIVIDE {24} \
|
|
CONFIG.MMCM_CLKOUT3_DIVIDE {18} \
|
|
CONFIG.MMCM_CLKOUT4_DIVIDE {9} \
|
|
CONFIG.MMCM_CLKOUT5_DIVIDE {6} \
|
|
CONFIG.MMCM_CLKOUT6_DIVIDE {12} \
|
|
CONFIG.NUM_OUT_CLKS {7} \
|
|
CONFIG.CLKOUT1_JITTER {168.247} \
|
|
CONFIG.CLKOUT1_PHASE_ERROR {91.235} \
|
|
CONFIG.CLKOUT2_JITTER {146.624} \
|
|
CONFIG.CLKOUT2_PHASE_ERROR {91.235} \
|
|
CONFIG.CLKOUT3_JITTER {135.178} \
|
|
CONFIG.CLKOUT3_PHASE_ERROR {91.235} \
|
|
CONFIG.CLKOUT4_JITTER {127.364} \
|
|
CONFIG.CLKOUT4_PHASE_ERROR {91.235} \
|
|
CONFIG.CLKOUT5_JITTER {110.629} \
|
|
CONFIG.CLKOUT5_PHASE_ERROR {91.235} \
|
|
CONFIG.CLKOUT6_JITTER {102.207} \
|
|
CONFIG.CLKOUT6_PHASE_ERROR {91.235} \
|
|
CONFIG.CLKOUT7_JITTER {117.249} \
|
|
CONFIG.CLKOUT7_PHASE_ERROR {91.235}] [get_ips vc707_sys_clock_mmcm0] """
|
|
)
|
|
}
|
|
|
|
class vc707_sys_clock_mmcm1 extends BlackBox {
|
|
val io = new Bundle {
|
|
val clk_in1 = Bool(INPUT)
|
|
val clk_out1 = Clock(OUTPUT)
|
|
val clk_out2 = Clock(OUTPUT)
|
|
val reset = Bool(INPUT)
|
|
val locked = Bool(OUTPUT)
|
|
}
|
|
|
|
ElaborationArtefacts.add(
|
|
"vc707_sys_clock_mmcm1.vivado.tcl",
|
|
"""create_ip -name clk_wiz -vendor xilinx.com -library ip -module_name vc707_sys_clock_mmcm1 -dir $ipdir -force
|
|
set_property -dict [list \
|
|
CONFIG.CLK_IN1_BOARD_INTERFACE {Custom} \
|
|
CONFIG.PRIM_SOURCE {No_buffer} \
|
|
CONFIG.CLKOUT2_USED {true} \
|
|
CONFIG.CLKOUT3_USED {false} \
|
|
CONFIG.CLKOUT4_USED {false} \
|
|
CONFIG.CLKOUT5_USED {false} \
|
|
CONFIG.CLKOUT6_USED {false} \
|
|
CONFIG.CLKOUT7_USED {false} \
|
|
CONFIG.CLKOUT1_REQUESTED_OUT_FREQ {32.5} \
|
|
CONFIG.CLKOUT2_REQUESTED_OUT_FREQ {65} \
|
|
CONFIG.CLK_IN1_BOARD_INTERFACE {Custom} \
|
|
CONFIG.PRIM_IN_FREQ {200.000} \
|
|
CONFIG.CLKIN1_JITTER_PS {50.0} \
|
|
CONFIG.MMCM_DIVCLK_DIVIDE {1} \
|
|
CONFIG.MMCM_CLKFBOUT_MULT_F {4.875} \
|
|
CONFIG.MMCM_CLKIN1_PERIOD {5.0} \
|
|
CONFIG.MMCM_CLKOUT0_DIVIDE_F {30.000} \
|
|
CONFIG.MMCM_CLKOUT1_DIVIDE {15} \
|
|
CONFIG.MMCM_CLKOUT2_DIVIDE {1} \
|
|
CONFIG.MMCM_CLKOUT3_DIVIDE {1} \
|
|
CONFIG.MMCM_CLKOUT4_DIVIDE {1} \
|
|
CONFIG.MMCM_CLKOUT5_DIVIDE {1} \
|
|
CONFIG.MMCM_CLKOUT6_DIVIDE {1} \
|
|
CONFIG.NUM_OUT_CLKS {2} \
|
|
CONFIG.CLKOUT1_JITTER {135.973} \
|
|
CONFIG.CLKOUT1_PHASE_ERROR {87.159} \
|
|
CONFIG.CLKOUT2_JITTER {117.878} \
|
|
CONFIG.CLKOUT2_PHASE_ERROR {87.159} \
|
|
CONFIG.CLKOUT3_JITTER {131.973} \
|
|
CONFIG.CLKOUT3_PHASE_ERROR {87.159}] \
|
|
[get_ips vc707_sys_clock_mmcm1] """
|
|
)
|
|
}
|
|
|
|
class vc707_sys_clock_mmcm2 extends BlackBox {
|
|
val io = new Bundle {
|
|
val clk_in1 = Bool(INPUT)
|
|
val clk_out1 = Clock(OUTPUT)
|
|
val clk_out2 = Clock(OUTPUT)
|
|
val clk_out3 = Clock(OUTPUT)
|
|
val clk_out4 = Clock(OUTPUT)
|
|
val clk_out5 = Clock(OUTPUT)
|
|
val clk_out6 = Clock(OUTPUT)
|
|
val clk_out7 = Clock(OUTPUT)
|
|
val reset = Bool(INPUT)
|
|
val locked = Bool(OUTPUT)
|
|
}
|
|
|
|
ElaborationArtefacts.add(
|
|
"vc707_sys_clock_mmcm2.vivado.tcl",
|
|
"""create_ip -name clk_wiz -vendor xilinx.com -library ip -module_name vc707_sys_clock_mmcm2 -dir $ipdir -force
|
|
set_property -dict [list \
|
|
CONFIG.CLK_IN1_BOARD_INTERFACE {Custom} \
|
|
CONFIG.PRIM_SOURCE {No_buffer} \
|
|
CONFIG.CLKOUT1_USED {true} \
|
|
CONFIG.CLKOUT2_USED {true} \
|
|
CONFIG.CLKOUT3_USED {true} \
|
|
CONFIG.CLKOUT4_USED {true} \
|
|
CONFIG.CLKOUT5_USED {true} \
|
|
CONFIG.CLKOUT6_USED {true} \
|
|
CONFIG.CLKOUT7_USED {true} \
|
|
CONFIG.CLKOUT1_REQUESTED_OUT_FREQ {12.5} \
|
|
CONFIG.CLKOUT2_REQUESTED_OUT_FREQ {25} \
|
|
CONFIG.CLKOUT3_REQUESTED_OUT_FREQ {37.5} \
|
|
CONFIG.CLKOUT4_REQUESTED_OUT_FREQ {50} \
|
|
CONFIG.CLKOUT5_REQUESTED_OUT_FREQ {100} \
|
|
CONFIG.CLKOUT6_REQUESTED_OUT_FREQ {150.000} \
|
|
CONFIG.CLKOUT7_REQUESTED_OUT_FREQ {100} \
|
|
CONFIG.CLKOUT7_REQUESTED_PHASE {180} \
|
|
CONFIG.CLK_IN1_BOARD_INTERFACE {Custom} \
|
|
CONFIG.PRIM_IN_FREQ {200.000} \
|
|
CONFIG.CLKIN1_JITTER_PS {50.0} \
|
|
CONFIG.MMCM_DIVCLK_DIVIDE {2} \
|
|
CONFIG.MMCM_CLKFBOUT_MULT_F {9.0} \
|
|
CONFIG.MMCM_CLKIN1_PERIOD {5.0} \
|
|
CONFIG.MMCM_CLKOUT0_DIVIDE_F {72.000} \
|
|
CONFIG.MMCM_CLKOUT1_DIVIDE {36} \
|
|
CONFIG.MMCM_CLKOUT2_DIVIDE {24} \
|
|
CONFIG.MMCM_CLKOUT3_DIVIDE {18} \
|
|
CONFIG.MMCM_CLKOUT4_DIVIDE {9} \
|
|
CONFIG.MMCM_CLKOUT5_DIVIDE {6} \
|
|
CONFIG.MMCM_CLKOUT6_DIVIDE {9} \
|
|
CONFIG.NUM_OUT_CLKS {7} \
|
|
CONFIG.CLKOUT1_JITTER {206.010} \
|
|
CONFIG.CLKOUT1_PHASE_ERROR {105.461} \
|
|
CONFIG.CLKOUT2_JITTER {180.172} \
|
|
CONFIG.CLKOUT2_PHASE_ERROR {105.461} \
|
|
CONFIG.CLKOUT3_JITTER {166.503} \
|
|
CONFIG.CLKOUT3_PHASE_ERROR {105.461} \
|
|
CONFIG.CLKOUT4_JITTER {157.199} \
|
|
CONFIG.CLKOUT4_PHASE_ERROR {105.461} \
|
|
CONFIG.CLKOUT5_JITTER {136.686} \
|
|
CONFIG.CLKOUT5_PHASE_ERROR {105.461} \
|
|
CONFIG.CLKOUT6_JITTER {126.399} \
|
|
CONFIG.CLKOUT6_PHASE_ERROR {105.461} \
|
|
CONFIG.CLKOUT7_JITTER {206.010} \
|
|
CONFIG.CLKOUT7_PHASE_ERROR {136.686}] [get_ips vc707_sys_clock_mmcm2] """
|
|
)
|
|
}
|
|
|
|
class vc707_sys_clock_mmcm3 extends BlackBox {
|
|
val io = new Bundle {
|
|
val clk_in1 = Bool(INPUT)
|
|
val clk_out1 = Clock(OUTPUT)
|
|
val reset = Bool(INPUT)
|
|
val locked = Bool(OUTPUT)
|
|
}
|
|
|
|
ElaborationArtefacts.add(
|
|
"vc707_sys_clock_mmcm3.vivado.tcl",
|
|
"""create_ip -name clk_wiz -vendor xilinx.com -library ip -module_name vc707_sys_clock_mmcm3 -dir $ipdir -force
|
|
set_property -dict [list \
|
|
CONFIG.PRIM_SOURCE {No_buffer} \
|
|
CONFIG.PRIM_IN_FREQ {100} \
|
|
CONFIG.CLKOUT1_REQUESTED_OUT_FREQ {100} \
|
|
CONFIG.CLKOUT1_REQUESTED_PHASE {180} \
|
|
CONFIG.CLK_IN1_BOARD_INTERFACE {Custom} \
|
|
CONFIG.CLKIN1_JITTER_PS {100.0} \
|
|
CONFIG.MMCM_DIVCLK_DIVIDE {1} \
|
|
CONFIG.MMCM_CLKFBOUT_MULT_F {10.000} \
|
|
CONFIG.MMCM_CLKIN1_PERIOD {10.0} \
|
|
CONFIG.MMCM_CLKOUT0_DIVIDE_F {10.000} \
|
|
CONFIG.MMCM_CLKOUT1_DIVIDE {10} \
|
|
CONFIG.MMCM_CLKOUT1_PHASE {180.000} \
|
|
CONFIG.NUM_OUT_CLKS {1} \
|
|
CONFIG.CLKOUT1_JITTER {130.958} \
|
|
CONFIG.CLKOUT1_PHASE_ERROR {98.575}] [get_ips vc707_sys_clock_mmcm3] """
|
|
)
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
// vc707reset
|
|
//-------------------------------------------------------------------------
|
|
|
|
class vc707reset() extends BlackBox
|
|
{
|
|
val io = new Bundle{
|
|
val areset = Bool(INPUT)
|
|
val clock1 = Clock(INPUT)
|
|
val reset1 = Bool(OUTPUT)
|
|
val clock2 = Clock(INPUT)
|
|
val reset2 = Bool(OUTPUT)
|
|
val clock3 = Clock(INPUT)
|
|
val reset3 = Bool(OUTPUT)
|
|
val clock4 = Clock(INPUT)
|
|
val reset4 = Bool(OUTPUT)
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
// sdio_spi_bridge
|
|
//-------------------------------------------------------------------------
|
|
|
|
class sdio_spi_bridge() extends BlackBox
|
|
{
|
|
val io = new Bundle{
|
|
val clk = Clock(INPUT)
|
|
val reset = Bool(INPUT)
|
|
val sd_cmd = Analog(1.W)
|
|
val sd_dat = Analog(4.W)
|
|
val spi_sck = Bool(INPUT)
|
|
val spi_cs = Bool(INPUT)
|
|
val spi_dq_o = Bits(INPUT,4)
|
|
val spi_dq_i = Bits(OUTPUT,4)
|
|
}
|
|
}
|