-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
171 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,8 @@ toolchains/mill | |
# Vivado | ||
vivado*.jou | ||
vivado*.log | ||
vivado*.str | ||
.gen/ | ||
.srcs/ | ||
.ip_user_files/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,84 @@ | ||
import chisel3.{BlackBox, _} | ||
import chisel3.util._ | ||
|
||
import java.io.PrintWriter | ||
|
||
class clk_wiz_0 extends BlackBox { | ||
|
||
class ClockingWizard( | ||
clk_out1_freq: Int, | ||
clk_out2_freq: Int = 0, | ||
clk_out3_freq: Int = 0, | ||
clk_out4_freq: Int = 0, | ||
clk_out5_freq: Int = 0, | ||
clk_out6_freq: Int = 0, | ||
clk_out7_freq: Int = 0 | ||
) extends BlackBox { | ||
val io = IO(new Bundle { | ||
val clk_in1 = Input(Clock()) | ||
val reset = Input(Bool()) | ||
val locked = Output(Bool()) | ||
val clk_out1 = Output(Clock()) | ||
val clk_out2 = Output(Clock()) | ||
val clk_out3 = Output(Clock()) | ||
val clk_out4 = Output(Clock()) | ||
val clk_out5 = Output(Clock()) | ||
val clk_out6 = Output(Clock()) | ||
val clk_out7 = Output(Clock()) | ||
}) | ||
|
||
def generate_tcl_script(): Unit = { | ||
val vivado_project_dir = "out/VivadoProject" | ||
val ip_name = "ClockingWizard" | ||
val ip_name_lower = ip_name.toLowerCase() | ||
|
||
var num_out_clks = 1 | ||
if (clk_out2_freq > 0) { | ||
num_out_clks += 1 | ||
} | ||
if (clk_out3_freq > 0) { | ||
num_out_clks += 1 | ||
} | ||
if (clk_out4_freq > 0) { | ||
num_out_clks += 1 | ||
} | ||
if (clk_out5_freq > 0) { | ||
num_out_clks += 1 | ||
} | ||
if (clk_out6_freq > 0) { | ||
num_out_clks += 1 | ||
} | ||
if (clk_out7_freq > 0) { | ||
num_out_clks += 1 | ||
} | ||
|
||
val tcl_script = new PrintWriter(s"${vivado_project_dir}/scripts/create_ip_${ip_name_lower}.tcl") | ||
|
||
tcl_script.println(s"create_ip -name clk_wiz -vendor xilinx.com -library ip -version 6.0 -module_name ${ip_name}") | ||
|
||
tcl_script.println(s""" | ||
set_property -dict [list \\ | ||
CONFIG.CLKOUT1_JITTER {125.247} \\ | ||
CONFIG.CLKOUT1_PHASE_ERROR {98.575} \\ | ||
CONFIG.CLKOUT1_REQUESTED_OUT_FREQ {${clk_out1_freq}} \\ | ||
CONFIG.CLKOUT2_JITTER {175.402} \\ | ||
CONFIG.CLKOUT2_PHASE_ERROR {98.575} \\ | ||
CONFIG.CLKOUT2_REQUESTED_OUT_FREQ {${clk_out2_freq}} \\ | ||
CONFIG.CLKOUT2_USED {${clk_out2_freq > 0}} \\ | ||
CONFIG.MMCM_CLKFBOUT_MULT_F {10.000} \\ | ||
CONFIG.MMCM_CLKOUT0_DIVIDE_F {8.000} \\ | ||
CONFIG.MMCM_CLKOUT1_DIVIDE {40} \\ | ||
CONFIG.NUM_OUT_CLKS {${num_out_clks}} \\ | ||
] [get_ips ${ip_name}] | ||
""") | ||
|
||
tcl_script.println(s"generate_target {instantiation_template} [get_ips ${ip_name}]") | ||
tcl_script.println("update_compile_order -fileset sources_1") | ||
tcl_script.println(s"generate_target all [get_ips ${ip_name}]") | ||
tcl_script.println(s"catch { config_ip_cache -export [get_ips -all ${ip_name}] }") | ||
tcl_script.println(s"export_ip_user_files -of_objects [get_ips ${ip_name}] -no_script -sync -force -quiet") | ||
tcl_script.println(s"create_ip_run [get_ips ${ip_name}]") | ||
|
||
tcl_script.close() | ||
} | ||
generate_tcl_script() | ||
} |