Skip to content

Commit

Permalink
Merge FPGA repository back into UHD repository
Browse files Browse the repository at this point in the history
The FPGA codebase was removed from the UHD repository in 2014 to reduce
the size of the repository. However, over the last half-decade, the
split between the repositories has proven more burdensome than it has
been helpful. By merging the FPGA code back, it will be possible to
create atomic commits that touch both FPGA and UHD codebases. Continuous
integration testing is also simplified by merging the repositories,
because it was previously difficult to automatically derive the correct
UHD branch when testing a feature branch on the FPGA repository.

This commit also updates the license files and paths therein.

We are therefore merging the repositories again. Future development for
FPGA code will happen in the same repository as the UHD host code and
MPM code.

== Original Codebase and Rebasing ==

The original FPGA repository will be hosted for the foreseeable future
at its original local location: https://github.com/EttusResearch/fpga/

It can be used for bisecting, reference, and a more detailed history.

The final commit from said repository to be merged here is
05003794e2da61cabf64dd278c45685a7abad7ec. This commit is tagged as
v4.0.0.0-pre-uhd-merge.

If you have changes in the FPGA repository that you want to rebase onto
the UHD repository, simply run the following commands:

- Create a directory to store patches (this should be an empty
  directory):

    mkdir ~/patches

- Now make sure that your FPGA codebase is based on the same state as
  the code that was merged:

    cd src/fpga # Or wherever your FPGA code is stored
    git rebase v4.0.0.0-pre-uhd-merge

  Note: The rebase command may look slightly different depending on what
  exactly you're trying to rebase.

- Create a patch set for your changes versus v4.0.0.0-pre-uhd-merge:

    git format-patch v4.0.0.0-pre-uhd-merge -o ~/patches

  Note: Make sure that only patches are stored in your output directory.
  It should otherwise be empty. Make sure that you picked the correct
  range of commits, and only commits you wanted to rebase were exported
  as patch files.

