
foundations of embedded systems 3
The hardware evaluation board you are using in this course is the iCE40
Mobile Development Platform (MDP). It contains four of the iCE5UP5Ks (U1,
U2, U3, and U4 on the board and in the schematics). The DIP switch SW5
determines which one of them you program at a given time. The default
setting of SW5 with both switch positions ON will program the U4 FPGA
which is at the bottom side of the MDP board (Figure
1.1).
Figure 1.1: The MDP
board, contains four
iCE5UP5K FPGAs. You
will use FPGA U4 for this
exercise and we recom-
mend you use it for the
remainder of the course.
1.3 A simple Verilog design
The example below is a simple Verilog design. You can find it in the file
verilog/hardware/blink/blink.v (from the top of the project repository).
Like all Verilog designs, it is organized into modules which represent blocks of
functionality. The module blink has only an output (led) and has no inputs.
The design contains a wire (clk), a 1-bit register of flip-flop (LEDstatus) and
a 4-bit register (count). All FPGAs contain some number of fixed hardware
resources, such as clock generators. The iCE5UP5K contains a high-frequency
clock generator module, named SB
_
HFOSC, that outputs a 48 MHz clock. The
iCE5UP5K also contains a low-frequency clock generator, named SB
_
LFOSC,
module that outputs a 10 kHz clock.
The construct beginning with SB
_
HFOSC OSCInst0 on line 12 creates an
instance of the SB
_
HFOSC module, named OSCInst0. In creating this instance,
we wire up the output of the OSCInst0 clock generator module instance to
our wire clk.
The block of Verilog statements from lines 21 through line 29 are what
is called a procedural block. The hardware that will eventually correspond to
the statements inside an always procedural block such as this, is updated
simultaneously and this update occurs on the condition in parenthesis fol-
lowing the @ symbol: the signals in this list are called the sensitivity list. In
our example, the hardware changes state on each positive edge (posedge) of
the clk signal. Every 2.5 million positive clock cycle edges, the 1-bit register
LEDstatus will therefore toggle in value.
Lastly, the last statement in the design, on line 34, connects the 1-bit regis-
ter LEDstatus to the output of the module.
1 ‘define kFofE
_
HFOSC
_
CLOCK
_
DIVIDER
_
FOR
_
1Hz 24000000
2
3 module blink(led);
4 output led;
5
6 wire clk;
7 reg LEDstatus = 1;
8 reg [31:0] count = 0;
9
10 /
*
11
*
Creates a 48MHz clock signal from