Browse Source

Minor update to TDES sim makefile and testbench

T. Meissner 1 month ago
parent
commit
2d708cbb51
2 changed files with 21 additions and 14 deletions
  1. 13
    12
      tdes/sim/vhdl/Makefile
  2. 8
    2
      tdes/sim/vhdl/tb_tdes.vhd

+ 13
- 12
tdes/sim/vhdl/Makefile View File

@@ -19,30 +19,31 @@
19 19
 # ======================================================================
20 20
 
21 21
 
22
-DES_SRC_FILES  := ../../../des/rtl/vhdl/des_pkg.vhd ../../../des/rtl/vhdl/des.vhd
23
-TDES_SRC_FILES := ../../rtl/vhdl/tdes.vhd
24
-SRC_FILES      := $(DES_SRC_FILES) $(TDES_SRC_FILES)
22
+DESIGN_NAME := tdes
23
+SRC_FILES   := ../../../des/rtl/vhdl/des_pkg.vhd \
24
+               ../../../des/rtl/vhdl/des.vhd \
25
+               ../../rtl/vhdl/$(DESIGN_NAME).vhd
25 26
 VHD_STD        := 08
26 27
 
27 28
 
28 29
 .PHONY: sim
29
-sim : tb_tdes.ghw
30
+sim : tb_$(DESIGN_NAME).ghw
30 31
 
31 32
 .PHONY: all
32 33
 all : wave
33 34
 
34 35
 
35
-tb_des.o: $(SRC_FILES) tb_tdes.vhd
36
-	ghdl -a --std=$(VHD_STD) $(SRC_FILES) tb_tdes.vhd
36
+tb_$(DESIGN_NAME).o: $(SRC_FILES) tb_$(DESIGN_NAME).vhd
37
+	ghdl -a --std=$(VHD_STD) $(SRC_FILES) $(basename $@).vhd
37 38
 
38
-tb_tdes.ghw : tb_des.o
39
-	ghdl -e --std=$(VHD_STD) tb_tdes
40
-	ghdl -r tb_tdes --wave=tb_tdes.ghw --assert-level=error --stop-time=45us
39
+tb_$(DESIGN_NAME).ghw : tb_$(DESIGN_NAME).o
40
+	ghdl -e --std=$(VHD_STD) $(basename $@)
41
+	ghdl -r $(basename $@) --wave=$@ --assert-level=error
41 42
 
42
-wave : tb_tdes.ghw
43
-	gtkwave -s tb_tdes.tcl tb_tdes.ghw
43
+wave : tb_$(DESIGN_NAME).ghw
44
+	gtkwave -s tb_$(DESIGN_NAME).tcl tb_$(DESIGN_NAME).ghw
44 45
 
45 46
 
46 47
 clean :
47 48
 	echo "# Cleaning files"
48
-	rm -f *.ghw *.o tb_tdes work*.cf
49
+	rm -f *.ghw *.o tb_$(DESIGN_NAME) work*.cf

+ 8
- 2
tdes/sim/vhdl/tb_tdes.vhd View File

@@ -23,12 +23,15 @@ library ieee;
23 23
 use ieee.std_logic_1164.all;
24 24
 use ieee.numeric_std.all;
25 25
 
26
+use std.env.all;
27
+
26 28
 
27 29
 
28 30
 entity tb_tdes is
29 31
 end entity tb_tdes;
30 32
 
31 33
 
34
+
32 35
 architecture rtl of tb_tdes is
33 36
 
34 37
 
@@ -124,21 +127,24 @@ begin
124 127
   testcheckerP : process is
125 128
   begin
126 129
     s_acceptout <= '1';
127
-    report "# ENCRYPTION TESTS";
130
+    report "# ENCRYPTION";
128 131
     for index in c_table_test_plain'range loop
129 132
       wait until rising_edge(s_clk) and s_validout = '1';
130 133
         s_tdes_answers(index) <= s_dataout;
134
+        report "TDES enc: 0x" & to_hstring(c_table_test_plain(index)) & " -> " & to_hstring(s_dataout);
131 135
     end loop;
132 136
     report "# DECRYPTION TESTS";
133 137
     report "# tdes known answer test";
134 138
     for index in c_table_test_plain'range loop
135 139
       wait until rising_edge(s_clk) and s_validout = '1';
140
+        report "TDES dec: 0x" & to_hstring(s_tdes_answers(index)) & " -> " & to_hstring(s_dataout);
136 141
         assert (s_dataout = c_table_test_plain(index))
137 142
           report "decryption error"
138 143
           severity error;
139 144
     end loop;
140 145
     report "# Successfully passed all tests";
141
-    wait;
146
+    wait for 10 us;
147
+    stop(0);
142 148
   end process testcheckerP;
143 149
 
144 150