From 3405c88c9e4171a793ea72385953e88f69d2c200 Mon Sep 17 00:00:00 2001 From: colin Date: Mon, 7 Feb 2022 13:23:34 +0000 Subject: [PATCH] Correct blink and use sample blink code --- fpga/blink/.gitignore | 2 +- fpga/blink/blink.v | 80 ++++++++++++++++++++++++++--------------- fpga/blink/cmsisdap.cfg | 28 +++++++++++++++ 3 files changed, 80 insertions(+), 30 deletions(-) create mode 100644 fpga/blink/cmsisdap.cfg diff --git a/fpga/blink/.gitignore b/fpga/blink/.gitignore index 15006ff..b39d90a 100644 --- a/fpga/blink/.gitignore +++ b/fpga/blink/.gitignore @@ -1,5 +1,5 @@ *.svf *.bit -*.cfg +blink.cfg *.ys *.json diff --git a/fpga/blink/blink.v b/fpga/blink/blink.v index 93f2be6..9809901 100644 --- a/fpga/blink/blink.v +++ b/fpga/blink/blink.v @@ -1,25 +1,55 @@ -module rst_gen ( - input clk_i, - input rst_i, - output rst_o -); +// module rst_gen ( +// input clk_i, +// input rst_i, +// output rst_o +// ); -/* try to generate a reset */ -reg [2:0] rst_cpt; -always @(posedge clk_i) begin - if (rst_i) - rst_cpt = 3'b0; - else begin - if (rst_cpt == 3'b100) - rst_cpt = rst_cpt; - else - rst_cpt = rst_cpt + 3'b1; - end -end +// /* try to generate a reset */ +// reg [2:0] rst_cpt; +// always @(posedge clk_i) begin +// if (rst_i) +// rst_cpt = 3'b0; +// else begin +// if (rst_cpt == 3'b100) +// rst_cpt = rst_cpt; +// else +// rst_cpt = rst_cpt + 3'b1; +// end +// end -assign rst_o = !rst_cpt[2]; +// assign rst_o = !rst_cpt[2]; + +// endmodule + +// module blink ( +// input clk_i, +// output reg led_o +// ); +// localparam MAX = 2_500_000_0; +// localparam WIDTH = $clog2(MAX); + +// wire rst_s; +// wire clk_s; + +// assign clk_s = clk_i; +// //pll_12_16 pll_inst (.clki(clk_i), .clko(clk_s), .rst(rst_s)); +// rst_gen rst_inst (.clk_i(clk_s), .rst_i(1'b0), .rst_o(rst_s)); + +// reg [WIDTH-1:0] cpt_s; +// wire [WIDTH-1:0] cpt_next_s = cpt_s + 1'b1; + +// wire end_s = cpt_s == MAX-1; + +// always @(posedge clk_s) begin +// cpt_s <= (rst_s || end_s) ? {WIDTH{1'b0}} : cpt_next_s; + +// if (rst_s) +// led_o <= 1'b0; +// else if (end_s) +// led_o <= ~led_o; +// end +// endmodule -endmodule module blink ( input clk_i, @@ -28,24 +58,16 @@ module blink ( localparam MAX = 2_500_000_0; localparam WIDTH = $clog2(MAX); -wire rst_s; wire clk_s; - assign clk_s = clk_i; -//pll_12_16 pll_inst (.clki(clk_i), .clko(clk_s), .rst(rst_s)); -rst_gen rst_inst (.clk_i(clk_s), .rst_i(1'b0), .rst_o(rst_s)); reg [WIDTH-1:0] cpt_s; wire [WIDTH-1:0] cpt_next_s = cpt_s + 1'b1; - wire end_s = cpt_s == MAX-1; always @(posedge clk_s) begin - cpt_s <= (rst_s || end_s) ? {WIDTH{1'b0}} : cpt_next_s; - - if (rst_s) - led_o <= 1'b0; - else if (end_s) + cpt_s <= cpt_next_s; + if (end_s) led_o <= ~led_o; end endmodule diff --git a/fpga/blink/cmsisdap.cfg b/fpga/blink/cmsisdap.cfg new file mode 100644 index 0000000..44fb6a4 --- /dev/null +++ b/fpga/blink/cmsisdap.cfg @@ -0,0 +1,28 @@ +# +# Buspirate with OpenOCD support +# +# http://dangerousprototypes.com/bus-pirate-manual/ +# +# http://www.fabienm.eu/flf/15-ecp5-board-kit/ +# https://github.com/Martoni/blp/tree/master/platforms/colorlight +# https://github.com/HarmonInstruments/JTAG_SWD + +interface cmsis-dap +transport select jtag + +adapter_khz 10000 + +#jtag newtap ecp5 tap -irlen 8 -expected-id 0x41111043 + +#LFE5U-25F 0x41111043 +#LFE5U-45F 0x41112043 +jtag newtap ecp5 tap -irlen 8 + +#init +#scan_chain +# +#svf -tap ecp5.tap -quiet -progress blink.svf +#exit + +# this depends on the cable, you are safe with this option +#reset_config srst_only \ No newline at end of file