- Go to the UHD repository and apply the patches:

    cd src/uhd # Or wherever your UHD repository is stored
    git am --directory fpga ~/patches/*
    rm -rf ~/patches # This is for cleanup

== Contributors ==

The following people have contributed mainly to these files (this list
is not complete):

Co-authored-by: Alex Williams <alex.williams@ni.com>
Co-authored-by: Andrej Rode <andrej.rode@ettus.com>
Co-authored-by: Ashish Chaudhari <ashish@ettus.com>
Co-authored-by: Ben Hilburn <ben.hilburn@ettus.com>
Co-authored-by: Ciro Nishiguchi <ciro.nishiguchi@ni.com>
Co-authored-by: Daniel Jepson <daniel.jepson@ni.com>
Co-authored-by: Derek Kozel <derek.kozel@ettus.com>
Co-authored-by: EJ Kreinar <ej@he360.com>
Co-authored-by: Humberto Jimenez <humberto.jimenez@ni.com>
Co-authored-by: Ian Buckley <ian.buckley@gmail.com>
Co-authored-by: Jörg Hofrichter <joerg.hofrichter@ni.com>
Co-authored-by: Jon Kiser <jon.kiser@ni.com>
Co-authored-by: Josh Blum <josh@joshknows.com>
Co-authored-by: Jonathon Pendlum <jonathan.pendlum@ettus.com>
Co-authored-by: Martin Braun <martin.braun@ettus.com>
Co-authored-by: Matt Ettus <matt@ettus.com>
Co-authored-by: Michael West <michael.west@ettus.com>
Co-authored-by: Moritz Fischer <moritz.fischer@ettus.com>
Co-authored-by: Nick Foster <nick@ettus.com>
Co-authored-by: Nicolas Cuervo <nicolas.cuervo@ettus.com>
Co-authored-by: Paul Butler <paul.butler@ni.com>
Co-authored-by: Paul David <paul.david@ettus.com>
Co-authored-by: Ryan Marlow <ryan.marlow@ettus.com>
Co-authored-by: Sugandha Gupta <sugandha.gupta@ettus.com>
Co-authored-by: Sylvain Munaut <tnt@246tNt.com>
Co-authored-by: Trung Tran <trung.tran@ettus.com>
Co-authored-by: Vidush Vishwanath <vidush.vishwanath@ettus.com>
Co-authored-by: Wade Fife <wade.fife@ettus.com>
  • Loading branch information
28 people committed Jan 28, 2020
1 parent 3075b98 commit bafa9d9
Show file tree
Hide file tree
Showing 3,095 changed files with 2,905,761 additions and 10 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
[submodule "fpga-src"]
path = fpga-src
url = https://github.com/EttusResearch/fpga.git
branch = master
2 changes: 1 addition & 1 deletion CODING.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ the FPGA repository.
[CppCoreGuideLines]: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md
[PEP8]: https://www.python.org/dev/peps/pep-0008/
[Pep257]: https://www.python.org/dev/peps/pep-0257/
[fpga-coding]: https://github.com/EttusResearch/fpga/blob/master/CODING.md
[fpga-coding]: https://github.com/EttusResearch/uhd/blob/master/fpga/CODING.md
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The following guidelines apply:
- [UHD Coding Guidelines][uhd-coding] (for anything in this repository)
- [FPGA Coding Guidelines][fpga-coding] (for any FPGA-related modifications)

[fpga-coding]: https://github.com/EttusResearch/fpga/blob/master/CODING.md
[fpga-coding]: https://github.com/EttusResearch/uhd/blob/master/fpga/CODING.md
[uhd-coding]: https://github.com/EttusResearch/uhd/blob/master/CODING.md
[ettus-cla]: http://files.ettus.com/licenses/Ettus_CLA.pdf
[ettus-ml]: http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
Expand Down
17 changes: 14 additions & 3 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

Please refer to the individual files to verify which license applies to them.

UHD itself, is, by default, licensed under the GPLv3. If you wish to obtain an
alternative license, please contact info@ettus.com.
UHD and MPM themselves, are, by default, licensed under the GPLv3. If you wish
to obtain an alternative license, please contact info@ettus.com. Some of UHD's
dependencies are shipped as part of the repository
(see https://github.com/EttusResearch/uhd/tree/master/host/lib/deps for details).

## GPLv3 License Text
The FPGA codebase (stored under fpga/) has its own
[licensing situation][fpga-license]. See the various subdirectories therein for
more details.

Individual source files in this repository may have different licenses than
discussed above. Please refer to individual files and directories to verify
which license applies to which file.

## GPLv3 License Text (applies to most of UHD and MPM)

GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Expand Down Expand Up @@ -629,3 +639,4 @@ copy of the Program in return for a fee.

END OF TERMS AND CONDITIONS

[fpga-license]: https://github.com/EttusResearch/uhd/blob/master/fpga/usrp3/LICENSE.md
1 change: 0 additions & 1 deletion fpga-src
Submodule fpga-src deleted from 36a7df
12 changes: 12 additions & 0 deletions fpga/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*~
\#*\#
a.out
*.vcd
*.lxt
.metadata
.project
.settings
*.swp
*.jou
*.log
*.pyc
159 changes: 159 additions & 0 deletions fpga/CODING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# UHD FPGA Coding Standards

## Preamble

To quote R. W. Emerson: "A foolish consistency is the hobgoblin of little minds,
adored by little statesmen and philosophers and divines". Ignoring the little
statesmen for a minute, these coding standards are here to make our life
*easier*, not simply add additional rules. They are meant as additional guidance
for developers, and are not meant to be interpreted as law.

So, ultimately, it is up to the developer to decide how much these guidelines
should be heeded when writing code, and up to reviewers how much they are
relevant to new submissions.
That said, a consistent codebase is easier to maintain, read, understand, and
extend. Choosing personal preferences over these coding guidelines is not a
helpful move for the team and future maintainability of the UHD FPGA codebase.

## General Coding Guidelines

* Code layout: We use 2 spaces for indentation levels, and never tabs.
* Never submit code with trailing whitespace.
* Code is read more often than it's written. Code readability is thus something
worth optimizing for.
* Try and keep line lengths to 79 characters, unless readability suffers.
* Comment your code. Especially if your code is tricky or makes unique assumptions.
* Use the following header at the top of each file:
```verilog
//
// Copyright <YEAR> Ettus Research, A National Instruments Company
//
// SPDX-License-Identifier: LGPL-3.0-or-later
//
// Module: <MODULE_NAME>
// Description:
// <DESCRIPTION>
```

## Verilog Style Guidelines

### General Syntax

* Always use `begin`and `end` statements for more complex code blocks even if the enclosing code is only
one line.
* Indent begin/end as follows:
```verilog
if (foo) begin
// Do something
end else if (bar) begin
case(xyz)
1'b0: begin
// Handle 0
end
default: begin
// Handle 1
end
endcase
end else begin
// Do nothing
end
```
* Instantiate and declare modules as follows:
```verilog
dummy_module #(
.PARAM1(0), .PARAM2(1)
) inst (
.clk(clk), .rst(rst)
);
```

### Assignments

* Sequential blocks **must** only have non-blocking assignments (`<=`)
* Combinational blocks should only have blocking assignments (`=`)
* Don't mix blocking and non-blocking assignments

### Modules

* Each module should be defined in a separate file
* Use Verilog 2001 ANSI-C style port declarations
```verilog
(
...
output reg foo,
input wire bar
);
```
* Declare inputs and outputs one per line. This makes searching and commenting easier.
* Add inline comments to input/output ports to describe their behavior
* Be explicit about whether an input or output is a wire or reg.
* Group signals logically instead of by direction. If a single AXI-Stream bus has multiple inputs and
outputs, keep them together.
* Instantiate all ports for a module even if they are tied off or unconnected. Don't let the compiler
insert values for any signals automatically.
```verilog
dummy_module inst (
.clk(clk), .rst(1'b0), .status(/* unused */)
);
```
* Don't instantiate modules using positional arguments. Use the dot form illustrated above.
* Every module requires a header giving a synopsis of its function below the
copyright header.

### Clocking and Resets

* Name clocks as `clk`. If there are multiple clocks then use a prefix like `bus_clk` and `radio_clk`.
* If a module has signals or input/outputs whose clock domain is not obvious, use a clock suffix
to be explicit about the domain, for example `axi_tdata_bclk`, `axi_tdata_rclk`.
* Try not to encode the frequency of the clock in the name unless the particular clock can
*never* take on any other frequency.
* Name resets as `rst`. If there are multiple clocks then use a prefix like `bus_rst` and `radio_rst`.
* If a reset is asynchronous, call it `arst`.
* Try to avoid asynchronous resets as much as possible.
* Don't active low resets unless it is used to drive IO.

### Parameters, defines and constants

* Parametrize modules wherever possible, especially if they are designed for reuse. Bus widths, addresses,
buffer sizes, etc are good candidates for parametrization.
* For modules with parameters, add inline comments to describe the behavior of each parameter
* Propagate parameters as far up the hierarchy as possible as long as it makes sense.
* Place `` `define`` statements in Verilog header file (.vh) and include them in modules.
* Avoid placing `` `define`` statements in modules
* For local parameters, use `localparam` instead on hard-coding things like widths, etc.

### AXI Specific

We heavily use AXI buses in the design so here are some best practices for those:
* Keep the components of an AXI-Stream or AXI-MM bus together in port/wire instantiations
* For module ports, use the master/slave naming convention as shown below. It makes connecting modules
easier because a master always connects to a slave
```verilog
input wire [63:0] s_axis_tdata,
input wire s_axis_tlast,
input wire s_axis_tvalid,
output wire s_axis_tready,
output reg [63:0] m_axis_tdata,
output reg m_axis_tlast,
output reg m_axis_tvalid,
input wire m_axis_tready,
```
* For connections between a master and slave, *do not* use the master/slave convention. Name the bus based
on its function or underlying data.
```verilog
wire [63:0] axis_eth2xbar_tdata,
wire axis_eth2xbar_tlast,
wire axis_eth2xbar_tvalid,
wire axis_eth2xbar_tready,
// If "axis" is obvious, drop the prefix
wire [63:0] samp_tdata,
wire samp_tlast,
wire samp_tvalid,
wire samp_tready,
```


## Design Best Practices

TBD
8 changes: 8 additions & 0 deletions fpga/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Contributing to UHD/FPGA

Please refer to the [UHD contribution guidelines](https://github.com/EttusResearch/uhd/blob/master/CONTRIBUTING.md),
they also apply to this repository.
Please note that the issue tracker for this repository has been disabled,
issues regarding the FPGA codebase can be reported on the
[UHD issue tracker](https://github.com/EttusResearch/uhd/issues).

57 changes: 57 additions & 0 deletions fpga/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Ettus Research USRP FPGA HDL Source
===================================

Welcome to the USRP FPGA HDL source code tree! This repository contains
free & open-source FPGA HDL for the Universal Software Radio Peripheral
(USRP&trade;) SDR platform, created and sold by Ettus Research. A large
percentage of the source code is written in Verilog.

## Product Generations

This repository contains the FPGA source for the following generations of
USRP devices.

### Generation 1

- Directory: __usrp1__
- Devices: USRP Classic Only
- Tools: Quartus from Altera
- [Build Instructions](http://files.ettus.com/manual/md_usrp1_build_instructions.html)

### Generation 2

- Directory: __usrp2__
- Devices: USRP N2X0, USRP B100, USRP E1X0, USRP2
- Tools: ISE from Xilinx, GNU make
- [Build Instructions](http://files.ettus.com/manual/md_usrp2_build_instructions.html)
- [Customization Instructions](http://files.ettus.com/manual/md_usrp2_customize_signal_chain.html)

### Generation 3

- Directory: __usrp3__
- Devices: USRP B2X0, USRP X Series, USRP E3X0, USRP N3xx
- Tools: Vivado from Xilinx, ISE from Xilinx, GNU make
- [Build Instructions](http://files.ettus.com/manual/md_usrp3_build_instructions.html)
- [Simulation](http://files.ettus.com/manual/md_usrp3_simulation.html)


## Pre-built FPGA Images

Pre-built FPGA and Firmware images are not hosted here. Please visit the
[FPGA and Firmware manual page](http://files.ettus.com/manual/page_images.html)
for instructions on downloading and using pre-built images. In most cases, running the following
command will do the right thing.

$ uhd_images_downloader

## Building This Manual

This FPGA manual is available on the web at http://files.ettus.com/manual/md_fpga.html for the most
recent stable version of UHD. If you wish to read documentation for a custom/unstable branch you will
need to build it and open it locally using a web browser. To do so please install
[Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html#srcbin) on your system and run the following commands:

$ cd docs
$ make
$ sensible-browser html/index.html

3 changes: 3 additions & 0 deletions fpga/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
html/
latex/
*.db
Loading

0 comments on commit bafa9d9

Please sign in to comment.