def _gen():
     f = open(PIPELINE_DEMO_CONFIG_FILEPATH)
     config = json.loads(f.read())
     arch = Architecture.from_dict(config)
     hooks = arch.get_hooks()
     f.close()
     return arch, hooks
 def _gen():
     f = open(SINGLE_CYCLE_FULL_CONFIG_FILEPATH)
     config = json.loads(f.read())
     arch = Architecture.from_dict(config)
     hooks = arch.get_hooks()
     f.close()
     return arch, hooks
示例#3
0
 def load(self, msg):
     """
     Loads the an architecture from a configuration file.
     Param: msg is dictionary with a filepath specified to config file
     Return: dictionary noting resulting state of operation.
     """
     try:
         f = open(msg['filepath'])
         config = json.loads(f.read())
         self.arch = Architecture.from_dict(config)
         self.hooks = self.arch.get_hooks()
         f.close()
     except KeyError as e:
         traceback.print_exc()
         return {
             'status': False,
             'error': 'invalid key : {}'.format(str(e))
         }
     except Exception as e:
         traceback.print_exc()
         return {'status': False, 'error': 'exception : {}'.format(str(e))}
     return {'status': True}
示例#4
0
    def test_from_dict(self):
        "Validates dictionary constructor"

        config = {
            "packages": ["user"],
            "system_clock":
            "clk",
            "system_reset":
            "rst",
            "system_memory":
            None,
            "time_step":
            0.001,
            "signals": [{
                "name":
                "container",
                "symbolic":
                True,
                "view": {},
                "signals": [{
                    "name": "clk",
                    "package": "core",
                    "simulation": {
                        "model": "Clock",
                        "frequency": 1,
                        "append_to_entities": True,
                        "width": 1
                    },
                    "view": {}
                }, {
                    "name": "rst",
                    "package": "core",
                    "simulation": {
                        "model": "Reset",
                        "width": 1
                    },
                    "view": {}
                }, {
                    "name": "d",
                    "package": "core",
                    "simulation": {
                        "model": "Bus",
                        "width": 4
                    },
                    "view": {}
                }, {
                    "name": "q",
                    "package": "core",
                    "simulation": {
                        "model": "Bus",
                        "width": 4
                    },
                    "view": {}
                }, {
                    "name": "const",
                    "package": "core",
                    "simulation": {
                        "model": "Constant",
                        "width": 4,
                        "value": 3
                    },
                    "view": {}
                }]
            }],
            "entities": [{
                "name":
                "container",
                "symbolic":
                True,
                "view": {},
                "entities": [{
                    "name": "adder",
                    "package": "core",
                    "simulation": {
                        "model": "Adder",
                        "width": 4,
                        "input_1": "const",
                        "input_2": "q",
                        "output": "d"
                    },
                    "view": {}
                }, {
                    "name": "register",
                    "package": "core",
                    "simulation": {
                        "model": "Register",
                        "append_to_signals": True,
                        "width": 4,
                        "clock": "clk",
                        "reset": "rst",
                        "input": "d",
                        "output": "q",
                        "edge_type": "both_edge"
                    },
                    "view": {}
                }]
            }]
        }

        arch = Architecture.from_dict(config)

        self.assertEqual(arch.inspect(["q"])["q"]["state"], 0)

        arch.logic_run()
        arch.logic_run()
        arch.logic_run()

        self.assertEqual(arch.inspect(["q"])["q"]["state"], 15)