Skip to content

Conversation

sukhmankkahlon
Copy link

Introduce a new hello world example for FPGA with instructions in a README and all necessary auxiliary files, as prescribed in the solution proposed for #657.

Copy link
Collaborator

@RyanGlScott RyanGlScott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thank you for writing it up!

I've left some minor review suggestions below.

The main Copilot specification is created in a file `HelloWorld.hs`. The final
contents of
[HelloWorld.hs](https://github.com/Copilot-Language/copilot/tree/master/copilot/examples/fpga/HelloWorld/HelloWorld.hs)
is available in the [examples/fpga
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should be:

Suggested change
is available in the [examples/fpga
is available in the [`examples/fpga/HelloWorld`

Comment on lines +143 to +156
of the repository. The directory contains several examples, as well as any
auxiliary files needed to run the code onto an FPGA board.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This says that the directory contains several examples, but I only see a single example (HelloWorld).

```

In the above trigger definition, `"leds"` is the name of the output, whereas
`leds` is an internal Copilot entity that, at each point in time will contain
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling leds "internal" is perhaps a bit misleading, as it is wholly possible to observe the value of the leds stream using the Copilot interpreter. Perhaps we should just say "leds is a Copilot stream that [...]".

Comment on lines +338 to +351
`mkTop.v` is successfully created in your current directory. To program the
code onto the FPGA, the ports declarations and assignments need modifications.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My hope is that after #654 is implemented upstream, we will no longer need to make modifications to the generated Verilog code. (This isn't a review suggestion so much as it is a TODO for myself.)

`mkTop.v` is successfully created in your current directory. To program the
code onto the FPGA, the ports declarations and assignments need modifications.

In our `Top.bs`, the module that had the register and interface for the leds
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In our `Top.bs`, the module that had the register and interface for the leds
In our `Top.bs`, the module that had the register and interface for the LEDs

edge of the `CLK`.

Replace / add the following lines mentioned above. For reference, the complete
contents of mkTop.v after applying the changes are included below.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
contents of mkTop.v after applying the changes are included below.
contents of `mkTop.v` after applying the changes are included below.


Once installed, open your Vivado Design Suite.

1. Click `Create Project` > `Next` > Project Name : `HelloWorld` and choose the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Click `Create Project` > `Next` > Project Name : `HelloWorld` and choose the
1. Click `Create Project` > `Next` > `Project Name` : `HelloWorld` and choose the

`Open Target` > Plug in your FPGA board via USB. > `Auto Connect` > `Program
Device`.

The LEDS on your FPGA board should now display the LEDS counting up in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The LEDS on your FPGA board should now display the LEDS counting up in
The LEDS on your FPGA board should now display the LEDs counting up in

We need an example that demonstrates how to work with FPGAs using Copilot. This
will help users start with copilot-bluespec, and also help validate our work.

This commit adds a hello world example that demonstrates how to control 4 LEDs
from 4 switches. The tutorial describes how to install Vivado, create the spec,
compile it (in bluespec and then verilog), and upload it to the board.
@sukhmankkahlon sukhmankkahlon force-pushed the develop-examples-fpga-helloworld branch from 22e142a to 24840c0 Compare August 22, 2025 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants