Simulation and Design: January 2005 Archives

Adding instructions to the Simplscalar decode tree.

|

The simplscalar decode tree for instructions can be at first quiet daunting.
Tracing the decode pattern is a pen and paper exercise.

e.g the range of instructions that start with 0x06 are defined as

DEFLINK(MEMREGPOST_LINK, 0x06, "memregpost_link", 20, 0x0f)

CONNECT(MEMREGPOST_LINK)

This means shift the inst that start with 0x06 e.g 0x06000000 and examine bits 20 - 23

After the connect code we have an entry for 0x00 this means that if bits 20 -23 are 00 this will match and generate an opcode for this instruction
e.g 0x06000000

#define STR_R_IMPL \
etc etc

DEFINST(STR_R, 0x00,
etc


The challenge facing anyone is to add extra opcodes that are meaningful.
If one examines the 0x06 range of opcodes it is evident that instructions such as
0x06000100, 0x06000200 are unused.

So how do we use them in Simplescalar?
Well what we need to do is modify arm.def to examine bits 8 - 11 first, if these bits are 0 then they are the original instructions defined under memregpost. If not they are our new instructions.

A statement such as the one below takes care of examining bits 8 -11 of an inst that starts with 0x06

DEFLINK(MEMREGPOST_LINK, 0x06, "memregpost_link", 8, 0x0f)

CONNECT(MEMREGPOST_LINK)

We now need to ensure that 0x06 instructions whose bits are 0 from pos 8 to 11 are directed to a different part of the decode tree. The deflink code below will be executed if the bits are 0 and will examine bits 20 - 23 of the 0x06 inst in the connect section.

In the example below inst 0x06000000 will be associated with a deflink to a new tree where the isnt str%c will be associated with 0x06000000. While inst 0x06000100 will be associated with the inst demo because bits 8 to 11 equate to 1


DEFLINK(MEMREGPOSTNEW_LINK, 0x00, "memregpostnew_link", 20, 0x0f)

#define demo_IMPL \
etc

DEFINST(demo, 0x01,
"demo%c", "%d,%n,%m",
etc

CONNECT(MEMREGPOSTNEW_LINK)
#define STR_R_IMPL \
etc

DEFINST(STR_R, 0x00,
"str%c", "%d,[%n],-%m!",
etc

We also need to to add these new opcodes to your gas see http://www-unix.ecs.umass.edu/~yhan/ for more details on how to hack GAS.

Hacking Simplescalar - Adding Instructions

|

I've been very busy for the past few weeks working on Simplescalar. As a result this site has suffered.

My bookmarks for Simplescalar have now grown into some essential how-to and readmes for the adding instructions to simplescalar.

The first place to look for help on this is the simplescalar website as they have a readme on the machine.def file format.

The information is very detailed but adding the instruction part was slightly confusing. I came across some other sites however that provided more info.

Simplescalar Archives - http://lists.cs.wisc.edu/archive/simplescalar/ I would like to thank Guri Sohi at the University of Wisconsin-Madison for restoring the email archives.

YongKhui Han's page - http://www-unix.ecs.umass.edu/~yhan/ describes how modify the compiler and simplescalar to recognise new instructions

Laura Pozzi a a PostDoc researcher in the LAP, Processor Architecture Laboratory, at EPFL, Lausanne describes how to add a new resource to simplescalar http://lapwww.epfl.ch/~lpozzi/words_on/toolchain.html

Inline assembly is sometimes necessary with simplescalar the GCC inline assembly how to is a useful resource. http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html

About this Archive

This page is a archive of entries in the Simulation and Design category from January 2005.

Simulation and Design: December 2004 is the previous archive.

Simulation and Design: February 2005 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Influenced by:

Irish Eyes
Jabit
Mike Maunsell
Buzzblog
Tom Raftery I.T. views
Damien Mulley
James Corbett (Eirepeneur)
Powered by Movable Type 4.12