Type.py (8266:66a3187a6714) Type.py (8602:836f8fad4a4c)
1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
2# Copyright (c) 2009 The Hewlett-Packard Development Company
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 430 unchanged lines hidden (view full) ---

439#include <iostream>
440#include <string>
441
442#include "mem/ruby/common/Global.hh"
443''')
444 if self.isStateDecl:
445 code('#include "mem/protocol/AccessPermission.hh"')
446
1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
2# Copyright (c) 2009 The Hewlett-Packard Development Company
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 430 unchanged lines hidden (view full) ---

439#include <iostream>
440#include <string>
441
442#include "mem/ruby/common/Global.hh"
443''')
444 if self.isStateDecl:
445 code('#include "mem/protocol/AccessPermission.hh"')
446
447 if self.isMachineType:
448 code('#include "base/misc.hh"')
449 code('#include "mem/protocol/GenericMachineType.hh"')
450 code('#include "mem/ruby/common/Address.hh"')
451 code('#include "mem/ruby/system/NodeID.hh"')
452 code('struct MachineID;')
453
447 code('''
448
449// Class definition
450/** \\enum ${{self.c_ident}}
451 * \\brief ${{self.desc}}
452 */
453enum ${{self.c_ident}} {
454 ${{self.c_ident}}_FIRST,

--- 28 unchanged lines hidden (view full) ---

483 code('''
484int ${{self.c_ident}}_base_level(const ${{self.c_ident}}& obj);
485MachineType ${{self.c_ident}}_from_base_level(int);
486int ${{self.c_ident}}_base_number(const ${{self.c_ident}}& obj);
487int ${{self.c_ident}}_base_count(const ${{self.c_ident}}& obj);
488''')
489
490 for enum in self.enums.itervalues():
454 code('''
455
456// Class definition
457/** \\enum ${{self.c_ident}}
458 * \\brief ${{self.desc}}
459 */
460enum ${{self.c_ident}} {
461 ${{self.c_ident}}_FIRST,

--- 28 unchanged lines hidden (view full) ---

490 code('''
491int ${{self.c_ident}}_base_level(const ${{self.c_ident}}& obj);
492MachineType ${{self.c_ident}}_from_base_level(int);
493int ${{self.c_ident}}_base_number(const ${{self.c_ident}}& obj);
494int ${{self.c_ident}}_base_count(const ${{self.c_ident}}& obj);
495''')
496
497 for enum in self.enums.itervalues():
491 code('#define MACHINETYPE_${{enum.ident}} 1')
498 if enum.ident == "DMA":
499 code('''
500MachineID map_Address_to_DMA(const Address &addr);
501''')
502 code('''
492
503
504MachineID get${{enum.ident}}MachineID(NodeID RubyNode);
505''')
506
507 code('''
508inline GenericMachineType
509ConvertMachToGenericMach(MachineType machType)
510{
511''')
512 for enum in self.enums.itervalues():
513 code('''
514 if (machType == MachineType_${{enum.ident}})
515 return GenericMachineType_${{enum.ident}};
516''')
517 code('''
518 panic("cannot convert to a GenericMachineType");
519}
520''')
521
493 if self.isStateDecl:
494 code('''
495
496// Code to convert the current state to an access permission
497AccessPermission ${{self.c_ident}}_to_permission(const ${{self.c_ident}}& obj);
498
499''')
500

--- 44 unchanged lines hidden (view full) ---

545 }
546}
547
548''')
549
550 if self.isMachineType:
551 for enum in self.enums.itervalues():
552 code('#include "mem/protocol/${{enum.ident}}_Controller.hh"')
522 if self.isStateDecl:
523 code('''
524
525// Code to convert the current state to an access permission
526AccessPermission ${{self.c_ident}}_to_permission(const ${{self.c_ident}}& obj);
527
528''')
529

--- 44 unchanged lines hidden (view full) ---

574 }
575}
576
577''')
578
579 if self.isMachineType:
580 for enum in self.enums.itervalues():
581 code('#include "mem/protocol/${{enum.ident}}_Controller.hh"')
582 code('#include "mem/ruby/system/MachineID.hh"')
553
554 code('''
555// Code for output operator
556ostream&
557operator<<(ostream& out, const ${{self.c_ident}}& obj)
558{
559 out << ${{self.c_ident}}_to_string(obj);
560 out << flush;

--- 157 unchanged lines hidden (view full) ---

718 code('''
719 case ${{self.c_ident}}_NUM:
720 default:
721 panic("Invalid range for type ${{self.c_ident}}");
722 }
723}
724''')
725
583
584 code('''
585// Code for output operator
586ostream&
587operator<<(ostream& out, const ${{self.c_ident}}& obj)
588{
589 out << ${{self.c_ident}}_to_string(obj);
590 out << flush;

--- 157 unchanged lines hidden (view full) ---

748 code('''
749 case ${{self.c_ident}}_NUM:
750 default:
751 panic("Invalid range for type ${{self.c_ident}}");
752 }
753}
754''')
755
756 for enum in self.enums.itervalues():
757 if enum.ident == "DMA":
758 code('''
759MachineID
760map_Address_to_DMA(const Address &addr)
761{
762 MachineID dma = {MachineType_DMA, 0};
763 return dma;
764}
765''')
766
767 code('''
768
769MachineID
770get${{enum.ident}}MachineID(NodeID RubyNode)
771{
772 MachineID mach = {MachineType_${{enum.ident}}, RubyNode};
773 return mach;
774}
775''')
776
726 # Write the file
727 code.write(path, "%s.cc" % self.c_ident)
728
729__all__ = [ "Type" ]
777 # Write the file
778 code.write(path, "%s.cc" % self.c_ident)
779
780__all__ = [ "Type" ]