From df3a74798e1db0bd2c7b45931fd6fa98ed80eba7 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Sun, 2 Feb 2020 09:02:33 +1100 Subject: [PATCH 1/7] Add a parameter to control the polarity of reset Signed-off-by: Anton Blanchard --- toplevel.v | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/toplevel.v b/toplevel.v index f3738f9..9f0977d 100644 --- a/toplevel.v +++ b/toplevel.v @@ -1,4 +1,6 @@ -module toplevel( +module toplevel #( + parameter RESET_LOW = 1 +) ( input clock, input reset, output io_tx, @@ -32,7 +34,7 @@ reg [21:0] cnt = ~0; always@(posedge clock) begin - if (~lock || ~reset) + if (~lock || (reset ^ RESET_LOW)) begin cnt <= ~0; end From e3990af2ef989c06c7bb34c8cc787ede540b8b5e Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Sun, 2 Feb 2020 09:30:57 +1100 Subject: [PATCH 2/7] Add FuseSoC support Signed-off-by: Anton Blanchard --- chiselwatt.core | 45 ++++++++++++++++++++++++++++++++++++++ constraints/cmod_a7-35.xdc | 20 +++++++++++++++++ pll_mmcme2.v | 22 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 chiselwatt.core create mode 100644 constraints/cmod_a7-35.xdc create mode 100644 pll_mmcme2.v diff --git a/chiselwatt.core b/chiselwatt.core new file mode 100644 index 0000000..85ff57c --- /dev/null +++ b/chiselwatt.core @@ -0,0 +1,45 @@ +CAPI=2: + +name : ::chiselwatt:0 + +filesets: + core: + files: + - Core.v + - MemoryBlackBox.v + - toplevel.v + - insns.hex : {copyto : insns.hex, file_type : user} + file_type : verilogSource + + cmod_a7-35: + files: + - constraints/cmod_a7-35.xdc : {file_type : xdc} + - pll_mmcme2.v : {file_type : verilogSource} + + ecp5-evn: + files: + - constraints/ecp5-evn.lpf : {file_type : LPF} + - pll_ecp5_evn.v : {file_type : verilogSource} + +targets: + cmod_a7-35: + default_tool: vivado + filesets: [core, cmod_a7-35] + parameters : + - RESET_LOW=false + tools: + vivado: {part : xc7a35tcpg236-1} + toplevel : toplevel + + ecp5-evn: + default_tool: diamond + filesets: [core, ecp5-evn] + tools: + diamond: {part: LFE5U-85F-8BG381I} + toplevel : toplevel + +parameters: + RESET_LOW: + datatype : bool + description : External reset button polarity + paramtype : generic diff --git a/constraints/cmod_a7-35.xdc b/constraints/cmod_a7-35.xdc new file mode 100644 index 0000000..1048145 --- /dev/null +++ b/constraints/cmod_a7-35.xdc @@ -0,0 +1,20 @@ +## Clock signal 12 MHz +set_property -dict { PACKAGE_PIN L17 IOSTANDARD LVCMOS33 } [get_ports { clock }]; +create_clock -add -name sys_clk_pin -period 83.33 -waveform {0 41.66} [get_ports {clock}]; + +set_property -dict { PACKAGE_PIN J18 IOSTANDARD LVCMOS33 } [get_ports { io_tx }]; +set_property -dict { PACKAGE_PIN J17 IOSTANDARD LVCMOS33 } [get_ports { io_rx }]; + +set_property -dict { PACKAGE_PIN A18 IOSTANDARD LVCMOS33 } [get_ports { reset }]; + +set_property -dict { PACKAGE_PIN A17 IOSTANDARD LVCMOS33 } [get_ports { io_terminate }]; + +set_property -dict { PACKAGE_PIN C16 IOSTANDARD LVCMOS33 } [get_ports { io_ledB }]; +set_property -dict { PACKAGE_PIN B17 IOSTANDARD LVCMOS33 } [get_ports { io_ledC }]; + +set_property CONFIG_VOLTAGE 3.3 [current_design] +set_property CFGBVS VCCO [current_design] + +set_property BITSTREAM.GENERAL.COMPRESS TRUE [current_design] +set_property BITSTREAM.CONFIG.CONFIGRATE 33 [current_design] +set_property CONFIG_MODE SPIx4 [current_design] diff --git a/pll_mmcme2.v b/pll_mmcme2.v new file mode 100644 index 0000000..ee4fc65 --- /dev/null +++ b/pll_mmcme2.v @@ -0,0 +1,22 @@ +module pll_ecp5_evn(input clki, output clko, output lock); + +wire clkfb; + +MMCME2_BASE #( + .BANDWIDTH("OPTIMIZED"), + .CLKFBOUT_MULT_F(50.0), + .CLKIN1_PERIOD(83.33), + .CLKOUT0_DIVIDE_F(12.0), + .DIVCLK_DIVIDE(1), + .STARTUP_WAIT("FALSE") + ) + MMCME2_BASE_inst ( + .CLKOUT0(clko), + .CLKFBOUT(clkfb), + .LOCKED(lock), + .CLKIN1(clki), + .PWRDWN(1'b0), + .RST(1'b0), + .CLKFBIN(clkfb) + ); +endmodule From d0a15b35de913ae19afb52ce150cecba0f6c4fcf Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Sun, 2 Feb 2020 09:42:15 +1100 Subject: [PATCH 3/7] Move PLLs into pll/ Also rename pll_ecp5_evn.v to pll_ehxplll.v Signed-off-by: Anton Blanchard --- Makefile | 4 ++-- chiselwatt.core | 4 ++-- pll_ecp5_evn.v => pll/pll_ehxplll.v | 0 pll_mmcme2.v => pll/pll_mmcme2.v | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename pll_ecp5_evn.v => pll/pll_ehxplll.v (100%) rename pll_mmcme2.v => pll/pll_mmcme2.v (100%) diff --git a/Makefile b/Makefile index 2f191fd..2723cff 100644 --- a/Makefile +++ b/Makefile @@ -68,8 +68,8 @@ OPENOCD_DEVICE_CONFIG=openocd/LFE5UM5G-85F.cfg synth: chiselwatt.bit -chiselwatt.json: $(verilog_files) insns.hex pll_ecp5_evn.v toplevel.v - $(YOSYS) -p "read_verilog -sv pll_ecp5_evn.v toplevel.v Core.v MemoryBlackBox.v; synth_ecp5 -json $@ -top toplevel" +chiselwatt.json: $(verilog_files) insns.hex pll/pll_ehxplll.v toplevel.v + $(YOSYS) -p "read_verilog -sv pll/pll_ehxplll.v toplevel.v Core.v MemoryBlackBox.v; synth_ecp5 -json $@ -top toplevel" chiselwatt_out.config: chiselwatt.json $(LPF) $(NEXTPNR) --json $< --lpf $(LPF) --textcfg $@ $(NEXTPNR_FLAGS) --package $(PACKAGE) diff --git a/chiselwatt.core b/chiselwatt.core index 85ff57c..edcafb3 100644 --- a/chiselwatt.core +++ b/chiselwatt.core @@ -14,12 +14,12 @@ filesets: cmod_a7-35: files: - constraints/cmod_a7-35.xdc : {file_type : xdc} - - pll_mmcme2.v : {file_type : verilogSource} + - pll/pll_mmcme2.v : {file_type : verilogSource} ecp5-evn: files: - constraints/ecp5-evn.lpf : {file_type : LPF} - - pll_ecp5_evn.v : {file_type : verilogSource} + - pll/pll_ehxplll.v : {file_type : verilogSource} targets: cmod_a7-35: diff --git a/pll_ecp5_evn.v b/pll/pll_ehxplll.v similarity index 100% rename from pll_ecp5_evn.v rename to pll/pll_ehxplll.v diff --git a/pll_mmcme2.v b/pll/pll_mmcme2.v similarity index 100% rename from pll_mmcme2.v rename to pll/pll_mmcme2.v From 43e1e73ce869a4e10e78afd0214db417f4fc55fc Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Sun, 2 Feb 2020 09:44:04 +1100 Subject: [PATCH 4/7] Rename PLL Now we have multiple PLLs it makes no sense to call it pll_ecp5_evn. Signed-off-by: Anton Blanchard --- pll/pll_ehxplll.v | 2 +- pll/pll_mmcme2.v | 2 +- toplevel.v | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pll/pll_ehxplll.v b/pll/pll_ehxplll.v index bc032ba..c8fe212 100644 --- a/pll/pll_ehxplll.v +++ b/pll/pll_ehxplll.v @@ -1,4 +1,4 @@ -module pll_ecp5_evn(input clki, output clko, output lock); +module pll(input clki, output clko, output lock); (* ICP_CURRENT="12" *) (* LPF_RESISTOR="8" *) (* MFG_ENABLE_FILTEROPAMP="1" *) (* MFG_GMCREF_SEL="2" *) EHXPLLL #( .PLLRST_ENA("DISABLED"), diff --git a/pll/pll_mmcme2.v b/pll/pll_mmcme2.v index ee4fc65..90014bf 100644 --- a/pll/pll_mmcme2.v +++ b/pll/pll_mmcme2.v @@ -1,4 +1,4 @@ -module pll_ecp5_evn(input clki, output clko, output lock); +module pll(input clki, output clko, output lock); wire clkfb; diff --git a/toplevel.v b/toplevel.v index 9f0977d..a9412fb 100644 --- a/toplevel.v +++ b/toplevel.v @@ -14,7 +14,7 @@ wire clock_out; reg reset_out; wire lock; -pll_ecp5_evn pll( +pll chiselwatt_pll( .clki(clock), .clko(clock_out), .lock(lock) From d2e04d01ffebaee3987a687eefa8a445562bf784 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Sun, 2 Feb 2020 09:51:56 +1100 Subject: [PATCH 5/7] Add pll_bypass.v Signed-off-by: Anton Blanchard --- pll/pll_bypass.v | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 pll/pll_bypass.v diff --git a/pll/pll_bypass.v b/pll/pll_bypass.v new file mode 100644 index 0000000..30bff07 --- /dev/null +++ b/pll/pll_bypass.v @@ -0,0 +1,12 @@ +module pll( + input clki, + output clko, + output lock +); + + always @* begin + lock <= 1; + clko <= clki; + end + +endmodule From c942fba2a96481fad41947cc30f0566375142e08 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Sun, 2 Feb 2020 10:01:28 +1100 Subject: [PATCH 6/7] Reformat PLLs Signed-off-by: Anton Blanchard --- pll/pll_ehxplll.v | 64 ++++++++++++++++++++++++++--------------------- pll/pll_mmcme2.v | 42 +++++++++++++++++-------------- 2 files changed, 58 insertions(+), 48 deletions(-) diff --git a/pll/pll_ehxplll.v b/pll/pll_ehxplll.v index c8fe212..0398fe2 100644 --- a/pll/pll_ehxplll.v +++ b/pll/pll_ehxplll.v @@ -1,30 +1,36 @@ -module pll(input clki, output clko, output lock); - (* ICP_CURRENT="12" *) (* LPF_RESISTOR="8" *) (* MFG_ENABLE_FILTEROPAMP="1" *) (* MFG_GMCREF_SEL="2" *) - EHXPLLL #( - .PLLRST_ENA("DISABLED"), - .INTFB_WAKE("DISABLED"), - .STDBY_ENABLE("DISABLED"), - .DPHASE_SOURCE("DISABLED"), - .CLKOP_FPHASE(0), - .CLKOP_CPHASE(11), - .OUTDIVIDER_MUXA("DIVA"), - .CLKOP_ENABLE("ENABLED"), - .CLKOP_DIV(12), - .CLKFB_DIV(25), - .CLKI_DIV(6), - .FEEDBK_PATH("CLKOP") - ) pll_i ( - .CLKI(clki), - .CLKFB(clko), - .CLKOP(clko), - .LOCK(lock), - .RST(1'b0), - .STDBY(1'b0), - .PHASESEL0(1'b0), - .PHASESEL1(1'b0), - .PHASEDIR(1'b0), - .PHASESTEP(1'b0), - .PLLWAKESYNC(1'b0), - .ENCLKOP(1'b0) - ); +module pll( + input clki, + output clko, + output lock +); + (* ICP_CURRENT="12" *) (* LPF_RESISTOR="8" *) (* MFG_ENABLE_FILTEROPAMP="1" *) (* MFG_GMCREF_SEL="2" *) + + EHXPLLL #( + .PLLRST_ENA("DISABLED"), + .INTFB_WAKE("DISABLED"), + .STDBY_ENABLE("DISABLED"), + .DPHASE_SOURCE("DISABLED"), + .CLKOP_FPHASE(0), + .CLKOP_CPHASE(11), + .OUTDIVIDER_MUXA("DIVA"), + .CLKOP_ENABLE("ENABLED"), + .CLKOP_DIV(12), + .CLKFB_DIV(25), + .CLKI_DIV(6), + .FEEDBK_PATH("CLKOP") + ) pll_i ( + .CLKI(clki), + .CLKFB(clko), + .CLKOP(clko), + .LOCK(lock), + .RST(1'b0), + .STDBY(1'b0), + .PHASESEL0(1'b0), + .PHASESEL1(1'b0), + .PHASEDIR(1'b0), + .PHASESTEP(1'b0), + .PLLWAKESYNC(1'b0), + .ENCLKOP(1'b0) + ); + endmodule diff --git a/pll/pll_mmcme2.v b/pll/pll_mmcme2.v index 90014bf..3b188de 100644 --- a/pll/pll_mmcme2.v +++ b/pll/pll_mmcme2.v @@ -1,22 +1,26 @@ -module pll(input clki, output clko, output lock); +module pll( + input clki, + output clko, + output lock +); -wire clkfb; + wire clkfb; + + MMCME2_BASE #( + .BANDWIDTH("OPTIMIZED"), + .CLKFBOUT_MULT_F(50.0), + .CLKIN1_PERIOD(83.33), + .CLKOUT0_DIVIDE_F(12.0), + .DIVCLK_DIVIDE(1), + .STARTUP_WAIT("FALSE") + ) MMCME2_BASE_inst ( + .CLKOUT0(clko), + .CLKFBOUT(clkfb), + .LOCKED(lock), + .CLKIN1(clki), + .PWRDWN(1'b0), + .RST(1'b0), + .CLKFBIN(clkfb) + ); -MMCME2_BASE #( - .BANDWIDTH("OPTIMIZED"), - .CLKFBOUT_MULT_F(50.0), - .CLKIN1_PERIOD(83.33), - .CLKOUT0_DIVIDE_F(12.0), - .DIVCLK_DIVIDE(1), - .STARTUP_WAIT("FALSE") - ) - MMCME2_BASE_inst ( - .CLKOUT0(clko), - .CLKFBOUT(clkfb), - .LOCKED(lock), - .CLKIN1(clki), - .PWRDWN(1'b0), - .RST(1'b0), - .CLKFBIN(clkfb) - ); endmodule From ae8466e8de563f715ce2b2b77dd47e580f045ae1 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Sun, 2 Feb 2020 12:04:15 +1100 Subject: [PATCH 7/7] Reformat toplevel.v Signed-off-by: Anton Blanchard --- toplevel.v | 72 ++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/toplevel.v b/toplevel.v index a9412fb..f567bb2 100644 --- a/toplevel.v +++ b/toplevel.v @@ -1,49 +1,45 @@ module toplevel #( - parameter RESET_LOW = 1 + parameter RESET_LOW = 1 ) ( - input clock, - input reset, - output io_tx, - input io_rx, - output io_terminate, - output io_ledB, - output io_ledC + input clock, + input reset, + output io_tx, + input io_rx, + output io_terminate, + output io_ledB, + output io_ledC ); -wire clock_out; -reg reset_out; -wire lock; + wire clock_out; + reg reset_out; + wire lock; -pll chiselwatt_pll( - .clki(clock), - .clko(clock_out), - .lock(lock) -); + pll chiselwatt_pll( + .clki(clock), + .clko(clock_out), + .lock(lock) + ); -Core core( - .clock(clock_out), - .reset(reset_out), - .io_tx(io_tx), - .io_rx(io_rx), - .io_terminate(io_terminate), - .io_ledB(io_ledB), - .io_ledC(io_ledC) -); + Core core( + .clock(clock_out), + .reset(reset_out), + .io_tx(io_tx), + .io_rx(io_rx), + .io_terminate(io_terminate), + .io_ledB(io_ledB), + .io_ledC(io_ledC) + ); -reg [21:0] cnt = ~0; + reg [21:0] cnt = ~0; -always@(posedge clock) -begin - if (~lock || (reset ^ RESET_LOW)) - begin - cnt <= ~0; - end - else if (cnt != 0) - begin - cnt <= cnt - 1; - end + always@(posedge clock) begin + if (~lock || (reset ^ RESET_LOW)) begin + cnt <= ~0; + end else if (cnt != 0) begin + cnt <= cnt - 1; + end - reset_out <= |cnt; -end + reset_out <= |cnt; + end endmodule