Skip to content

Commit 0604fb9

Browse files
steps towards getting integer inputs to work
1 parent bf72451 commit 0604fb9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

hls4ml/model/types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,12 @@ def __str__(self):
104104
args = [self.width, self.integer, self.rounding_mode, self.saturation_mode, self.saturation_bits]
105105
args = ','.join([str(arg) for arg in args if arg is not None])
106106
typestring = '{signed}fixed<{args}>'.format(signed='u' if not self.signed else '', args=args)
107+
typestring = 'ap_{signed}fixed<{args}>'.format(signed='u' if not self.signed else '', args=args)
107108
return typestring
108109

109110
def __eq__(self, other):
111+
if not isinstance(other, FixedPrecisionType):
112+
return False
110113
eq = self.width == other.width
111114
eq = eq and self.integer == other.integer
112115
eq = eq and self.fractional == other.fractional

hls4ml/writer/vivado_accelerator_writer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def write_axi_wrapper(self, model):
4545
indent + 'in_struct(const T_in& data, const ap_uint<1>& last){this->data = data; this->last = last;};\n' + \
4646
indent + 'in_struct(){this->data = 0; this->last = 0;};\n' + \
4747
indent + 'friend std::ostream& operator<<(std::ostream& stream, const in_struct& in)\n' + \
48-
indent + '{ return stream << "{ data: " << in.data << ", last: " << in.last << " }" << std::endl; }\n' + \
48+
indent + '{ return stream << "{ data: " << float(in.data) << ", last: " << float(in.last) << " }" << std::endl; }\n' + \
4949
indent + 'operator float() const {return this->data;}\n' + \
5050
indent + 'operator double() const {return this->data;}\n' + \
5151
indent + 'in_struct(float data) {this->data = data; this->last = 0;}\n' + \
@@ -57,7 +57,7 @@ def write_axi_wrapper(self, model):
5757
indent + 'out_struct(const T_out& data, const ap_uint<1>& last){this->data = data; this->last = last;};\n' + \
5858
indent + 'out_struct(){this->data = 0; this->last = 0;};\n' + \
5959
indent + 'friend std::ostream& operator<<(std::ostream& stream, const out_struct& out)\n' + \
60-
indent + '{ return stream << "{ data: " << out.data << ", last: " << out.last << " }" << std::endl; }\n' + \
60+
indent + '{ return stream << "{ data: " << float(out.data) << ", last: " << float(out.last) << " }" << std::endl; }\n' + \
6161
indent + 'operator float() const {return this->data;}\n' + \
6262
indent + 'operator double() const {return this->data;}\n' + \
6363
indent + 'out_struct(float data) {this->data = data; this->last = 0;}\n' + \

0 commit comments

Comments
 (0)