diff --git a/firmware/dhb_fpga_top/build/dhb_fpga_top.cdf b/firmware/dhb_fpga_top/build/dhb_fpga_top.cdf new file mode 100644 index 0000000..d307ef3 --- /dev/null +++ b/firmware/dhb_fpga_top/build/dhb_fpga_top.cdf @@ -0,0 +1,13 @@ +/* Quartus Prime Version 19.1.0 Build 670 09/22/2019 SJ Lite Edition */ +JedecChain; + FileRevision(JESD32A); + DefaultMfr(6E); + + P ActionCode(Cfg) + Device PartName(10CL006Y) Path("") File("") MfrSpec(OpMask(1) SEC_Device(MT25QL128) Child_OpMask(1 1)); + +ChainEnd; + +AlteraBegin; + ChainType(JTAG); +AlteraEnd; diff --git a/firmware/dhb_fpga_top/build/dhb_fpga_top.cof b/firmware/dhb_fpga_top/build/dhb_fpga_top.cof new file mode 100644 index 0000000..d7f0d13 --- /dev/null +++ b/firmware/dhb_fpga_top/build/dhb_fpga_top.cof @@ -0,0 +1,32 @@ + + + MT25QL128 + 10CL006Y + dhb_fpga_top.jic + 1 + 1 + 7 + + Page_0 + 1 + + ./output_files/dhb_fpga_top.sof + + + 10 + 0 + 0 + 0 + 1 + + 1 + + + 1 + 2 + 0 + -1 + -1 + 1 + + \ No newline at end of file diff --git a/firmware/dhb_fpga_top/build/output_files/dhb_fpga_top.rbf b/firmware/dhb_fpga_top/build/output_files/dhb_fpga_top.rbf index 722968f..b7f52e9 100644 Binary files a/firmware/dhb_fpga_top/build/output_files/dhb_fpga_top.rbf and b/firmware/dhb_fpga_top/build/output_files/dhb_fpga_top.rbf differ diff --git a/firmware/dhb_fpga_top/build/output_files/dhb_fpga_top.sof b/firmware/dhb_fpga_top/build/output_files/dhb_fpga_top.sof index 3856802..bac0e7e 100644 Binary files a/firmware/dhb_fpga_top/build/output_files/dhb_fpga_top.sof and b/firmware/dhb_fpga_top/build/output_files/dhb_fpga_top.sof differ diff --git a/firmware/hmb_fpga_top/build/hmb_fpga_top.qsf b/firmware/hmb_fpga_top/build/hmb_fpga_top.qsf index f71343e..4c0de8a 100644 --- a/firmware/hmb_fpga_top/build/hmb_fpga_top.qsf +++ b/firmware/hmb_fpga_top/build/hmb_fpga_top.qsf @@ -123,21 +123,25 @@ set_location_assignment PIN_G15 -to led_green set_location_assignment PIN_K10 -to shutdown set_location_assignment PIN_F16 -to wd_to -set_instance_assignment -name CURRENT_STRENGTH_NEW 8MA -to fpga_dout[*] set_instance_assignment -name CURRENT_STRENGTH_NEW 8MA -to led[*] set_instance_assignment -name CURRENT_STRENGTH_NEW 8MA -to led_green set_instance_assignment -name CURRENT_STRENGTH_NEW 8MA -to shutdown set_instance_assignment -name CURRENT_STRENGTH_NEW 8MA -to wd_to set_instance_assignment -name CURRENT_STRENGTH_NEW 8MA -to fpga_scl set_instance_assignment -name CURRENT_STRENGTH_NEW 8MA -to fpga_sda +set_instance_assignment -name CURRENT_STRENGTH_NEW 8MA -to shdn_v_hb_stby +set_instance_assignment -name CURRENT_STRENGTH_NEW 8MA -to hb_en[*] -set_global_assignment -name VERILOG_FILE ../src/simple_i2c_slave.v -set_global_assignment -name VHDL_FILE ../src/hmb_fpga_top.vhd -set_global_assignment -name VHDL_FILE ip/pll_25in_100out.vhd -set_global_assignment -name VHDL_FILE ip/io_buf_i2c.vhd set_global_assignment -name EDA_GENERATE_FUNCTIONAL_NETLIST ON -section_id eda_simulation set_global_assignment -name VHDL_INPUT_VERSION VHDL_2008 set_global_assignment -name VHDL_SHOW_LMF_MAPPING_MESSAGES OFF set_global_assignment -name CYCLONEII_RESERVE_NCEO_AFTER_CONFIGURATION "USE AS REGULAR IO" +set_global_assignment -name VHDL_FILE ../src/hmb_fpga_pkg_auto.vhd +set_global_assignment -name VHDL_FILE ../src/hmb_fpga_csr_regs_auto.vhd +set_global_assignment -name VHDL_FILE ../src/hmb_fpga_csr_decode_auto.vhd +set_global_assignment -name VERILOG_FILE ../src/simple_i2c_slave.v +set_global_assignment -name VHDL_FILE ../src/hmb_fpga_top.vhd +set_global_assignment -name VHDL_FILE ip/pll_25in_100out.vhd +set_global_assignment -name VHDL_FILE ip/io_buf_i2c.vhd set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top \ No newline at end of file diff --git a/firmware/hmb_fpga_top/build/hmb_fpga_top.sdc b/firmware/hmb_fpga_top/build/hmb_fpga_top.sdc index 8e717ca..97a83df 100644 --- a/firmware/hmb_fpga_top/build/hmb_fpga_top.sdc +++ b/firmware/hmb_fpga_top/build/hmb_fpga_top.sdc @@ -69,8 +69,8 @@ set_input_delay -min 0.0 -clock virtual_ext_clk_1MHz [get_ports {hb_trip* hb # Set Output Delay #************************************************************** -set_output_delay -max 100.0 -clock virtual_ext_clk_1MHz [get_ports {shdn_v_hb_stby hb_en* shutdown led* wd_to fpga_sda fpga_scl}] -set_output_delay -min 0.0 -clock virtual_ext_clk_1MHz [get_ports {shdn_v_hb_stby hb_en* shutdown led* wd_to fpga_sda fpga_scl}] +set_output_delay -max 100.0 -clock virtual_ext_clk_1MHz [get_ports {shdn_v_hb_stby hb_en[*] shutdown led* wd_to fpga_sda fpga_scl}] +set_output_delay -min 0.0 -clock virtual_ext_clk_1MHz [get_ports {shdn_v_hb_stby hb_en[*] shutdown led* wd_to fpga_sda fpga_scl}] #************************************************************** # Set Clock Groups diff --git a/firmware/hmb_fpga_top/build/output_files/hmb_fpga_top.rbf b/firmware/hmb_fpga_top/build/output_files/hmb_fpga_top.rbf index 60bead0..47feb2f 100644 Binary files a/firmware/hmb_fpga_top/build/output_files/hmb_fpga_top.rbf and b/firmware/hmb_fpga_top/build/output_files/hmb_fpga_top.rbf differ diff --git a/firmware/hmb_fpga_top/build/output_files/hmb_fpga_top.sof b/firmware/hmb_fpga_top/build/output_files/hmb_fpga_top.sof index 48edce0..0c08fad 100644 Binary files a/firmware/hmb_fpga_top/build/output_files/hmb_fpga_top.sof and b/firmware/hmb_fpga_top/build/output_files/hmb_fpga_top.sof differ diff --git a/firmware/hmb_fpga_top/doc/hmb_fpga.json b/firmware/hmb_fpga_top/doc/hmb_fpga.json index c216998..f03c1be 100644 --- a/firmware/hmb_fpga_top/doc/hmb_fpga.json +++ b/firmware/hmb_fpga_top/doc/hmb_fpga.json @@ -1,8 +1,16 @@ [{ "ip_name" : "hmb_fpga", "bus" : "csr", - "addr_width" : "16", "description" : "This block the top level HMB FPGA", + "addr_hi_bit" : "9", + "addr_lo_bit" : "5", + "sub_blocks" : { + "local" : { + "instance" : "", + "process" : "hdl, cpp, txt", + "offset" : "0x000" + } + }, "registers" : { "scratch0" : { "address" : "0", @@ -37,8 +45,57 @@ } } }, + "shutdown_master" : { + "address" : "3", + "width" : "1", + "type" : "r", + "reset" : "0", + "description" : "Master shutdown output status" + }, + "shutdn_en0" : { + "address" : "4", + "width" : "8", + "type" : "w", + "reset" : "0", + "description" : "Shutdown new trip enables for channels 0 to 7" + }, + "shutdn_en1" : { + "address" : "5", + "width" : "4", + "type" : "w", + "reset" : "0", + "description" : "Shutdown new trip enables for channels 8 to 11" + }, + "shutdn_dly_lo" : { + "address" : "6", + "width" : "8", + "type" : "w", + "reset" : "0", + "description" : "Shutdown enable delay LSB in units of clock ticks (nominally 10ns)" + }, + "shutdn_dly_mid" : { + "address" : "7", + "width" : "8", + "type" : "w", + "reset" : "0", + "description" : "Shutdown enable delay mid byte in units of clock ticks (nominally 10ns)" + }, + "shutdn_dly_hi" : { + "address" : "8", + "width" : "8", + "type" : "w", + "reset" : "0", + "description" : "Shutdown enable delay MSB in units of clock ticks (nominally 10ns)" + }, + "shutdn_go" : { + "address" : "9", + "width" : "1", + "type" : "w0", + "reset" : "0", + "description" : "Shutdown trip go control" + }, "wd_ctrl" : { - "address" : "16", + "address" : "10", "width" : "6", "description" : "Watchdog Control", "fields": { @@ -64,11 +121,53 @@ } }, "wd_status" : { - "address" : "17", + "address" : "11", "width" : "1", "type" : "r", "reset" : "0", "description" : "Watchdog fire alarm status" }, + "shutdn_clr0" : { + "address" : "12", + "width" : "8", + "type" : "w0", + "reset" : "0", + "description" : "Shutdown enable clear control for channels 0 to 7. Writing a 1 clears the relevant shutdown enable." + }, + "shutdn_clr1" : { + "address" : "13", + "width" : "4", + "type" : "w0", + "reset" : "0", + "description" : "Shutdown enable clear control for channels 8 to 11. Writing a 1 clears the relevant shutdown enable." + }, + "trip_clr0" : { + "address" : "14", + "width" : "8", + "type" : "w0", + "reset" : "0", + "description" : "Shutdown trip clear control for channels 0 to 7. Writing a 1 clears the relevant shutdown status." + }, + "trip_clr1" : { + "address" : "15", + "width" : "4", + "type" : "w0", + "reset" : "0", + "description" : "Shutdown trip clear control for channels 8 to 11. Writing a 1 clears the relevant shutdown status." + }, + "shutdn_status0" : { + "address" : "16", + "width" : "8", + "type" : "r", + "reset" : "0", + "description" : "Shutdown statuses clear control for channels 0 to 7" + }, + "shutdn_status1" : { + "address" : "17", + "width" : "4", + "type" : "r", + "reset" : "0", + "description" : "Shutdown statuses clear control for channels 8 to 11" + } } }] \ No newline at end of file diff --git a/firmware/hmb_fpga_top/src/hmb_fpga_top.vhd b/firmware/hmb_fpga_top/src/hmb_fpga_top.vhd index e4b0a44..42ff208 100644 --- a/firmware/hmb_fpga_top/src/hmb_fpga_top.vhd +++ b/firmware/hmb_fpga_top/src/hmb_fpga_top.vhd @@ -112,11 +112,15 @@ architecture struct of hmb_fpga_top is signal scl_out : std_logic; signal sda_in : std_logic; signal sda_out : std_logic; - signal address : std_logic_vector(15 downto 0); - signal wr_data : std_logic_vector(7 downto 0); - signal rd_data : std_logic_vector(7 downto 0); - signal wr_en : std_logic := '0'; - signal rd_en : std_logic := '0'; + + signal avs_csr_address : std_logic_vector(15 downto 0); + signal avs_csr_writedata : std_logic_vector(31 downto 0) := (others => '0'); + signal avs_csr_readdata : std_logic_vector(31 downto 0) := (others => '0'); + signal avs_csr_write : std_logic := '0'; + signal avs_csr_read : std_logic := '0'; + signal local_readdata : std_logic_vector(31 downto 0); + signal local_read : std_logic; + signal local_write : std_logic; signal rd_dv : std_logic := '0'; -- Shutdown signals @@ -143,6 +147,7 @@ architecture struct of hmb_fpga_top is signal en_wd : std_logic := '0'; signal wd_period : std_logic_vector(3 downto 0) := 4x"A"; -- 1 second (10 * 100ms) signal cmp_count : std_logic_vector(3 downto 0); + signal rst_n : std_logic := '0'; begin @@ -218,28 +223,27 @@ begin process (clk100) begin if rising_edge(clk100) then - -- Read data is valid the cycle after rd_en is asserted - rd_dv <= rd_en; + -- Read data is valid the cycle after avs_csr_read is asserted + rd_dv <= avs_csr_read; end if; end process; simple_i2c_slave_inst : simple_i2c_slave port map ( - clk => clk100, - scl_in => scl_in, - scl_out => scl_out, - sda_in => sda_in, - sda_out => sda_out, - i2c_busy_out => open, - add_out => address, - wr_data_out => wr_data, - wr_en_out => wr_en, - rd_en_out => rd_en, - rd_data_in => rd_data, - rd_dv_in => rd_dv + clk => clk100, + scl_in => scl_in, + scl_out => scl_out, + sda_in => sda_in, + sda_out => sda_out, + i2c_busy_out => open, + add_out => avs_csr_address, + wr_data_out => avs_csr_writedata(7 downto 0), + wr_en_out => avs_csr_write, + rd_en_out => avs_csr_read, + rd_data_in => avs_csr_readdata(7 downto 0), + rd_dv_in => rd_dv ); --- Instantiate I2C I/O cells i2c_scl_io_inst : entity work.io_buf_i2c port map ( datain(0) => scl_out, @@ -281,6 +285,10 @@ begin wd_alarm <= '1'; end if; + if rst_n = '0' and unsigned(us_count) > 100 then + rst_n <= '1'; + end if; + -- If watchdog enabled and no shut down, count the time if en_wd = '1' and shutdown_out = '0' then @@ -319,65 +327,68 @@ begin -- Create registers (non-monitor) and address decoding ------------------------------------------------------------------------------ - PROC_REGS : process (clk100) - begin - if rising_edge(clk100) then + hmb_fpga_csr_decode_inst : entity work.hmb_fpga_csr_decode + generic map ( + ADDR_DECODE_HI_BIT => 9, + ADDR_DECODE_LO_BIT => 5 + ) + port map ( - -- Default register values - clr_wd <= '0'; - rd_data <= 8x"0"; - - -- Write registers - if wr_en = '1' then - case address is - when I2C_ADDR_SCRATCH0 => scratch0 <= wr_data(7 downto 0); - when I2C_ADDR_SCRATCH1 => scratch1 <= wr_data(7 downto 0); - when I2C_ADDR_DBG_LED => cpu_led <= wr_data(5 downto 0); - when I2C_ADDR_WD_CTRL => clr_wd <= wr_data(0); - en_wd <= wr_data(1); - wd_period <= wr_data(5 downto 2); - when I2C_SHUTDN_CTRL => shutdn_go <= wr_data(0); - when I2C_SHUTDN1_EN_CLR => shutdn_clr( 7 downto 0) <= wr_data(7 downto 0); - when I2C_SHUTDN2_EN_CLR => shutdn_clr(11 downto 8) <= wr_data(3 downto 0); - when I2C_SHUTDN1_TR_CLR => trip_clr( 7 downto 0) <= wr_data(7 downto 0); - when I2C_SHUTDN2_TR_CLR => trip_clr(11 downto 8) <= wr_data(3 downto 0); - when I2C_SHUTDN1_EN => shutdn_trip_en_new( 7 downto 0) <= wr_data(7 downto 0); - when I2C_SHUTDN2_EN => shutdn_trip_en_new(11 downto 8) <= wr_data(3 downto 0); - when I2C_SHUTDNLO_DLY => shutdn_dly( 7 downto 0) <= wr_data(7 downto 0); - when I2C_SHUTDNMID_DLY => shutdn_dly(15 downto 8) <= wr_data(7 downto 0); - when I2C_SHUTDNHI_DLY => shutdn_dly(23 downto 16) <= wr_data(7 downto 0); - - when others => null; - end case; - end if; + local_write => local_write, + local_read => local_read, + local_readdata => local_readdata, - -- Read registers - case? address is - when I2C_ADDR_SCRATCH0 => rd_data(7 downto 0) <= scratch0; - when I2C_ADDR_SCRATCH1 => rd_data(7 downto 0) <= scratch1; - when I2C_ADDR_DBG_LED => rd_data(5 downto 0) <= cpu_led; - when I2C_ADDR_WD_CTRL => rd_data(5 downto 0) <= wd_period & en_wd & clr_wd; - when I2C_ADDR_WD_STATUS => rd_data(0) <= wd_alarm; - when I2C_SHUTDN_CTRL => rd_data(0) <= shutdn_go; - when I2C_SHUTDN_STATUS => rd_data(0) <= shutdown_out; - when I2C_SHUTDN1_TR_ST => rd_data(7 downto 0) <= shutdown_int( 7 downto 0); - when I2C_SHUTDN2_TR_ST => rd_data(3 downto 0) <= shutdown_int(11 downto 8); - when I2C_SHUTDN1_EN_CLR => rd_data(7 downto 0) <= shutdn_clr( 7 downto 0); - when I2C_SHUTDN2_EN_CLR => rd_data(3 downto 0) <= shutdn_clr(11 downto 8); - when I2C_SHUTDN1_TR_CLR => rd_data(7 downto 0) <= trip_clr( 7 downto 0); - when I2C_SHUTDN2_TR_CLR => rd_data(3 downto 0) <= trip_clr(11 downto 8); - when I2C_SHUTDN1_EN => rd_data(7 downto 0) <= shutdn_trip_en_new( 7 downto 0); - when I2C_SHUTDN2_EN => rd_data(3 downto 0) <= shutdn_trip_en_new(11 downto 8); - when I2C_SHUTDNLO_DLY => rd_data(7 downto 0) <= shutdn_dly( 7 downto 0); - when I2C_SHUTDNMID_DLY => rd_data(7 downto 0) <= shutdn_dly(15 downto 8); - when I2C_SHUTDNHI_DLY => rd_data(7 downto 0) <= shutdn_dly(23 downto 16); + avs_address => avs_csr_address(9 downto 5), + avs_write => avs_csr_write, + avs_read => avs_csr_read, + avs_readdata => avs_csr_readdata - when others => rd_data(0) <= '0'; - end case?; - end if; + ); - end process; + hmb_fpga_csr_regs_inst : entity work.hmb_fpga_csr_regs + generic map( + ADDR_DECODE_WIDTH => 5 + ) + port map( + -- Clock and reset + clk => clk100, + rst_n => rst_n, + scratch0 => scratch0, + scratch1 => open, + cpu_dbg_led_en => cpu_led(0), + cpu_dbg_led_val => cpu_led(5 downto 1), + shutdn_en0 => shutdn_trip_en_new(7 downto 0), + shutdn_en1 => shutdn_trip_en_new(11 downto 8), + + shutdn_go => shutdn_go, + shutdn_dly_lo => shutdn_dly(7 downto 0), + shutdn_dly_mid => shutdn_dly(15 downto 8), + shutdn_dly_hi => shutdn_dly(23 downto 16), + + shutdn_clr0 => shutdn_clr( 7 downto 0), + shutdn_clr1 => shutdn_clr(11 downto 8), + + trip_clr0 => trip_clr( 7 downto 0), + trip_clr1 => trip_clr(11 downto 8), + + shutdn_status0 => shutdown_int( 7 downto 0), + shutdn_status1 => shutdown_int(11 downto 8), + + wd_ctrl_en => en_wd, + wd_ctrl_period => wd_period, + wd_ctrl_clr => clr_wd, + shutdown_master => shutdown_out, + wd_status => wd_alarm, + + avs_address => avs_csr_address(4 downto 0), + avs_write => local_write, + avs_writedata => avs_csr_writedata, + avs_read => local_read, + avs_readdata => local_readdata + + ); + ------------------------------------------------------------------------------ -- Shutdown delay ------------------------------------------------------------------------------ diff --git a/firmware/top/src/test/autobuild.bat b/firmware/top/src/test/autobuild.bat index 9c8c525..0011723 100644 --- a/firmware/top/src/test/autobuild.bat +++ b/firmware/top/src/test/autobuild.bat @@ -1,4 +1,4 @@ -@REM Directories + @REM Directories @set FWTOOLSDIR=..\..\..\..\..\fw_development_tools\logic_memory_mapper @set LIBDOCDIR=..\..\..\..\..\fw_development_tools\verification\lib\hdl\doc @set REPODIR=..\..\..\.. @@ -15,8 +15,12 @@ @py -3 %FWTOOLSDIR%\gen_elhal.py -j %LIBDOCDIR%\fpga.json -b csr -o .\src\hal @py -3 %FWTOOLSDIR%\gen_elhal.py -r ..\..\..\.. -b csr -o .\src\hal +@py -3 %FWTOOLSDIR%\gen_htm.py -j ..\..\..\hmb_fpga_top\doc\hmb_fpga.json -b csr +@py -3 %FWTOOLSDIR%\gen_elhal.py -j ..\..\..\hmb_fpga_top\doc\hmb_fpga.json -b csr -o .\src\hal +@py -3 %FWTOOLSDIR%\gen_hdl.py -j ..\..\..\hmb_fpga_top\doc\hmb_fpga.json -b csr -s _auto + @REM Add project specific build here. Normally just point to top of the repository for hierarchical scan @py -3 %FWTOOLSDIR%\gen_hdl.py -r %REPODIR% -b csr seq avalon_slave_0 -s _auto @py -3 %FWTOOLSDIR%\gen_htm.py -r %REPODIR% -b csr seq -B -@py -3 %FWTOOLSDIR%\gen_json.py -r %REPODIR% -b csr seq -s _auto -o %REPODIR%\firmware\top\doc \ No newline at end of file +@py -3 %FWTOOLSDIR%\gen_json.py -r %REPODIR% -b csr seq -s _auto -o %REPODIR%\firmware\top\doc diff --git a/firmware/top/src/test/makefile b/firmware/top/src/test/makefile index 17af1ab..0ee0816 100644 --- a/firmware/top/src/test/makefile +++ b/firmware/top/src/test/makefile @@ -58,6 +58,7 @@ JSONFILES = doc/*.json \ ../../../print_streamer/doc/*.json \ ../../../print_unit/doc/*.json \ ../../../top/doc/core.json \ + ../../../hmb_fpga_top/doc/*.json \ ${LIBDOCDIR}/*.json \ ${ELGIPDIRLOCAL}/shutdown_monitor/0/doc/*.json \ ${ELGIPDIRLOCAL}/enc_pd_emul/1/doc/*.json \