Coder Social home page Coder Social logo

rftafas / hdl_string_format Goto Github PK

View Code? Open in Web Editor NEW

This project forked from suoto/hdl_string_format

0.0 0.0 0.0 32 KB

VHDL package to provide C-like string formatting

License: GNU General Public License v2.0

Python 3.11% VHDL 86.98% Shell 9.91%

hdl_string_format's Introduction

hdl_string_format

Build Status Analytics

hdl_string_format is based on Easics' PCK_FIO and aims to provide C-like string formatting.

Usage

Please note that the original PCK_FIO manual can be found at Easics' site.

fprint

The fprint procedure writes a formatted string to a line:

variable L : line;
fprint(L, "It's %d now", fo(2016));

report L.all;

Should print

It's 2016 now

sformat

Very similar to fprint, only that it returns a string. The example above would look like

report sformat("It's %d now", fo(2016));

Format specifiers

The general format of a format specifier is:

%[-][n]c

The optional - sign specifies left justified output; default is right justified.

The optional number n specifies a field width. If it is not specified, fprint does something reasonable.

c is the conversion specifier. Currently the following conversion specifiers are supported:

  • r: Reasonable output

    Prints the "most reasonable" representation e.g. hex for unsigned, signed and other bit-like vectors (not preferred for integers)

  • b: Bit-oriented output

  • d: Decimal output

  • s: string output (e.g. in combination with 'IMAGE for enum types)

  • q: "qualified" string output (shows internal representation from fo)

  • {}: Iteration operator, used as follows:

    %n{<format-string>}
    

    In this case, n is the iteration count and is mandatory. Iteration can be nested. Special characters

To print a double quote, use "" in the format string (VHDL convention). To print the special characters, \, and %, escape them with \. To prevent { and } from being interpreted as opening and closing brackets in iteration strings, escape them with \.

Copyright

1995, 2001 by Jan Decaluwe/Easics NV (under the name PCK_FIO)

2016 by Andre Souto (suoto)

License

This software is licensed under the GPL v2 license.

hdl_string_format's People

Contributors

suoto avatar pkorpine avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.