[libre-riscv-dev] Introduction

Luke Kenneth Casson Leighton lkcl at lkcl.net
Mon Feb 4 12:05:27 GMT 2019


Rust means that the build and development of the hardware will be
critically reliant on an unnecessarily large set of dependencies.

I assumed c by suggesting using scanf, as it is tge language softfloat is
written in.

Reading a string with scanf is dead simple.

A switch statement or just a strcmp set of if statements or even just a 1
character read is sufficient.

The fadd switch statement is a scanf of 2 ints.

The fmuladd switch statement is 3.

Real simple, no need for rust or a stack or a parser  or any complexity of
any kind.


On Monday, February 4, 2019, Jacob Lifshay <programmerjake at gmail.com> wrote:

> I implemented the calculator in rust:
> https://salsa.debian.org/Kazan-team/softfloat-verify
>
> Supports RPN and multiple calculations per invocation by having one
> space-separated sequence of calculations per line. It prints and clears the
> stack after each line.
> See https://docs.rs/softfloat-sys/0.1.1/softfloat_sys/ for the list of
> supported functions and constants.
>
> Since I had to write the softfloat rust bindings and I didn't want to take
> much time, I only implemented it for linux x86_64.
>
> I had to work around a bug in softfloat where they used C inline functions
> but didn't supply the out-of-line definitions, so it won't build on -O0.
> Took lots of time to figure out.
>
> You will want to use softfloat_detectTininess_write_helper and
> softfloat_roundingMode_write_helper to set the correct rounding modes and
> tininess detection.
> You will also want to use softfloat_exceptionFlags_read_helper and
> softfloat_exceptionFlags_write_helper to clear and check the exception
> flags.
>
> Build instructions:
> Install dependencies: sudo apt install cmake build-essential git
> Get rust from https://rustup.rs/
>
> git clone https://salsa.debian.org/Kazan-team/softfloat-verify
> cd softfloat-verify
> cargo build
> ./softfloat-verify <<<"2 i32_to_f128 f128_sqrt"
> observe the f128 sqrt of 2.
>
> Jacob Lifshay
>
> On Sat, Feb 2, 2019 at 11:25 PM Luke Kenneth Casson Leighton <
> lkcl at lkcl.net>
> wrote:
>
> > On Sunday, February 3, 2019, Jacob Lifshay <programmerjake at gmail.com>
> > wrote:
> >
> > > I could write the calculator, shouldn't take very long. It will use
> > > integers for i/o, they will be bitcasted to the fp types. This way we
> > avoid
> > > problems with decimal representations while still being simple enough
> to
> > > implement since not everything can read/write hex floats (like
> > > 0x1234.5678P+25).
> >
> >
> > Yeh definitely int representation, fscanf does the job.
> >
> >
> > >
> > > Should I use infix notation, lisp-like S expressions, or RPN?
> > > I think we should not use infix notation as it's harder to parse and
> not
> > as
> > > clear which order operators are being applied.
> > >
> > > RPN is the easiest to parse.
> > > S expressions maintain the familiar operation nesting and is second
> > easiest
> > > to parse.
> >
> >
> > I hadn't thought about it, basically needs to be dead simple, yet enough
> to
> > represent FMULADD.
> >
> > even avoid stack, put operator first then operands, because operator can
> be
> > done as a switch statement then straight to read of num of ops, then
> print
> > result. Loop.
> >
> > fscanf to read line up to \n to get operator.
> > switch statement
> > fscanf with %x's to read operands.
> >
> >
> >
> >
> >
> > --
> > ---
> > crowd-funded eco-conscious hardware: https://www.crowdsupply.com/eoma68
> > _______________________________________________
> > libre-riscv-dev mailing list
> > libre-riscv-dev at lists.libre-riscv.org
> > http://lists.libre-riscv.org/mailman/listinfo/libre-riscv-dev
> >
> _______________________________________________
> libre-riscv-dev mailing list
> libre-riscv-dev at lists.libre-riscv.org
> http://lists.libre-riscv.org/mailman/listinfo/libre-riscv-dev
>


-- 
---
crowd-funded eco-conscious hardware: https://www.crowdsupply.com/eoma68


More information about the libre-riscv-dev mailing list