Skip to content

Commit 4d93f8f

Browse files
Add Sonata One-compatible Sonata XL build target
Add Sonata XL bitstream build target that maintains software compatibility with the Sonata One board. Tweaks the design using `ifdef` statements and alternative XDC files. Uses the extra block RAM of the Sonata XL FPGA to create a faux-HyperRAM (1 MiB only) so that the memory map can be kept the same. Does not yet make use of the extra board-to-board connectors present only on the XL board. Change the fusesoc target from `synth` to `synth_xl` to build.
1 parent 06b1a5d commit 4d93f8f

File tree

7 files changed

+1116
-948
lines changed

7 files changed

+1116
-948
lines changed

data/synth_timing.xdc

Lines changed: 6 additions & 945 deletions
Large diffs are not rendered by default.

data/synth_timing_common.xdc

Lines changed: 977 additions & 0 deletions
Large diffs are not rendered by default.

data/synth_timing_xl.xdc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Copyright lowRISC contributors.
2+
## Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
## SPDX-License-Identifier: Apache-2.0
4+
5+
# Sonata XL-specific, to be sourced after synth_timing_common.xdc
6+
7+
# This file is for timing constraints to be applied *before* synthesis.
8+
# i.e. timing constraints on top-level ports.
9+
#
10+
# See UG949 and UG903 for information on setting various timing constraints.
11+
12+
#### Recommended timing constraints sequence from UG949 ####
13+
## Timing Assertions Section
14+
# Primary clocks
15+
# Virtual clocks
16+
# Generated clocks
17+
# Delay for external MMCM/PLL feedback loop
18+
# Clock Uncertainty and Jitter
19+
# Input and output delay constraints
20+
# Clock Groups and Clock False Paths
21+
## Timing Exceptions Section
22+
# False Paths
23+
# Max Delay / Min Delay
24+
# Multicycle Paths
25+
# Case Analysis
26+
# Disable Timing
27+
28+
### Clock Groups and Clock False Paths ###
29+
# JTAG tck is completely asynchronous to FPGA mainClk and
30+
# internal clocks generated from it (and thus synchronous with it).
31+
# No HyperRAM on Sonata XL, so exclude HyperRAM clocks.
32+
set_clock_groups -asynchronous -group tck -group {mainClk clk_sys clk_usb}

doc/dev/fpga-development.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,20 @@ Optionally, the bitstream can be built using a nix command:
3232
nix run .#bitstream-build
3333
```
3434
Note: Vivado must be in one's path for this command to work.
35+
36+
## Sonata XL bitstream
37+
38+
To build a bitstream for the Sonata XL board instead of the Sonata One board, change the fusesoc target from `synth` to `synth_xl`.
39+
i.e. run this command:
40+
41+
```sh
42+
fusesoc --cores-root=. run --target=synth_xl --setup --build lowrisc:sonata:system
43+
```
44+
45+
The resulting Sonata XL bitstream should be broadly compatible with software compiled for the Sonata One board.
46+
Compatibility is key, given the present lack of a software target for Sonata XL.
47+
Excluding HyperRAM and a couple of minor details, Sonata XL is a superset of Sonata One.
48+
A faux-HyperRAM is instantiated using the additional block RAM of the larger FPGA to account for the lack of HyperRAM onboard.
49+
The faux-HyperRAM is mounted at the same memory location as the real HyperRAM would be, providing software compatibility.
50+
It has the added benefit of being faster, which may aid some programs.
51+
Currently there is no way to use the additional board-to-board connectors provided by the Sonata XL board.

rtl/fpga/top_sonata.sv

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ module top_sonata
3535
output logic ethmac_cs,
3636

3737
output logic rgbled0,
38+
`ifdef TARGET_XL_BOARD
39+
// Sonata XL can turn off the RGB LEDs entirely
40+
output logic rgbled_en,
41+
`endif
3842

3943
// UART 0
4044
output logic ser0_tx,
@@ -192,12 +196,23 @@ module top_sonata
192196
output logic microsd_cmd, // SPI mode: COPI
193197
input logic microsd_det, // Card insertion detection
194198

199+
// HyperRAM interface
200+
`ifdef TARGET_XL_BOARD
201+
// No HyperRAM on Sonata XL
202+
`else
195203
inout wire [7:0] hyperram_dq,
196204
inout wire hyperram_rwds,
197205
output wire hyperram_ckp,
198206
output wire hyperram_ckn,
199207
output wire hyperram_nrst,
200208
output wire hyperram_cs
209+
`endif
210+
211+
`ifdef TARGET_XL_BOARD
212+
// Sonata XL-only expansion headers
213+
inout logic [63:0] ex0,
214+
inout logic [63:0] ex1
215+
`endif
201216
);
202217
import sonata_pkg::*;
203218

@@ -282,10 +297,14 @@ module top_sonata
282297
.rst_usb_ni (rst_usb_n),
283298

284299
// HyperRAM clocks and reset
300+
`ifdef TARGET_XL_BOARD
301+
// No HyperRAM on Sonata XL
302+
`else
285303
.clk_hr_i (clk_hr),
286304
.clk_hr90p_i (clk_hr90p),
287305
.clk_hr3x_i (clk_hr3x),
288306
.rst_hr_ni (rst_hr_n),
307+
`endif
289308

290309
// GPIO
291310
.gp_i ({
@@ -354,12 +373,17 @@ module top_sonata
354373

355374
.rgbled_dout_o(rgbled_dout),
356375

376+
// HyperRAM
377+
`ifdef TARGET_XL_BOARD
378+
// No HyperRAM on Sonata XL
379+
`else
357380
.hyperram_dq,
358381
.hyperram_rwds,
359382
.hyperram_ckp,
360383
.hyperram_ckn,
361384
.hyperram_nrst,
362385
.hyperram_cs,
386+
`endif
363387

