Files
b210-k7-fpga/sim/control/sim_set_rb_lib.svh
+18 6b67702ad7 Merge FPGA repository back into UHD repository
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>


Original-commit: bafa9d95453387814ef25e6b6256ba8db2df612f
2020-01-28 09:35:36 -08:00

169 lines
5.0 KiB
Systemverilog

//
// Copyright 2015 Ettus Research LLC
//
`ifndef INCLUDED_SIM_SET_RB_LIB
`define INCLUDED_SIM_SET_RB_LIB
interface settings_bus_t #(
parameter SR_AWIDTH = 8,
parameter SR_DWIDTH = 32,
parameter RB_AWIDTH = 8,
parameter RB_DWIDTH = 64,
parameter NUM_BUSES = 1
)(
input clk
);
logic [NUM_BUSES-1:0] set_stb;
logic [NUM_BUSES*SR_AWIDTH-1:0] set_addr;
logic [NUM_BUSES*SR_DWIDTH-1:0] set_data;
logic [NUM_BUSES-1:0] rb_stb;
logic [NUM_BUSES*RB_AWIDTH-1:0] rb_addr;
logic [NUM_BUSES*RB_DWIDTH-1:0] rb_data;
modport master (output set_stb, output set_addr, output set_data,
input rb_stb, output rb_addr, input rb_data);
modport slave (input set_stb, input set_addr, input set_data,
output rb_stb, input rb_addr, output rb_data);
endinterface
interface settings_bus_master #(
parameter SR_AWIDTH = 8,
parameter SR_DWIDTH = 32,
parameter RB_AWIDTH = 8,
parameter RB_DWIDTH = 64,
parameter NUM_BUSES = 1,
parameter TIMEOUT = 65535 // readback() timeout
)(
input clk
);
settings_bus_t #(
.SR_AWIDTH(SR_AWIDTH), .SR_DWIDTH(SR_DWIDTH),
.RB_AWIDTH(RB_AWIDTH), .RB_DWIDTH(RB_DWIDTH),
.NUM_BUSES(NUM_BUSES))
settings_bus (.clk(clk));
// Reset signals / properties used by this interface
task automatic reset;
settings_bus.set_stb = 0;
settings_bus.set_addr = 0;
settings_bus.set_data = 0;
settings_bus.rb_addr = 0;
endtask
// Push a transaction onto the settings bus
// Args:
// - set_addr: Settings bus address
// - set_data: Settings bus data
// - rb_addr: Readback bus address
task automatic write (
input logic [SR_AWIDTH-1:0] set_addr,
input logic [SR_DWIDTH-1:0] set_data,
input logic [RB_AWIDTH-1:0] rb_addr = 'd0,
input int bus = 0); // Optional
begin
if (clk) @(negedge clk);
settings_bus.set_stb[bus] = 1'b1;
settings_bus.set_addr[SR_AWIDTH*bus +: SR_AWIDTH] = set_addr;
settings_bus.set_data[SR_DWIDTH*bus +: SR_DWIDTH] = set_data;
settings_bus.rb_addr[RB_AWIDTH*bus +: RB_AWIDTH] = rb_addr;
@(negedge clk);
settings_bus.set_stb[bus] = 1'b0;
settings_bus.set_addr[SR_AWIDTH*bus +: SR_AWIDTH] = 'd0;
settings_bus.set_data[SR_DWIDTH*bus +: SR_DWIDTH] = 'd0;
settings_bus.rb_addr[RB_AWIDTH*bus +: RB_AWIDTH] = 'd0;
end
endtask
// Pull a transaction from the readback bus. Typically called immediately after write().
// Args:
// - rb_data: Readback data
task automatic readback (
output logic [RB_DWIDTH-1:0] rb_data,
input int bus = 0);
begin
integer timeout_counter = 0;
if (clk & ~settings_bus.rb_stb[bus]) @(negedge clk);
while (~settings_bus.rb_stb[bus]) begin
if (timeout_counter < TIMEOUT) begin
timeout_counter++;
end else begin
$error("settings_bus_t::readback(): Timeout waiting for readback strobe!");
break;
end
@(negedge clk);
end
rb_data = settings_bus.rb_data[RB_DWIDTH*bus +: RB_DWIDTH];
end
endtask
endinterface
interface settings_bus_slave #(
parameter SR_AWIDTH = 8,
parameter SR_DWIDTH = 32,
parameter RB_AWIDTH = 8,
parameter RB_DWIDTH = 64,
parameter NUM_BUSES = 1,
parameter TIMEOUT = 65535 // read() timeout
)(
input clk
);
settings_bus_t #(
.SR_AWIDTH(SR_AWIDTH), .SR_DWIDTH(SR_DWIDTH),
.RB_AWIDTH(RB_AWIDTH), .RB_DWIDTH(RB_DWIDTH),
.NUM_BUSES(NUM_BUSES))
settings_bus (.clk(clk));
// Reset signals / properties used by this interface
task automatic reset;
settings_bus.rb_stb = 0;
settings_bus.rb_data = 0;
endtask
// Pull a transaction from the settings bus
// Args:
// - set_addr: Settings bus address
// - set_data: Settings bus data
// - rb_addr: Readback bus address
task automatic read (
output logic [SR_AWIDTH-1:0] set_addr,
output logic [SR_DWIDTH-1:0] set_data,
output logic [RB_AWIDTH-1:0] rb_addr,
input int bus = 0);
begin
integer timeout_counter = 0;
while (~settings_bus.set_stb[bus]) begin
@(negedge clk);
if (timeout_counter < TIMEOUT) begin
timeout_counter++;
end else begin
$error("settings_bus_t::read(): Timeout waitling for settings bus strobe!");
break;
end
end
set_addr = settings_bus.set_addr[SR_AWIDTH*bus +: SR_AWIDTH];
set_data = settings_bus.set_data[SR_DWIDTH*bus +: SR_DWIDTH];
rb_addr = settings_bus.rb_addr[RB_AWIDTH*bus +: RB_AWIDTH];
@(negedge clk);
end
endtask
// Push a transaction onto the readback bus, typically called immediately after read()
// Args:
// - rb_data: Readback data
task writeback (
input logic [RB_AWIDTH-1:0] rb_data,
input int bus = 0);
begin
if (clk & ~settings_bus.set_stb[bus]) @(negedge clk);
settings_bus.rb_stb[bus] = 1'b1;
settings_bus.rb_data[RB_DWIDTH*bus +: RB_DWIDTH] = rb_data;
@(negedge clk);
settings_bus.rb_stb[bus] = 1'b0;
settings_bus.rb_data[RB_DWIDTH*bus +: RB_DWIDTH] = 'd0;
end
endtask
endinterface
`endif