ucb-bar / midas

FPGA-Accelerated Simulation Framework Automatically Transforming Arbitrary RTL
Other
97 stars 15 forks source link

Add toBits, fromBits, and token definition CPP generators #22

Closed davidbiancolin closed 7 years ago

davidbiancolin commented 7 years ago

I clearly need to spend sometime developing a better CPP emitter. I'll do that after the retreat. This will do for now.

I committed the generated AXI tokens as an example. I'd like to come up with a better way to register token definitions outside of the Token Registry object, and ideally the midas package altogether.

aswaterman commented 7 years ago

Why are you guys inventing your own bigint library? This is a classic pitfall...

davidbiancolin commented 7 years ago

Chuuuump city.

If i'm not mistaken it's a holdover from strober, where i'd assume Donggyu wanted something super lightweight for writing test benches. I'm using it here merely to bootstrap the demo effort. For the purpose of moving, generating, and otherwise acting on tokens outside of models, we don't even care for the semantics of bigint, all we really require is a vessel for fields > 64 bits. The right call seems to be to simply use a bare array of a fixed width type wherever we need storage for large types and punt to the model writers/generators to cast those bits into whatever form they wish, using whatever library they wish.

davidbiancolin commented 7 years ago

I suppose on that note, i should look harder for a codegen library in scala.

aswaterman commented 7 years ago

Hardly any signals are >64b, so writing your own library to deal with them is an ill-considered pre-optimization. If you are concerned about performance, consider the fact that around half of signals in FIrrtl output are one bit wide, but still use an entire ISA register when operated upon. Optimize those.

For the big ones, just use GMP or whatever.

donggyukim commented 7 years ago

@aswaterman It's not only for performance. I used it heavily for snapshotting to handle arbitrary length signals. It also converts binary/hex to integer arrays or vice versa. I don't really want to write it, but I couldn't find a good external library to handle this. Also, I don't want to use heavy-weight external libraries because we are running this on zynq boards.

donggyukim commented 7 years ago

By the way, GMP looks good to me. We should consider using it.

aswaterman commented 7 years ago

Makes sense. I think GMP's lightweight enough for running on Zynq. You can probably statically link it if need be.