0% found this document useful (0 votes)
58 views

Picoblaze 2022

The document describes the steps for designing a Picoblaze embedded system using Fidex and Vivado tools. The steps include: writing assembly code in Fidex, simulating the code, generating an instruction memory file, combining the memory with the Picoblaze design in Vivado, writing a testbench, and simulating in Vivado. It also provides overviews of the Picoblaze processor features, instruction set, and interfaces. Programming is done in Fidex, which can generate HDL output for the instruction memory to use in Vivado.

Uploaded by

Alex Pérez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Picoblaze 2022

The document describes the steps for designing a Picoblaze embedded system using Fidex and Vivado tools. The steps include: writing assembly code in Fidex, simulating the code, generating an instruction memory file, combining the memory with the Picoblaze design in Vivado, writing a testbench, and simulating in Vivado. It also provides overviews of the Picoblaze processor features, instruction set, and interfaces. Programming is done in Fidex, which can generate HDL output for the instruction memory to use in Vivado.

Uploaded by

Alex Pérez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

PICOBLAZE DESIGN

Intro. to Embedded Systems - EHB326E

SERDAR DURAN
ITU Embedded System Design Laboratory

1 gstl.itu.edu.tr
Picoblaze Design Steps
I. Write your algorithm as an Assembly Code
II. Simulate your Assembly Code in Fidex IDE
III.Generate your instruction memory from Fidex IDE
IV. Combine your instruction memory and picoblaze design in Vivado
(implementation of the picoblaze in an FPGA)
V. Write a testbench file to make a simulation.
VI. Make your simulations in Xilinx Vivado

2 gstl.itu.edu.tr
Vivado and Fidex Environments
• Install one of the recent version of Xilinx Vivado:
https://www.xilinx.com/support/download.html

• Install Fidex IDE – FIDEx 2016-01.0:


https://www.fautronix.com/en/en-fidex-downloads

• Download the ‘‘PicoBlaze for UltraScale, 7-series, 6-series FPGAs’’ design files:
https://www.xilinx.com/products/intellectual-property/picoblaze.html#design

3 gstl.itu.edu.tr
Picoblaze Overview

4 gstl.itu.edu.tr
Picoblaze
• The PicoBlaze processor is a simple 8-bit microcontroller specifically designed and
optimized for Xilinx FPGA devices.
• Basic Features:
• 8-bit data width,
• 8-bit ALU with carry and zero flags,
• 16 8-bit general-purpose registers,
• 64-byte data memory (Scratchpad RAM, 64*8 bit),
• 8 input and 8 output pins,
• 8 bit port identifier, meaning 256 addressable input and output ports,
• 2 clock cycles per each instruction.

*Link: PicoBlaze 8-bit Embedded Microcontroller User Guide

5 gstl.itu.edu.tr
6 gstl.itu.edu.tr
7 gstl.itu.edu.tr
Interfaces
• IN_PORT [7:0] : 8-bit data
• OUT_PORT [7:0] : 8-bit data
• PORT_ID [7:0] : port address for both
INPUT and OUTPUT pins

• READ_STROBE : indicating input


operation is done
• WRITE_STROBE : indicating output
operation is done

8 gstl.itu.edu.tr
Instruction Format
• Instruction Format:
• op sX,sY ; register-register format. sX = sX op sY
• op sX,KK ; register-constant format. sX = sX op KK
• op sX ; single-register format. sX = op sX
• op AAA ; single-address format (jump and call operations).

• Instruction Types:
• Arithmetic
• Logical
• Shift and Rotate
• Data Transfer
• Branch Instructions

9 gstl.itu.edu.tr
Instruction Set
• Arithmetic Instructions: ADD, ADDC, SUB, SUBC
• ADD sX, constant ; sX = sX + constant
• ADD sX, sY ; sX = sX + sY

• ADDC sX, constant ; sX = sX + constant + carry bit


• ADDC sX, sY ; sX = sX + sY + carry bit

• Logical Instructions: AND, OR, XOR


• AND sX, constant ; sX = sX & constant
• AND sX, sY ; sX = sX & sY

10 gstl.itu.edu.tr
Instruction Set
• Comparison Instructions: COMP, COMPC, TEST, TESTC
• COMP sX, sY ; if regY > regX, then set CARRY, if regY = regX then set ZERO flag.
• COMP sX, const ; if regY > const, then set CARRY, if regY = regX then set ZERO flag.

• Shift and Rotate: SL0, SL1, SLA, SLX, SR0, SR1, SRA, SRX, RL, RR
• SL0 sX ; shift register sX left, zero fill
• SR1 sX ; shift register sX right, one fill

• Branch Instructions: JUMP, RETURN


• JUMP aaa ; Unconditionally jump to aaa label
• JUMP C aaa ; If CARRY flag set, jump to aaa label
• JUMP Z aaa ; If ZERO flag set, jump to aaa label

11 gstl.itu.edu.tr
Instruction Set
• Data Transfer Instructions: LOAD, FETCH, STORE, INPUT, OUTPUT
• LOAD sX, constant ; Load register sX with constant
• LOAD sX, sY ; Load register sX with sY

• WRMEM sX, scrpdAddr ; store regX into the memory at address scrpdAddr.
• WRMEM sX, ( sY ) ; store regX into the memory at address (sY).

• RDMEM sX, scrpdAddr ; fetch the value at address scrpdAddr into the sX.
• RDMEM sX, ( sY ) ; fetch the value at address (sY) into the sX.

• WRPRT sX, busAddr ; output value on output port busAddr


• RDPRT sX, (sY) ; input value on input port (sY)

12 gstl.itu.edu.tr
Fidex Part

13 gstl.itu.edu.tr
Default Specifications for Verilog
#ifDef proc::xPblze6
Picoblaze 6 Configs
; PICOBLAZE 6 CONFIGs
• Scratchpad RAM size
#set proc::xPblze6:: scrpdSize, 64 ; [64, 128, 256]
#set proc::xPblze6:: clkFreq, 100000000 ; in Hz
• Clock frequency

; INST MEMORY SPECs


#set IOdev::BRAM0:: en, TRUE
#set IOdev::BRAM0:: type, mem
Instruction Memory Settings
#set IOdev::BRAM0:: size, 4096
• Page Size
#set instmem:: pageSize, 4096
#set instmem:: pageCount, 1
• Page number
#set instmem:: sharedMemLocation, loMem ;[ hiMem, loMem ]
#set IOdev::BRAM0:: value, instMem

; VERILOG OUTPUT FILES


#set IOdev::BRAM0:: verilogEn, TRUE
#set IOdev::BRAM0:: verilogEntityName, "BRAM0" Verilog Output File Settings
#set IOdev::BRAM0:: verilogTmplFile, "ROM_form.v" • ROM_form.v is a template
#set IOdev::BRAM0:: verilogTargetFile, "BRAM0.v" • BRAM0.v is the Verilog output for
#endIf instruction memory

14 gstl.itu.edu.tr
Default Specifications for VHDL
#ifDef proc::xPblze6
; PICOBLAZE 6 CONFIGs
#set proc::xPblze6:: scrpdSize, 64 ; [64, 128, 256]
#set proc::xPblze6:: clkFreq, 100000000 ; in Hz

; INST MEMORY SPECs


#set IOdev::BRAM0:: en, TRUE
#set IOdev::BRAM0:: type, mem
#set IOdev::BRAM0:: size, 4096
#set instmem:: pageSize, 4096
#set instmem:: pageCount, 1
#set instmem:: sharedMemLocation, loMem ;[ hiMem, loMem ]
#set IOdev::BRAM0:: value, instMem

; VERILOG OUTPUT FILES


#set IOdev::BRAM0:: vhdlEn, TRUE
#set IOdev::BRAM0:: vhdlEntityName, "BRAM0" VHDL Output File Settings
#set IOdev::BRAM0:: vhdlTmplFile, "ROM_form.vhd" • ROM_form.vhd is a template
#set IOdev::BRAM0:: vhdlTargetFile, "BRAM0.vhd" • BRAM0.vhd is the VHDL output for
#endIf instruction memory

15 gstl.itu.edu.tr
Example - Fidex
Program Counter

Flags (Carry, Zero, Interrupt_Enable)


; starting address
#ORG ADDR, 0

LOAD s0, 0
LOAD s1, 1

loop: ADD s0, s1


COMP s0, 63
WRMEM s0,(s0)
JUMP C, loop
General Purpose Registers
Simulation
end: JUMP end

; fill the scratchpad RAM with


values 0 to 63 (0x3F)

Scratchpad RAM

16 gstl.itu.edu.tr
Instruction Set
Manual
help->content

17 gstl.itu.edu.tr
Generate the HDL output Reset Run all the
of instruction memory Simulation codes

Run Simulate Give an Simulate Next Change the


Assembler your code external instruction numeric base
interrupt

18 gstl.itu.edu.tr
Coding Steps
1) Open or Create a new project
2) Make a configuration for your project
• Xilinx Picoblaze 6
• Scratchpad Size 64
• Interrupt vector address 1023
• Clock frequency 100 MHz
3) Write the default specifications (Verilog or VHDL)
4) Write your Assembly code
5) Run Assembler
6) Make a Simulation
7) Generate the HDL file if there is no problem with your code.
8) BRAM0.v or BRAM0.vhd will be your instruction memory file.

19 gstl.itu.edu.tr
Vivado Part

