Skip to content

Commit

Permalink
steps towards getting integer inputs to work
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan-Shoemaker committed Oct 12, 2022
1 parent 5895737 commit 2be0bd7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions hls4ml/model/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ def __str__(self):
args = [self.width, self.integer, self.rounding_mode, self.saturation_mode, self.saturation_bits]
args = ','.join([str(arg) for arg in args if arg is not None])
typestring = '{signed}fixed<{args}>'.format(signed='u' if not self.signed else '', args=args)
typestring = 'ap_{signed}fixed<{args}>'.format(signed='u' if not self.signed else '', args=args)
return typestring

def __eq__(self, other):
if not isinstance(other, FixedPrecisionType):
return False
eq = self.width == other.width
eq = eq and self.integer == other.integer
eq = eq and self.fractional == other.fractional
Expand Down
4 changes: 2 additions & 2 deletions hls4ml/writer/vivado_accelerator_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def write_axi_wrapper(self, model):
indent + 'in_struct(const T_in& data, const ap_uint<1>& last){this->data = data; this->last = last;};\n' + \
indent + 'in_struct(){this->data = 0; this->last = 0;};\n' + \
indent + 'friend std::ostream& operator<<(std::ostream& stream, const in_struct& in)\n' + \
indent + '{ return stream << "{ data: " << in.data << ", last: " << in.last << " }" << std::endl; }\n' + \
indent + '{ return stream << "{ data: " << float(in.data) << ", last: " << float(in.last) << " }" << std::endl; }\n' + \
indent + 'operator float() const {return this->data;}\n' + \
indent + 'operator double() const {return this->data;}\n' + \
indent + 'in_struct(float data) {this->data = data; this->last = 0;}\n' + \
Expand All @@ -57,7 +57,7 @@ def write_axi_wrapper(self, model):
indent + 'out_struct(const T_out& data, const ap_uint<1>& last){this->data = data; this->last = last;};\n' + \
indent + 'out_struct(){this->data = 0; this->last = 0;};\n' + \
indent + 'friend std::ostream& operator<<(std::ostream& stream, const out_struct& out)\n' + \
indent + '{ return stream << "{ data: " << out.data << ", last: " << out.last << " }" << std::endl; }\n' + \
indent + '{ return stream << "{ data: " << float(out.data) << ", last: " << float(out.last) << " }" << std::endl; }\n' + \
indent + 'operator float() const {return this->data;}\n' + \
indent + 'operator double() const {return this->data;}\n' + \
indent + 'out_struct(float data) {this->data = data; this->last = 0;}\n' + \
Expand Down

0 comments on commit 2be0bd7

Please sign in to comment.