Commit b8d86ce2 authored by Davide Cieri's avatar Davide Cieri
Browse files

Quartus tutorial

parent 7456a696
Loading
Loading
Loading
Loading
+139 −1
Original line number Diff line number Diff line
@@ -536,6 +536,8 @@ The final configuration we need is in `Settings->CI/CD->General pipelines`. Here

The GitLab repository should be now ready to run our CI. All we need to do is setup the actual jobs. This is done in GitLab using a yaml configuration file (`.gitlab-ci.yml`), which should be in the parent path of your repository. Hog provides templates to setup the Hog-CI, using the novel dynamic CI feature from GitLab, or the standard static CI, which allows more configuration.

### 5.1 Setup the Dynamic CI

Let's try first to setup the dynamic CI. Go back to the shell with your repository and copy the template from Hog.

```bash
@@ -570,7 +572,7 @@ If everything went well you should see the pipeline starting.
![](figures/08_pipeline.png)


### Static CI
### 5.2 Setup the Static CI

To setup the static CI, copy the corresponding template from the Hog submodule

@@ -625,3 +627,139 @@ git push

Once the pipeline is succesfull, we can merge the merge the merge request. This will trigger the `main` pipeline that should tag our repository, followed by the `tag` pipeline that creates the GitLab release and the badges.

## Step 6. Create a Quartus Project

For this step you need to have Quartus installed on your local machine, and on your CI machines, in the case you want to add the Quartus build to the pipeline.

We want to implement the same BFT project in a MAX10 FPGA (`10M50DAF484C6GES`). The first step is to copy the Hog BFT project into a new directory of `Top`.

```bash
cp -r Top/BFT Top/BFT_Quartus
```

Let's modify the `hog.conf` file for Quartus. Replace its content with the following code. Change the version of quartus in the header to match with the version you are using.

```ini
#quartus 23.1

[main]
PART = 10M50DAF484C6GES
FAMILY = "MAX 10"
```

We also need some constraint files for our project. Quartus utilises `.qsf` files for the location constraints and `.sdc` for timing constraints.

Create a new folder for the Quartus constraint, somewhere in your repository.

```bash
mkdir -p quartus/con
```

Create two files `pin.qsf` and `timing.sdc` in the folder, with the following content.

::::{tab-set}
:::{tab-item} pin.qsf
set_location_assignment PIN_M8 -to wbClk
set_location_assignment  PIN_M9 -to bftClk
set_instance_assignment -name IO_STANDARD "2.5 V" -to CLK_50_MAX10
set_instance_assignment -name IO_STANDARD "2.5 V" -to CLK_25_MAX10
:::

:::{tab-item} timing.sdc
set_time_format -unit ns -decimal_places 3
create_clock -name {clk} -period 20.000 [get_ports {bftClk}]
create_clock -name {clk} -period 40.000 [get_ports {wbClk}]
:::
::::

:::{warning}
For this tutorial, we are not specifying all the pin constraints, therefore the bitstream will be unusable. The goal is just to show how to use Hog to manage a Quartus project
:::

Now modify the `Top/BFT_Quartus/list/sources.con` file to include the new constraints.

```bash
quartus/con/*
```

Let's create also folders to store the quartus sources and ips.

```bash
mkdir -p quartus/ip quartus/src
```

Make a copy of the `FifoBuffer.v` file, which we'll use to add the Quartus specific IP.

```bash
cp -r BFT/BFT.srcs/sources_1/imports/Sources/FifoBuffer.v quartus/src/FifoQuartus.v
```

Modify the `Top/BFT_Quartus/list/others.src` to include the new file.

```bash
quartus/src/FifoQuartus.v
```

We are now ready to create the Quartus project with Hog.

```bash
./Hog/Do C BFT_Quartus
```

In the output log, you should get some warnings, for the simulation files. That's ok since Hog does not support yet simulation with Quartus.

Open now the just created project with Quartus.

```bash
quartus Projects/BFT_Quartus/BFT_Quartus.qpf &
```

We need to replace the FIFO IP. In the IP Catalog window on the right, search for `FIFO` and double click to configure the IP.

Save the IP in `quartus/ip/fifo`, and select `Verilog` as type.

![](figures/09_quartus_fifo_loc.png)

Configure the Fifo as following

![](figures/10_fifo1.png)
![](figures/10_fifo2.png)
![](figures/10_fifo3.png)
![](figures/10_fifo4.png)
![](figures/10_fifo5.png)
![](figures/10_fifo6.png)
![](figures/10_fifo7.png)

Click on finish and ok to save the `.qip`. Now close the project, and open the `FifoQuartus.v` file with your editor. Remove the Vivado IP instantiation and add the following snippet to instantiate the Quartus FIFO IP.

```verilog
fifo	fifo_inst (
	.aclr ( rst ),
	.data ( din ),
	.rdclk ( rd_clk ),
	.rdreq ( rd_en ),
	.wrclk ( wr_clk ),
	.wrreq ( wr_en ),
	.q ( dout ),
	.rdempty ( empty ),
	.wrfull ( full_wire )
	);
```

Open the `Top/BFT_Quartus/ips.src` file now, to include the new IP files.

```bash
quartus/ip/fifo.qip
```

Commit all changes and launch the Quartus workflow, this time from batch, recreating the full project.

```bash
git add Top/BFT_Quartus quartus
git commit -m "FEATURE: Adding Quartus BFT project"
./Hog/Do W BFT_Quartus -recreate
```

If everything goes well, Hog should have copied to the `bin` folder the report and binary files for the Quartus project.