From 2d708cbb5182047e7ed440cccbfb32c051ff4ace Mon Sep 17 00:00:00 2001 From: tmeissner Date: Mon, 30 Nov 2020 11:07:23 +0100 Subject: [PATCH] Minor update to TDES sim makefile and testbench --- tdes/sim/vhdl/Makefile | 25 +++++++++++++------------ tdes/sim/vhdl/tb_tdes.vhd | 10 ++++++++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/tdes/sim/vhdl/Makefile b/tdes/sim/vhdl/Makefile index 8ff4f2e..8426f1f 100644 --- a/tdes/sim/vhdl/Makefile +++ b/tdes/sim/vhdl/Makefile @@ -19,30 +19,31 @@ # ====================================================================== -DES_SRC_FILES := ../../../des/rtl/vhdl/des_pkg.vhd ../../../des/rtl/vhdl/des.vhd -TDES_SRC_FILES := ../../rtl/vhdl/tdes.vhd -SRC_FILES := $(DES_SRC_FILES) $(TDES_SRC_FILES) +DESIGN_NAME := tdes +SRC_FILES := ../../../des/rtl/vhdl/des_pkg.vhd \ + ../../../des/rtl/vhdl/des.vhd \ + ../../rtl/vhdl/$(DESIGN_NAME).vhd VHD_STD := 08 .PHONY: sim -sim : tb_tdes.ghw +sim : tb_$(DESIGN_NAME).ghw .PHONY: all all : wave -tb_des.o: $(SRC_FILES) tb_tdes.vhd - ghdl -a --std=$(VHD_STD) $(SRC_FILES) tb_tdes.vhd +tb_$(DESIGN_NAME).o: $(SRC_FILES) tb_$(DESIGN_NAME).vhd + ghdl -a --std=$(VHD_STD) $(SRC_FILES) $(basename $@).vhd -tb_tdes.ghw : tb_des.o - ghdl -e --std=$(VHD_STD) tb_tdes - ghdl -r tb_tdes --wave=tb_tdes.ghw --assert-level=error --stop-time=45us +tb_$(DESIGN_NAME).ghw : tb_$(DESIGN_NAME).o + ghdl -e --std=$(VHD_STD) $(basename $@) + ghdl -r $(basename $@) --wave=$@ --assert-level=error -wave : tb_tdes.ghw - gtkwave -s tb_tdes.tcl tb_tdes.ghw +wave : tb_$(DESIGN_NAME).ghw + gtkwave -s tb_$(DESIGN_NAME).tcl tb_$(DESIGN_NAME).ghw clean : echo "# Cleaning files" - rm -f *.ghw *.o tb_tdes work*.cf + rm -f *.ghw *.o tb_$(DESIGN_NAME) work*.cf diff --git a/tdes/sim/vhdl/tb_tdes.vhd b/tdes/sim/vhdl/tb_tdes.vhd index 6eeae92..8d492ac 100644 --- a/tdes/sim/vhdl/tb_tdes.vhd +++ b/tdes/sim/vhdl/tb_tdes.vhd @@ -23,12 +23,15 @@ library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; +use std.env.all; + entity tb_tdes is end entity tb_tdes; + architecture rtl of tb_tdes is @@ -124,21 +127,24 @@ begin testcheckerP : process is begin s_acceptout <= '1'; - report "# ENCRYPTION TESTS"; + report "# ENCRYPTION"; for index in c_table_test_plain'range loop wait until rising_edge(s_clk) and s_validout = '1'; s_tdes_answers(index) <= s_dataout; + report "TDES enc: 0x" & to_hstring(c_table_test_plain(index)) & " -> " & to_hstring(s_dataout); end loop; report "# DECRYPTION TESTS"; report "# tdes known answer test"; for index in c_table_test_plain'range loop wait until rising_edge(s_clk) and s_validout = '1'; + report "TDES dec: 0x" & to_hstring(s_tdes_answers(index)) & " -> " & to_hstring(s_dataout); assert (s_dataout = c_table_test_plain(index)) report "decryption error" severity error; end loop; report "# Successfully passed all tests"; - wait; + wait for 10 us; + stop(0); end process testcheckerP;