diff --git a/blink/syn/Makefile b/blink/syn/Makefile index 80c5b68..c0c866e 100644 --- a/blink/syn/Makefile +++ b/blink/syn/Makefile @@ -1,5 +1,5 @@ DESIGN_NAME := blink -WORK_FILES := ../rtl/blink.vhd +WORK_FILES := ../../lib/user_components.vhd ../rtl/blink.vhd GM_FILES := ../../lib/rtl_components.vhd GHDL_FLAGS := --std=08 --workdir=build -Pbuild YOSYSPIPE := -nomx8 -luttree -retime @@ -20,6 +20,7 @@ build/gatemate-obj08.cf: ${GM_FILES} ghdl -a ${GHDL_FLAGS} --work=gatemate ${GM_FILES} ${DESIGN_NAME}.v: build/work-obj08.cf + ghdl --synth ${GHDL_FLAGS} ${DESIGN_NAME} > ${DESIGN_NAME}.vhd yosys -m ghdl -p 'ghdl ${GHDL_FLAGS} --no-formal ${DESIGN_NAME}; synth_gatemate -top $(DESIGN_NAME) ${YOSYSPIPE} -vlog $@' \ 2>&1 | tee build/yosys-report.txt @@ -34,4 +35,4 @@ prog: ${DESIGN_NAME}.bit clean : echo "# Cleaning files" - rm -rf build ${DESIGN_NAME}.v ${DESIGN_NAME}.bit + rm -rf build ${DESIGN_NAME}.v ${DESIGN_NAME}.vhd ${DESIGN_NAME}.bit diff --git a/lib/user_components.vhd b/lib/user_components.vhd new file mode 100644 index 0000000..0f31cda --- /dev/null +++ b/lib/user_components.vhd @@ -0,0 +1,40 @@ +library ieee ; +use ieee.std_logic_1164.all; + + +-- Async reset synchronizer circuit inspired from +-- Chris Cummings SNUG 2002 paper +-- Synchronous Resets? Asynchronous Resets? +-- I am so confused! +-- How will I ever know which to use? + +entity reset_sync is +generic ( + POLARITY : std_logic := '0' +); +port ( + clk_i : in std_logic; + rst_i : in std_logic; + rst_o : out std_logic +); +end entity; + + +architecture sim of reset_sync is + + signal s_rst_d : std_logic_vector(1 downto 0); + +begin + + process (clk_i, rst_i) is + begin + if (rst_i = POLARITY) then + s_rst_d <= (others => POLARITY); + elsif (rising_edge(clk_i)) then + s_rst_d <= s_rst_d(0) & not POLARITY; + end if; + end process; + + rst_o <= s_rst_d(1); + +end architecture;