Add a top level zynq project and link against RC

This commit is contained in:
David Biancolin 2016-08-10 13:54:11 -07:00
parent 0b3237681b
commit 3ca6ba6f94
13 changed files with 271124 additions and 79615 deletions

8
.gitignore vendored
View File

@ -1,15 +1,19 @@
*.log
*.jou
*.Xil
*.swp
common/build
common/target
common/project/target
common/lib
common/bootrom
zedboard/zedboard_rocketchip_*
zedboard/src/tcl/zedboard_rocketchip_*.tcl
zedboard/src/tcl/make_bitstream_*.tcl
zedboard/src/verilog/rocketchip_wrapper.v
zedboard/src/verilog/Top.*.v
zedboard/src/verilog/ZynqAdapter.*.v
zedboard/deliver_output
zedboard/soft_build
@ -18,7 +22,6 @@ zybo/src/tcl/zybo_rocketchip_*.tcl
zybo/src/tcl/make_bitstream_*.tcl
zybo/src/verilog/rocketchip_wrapper.v
zybo/src/verilog/Top.*.v
zybo/src/verilog/ZynqAdapter.*.v
zybo/deliver_output
zybo/soft_build
@ -27,6 +30,5 @@ zc706/src/tcl/zc706_rocketchip_*.tcl
zc706/src/tcl/make_bitstream_*.tcl
zc706/src/verilog/rocketchip_wrapper.v
zc706/src/verilog/Top.*.v
zc706/src/verilog/ZynqAdapter.*.v
zc706/deliver_output
zc706/soft_build

3
.gitmodules vendored
View File

@ -15,3 +15,6 @@
[submodule "zc706/fpga-images-zc706"]
path = zc706/fpga-images-zc706
url = https://github.com/ucb-bar/fpga-images-zc706.git
[submodule "rocket-chip"]
path = rocket-chip
url = https://github.com/ucb-bar/rocket-chip.git

View File

