OpenASIP  2.0
LHSValue.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2017 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25 * @file LHSValue.hh
26 *
27 * @author Lasse Lehtonen 2017 (lasse.lehtonen-no.spam-tut.fi)
28 */
29 #pragma once
30 #include "HWGenTools.hh"
31 #include <iostream>
32 #include <string>
33 #include <unordered_set>
34 
35 namespace HDLGenerator {
36  /**
37  * Base class for left-hand side values (assignments, If clauses)
38  */
39  class LHSValue {
40  public:
41  LHSValue() {}
42  void hdl(std::ostream& stream, Language lang, int level);
43  void hdl(std::ostream& stream, Language lang);
44  void writeSignals(std::unordered_set<std::string>& readList) const;
45  std::string vhdl() const { return vhdl_; }
46  std::string verilog() const { return verilog_; }
47 
48  // Operator overloading for more readable code
56 
57  protected:
58  std::unordered_set<std::string> readList_;
59  std::string vhdl_;
60  std::string verilog_;
61  };
62 
63  /**
64  * Base class for left-hand side values (assignments, If clauses)
65  */
66  class LHSSignal : public LHSValue {
67  public:
68  LHSSignal(std::string name);
69  };
70 
71  class BinaryLiteral : public LHSValue {
72  public:
73  BinaryLiteral(std::string value);
74  BinaryLiteral(int value, int width, bool signExtend);
75  std::string name() { return value_; }
76  private:
77  std::string value_;
78  };
79 }
HDLGenerator::LHSValue
Definition: LHSValue.hh:39
HDLGenerator::BinaryLiteral
Definition: LHSValue.hh:71
HDLGenerator
Definition: BinaryOps.hh:35
HDLGenerator::LHSValue::operator~
LHSValue operator~()
Definition: LHSValue.cc:89
HDLGenerator::LHSValue::vhdl_
std::string vhdl_
Definition: LHSValue.hh:59
HDLGenerator::LHSValue::operator^
LHSValue operator^(LHSValue rhs)
Definition: LHSValue.cc:79
HDLGenerator::LHSValue::operator||
LHSValue operator||(LHSValue rhs)
Definition: LHSValue.cc:59
HDLGenerator::LHSValue::operator&
LHSValue operator&(LHSValue rhs)
Definition: LHSValue.cc:74
HDLGenerator::LHSValue::writeSignals
void writeSignals(std::unordered_set< std::string > &readList) const
Definition: LHSValue.cc:52
HDLGenerator::LHSValue::vhdl
std::string vhdl() const
Definition: LHSValue.hh:45
HDLGenerator::BinaryLiteral::value_
std::string value_
Definition: LHSValue.hh:77
HDLGenerator::LHSValue::verilog
std::string verilog() const
Definition: LHSValue.hh:46
HDLGenerator::LHSValue::LHSValue
LHSValue()
Definition: LHSValue.hh:41
HDLGenerator::LHSValue::operator|
LHSValue operator|(LHSValue rhs)
Definition: LHSValue.cc:64
HDLGenerator::Language
Language
Definition: HWGenTools.hh:33
HDLGenerator::LHSSignal
Definition: LHSValue.hh:66
HDLGenerator::LHSValue::operator!
LHSValue operator!()
Definition: LHSValue.cc:84
HDLGenerator::BinaryLiteral::BinaryLiteral
BinaryLiteral(std::string value)
Definition: LHSValue.cc:99
HWGenTools.hh
HDLGenerator::BinaryLiteral::name
std::string name()
Definition: LHSValue.hh:75
HDLGenerator::LHSSignal::LHSSignal
LHSSignal(std::string name)
Definition: LHSValue.cc:93
HDLGenerator::LHSValue::hdl
void hdl(std::ostream &stream, Language lang, int level)
Definition: LHSValue.cc:37
HDLGenerator::LHSValue::verilog_
std::string verilog_
Definition: LHSValue.hh:60
HDLGenerator::LHSValue::readList_
std::unordered_set< std::string > readList_
Definition: LHSValue.hh:58
HDLGenerator::LHSValue::operator&&
LHSValue operator&&(LHSValue rhs)
Definition: LHSValue.cc:69