20 gstl.itu.edu.tr
Creating Project
• Create a new project in Vivado and use either Nexys4 DDR board or xc7a100tcsg324-1 chip. (they
are same)
• Please look at the online tutorial here!

• To install the NEXSYS 4 DDR


boardfile click here!

21 gstl.itu.edu.tr
Creating Project

22 gstl.itu.edu.tr
Vivado Part
• Fidex IDE generates instruction memory according to your assembly code.
• Picoblaze projects are implemented by combining generated instruction memory and picoblaze
design file.
• You can write a top entity that combine BRAM0 (inst memory) and KCPSM6 (picoblaze) files.

BRAM0.vhd kcpsm6.vhd

top.vhd

23 gstl.itu.edu.tr
• Include the generated BRAM0.vhd, kcpsm6.vhd and top.vhd as Design Sources.

24 gstl.itu.edu.tr
25 gstl.itu.edu.tr
Vivado Part
• After adding Design Files you can see the hierarchy between these files.
• To see your design works as expected you need to write a testbench file and add
it as a Simulation Source File.

Top entity includes inst_memory and picoblaze

Picoblaze (kcpsm6.vhd)

instruction memory (BRAM0.vhd)

26 gstl.itu.edu.tr
• Include the top_tb.vhd as a Simulation Source.

27 gstl.itu.edu.tr
28 gstl.itu.edu.tr
Vivado Part
• Hierarchy between these entities (files):

Top entity includes inst_memory and picoblaze

Picoblaze (kcpsm6.vhd)

instruction memory (BRAM0.vhd)

Testbench file for simulation (top_tb.vhd)

29 gstl.itu.edu.tr
Vivado Part
• If the top_tb.vhd testbench is not seen as top entity (bald) ‘‘ right click->Set as Top’’ this
entity.

30 gstl.itu.edu.tr
• After adding the design files and top_tb.vhd simulation file you can make a simulation
for your design.

To add design and simulation files

Click Run Behavioral Simulation

31 gstl.itu.edu.tr
• After running behavioral simulation you can see the waveform of the ports and signals of the
picoblaze.

Picoblaze and Inst_memory


entities inside the top entity Ports and Signals waveform

32 gstl.itu.edu.tr
Advance the simulation(waveform)
for 1 us more Restart the Simulation

33 gstl.itu.edu.tr
• Values of registers, buses, ports, ram etc. can be found from the scope and objects section
• Drag these objects to the waveform and restart the simulation.

Spad Memory Values Spad Memory Values in the time diagram


34 gstl.itu.edu.tr
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; top_tb.vhd - Testbench File
entity top_tb is
end top_tb;

architecture Behavioral of top_tb is


component top is
Port ( clk : in STD_LOGIC;
in_port : in STD_LOGIC_VECTOR (7 downto 0);
port_id : out STD_LOGIC_VECTOR (7 downto 0);
out_port : out STD_LOGIC_VECTOR (7 downto 0);
Ports of the top file
write_strobe : out STD_LOGIC;
read_strobe : out STD_LOGIC;
interrupt : in STD_LOGIC;
interrupt_ack : out STD_LOGIC );
end component top;

signal clk : STD_LOGIC;


signal in_port : STD_LOGIC_VECTOR(7 downto 0);
signal port_id : STD_LOGIC_VECTOR(7 downto 0);
signal out_port : STD_LOGIC_VECTOR(7 downto 0);
signal write_strobe : STD_LOGIC;
signal read_strobe : STD_LOGIC;
signal interrupt : STD_LOGIC;
signal interrupt_ack : STD_LOGIC;

begin
uut: top
port map( clk => clk, in_port => in_port, port_id => port_id, out_port => out_port, write_strobe =>
write_strobe, read_strobe => read_strobe, interrupt => interrupt, interrupt_ack => interrupt_ack ); Port connections
process
begin
clk <= '0'; wait for 5ns;
clk <= '1'; wait for 5ns; Clock signal 10ns period
end process;

end Behavioral;

