summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2007-05-31 22:21:19 +0000
committerGabe Black <gblack@eecs.umich.edu>2007-05-31 22:21:19 +0000
commit287446396cceadec0f758ecde8dca268b9a60cd5 (patch)
treeea3c006fa01b33a32fcd01d0ee00b6a6558156c7 /src
parentfbcc35450db7f70889b9769b3f4e704413e52f1c (diff)
downloadgem5-287446396cceadec0f758ecde8dca268b9a60cd5.tar.xz
Do something with ROM based macroops
--HG-- extra : convert_revision : 3a14c683ab89217c083c58e8c374607dd04b66c4
Diffstat (limited to 'src')
-rw-r--r--src/arch/micro_asm.py21
-rwxr-xr-xsrc/arch/micro_asm_test.py6
2 files changed, 21 insertions, 6 deletions
diff --git a/src/arch/micro_asm.py b/src/arch/micro_asm.py
index e36daf862..d9d9d1b21 100644
--- a/src/arch/micro_asm.py
+++ b/src/arch/micro_asm.py
@@ -64,9 +64,14 @@ class Micro_Container(object):
string += " %s\n" % microop
return string
-class Macroop(Micro_Container):
+class Combinational_Macroop(Micro_Container):
pass
+class Rom_Macroop(object):
+ def __init__(self, name, target):
+ self.name = name
+ self.target = target
+
class Rom(Micro_Container):
def __init__(self, name):
super(Rom, self).__init__(name)
@@ -310,6 +315,9 @@ def p_block(t):
# Defines a section of microcode that should go in the current ROM
def p_rom_block(t):
'rom_block : DEF ROM block SEMI'
+ if not t.parser.rom:
+ print_error("Rom block found, but no Rom object specified.")
+ raise TypeError, "Rom block found, but no Rom object was specified."
for statement in t[3].statements:
handle_statement(t.parser, t.parser.rom, statement)
t[0] = t.parser.rom
@@ -317,7 +325,12 @@ def p_rom_block(t):
# Defines a macroop that jumps to an external label in the ROM
def p_macroop_def_0(t):
'macroop_def : DEF MACROOP ID LPAREN ID RPAREN SEMI'
- t[0] = t[4]
+ if not t.parser.rom_macroop_type:
+ print_error("ROM based macroop found, but no ROM macroop class was specified.")
+ raise TypeError, "ROM based macroop found, but no ROM macroop class was specified."
+ macroop = t.parser.rom_macroop_type(t[3], t[5])
+ t[0] = macroop
+
# Defines a macroop that is combinationally generated
def p_macroop_def_1(t):
@@ -438,13 +451,15 @@ def p_error(t):
class MicroAssembler(object):
- def __init__(self, macro_type, microops, rom):
+ def __init__(self, macro_type, microops,
+ rom = None, rom_macroop_type = None):
self.lexer = lex.lex()
self.parser = yacc.yacc()
self.parser.macro_type = macro_type
self.parser.macroops = {}
self.parser.microops = microops
self.parser.rom = rom
+ self.parser.rom_macroop_type = rom_macroop_type
def assemble(self, asm):
self.parser.parse(asm, lexer=self.lexer)
diff --git a/src/arch/micro_asm_test.py b/src/arch/micro_asm_test.py
index 858ac511e..f0aebe2b2 100755
--- a/src/arch/micro_asm_test.py
+++ b/src/arch/micro_asm_test.py
@@ -26,7 +26,7 @@
#
# Authors: Gabe Black
-from micro_asm import MicroAssembler, Macroop, Rom
+from micro_asm import MicroAssembler, Combinational_Macroop, Rom_Macroop, Rom
class Bah(object):
def __init__(self):
@@ -52,7 +52,7 @@ microops = {
"dah": Dah
}
-class TestMacroop(Macroop):
+class TestMacroop(Combinational_Macroop):
def tweak(self):
microops["bah"] = Bah_Tweaked
def untweak(self):
@@ -68,7 +68,7 @@ class TestMacroop(Macroop):
"print": self.print_debug
}
-assembler = MicroAssembler(TestMacroop, microops, Rom('main ROM'))
+assembler = MicroAssembler(TestMacroop, microops, Rom('main ROM'), Rom_Macroop)
testAssembly = '''
# Single line comment