Cerata
A library to generate structural hardware designs
domain.cc
1
// Copyright 2018-2019 Delft University of Technology
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include <memory>
16
#include <string>
17
#include <utility>
18
19
#include "cerata/domain.h"
20
#include "cerata/node.h"
21
#include "cerata/port.h"
22
#include "cerata/signal.h"
23
24
namespace
cerata
{
25
26
ClockDomain::ClockDomain
(std::string name) :
Named
(std::move(name)) {}
27
28
std::shared_ptr<ClockDomain>
default_domain
() {
29
static
std::shared_ptr<ClockDomain> result = std::make_shared<ClockDomain>(
"default"
);
30
return
result;
31
}
32
33
std::optional<std::shared_ptr<ClockDomain>>
GetDomain
(
const
Node
&node) {
34
if
(node.IsPort()) {
35
return
node.AsPort()->domain();
36
}
else
if
(node.IsSignal()) {
37
return
node.AsSignal()->domain();
38
}
39
return
std::nullopt;
40
}
41
42
}
// namespace cerata
43
44
cerata::GetDomain
std::optional< std::shared_ptr< ClockDomain > > GetDomain(const Node &node)
Return the clock domain of a node, if it is a synchronous node.
Definition:
domain.cc:33
cerata
Contains every Cerata class, function, etc...
Definition:
api.h:41
cerata::Node
A node.
Definition:
node.h:42
cerata::Named
Convenience structure for anything that is named. Names are case-sensitive.
Definition:
utils.h:40
cerata::default_domain
std::shared_ptr< ClockDomain > default_domain()
Return a static default clock domain.
Definition:
domain.cc:28
cerata::ClockDomain::ClockDomain
ClockDomain(std::string name)
Clock domain constructor.
Definition:
domain.cc:26
src
cerata
domain.cc
Generated on Tue Nov 24 2020 13:17:12 for Cerata by
1.8.20