I often find myself writing blocks of VHDL code (aka VHDL “components”) to process and manipulate MPEG transport streams. Once the component code is written, the next step is to simulate it to be sure it is functioning as intended. The usual approach is to write a “testbench” which is a further block of VHDL code that forms a “wrapper” around the component under test and feeds it with a variety of known and pre-programmed input stimuli. A VHDL simulator then allows the inputs, outputs and internal nodes of the component under test to be monitored, analysed and verified.
The testbench needs to instantiate the component under test and generate all the input signals required to thoroughly exercise it. This includes clocks, reset signals and, in the case of a component designed to manipulate a transport stream, a representative source of transport stream data.
If the function of the component under test is relatively trivial, then it is often sufficient to represent the transport stream data in a simplistic way such as a continuum of bytes where every 188th byte has the value 0x47 (the transport stream “sync” byte) and the intervening bytes are either a constant value or perhaps a rolling count. Creation of a process within the testbench to generate such data is quite straightforward.
However, for components performing more sophisticated processing of transport streams, such a simplistic approach is unsuitable and there is no substitute for using an actual captured transport stream file as the source of transport stream data. However, the testbench VHDL code required to “open and play” an actual transport stream file is not obvious especially if you are new to VHDL. The attached example testbench (testbench.vhd) shows how this is done (see process “read_ts” in particular).
Points relating to the testbench.vhd code:
Fig 1: Input signals presented to component under test when N_INVALID_BYTES = 2
Fig 2: Input signals presented to component under test when N_INVALID_BYTES = 0
Ripcord Designs Ltd.
Ripcord Designs is a UK based design consultancy specializing in television broadcast equipment. Our expertise includes optical and wireless video transmission, video and audio compression and hand-held RF camera systems.
Comments will be approved before showing up.