Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16330 Discussions

How to write testbench for 18x18 multiplier


I need to write testbench for 18x18 multiplier, which reads input from a text file (at least 10 numbers). Every input has to have at least 1 one and 1 zero in 4 most significant bits, and half of the tested numbers are negative. If the results are correct, must be tested in testbench file.


Code is simple:

LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.numeric_std.ALL;   ENTITY signed_mult18 is PORT( a : IN SIGNED (17 DOWNTO 0); b : IN SIGNED (17 DOWNTO 0); result : OUT SIGNED (35 DOWNTO 0)); END ENTITY;   ARCHITECTURE rtl OF signed_mult18 IS   BEGIN   result <= a * b; END rtl;

Thank you very much.

0 Kudos
2 Replies


Here in community, no one will provide complete code so user should come with their own code/logic & people in community may help to make it correct/better appropriate.

In this case, I would like to suggest you need to use the STD.textio package that defines routines for reading and writing to

a text file , refer the below old thread ,


Let me know if this has helped resolve the issue you are facing or if you need any further assistance.

Best Regards

Vikas Jathar 

(This message was posted on behalf of Intel Corporation)

0 Kudos
Valued Contributor II

You can create a basic testbench usign the Quartus university VWF editor and then have it generate VHDL/Verilog bench. Then modify the bench accordingly to read / write from files using textio library.

0 Kudos