Browse Source

Adapt sim to updated RTL

main
T. Meissner 2 years ago
parent
commit
d57f683506
2 changed files with 18 additions and 11 deletions
  1. +7
    -4
      blink/sim/Makefile
  2. +11
    -7
      blink/sim/tb_blink.vhd

+ 7
- 4
blink/sim/Makefile View File

@ -1,4 +1,5 @@
DESIGN_NAME := blink DESIGN_NAME := blink
LIB_SRC := ../../lib/components.vhd ../../lib/sim_components.vhd
RTL_SRC := ../rtl/${DESIGN_NAME}.vhd RTL_SRC := ../rtl/${DESIGN_NAME}.vhd
SIM_SRC := tb_${DESIGN_NAME}.vhd SIM_SRC := tb_${DESIGN_NAME}.vhd
VHD_STD := 08 VHD_STD := 08
@ -8,11 +9,13 @@ VHD_STD := 08
all: sim all: sim
compile: tb_${DESIGN_NAME} compile: tb_${DESIGN_NAME}
tb_${DESIGN_NAME}: ${RTL_SRC} ${SIM_SRC} | work
tb_${DESIGN_NAME}: ${LIB_SRC} ${RTL_SRC} ${SIM_SRC} | work
@echo "Analyze gatemate library ..."
ghdl -a --std=${VHD_STD} -fpsl --workdir=work --work=gatemate ${LIB_SRC}
@echo "Analyze testbench & design ..." @echo "Analyze testbench & design ..."
ghdl -a --std=${VHD_STD} -fpsl --workdir=work ${RTL_SRC} ${SIM_SRC}
ghdl -a --std=${VHD_STD} -fpsl --workdir=work -Pwork ${RTL_SRC} ${SIM_SRC}
@echo "Elaborate testbench & design ..." @echo "Elaborate testbench & design ..."
ghdl -e --std=${VHD_STD} -fpsl --workdir=work $@
ghdl -e --std=${VHD_STD} -fpsl --workdir=work -Pwork $@
sim: tb_${DESIGN_NAME} sim: tb_${DESIGN_NAME}
@echo "Run testbench ..." @echo "Run testbench ..."
@ -23,4 +26,4 @@ work:
clean: clean:
@echo "Cleaning simulation files ..." @echo "Cleaning simulation files ..."
rm -rf tb_${DESIGN_NAME} *.o *.json work/
rm -rf tb_${DESIGN_NAME} *.o work/

+ 11
- 7
blink/sim/tb_blink.vhd View File

@ -13,6 +13,7 @@ architecture sim of tb_blink is
signal s_clk : std_logic := '1'; signal s_clk : std_logic := '1';
signal s_rst_n : std_logic := '0'; signal s_rst_n : std_logic := '0';
signal s_led_n : std_logic_vector(7 downto 0); signal s_led_n : std_logic_vector(7 downto 0);
begin begin
@ -24,21 +25,24 @@ begin
led_n_o => s_led_n led_n_o => s_led_n
); );
s_rst_n <= '1' after 1.2 us;
s_clk <= not s_clk after 500 ns;
s_rst_n <= '1' after 120 ns;
s_clk <= not s_clk after 50 ns;
-- Let's test the first 8 values of LED output
process is
-- Let's test one complete rotate of LED output
TestP : process is
variable v_led_n : std_logic_vector(s_led_n'range) := x"FE";
begin begin
wait until s_rst_n; wait until s_rst_n;
wait until rising_edge(s_clk); wait until rising_edge(s_clk);
for i in 0 to 7 loop for i in 0 to 7 loop
report "LED: " & to_hstring(not s_led_n);
assert to_integer(unsigned(not s_led_n)) = i
report "LED error, got 0x" & to_hstring(s_led_n) & ", expected 0x" & to_hstring(to_unsigned(255-i, 8))
report "LED: " & to_hstring(s_led_n);
assert s_led_n = v_led_n
report "LED error, got 0x" & to_hstring(s_led_n) & ", expected 0x" & to_hstring(v_led_n)
severity failure; severity failure;
wait until s_led_n'event; wait until s_led_n'event;
v_led_n := v_led_n(6 downto 0) & v_led_n(7);
end loop; end loop;
report "Simulation finished :-)";
stop(0); stop(0);
end process; end process;


Loading…
Cancel
Save