Browse Source

Add user_components.vhd containing generic RTL modules

main
T. Meissner 1 year ago
parent
commit
3b6a315a0d
2 changed files with 43 additions and 2 deletions
  1. +3
    -2
      blink/syn/Makefile
  2. +40
    -0
      lib/user_components.vhd

+ 3
- 2
blink/syn/Makefile View File

@ -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

+ 40
- 0
lib/user_components.vhd View File

@ -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;

Loading…
Cancel
Save