OpenCores
URL https://opencores.org/ocsvn/wb_z80/wb_z80/trunk

Subversion Repositories wb_z80

[/] [wb_z80/] [trunk/] [runit.pl] - Blame information for rev 39

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 bporcella
#!/perl/bin/perl
2
# runit.pl is a little perl script that complies a verilog testbed (for a z80
3
# processor and also assembles a test program - converts output to a form 
4
# compatable with the verilog $readmemh function.
5
#
6
# this is all pretty simple. But serves to document in one place the build 
7
# process.
8
if ($signo = system("asm\\as80 -l -x2 -h0 -s2 -m asm\\bjs80tst.asm"))
9
{
10
        die "assembler error = $signo";
11
}
12
 
13
# bjp   now gotta convert the hex file 
14
#
15
# An Intel HEX file is composed of any number of HEX records. Each record is made up of five fields that are arranged in the following format:  
16
# :llaaaatt[dd...]cc
17
# Each group of letters corresponds to a different field, and each letter represents a single hexadecimal digit. Each field is composed of at least two hexadecimal digits-which make up a byte-as described below: 
18
# : is the colon that starts every Intel HEX record. 
19
# ll is the record-length field that represents the number of data bytes (dd) in the record. 
20
# aaaa is the address field that represents the starting address for subsequent data in the record. 
21
# tt is the field that represents the HEX record type, which may be one of the following:
22
# 00 - data record
23
# 01 - end-of-file record
24
# 02 - extended segment address record
25
# 04 - extended linear address record 
26
# dd is a data field that represents one byte of data. A record may have multiple data bytes. The number of data bytes in the record must match the number specified by the ll field. 
27
# cc is the checksum field that represents the checksum of the record. The checksum is calculated by summing the values of all hexadecimal digit pairs in the record modulo 256 and taking the two's complement. 
28
# 
29
open(ASMDAT, "asm\\bjs80tst.hex"), or die "can't open bjs80tst.hex: $!\n";
30
open(VERDAT, ">readmem.txt"), or die "can't open readmem.txt: $!\n";
31
while ($line = <ASMDAT>)
32
{
33
        #print $line;
34
        ($ll, $aaaa, $tt, $dat) = unpack("x1 A2 A4 A2 A*", $line);
35
        if ($tt == "00")
36
        {
37
                print VERDAT "\@$aaaa\n";
38
                for( $i = 0; $i<hex($ll); $i+=1)
39
                {
40
                        $byte = substr($dat, $i*2, 2);
41
                        print VERDAT  $byte, " ";
42
                }
43
                print VERDAT "\n";
44
        }
45
}
46
#
47
#
48
# now compile the verilog, start the verilog and get the waveform viewer going.
49
# this is all logically seperate from the assembly stuff....   so if time matters
50
# one could break this file up - or comment out the part not needed. 
51
#
52
if ($signo = system ("iverilog -c rtl\\files.txt"))
53
{
54
        die "iverilog error = $signo";
55
}
56
 
57
if ($signo = system ("vvp a.out"))
58
{
59
        die "vvp error = $signo";
60
}
61 32 bporcella
if ($signo = system ("gtkwave  dump.vcd"))
62 21 bporcella
{
63
        die "assembler error = $signo";
64
};

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.