sifive / freedom

Source files for SiFive's Freedom platforms
Apache License 2.0
1.11k stars 284 forks source link

Differences between the file VC707Shell.scala and VC707NewShell.scala #137

Open wwMark opened 4 years ago

wwMark commented 4 years ago

Hello, could somebody give a short explain about the differences between the file VC707Shell.scala and VC707NewShell.scala under path fpga-shells/src/main/scala/shell/xilinx/? Do they complement each other or VC707Shell.scala is a legacy file?

erikdanie commented 4 years ago

Hello,

You are correct, VC707Shell.scala is legacy, however, the e300 build in freedom still uses it, and it is easier to read and understand. VC707NewShell is doing most of the same things: Defining top-level IOs and doing some top level buffering/logic. The benefit to the NewShell is that it actually does what a shell should do, it acts as a wrapper around the design that provides these things logically. These are done via Overlays, code that exists at the IO level but can reach into the core and connect/add logic there. There are 2 important aspects of the overlays. First, the shell instantiates the overlays based on what hardware it can actually support and sets the value of a key (i.e. a fpga without a spi flash chip wouldn't have a spi flash overlay) and secondly, the design queries these keys and decides whether or not to actually "place" the overlay, in which case, the constructor code contained in the overlay is actually run.

Shell creating overlays: https://github.com/sifive/fpga-shells/blob/14297af2878dc648ffd5751010fa72094ff444b0/src/main/scala/shell/xilinx/VC707NewShell.scala#L209

Design placing an overlay: https://github.com/sifive/freedom/blob/master/src/main/scala/unleashed/DevKitFPGADesign.scala#L120

Hope this clears up some confusion