@ -18,11 +18,19 @@ verilog_srcs = \
src/verilog/clocking.vh \
src/verilog/rocketchip_wrapper.v \
src/verilog/Top.$(CONFIG).v \
src/verilog/ZynqAdapter.$(CONFIG).v \
default: project
# Taken from rocket chip 2a5aeea. TODO: Maybe source this directly from makefrag?
SBT ?= java -Xmx2G -Xss8M -XX:MaxPermSize=256M -jar $(ROCKET_DIR)/sbt-launch.jar
FIRRTL_JAR ?= $(ROCKET_DIR)/firrtl/utils/bin/firrtl.jar
FIRRTL ?= java -Xmx2G -Xss8M -XX:MaxPermSize=256M -cp $(FIRRTL_JAR) firrtl.Driver
$(FIRRTL_JAR): $(@shell find $(ROCKET_DIR)/firrtl/src/main/scala -iname "*.scala")
$(MAKE) -C $(ROCKET_DIR)/firrtl SBT="$(SBT)" root_dir=$(ROCKET_DIR)/firrtl build-scala
CHISEL_ARGS := --W0W --minimumCompatibility 3.0.0 --backend $(BACKEND) --configName $(CONFIG) --compileInitializationUnoptimized --targetDir $(common_build)
# Specialize sources for board
# ------------------------------------------------------------------------------
@ -37,14 +45,29 @@ src/tcl/make_bitstream_$(CONFIG).tcl: $(common)/make_bitstream.tcl
sed 's/BOARD_NAME_HERE/$(BOARD)/g;s/CHISEL_CONFIG_HERE/$(CONFIG)/g' \
$(common)/make_bitstream.tcl > src/tcl/make_bitstream_$(CONFIG).tcl
src/verilog/ZynqAdapter.$(CONFIG).v:
cp $(common)/ZynqAdapter.DefaultFPGAConfig.v $@
# TODO: Can we pass this as an argument to the generator, instead of having
# to put the bootrom in a specific place?
$(common)/bootrom:
ln -s $(ROCKET_DIR)/bootrom $(common)/bootrom
rocket:
cd $(ROCKET_DIR)/fsim; \
make verilog CONFIG=$(CONFIG); \
cp $(common_build)/Top.$(CONFIG).v $(base_dir)/$(BOARD)/src/verilog
# TODO: Need a clever way of knowing when to repack rocketchip
$(common)/lib:
cd $(ROCKET_DIR) && sbt pack
mkdir -p $(common)/lib
cp $(ROCKET_DIR)/target/pack/lib/* $(common)/lib
$(common_build)/Top.$(CONFIG).fir: $(common)/lib $(common)/bootrom
mkdir -p $(@D)
cd $(common) && $(SBT) "run zynq Top $(CONFIG) $(CHISEL_ARGS)"
mv $(common_build)/Top.fir $@
$(common_build)/Top.$(CONFIG).v: $(common_build)/Top.$(CONFIG).fir $(FIRRTL_JAR)
$(FIRRTL) -i $< -o $@ -X verilog
src/verilog/Top.$(CONFIG).v: $(common_build)/Top.$(CONFIG).v
cp $< $@
rocket: src/verilog/Top.$(CONFIG).v
# Project generation

View File

@ -0,0 +1,14 @@
import sbt._
import Keys._
object BuildSettings extends Build {
override lazy val settings = super.settings ++ Seq(
organization := "berkeley",
version := "1.2",
scalaVersion := "2.11.7",
parallelExecution in Global := false,
traceLevel := 15,
scalacOptions ++= Seq("-deprecation","-unchecked")
)
lazy val zynq = (project in file("."))
}

View File

@ -133,17 +133,6 @@ module rocketchip_wrapper
wire S_AXI_rlast;
wire reset, reset_cpu;
wire debug_req_ready;
wire debug_req_valid;
wire [4:0] debug_req_bits_addr;
wire [1:0] debug_req_bits_op;
wire [33:0] debug_req_bits_data;
wire debug_resp_ready;
wire debug_resp_valid;
wire [1:0] debug_resp_bits_resp;
wire [33:0] debug_resp_bits_data;
wire host_clk;
wire gclk_i, gclk_fbout, host_clk_i, mmcm_locked;
@ -265,65 +254,6 @@ module rocketchip_wrapper
assign reset = !FCLK_RESET0_N || !mmcm_locked;
ZynqAdapter adapter (
.clk (host_clk),
.reset (reset),
.io_reset(reset_cpu),
.io_debug_req_ready(debug_req_ready),
.io_debug_req_valid(debug_req_valid),
.io_debug_req_bits_addr(debug_req_bits_addr),
.io_debug_req_bits_op(debug_req_bits_op),
.io_debug_req_bits_data(debug_req_bits_data),
.io_debug_resp_ready(debug_resp_ready),
.io_debug_resp_valid(debug_resp_valid),
.io_debug_resp_bits_resp(debug_resp_bits_resp),
.io_debug_resp_bits_data(debug_resp_bits_data),
.io_nasti_aw_ready (M_AXI_awready),
.io_nasti_aw_valid (M_AXI_awvalid),
.io_nasti_aw_bits_addr (M_AXI_awaddr),
.io_nasti_aw_bits_len (M_AXI_awlen),
.io_nasti_aw_bits_size (M_AXI_awsize),
.io_nasti_aw_bits_burst (M_AXI_awburst),
.io_nasti_aw_bits_id (M_AXI_awid),
.io_nasti_aw_bits_lock (),
.io_nasti_aw_bits_prot (),
.io_nasti_aw_bits_qos (),
.io_nasti_aw_bits_region (),
.io_nasti_ar_ready (M_AXI_arready),
.io_nasti_ar_valid (M_AXI_arvalid),
.io_nasti_ar_bits_addr (M_AXI_araddr),
.io_nasti_ar_bits_len (M_AXI_arlen),
.io_nasti_ar_bits_size (M_AXI_arsize),
.io_nasti_ar_bits_burst (M_AXI_arburst),
.io_nasti_ar_bits_id (M_AXI_arid),
.io_nasti_ar_bits_lock (),
.io_nasti_ar_bits_prot (),
.io_nasti_ar_bits_qos (),
.io_nasti_ar_bits_region (),
.io_nasti_w_valid (M_AXI_wvalid),
.io_nasti_w_ready (M_AXI_wready),
.io_nasti_w_bits_data (M_AXI_wdata),
.io_nasti_w_bits_strb (M_AXI_wstrb),
.io_nasti_w_bits_last (M_AXI_wlast),
.io_nasti_r_valid (M_AXI_rvalid),
.io_nasti_r_ready (M_AXI_rready),
.io_nasti_r_bits_id (M_AXI_rid),
.io_nasti_r_bits_resp (M_AXI_rresp),
.io_nasti_r_bits_data (M_AXI_rdata),
.io_nasti_r_bits_last (M_AXI_rlast),
.io_nasti_b_valid (M_AXI_bvalid),
.io_nasti_b_ready (M_AXI_bready),
.io_nasti_b_bits_id (M_AXI_bid),
.io_nasti_b_bits_resp (M_AXI_bresp)
);
wire [31:0] mem_araddr;
wire [31:0] mem_awaddr;
@ -333,9 +263,50 @@ module rocketchip_wrapper
Top top(
.clk(host_clk),
.reset(reset_cpu),
.io_interrupts_0(1'b0),
.io_interrupts_1(1'b0),
.reset(reset),
.io_ps_axi_slave_aw_ready (M_AXI_awready),
.io_ps_axi_slave_aw_valid (M_AXI_awvalid),
.io_ps_axi_slave_aw_bits_addr (M_AXI_awaddr),
.io_ps_axi_slave_aw_bits_len (M_AXI_awlen),
.io_ps_axi_slave_aw_bits_size (M_AXI_awsize),
.io_ps_axi_slave_aw_bits_burst (M_AXI_awburst),
.io_ps_axi_slave_aw_bits_id (M_AXI_awid),
.io_ps_axi_slave_aw_bits_lock (),
.io_ps_axi_slave_aw_bits_prot (),
.io_ps_axi_slave_aw_bits_qos (),
.io_ps_axi_slave_aw_bits_region (),
.io_ps_axi_slave_ar_ready (M_AXI_arready),
.io_ps_axi_slave_ar_valid (M_AXI_arvalid),
.io_ps_axi_slave_ar_bits_addr (M_AXI_araddr),
.io_ps_axi_slave_ar_bits_len (M_AXI_arlen),
.io_ps_axi_slave_ar_bits_size (M_AXI_arsize),
.io_ps_axi_slave_ar_bits_burst (M_AXI_arburst),
.io_ps_axi_slave_ar_bits_id (M_AXI_arid),
.io_ps_axi_slave_ar_bits_lock (),
.io_ps_axi_slave_ar_bits_prot (),
.io_ps_axi_slave_ar_bits_qos (),
.io_ps_axi_slave_ar_bits_region (),
.io_ps_axi_slave_w_valid (M_AXI_wvalid),
.io_ps_axi_slave_w_ready (M_AXI_wready),
.io_ps_axi_slave_w_bits_data (M_AXI_wdata),
.io_ps_axi_slave_w_bits_strb (M_AXI_wstrb),
.io_ps_axi_slave_w_bits_last (M_AXI_wlast),
.io_ps_axi_slave_r_valid (M_AXI_rvalid),
.io_ps_axi_slave_r_ready (M_AXI_rready),
.io_ps_axi_slave_r_bits_id (M_AXI_rid),
.io_ps_axi_slave_r_bits_resp (M_AXI_rresp),
.io_ps_axi_slave_r_bits_data (M_AXI_rdata),
.io_ps_axi_slave_r_bits_last (M_AXI_rlast),
.io_ps_axi_slave_b_valid (M_AXI_bvalid),
.io_ps_axi_slave_b_ready (M_AXI_bready),
.io_ps_axi_slave_b_bits_id (M_AXI_bid),
.io_ps_axi_slave_b_bits_resp (M_AXI_bresp),
.io_mem_axi_0_ar_valid (S_AXI_arvalid),
.io_mem_axi_0_ar_ready (S_AXI_arready),
.io_mem_axi_0_ar_bits_addr (mem_araddr),
@ -374,16 +345,7 @@ module rocketchip_wrapper
.io_mem_axi_0_r_bits_resp (S_AXI_rresp),
.io_mem_axi_0_r_bits_id (S_AXI_rid),
.io_mem_axi_0_r_bits_data (S_AXI_rdata),
.io_mem_axi_0_r_bits_last (S_AXI_rlast),
.io_debug_req_ready(debug_req_ready),
.io_debug_req_valid(debug_req_valid),
.io_debug_req_bits_addr(debug_req_bits_addr),
.io_debug_req_bits_op(debug_req_bits_op),
.io_debug_req_bits_data(debug_req_bits_data),
.io_debug_resp_ready(debug_resp_ready),
.io_debug_resp_valid(debug_resp_valid),
.io_debug_resp_bits_resp(debug_resp_bits_resp),
.io_debug_resp_bits_data(debug_resp_bits_data)
.io_mem_axi_0_r_bits_last (S_AXI_rlast)
);
`ifndef differential_clock
IBUFG ibufg_gclk (.I(clk), .O(gclk_i));

View File

@ -1,3 +1,4 @@
package zynq
import scala.math.min
@ -6,7 +7,7 @@ import uncore.tilelink._
import junctions._
import cde.Parameters
import uncore.devices.{DebugBusIO, DebugBusReq, DebugBusResp, DMKey}
import uncore.devices.DbBusConsts
import uncore.devices.DbBusConsts._
/* TODO: This module should be instantiated by a top-level project that also
* instantiates rocket-chip.
@ -44,7 +45,6 @@ class ZynqAdapter(implicit val p: Parameters)
val RESP_ADDR = 0x10
val RESET_ADDR = 0x20
import DbBusConsts._
val debugAddrSize = p(DMKey).nDebugBusAddrSize
val reqOffset = dbDataSize
val opOffset = dbDataSize

View File

@ -0,0 +1,76 @@
package zynq
import Chisel._
import junctions._
import cde.{Parameters, Config, CDEMatchError}
import rocketchip._
import uncore.devices.{DebugBusIO}
class Top(implicit val p: Parameters) extends Module
with HasTopLevelParameters {
val adapterParams = p.alterPartial({
case NastiKey => NastiParameters(
dataBits = 32,
addrBits = 32,
idBits = 12)
})
val io = new Bundle {
val ps_axi_slave = new NastiIO()(adapterParams).flip
val mem_axi = Vec(nMemAXIChannels, new NastiIO)
}
val adapter = Module(new ZynqAdapter()(adapterParams))
val rocket = Module(new rocketchip.Top(p))
adapter.io.nasti <> io.ps_axi_slave
rocket.reset := adapter.io.reset
rocket.io.debug <> adapter.io.debug
io.mem_axi <> rocket.io.mem_axi
rocket.io.interrupts map(_ := Bool(false))
}
/* Would like to disable interrupts in zynq configurations
class ZynqConfig extends Config(
(pname, site, here) => pname match {
case NExtInterrupts => 0
case _ => throw new CDEMatchError
})
*/
// Do this to avoid looking up the config in a second (in this case, RC) project
class DefaultFPGAConfig extends Config(new rocketchip.DefaultFPGAConfig)
class DefaultFPGASmallConfig extends Config(new rocketchip.DefaultFPGASmallConfig)
// This copied directly from rocketchip 2a5aeea
// Could invoke RC main directly, but don't want all the test generation
object Generator extends App {
val projectName = args(0)
val topModuleName = args(1)
val configClassName = args(2)
val aggregateConfigs = configClassName.split('_')
val finalConfig = aggregateConfigs.foldRight(new Config()) { case (currentConfigName, finalConfig) =>
val currentConfig = try {
Class.forName(s"$projectName.$currentConfigName").newInstance.asInstanceOf[Config]
} catch {
case e: java.lang.ClassNotFoundException =>
throwException("Unable to find part \"" + currentConfigName +
"\" of configClassName \"" + configClassName +
"\", did you misspell it?", e)
}
currentConfig ++ finalConfig
}
val world = finalConfig.toInstance
val paramsFromConfig: Parameters = Parameters.root(world)
val gen = () =>
Class.forName(s"$projectName.$topModuleName")
.getConstructor(classOf[cde.Parameters])
.newInstance(paramsFromConfig)
.asInstanceOf[Module]
chiselMain.run(args.drop(3), gen)
}

View File

@ -91,7 +91,6 @@ set obj [get_filesets sources_1]
set files [list \
"[file normalize "$origin_dir/src/verilog/clocking.vh"]"\
"[file normalize "$origin_dir/src/verilog/Top.CHISEL_CONFIG_HERE.v"]"\
"[file normalize "$origin_dir/src/verilog/ZynqAdapter.CHISEL_CONFIG_HERE.v"]"\
"[file normalize "$origin_dir/src/verilog/rocketchip_wrapper.v"]"\
]
add_files -norecurse -fileset $obj $files

View File

@ -1 +0,0 @@
..

1
rocket-chip Submodule

@ -0,0 +1 @@
Subproject commit 2906c7516739f2eed1299bb07457583fa1fdcbc4

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit 592c42bb6d125dcb05a6cde020cc01f720935990
Subproject commit 396e68f5ba5db672c49972be915a02a2242044bb

File diff suppressed because it is too large Load Diff