George Mason University
Software/Hardware Co-design
Using the FPro System
Part 1: Sorting Core
ECE 448
2
Developing a software/hardware
implementation using an FPro system
Conceptual Design:
C1. Software/hardware partitioning C2. I/O register map of the IP core
Hardware Design:
H1. Basic circuit performing the required functionality
* datapath * controller * top-level * functional verification H2. A wrapper matching the interface of an MMIO core
* design adjustments * coding * functional verification
Software Design:
S1. Software driver
* declarations (.h) * implementations (.cpp) * testing
3
Software/Hardware Co-design
4
Software/Hardware Co-design
time C1 C2 H1 H2 S1 S2 C1 C2 H1 H2 S1 S2 C1 C2 H1 H2 S1’ S1”Approach 1 Approach 2 Approach 3
S2’
S2’’
Driver development
App development Part 1 & preliminary testing
Driver testing
App development Part 2 & final testing
SW/HW partitioning
Custom core – basic function
I/O Register Map
Software/Hardware Partitioning: Lab 5
5
• Setting Size of Memory • Initializing Memory
• Display Mode
• Sorting in Software • Cycle Count Display
• Sorting in Hardware Application [main_sorting.cpp]: Custom Core [sorting_core.vhd]: Custom Driver [sorting_core.h, sorting_core.cpp]: • SortingCore class • Transfer of Data SW=>HW • Sorting in Hardware • Reading Results HW=>SW
Independent of hardware core:
Standard Drivers to be Used
6
Driver Major Functionality Description of functions in
TimerCore Measuring Time timer_core.h GpiCore Reading positions
of switches
gpio_cores.h
DebounceCore Detecting which button was pressed
gpio_cores.h
SsegCore Writing to seven segment displays
sseg_core.h
UartCore Debugging using
messages displayed in a terminal window of your computer
#include "chu_init.h" #include "gpio_cores.h" #include "sseg_core.h"
Beginning of
main_sorting.cpp
No need to have #include "timer_core.h" #include "uart_core.h"8
Developing a software/hardware
implementation using an FPro system
Conceptual Design:
C1. Software/hardware partitioning
C2. I/O register map of the IP core
Hardware Design:
H1. Basic circuit performing the required functionality
* datapath * controller * top-level * functional verification
H2. A wrapper matching the interface of an MMIO core * design adjustments * coding * functional verification
Software Design:
S1. Software driver
* declarations (.h) * implementations (.cpp) * testing
Sorting
Sorting
clk reset DataIn w DataOut w Done RAdd k WrInit s (0=initialization/readout 1=computations) RdSimulation results for the sort operation (1)
Loading memory and starting sorting
clk reset
Simulation results for the sort operation (2)
Completing sorting and reading out memory
clk reset
Before sorting
During Sorting
Aftersorting Address
0
1
2
3
3
3
2
2
1
1
1
1
2
2
3
3
3
3
2
2
4
4
4
4
4
4
4
3
1
1
1
1
2
2
3
4
i=0 i=0 i=0 i=1 i=1 i=2 j=1 j=2 j=3 j=2 j=3 j=3 Mi Mj Legend: position of memory indexed by i position of memory indexed by j
Pseudocode
wait for s=1 for i=0 to N-2 do for j=i+1 to N-1 do if Mi > Mj then Swap Mi with Mj end if end for end for Done wait for s=0 go to the beginningDINA DOUTA ADDRA WEA DINB ADDRB WEB DOUTB RAM 2k x w Mi Mj w w k w w k
Pseudocode
wait for s=1 // initialize internal memory for i=0 to N-2 do for j=i+1 to N-1 do if Mi > Mj then Swap Mi with Mj end if end for end for Done wait for s=0 go to the beginningDINA DOUTA ADDRA WEA 0 1 s WrInit clk Wr DataIn w w
Block diagram of the Datapath
s 0 1 DINB ADDRB WEB Wr DOUTB RAM 2k x w Mi Mj w w w w Addr s 0 1 RAdd k i j k k w w k
Pseudocode
wait for s=1 for i=0 to N-2 do for j=i+1 to N-1 do if Mi > Mj then Swap Mi with Mj end if end for end for Done wait for s=0 go to the beginningDINA DOUTA ADDRA WEA 0 1 s WrInit clk Wr Addr s 0 1 DataIn RAdd ld en Li Ei clk w k k k w w i j 0 k +1
Block diagram of the Datapath
s 0 1 counter DINB ADDRB WEB Wr DOUTB RAM 2k x w w Mi Mj w ld en Lj Ej clk counter w w w k k k
Pseudocode
wait for s=1 for i=0 to N-2 do for j=i+1 to N-1 do if Mi > Mj then Swap Mi with Mj end if end for end for Done wait for s=0 go to the beginningDINA DOUTA ADDRA WEA 0 1 s WrInit clk Wr Addr s 0 1 DataIn RAdd ld en Li Ei clk == N-2 == N-1 zi zj w k k k w w i j 0 k +1
Block diagram of the Datapath
s 0 1 counter DINB ADDRB WEB Wr DOUTB RAM 2k x w w Mi Mj w ld en Lj Ej clk counter w w w k k k
Pseudocode
wait for s=1 for i=0 to N-2 do for j=i+1 to N-1 do if Mi > Mj then Swap Mi with Mj end if end for end for Done wait for s=0 go to the beginningDINA DOUTA ADDRA WEA A>B 0 1 s WrInit clk Wr MigtMj Addr s 0 1 DataIn RAdd ld en Li Ei clk == N-2 == N-1 zi zj w k k k w w A i j 0 k +1
Block diagram of the Datapath
s 0 1 counter DINB ADDRB WEB Wr DOUTB RAM 2k x w B AgtB w Mi Mj w ld en Lj Ej clk counter w w w k k k
Pseudocode
wait for s=1 // read out resultsfor i=0 to N-2 do for j=i+1 to N-1 do if Mi > Mj then Swap Mi with Mj end if end for end for Done wait for s=0 go to the beginning
DINA DOUTA ADDRA WEA A>B 0 1 s WrInit clk Wr 1 0 MigtMj Addr s 0 1 DataIn RAdd Rd DataOut ld en Li Ei clk == N-2 == N-1 zi zj w k k k w w w A i j 0 k +1
Block diagram of the Datapath
s 0 1 counter DINB ADDRB WEB Wr DOUTB RAM 2k x w B AgtB w Mi Mj w 0 w ld en Lj Ej clk counter w w w k k k
w clk DataOut w WrInit s Done Wr Li Ei Lj Ej Datapath Controller RAddr k zi
Interface with the division into
the Datapath and Controller
DataIn Rd
MigtMj zj
Pseudocode
wait for s=1 for i=0 to N-2 do for j=i+1 to N-1 do if Mi > Mj then Swap Mi with Mj end if end for end for Done wait for s=0 go to the beginningASM
Chart
i=0 s j=i+1 Read Mi Read Mj Mi>Mj Swap Mi with Mj j=N-1 i=N-2 s Done j++ i++ reset 0 1 T F T F F T 0 1 S0 S1 S2 S4 S3ASM
Chart
Li s Lj MigtMj zj zi s Done Ej Ei reset 0 1 1 0 1 0 0 1 0 1 S0 S1 S2 S4 S3 WrTiming Analysis
S2 S3 S2 S3 State new j new j j new Mi new Mi Mi new Mj new Mj Mjnew MigtMj new MigtMj MigtMj
new Wr new Wr Wr