Monday 28 March 2011

VHDL Test Bench: CPU or Logic Script Commands

There may come a time when you want to perform some logic on values read from the DUT. This could be facilitated by some kind of special command or process. But, the logic manipulations should be implemented using simple standard logic commands. This is so that other tests can take advantage of a generic command structure.

I speak about CPU like assembly instructions being implemented as test bench script commands. This includes a register set (an array of std_logic_vectors), a condition code register, basic read/write commands that target the register set, logic commands and branch commands. These commands can be used in both an internal test bench and external test bench. The code for this addition to the command set is presented in Section 2 of the code snips download .zip file. A link to this file can be found in the “Useful Links” section of the blog page, low on the right.  Or Code Snips here.

The commands found in Code Snips for CPU emulation are:  MOV, MOVI, AND, ANDI, OR, XOR, NOT, BZ, BE, BB.  In text:  move, move immediate, and, and immediate, or, exclusive or, not, branch if zero, branch if equal, branch if bit set/clear.  These form the basics, and the user can easily create more as needed with the examples provided in Code Snips.

I have used these CPUish commands in the past for some external test benches. I have always used the CPU commands when emulating a CPU internal to a design. This was done because it is simpler to create/use the scripting system inside a DUT for testing, than it is to have the over head of the real RTL CPU in place. If you are creating a processor system, and you want to prove the system, but not really the CPU and code, you can put your own in. You can now test the system, within limits, and be sure that at least basics are functioning before trying to run compiled software on the real RTL CPU. Of course you do, in the end, want to run compiled code on the RTL CPU, just maybe not at the very start of the design process.

The code in the tb_code_snips.zip download file is optional code, specially the CPU commands. I would only include the code that is needed. If your testing does not need CPUish commands, do not add them.

I have been working on more topics that include code. I know I have been Blah, Blah, Blah since I started this blog .... time to pump out some code. Code will always be published through the Code Snips link and content will be updated each time I post about some code. Also, keep an eye for a new Application called Winttb_gen, I am playing with some C# and figured that it would be a nice little application to start on.

Sckoarn

No comments:

Post a Comment