SamWibatt / VerilogSkeleton

Project framework for icestorm / verilog projects. My 13th repository! So why not a skeleton.
GNU General Public License v3.0
0 stars 0 forks source link

VerilogSkeleton: IN PROGRESS

Skeleton project for Verilog / IceStorm.

The idea is to make top.v the main module for the .bin file, and top_test.v is the testbench top module. You can have any number of submodules - see Makefile for how to organize this.

Implements a blinky for testing, which you can pull out and replace with your own design.

Usage

Zeroth, clone this repo or grab it as a zip file.

First, change the BOARD value in Makefile.icestorm to the board you plan to use. Find the line that looks like this:

BOARD ?= upduino

and replace the right-hand side with:

IF YOU ARE USING AN ICESTORM-COMPATIBLE BOARD NOT IN THAT LIST, YOU MAY NEED TO ADD A PIN FILE (PCF) AND ADD ITS CONFIGURATION VALUES FOR DEVICE AND PACKAGE TO Makefile.icestorm.

Currently supported are:

Next, copy the appropriate "top" source file to top.v. For instance, if you're building for icestick, do

cp top-icestick.v top.v

OR you can change the list of required files in Makefile for the alldeps target from

alldeps = top.v $(submodules) to

alldeps = top-icestick.v $(submodules)

(VERIFY THAT THIS WORKS!)

modifying to suit

  1. Rename files as you like, reflecting changes in Makefile.
  2. when you add new module .v files, be sure to add them to alldeps in Makefile.
  3. change top.v and top-test.v as needed; I recommend keeping them as much the same as possible - I think "minimal top" is a nice design idea but I'm a n00b and may be totally wrong
    1. However, I recommend putting hardware-specific stuff in top.v

building

make all is intended to build the .bin output file to send to the target hardware.

toolchain is yosys / nextpnr / icepack

make test is intended to build a simulation

top-test.v as written will work with all platforms; it doesn't use any of the hardware-specific settings. Try to keep it that way.

toolchain is iverilog / vvp / vcd2fst, yielding a .fst file that can be viewed in gtkwave

make clean does the usual cleanup of all the non-source files.

stdout and stderr are redirected during the compile, to build_top_out.txt and build_top_err.txt for the "all" target, to sim_top_tb_out.txt and sim_top_tb_err.txt in the "test" target.

Makefile, Makefile.icestorm, and upduino_v2.pcf are copied and modified from osresearch's code at https://github.com/osresearch/up5k licensed under GPL3

tinyfpga-bx.pcf is copied and modified from Luke Valenty's pins.pcf code at https://github.com/tinyfpga/TinyFPGA-BX/tree/master/apio_template, licensed under CERN Open Hardware Licence v1.2.

icestick.pcf is copied and modified from Juan Gonzalez's code at https://github.com/FPGAwars/apio-examples

test to see if markdown on github can syntax highlight verilog

Oh wow it looks like the Atom previewer, anyway

And indeed github does too!

//Based on Dan Gisselquist's blinky at https://zipcpu.com/blog/2017/05/19/blinky.html
`default_nettype none

module blinky(
    input wire i_clk,
    output wire o_led
);

    parameter CBITS = 26;

    reg [CBITS-1:0] counter = 0;
    always @(posedge i_clk)
        counter <= counter + 1'b1;
    assign o_led = counter[CBITS-1];
endmodule