35 gstl.itu.edu.tr
`timescale 1ns / 1ps top_tb.v - Testbench File

module top_tb();
reg clk = 1'b0;
reg [7:0] in_port;
wire [7:0] port_id;
wire [7:0] out_port;
wire write_strobe;
wire read_strobe;
reg interrupt;
wire interrupt_ack;
Clock signal 10ns period
always #5 clk = ~clk;

top UUT(
.clk(clk),
.in_port(in_port),
.port_id(port_id),
.out_port(out_port), Port connections of the top file
.write_strobe(write_strobe),
.read_strobe(read_strobe),
.interrupt(interrupt),
.interrupt_ack(interrupt_ack)
);

endmodule

36 gstl.itu.edu.tr
Implementation of the Picoblaze in an FPGA
1) Create a new project in Vivado.
2) Take kcpsm6.vhd and BRAM0.vhd (generated from Fidex IDE) design files and
add them as design sources.
3) Take top.vhd file that provided for you or write a new one and add it as a
Design Source.
4) Take top_tb.vhd or top_tb.v file that provided for you or write a new one and
add it as a Simulation Source.
5) Run Behavioral Simulation and check the objects and waveform to see your
algorithm works properly.

37 gstl.itu.edu.tr
Vivado Block Design

38 gstl.itu.edu.tr
Vivado Block Design
• Any blocks (entities) can be included into a project alongside with the Picoblaze.
• You can add predefined IP Blocks in Vivado (like Block RAM).
• You can also add your own designed entities.

• An Example:

Com.
Block RAM #1 Picoblaze Interface #2 Picoblaze
(e.g. UART)

39 gstl.itu.edu.tr
Vivado Block Design
• Create a project and add BRAM0.vhd, kcpsm6.vhd and top.vhd files into this project as Design
Sources.
• Then click ‘‘Create Block Design’’ .

• Let the design


name as top.

40 gstl.itu.edu.tr
• Drag top.vhd file into the Diagram window.

41 gstl.itu.edu.tr
42 gstl.itu.edu.tr
• To create the ports ‘’right click->make external’’

43 gstl.itu.edu.tr
• You can change the names of the ports.

44 gstl.itu.edu.tr
45 gstl.itu.edu.tr
Including a Block RAM
• Click IP Catalog
• Type Block Memory Generator

46 gstl.itu.edu.tr
• Add IP to Block Design

47 gstl.itu.edu.tr
• Double click to customize Block RAM

48 gstl.itu.edu.tr
• Change the default specifications:

49 gstl.itu.edu.tr
• We have 8-bit bus.
( Picoblaze is an 8-bit
microcontroller )
• 256 different locations
can be addressable.
(Port id is 8 bit)

50 gstl.itu.edu.tr
• After customizing Block RAM, make the following connections:
• port_id to addra
• out_port to dina
• in_port to douta
• Create ena and wea ports.

51 gstl.itu.edu.tr
• Right click on design_1 -> Create HDL Wrapper

52 gstl.itu.edu.tr
• A top entity called design_1_wrapper is generated by Vivado.
• design_1_wrapper combines the top (picoblaze + inst memory) and Block RAM.

53 gstl.itu.edu.tr
BRAM0.vhd kcpsm6.vhd

top.vhd Block RAM

design_1_wrapper

Testbench

54 gstl.itu.edu.tr
• Write a testbench file and add it as a Simulation Source File.
`timescale 1ns / 1ps block_design_verilog_tb.v - Testbench File

module block_design_verilog_tb();
reg clk = 1'b0;
reg ena;
reg [0:0] wea;
reg interrupt;
wire interrupt_ack;
wire read_strobe;
wire write_strobe;
wire k_write_strobe;
Clock signal 10ns period
always #5 clk = ~clk;

design_1_wrapper UUT(
.clk(clk),
.ena(ena),
.wea(wea),
.interrupt(interrupt), Port connections of the
.interrupt_ack(interrupt_ack),
design_1_wrapper file
.read_strobe(read_strobe),
.write_strobe(write_strobe),
.k_write_strobe(k_write_strobe)
);

endmodule

55 gstl.itu.edu.tr
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; block_design_tb.vhd - Testbench File
entity block_design_tb is
end block_design_tb;

architecture Behavioral of block_design_tb is


component design_1_wrapper is
port ( clk : in STD_LOGIC;
ena : in STD_LOGIC;
interrupt : in STD_LOGIC;
interrupt_ack : out STD_LOGIC;
Ports of the
k_write_strobe : out STD_LOGIC; desing_1_wrapper file
read_strobe : out STD_LOGIC;
wea : in STD_LOGIC_VECTOR ( 0 to 0 );
write_strobe : out STD_LOGIC
);
end component design_1_wrapper;

signal clk : STD_LOGIC;


signal ena : STD_LOGIC;
signal interrupt : STD_LOGIC;
signal interrupt_ack : STD_LOGIC;
signal k_write_strobe : STD_LOGIC;
signal read_strobe : STD_LOGIC;
signal wea : STD_LOGIC_VECTOR ( 0 to 0 );
signal write_strobe : STD_LOGIC;

begin
uut: design_1_wrapper
port map( clk => clk, ena => ena, interrupt => interrupt, interrupt_ack => interrupt_ack,
k_write_strobe => k_write_strobe, read_strobe => read_strobe, wea => wea, write_strobe => write_strobe); Port connections
process
begin
clk <= '0'; wait for 5ns;
clk <= '1'; wait for 5ns; Clock signal 10ns period
end process;

end Behavioral;

56 gstl.itu.edu.tr
References
• Picoblaze user guide

57 gstl.itu.edu.tr

You might also like