364388
.rs485_tx_enable_o(rs485_tx_enable),
365389
.rs485_rx_enable_o(rs485_rx_enable),
@@ -372,6 +396,10 @@ module top_sonata
372396
);
373397

374398
assign rgbled0 = ~rgbled_dout;
399+
`ifdef TARGET_XL_BOARD
400+
// Leave RGBs always on, like Sonata One, until we can do something better
401+
assign rgbled_en = 1'b1;
402+
`endif
375403

376404
// Tie flash wp_n and hold_n to 1 as they're active low and we don't need either signal
377405
assign appspi_d2 = 1'b1;

rtl/system/sonata_system.sv

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ module sonata_system
2323
input logic rst_usb_ni,
2424

2525
// HyperRAM clocks and reset
26+
`ifdef TARGET_XL_BOARD
27+
// No HyperRAM on Sonata XL
28+
`else
2629
input logic clk_hr_i,
2730
input logic clk_hr90p_i,
2831
input logic clk_hr3x_i,
2932
input logic rst_hr_ni,
33+
`endif
3034

3135
// General purpose input and output
3236
input logic [GPIO_IOS_WIDTH-1:0] gp_i,
@@ -87,12 +91,16 @@ module sonata_system
8791

8892
output logic rgbled_dout_o,
8993

94+
`ifdef TARGET_XL_BOARD
95+
// No HyperRAM on Sonata XL
96+
`else
9097
inout wire [7:0] hyperram_dq,
9198
inout wire hyperram_rwds,
9299
output wire hyperram_ckp,
93100
output wire hyperram_ckn,
94101
output wire hyperram_nrst,
95102
output wire hyperram_cs,
103+
`endif
96104

97105
output wire rs485_rx_enable_o,
98106
output wire rs485_tx_enable_o,
@@ -494,6 +502,24 @@ module sonata_system
494502
.tl_b_o (tl_sram_b_d2h)
495503
);
496504

505+
// HyperRAM
506+
`ifdef TARGET_XL_BOARD
507+
// No HyperRAM on Sonata XL, but we can replace it with internal block RAM
508+
sram #(
509+
.AddrWidth ( $clog2(HyperRAMSize) ),
510+
.DataWidth ( BusDataWidth ),
511+
.DataBitsPerMask ( DataBitsPerMask ),
512+
.InitFile ()
513+
) u_hyperram (
514+
.clk_i (clk_sys_i),
515+
.rst_ni (rst_sys_ni),
516+
517+
.tl_a_i (tl_hyperram_ds_h2d),
518+
.tl_a_o (tl_hyperram_ds_d2h),
519+
.tl_b_i (),
520+
.tl_b_o ()
521+
);
522+
`else
497523
hyperram #(
498524
.HyperRAMClkFreq ( HyperRAMClkFreq ),
499525
.HyperRAMSize ( HyperRAMSize )
@@ -516,6 +542,7 @@ module sonata_system
516542
.hyperram_nrst,
517543
.hyperram_cs
518544
);
545+
`endif
519546

520547
// Manual M:1 socket instantiation as xbar generator cannot deal with multiple ports for one
521548
// device and we want to utilize the dual port SRAM. So totally separate crossbars are generated

sonata.core

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,14 @@ filesets:
6363
files_constraints_sonata:
6464
files:
6565
# Per AMD advice (UG949):
66-
- data/pins_sonata.xdc # 1 file for physical +
67-
- data/synth_timing.xdc # 1 file for timing (synthesis) +
68-
- data/impl_timing.xdc # 1 file for timing (implementation)
66+
# 1 file for physical + 1 file for timing (synthesis) + 1 file for timing (implementation)
67+
# Complicated by the differences between Sonata One and Sonata XL
68+
- target_synth ? (data/pins_sonata.xdc)
69+
- target_synth_xl ? (data/pins_sonata_xl.xdc)
70+
- data/synth_timing_common.xdc
71+
- target_synth ? (data/synth_timing.xdc)
72+
- target_synth_xl ? (data/synth_timing_xl.xdc)
73+
- data/impl_timing.xdc
6974
file_type: xdc
7075

7176
files_tcl:
@@ -98,6 +103,11 @@ parameters:
98103
paramtype: vlogdefine
99104
description: Use an SRAM simulation model rather than the real hyperram controller
100105

106+
TARGET_XL_BOARD:
107+
datatype: bool
108+
paramtype: vlogdefine
109+
description: Targeting the Sonata XL board rather than the Sonata One board.
110+
101111
targets:
102112
default: &default_target
103113
filesets:
@@ -118,6 +128,22 @@ targets:
118128
- SRAMInitFile
119129
- PRIM_DEFAULT_IMPL=prim_pkg::ImplXilinx
120130

131+
synth_xl:
132+
<<: *default_target
133+
default_tool: vivado
134+
filesets_append:
135+
- files_sonata
136+
- files_constraints_sonata
137+
- files_tcl
138+
toplevel: top_sonata
139+
tools:
140+
vivado:
141+
part: "xc7a200tfbg676-2" # Artix-7 200T
142+
parameters:
143+
- SRAMInitFile
144+
- PRIM_DEFAULT_IMPL=prim_pkg::ImplXilinx
145+
- TARGET_XL_BOARD=true
146+
121147
sim:
122148
<<: *default_target
123149
default_tool: verilator

0 commit comments

Comments
 (0)