Download - Virtual platform
![Page 1: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/1.jpg)
Virtual platform with OpenRisc
2010/06/08 by Sean Chen
![Page 2: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/2.jpg)
Agenda
• Physical platform• Virtual platform• How to Co-Work?• Case for OpenRisc• Requirements
– SystemC /TLM– Toolchain– Other tools
• Getting Start– How to write your test program?– UART sample case– How to run and simulation ?
• References
![Page 3: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/3.jpg)
Physical platform
![Page 4: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/4.jpg)
Physical platform
• Requirements– Physical hardware
• Your IP– Include JTAG interface
• External bridge– Communication between host and target
» FT232, MAX232…
– Software• Driver
– FT232, MAX232
• Tool-chain– GDB debug– Cross compiler (gcc 4 ARM)
![Page 5: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/5.jpg)
Physical platform
• Background– Firmware
• Software control– Compiler
– Tool chain
– How to debug?
• hardware control– Memory map
– Configure register
– Timing sequence
![Page 6: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/6.jpg)
Virtual platform
Black Box(c)
TDI
TDOTMSTCLK
TRST
JTAG(SystemC)
GDB (Client)
Wrapper (SystemC)
Console(Host)
Using the software platform to model the hardware components
Benefits: Fast, build easily, debug quickly ….
Effort: Model building (the Model accurately issue)
![Page 7: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/7.jpg)
Virtual platform V.S Physical platform
• Virtual platform– High level control
• Software – C / SystemC / GDB….
» Dynamic» Portable
• Physical platform– Low level control
• Hardware devices– C
» Driver» Memory map» Configure register
Physical
virtual
![Page 8: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/8.jpg)
Virtual && Physical Co-Work
Virtual platform
Physical platform
![Page 9: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/9.jpg)
Case for OpenRisc
• How to build the virtual platform– Test model
• OpenRisc– C / Verilog
– Wrapper• C 2 SystemC
– Cross Compiler• executable• Debug
– Instruction set• Instruction definition
– putc -> asm()– printf
![Page 10: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/10.jpg)
OpenRisc
• Architecture
JTAG
UART
![Page 11: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/11.jpg)
OpenRisc
• Memory Map
Boot loader location
![Page 12: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/12.jpg)
Requirements/SystemC/TLM
• What’s SystemC?– SystemC processes can communicate in a simulated real-time e
nvironment, using signals of all the datatypes offered by C++, some additional ones offered by the SystemC library, as well as user defined. In certain respects, SystemC deliberately mimics the hardware description languages VHDL and Verilog, but is more aptly described as a system-level modeling language
• What’s TLM?– Transaction-level modeling (TLM) is a high-level approach to
modeling digital systems where details of communication among modules are separated from the details of the implementation of functional units or of the communication architecture. Communication mechanisms such as busses or FIFOs are modeled as channels,
![Page 13: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/13.jpg)
Requirements/Toolchain
• what’s Toolchain?– a toolchain is the set of programming tools that are used to crea
te a product (typically another computer program or system of programs). The tools may be used in a chain, so that the output of each tool becomes the input for the next, but the term is used widely to refer to any set of linked development tools.
• Requirements– GNU compiler (cross compiler)
• GCC• GDB• Lib …• Patch
![Page 14: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/14.jpg)
Requirements/other tools
• Verilog-Perl– Verilog Parser– Include
• Syntax Tree • SigParser • Netlist • …
• System-Perl– SystemPerl is a version of the SystemC language. It is designed
to expand text so that needless repetition in the language is minimized. By using sp_preproc, SystemPerl files can be expanded into C++ files at compile time, or expanded in place to make them valid stand-alone SystemC files.
![Page 15: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/15.jpg)
Requirements/other tools
• Verilator– Verilator is the fastest free Verilog HDL simula
tor, and beats many commercial simulators. It compiles synthesizable Verilog (not test-bench code!), plus some PSL, SystemVerilog and Synthesis assertions into C++ or SystemC code
![Page 16: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/16.jpg)
Getting start 1/2
• Download requirements && Path set – Toolchain and other tools
• Ref: http://funningboy.blogspot.com/2010/05/openrisc-4-install.html
– Waveform or simulation tool• gtkwave / Modelsim( default Icarus Verilog simulation)
• File lists– or32-elf
• bin• Include• lib• …
– Or1ksim-0.0.3 (software link)
![Page 17: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/17.jpg)
Getting start 2/2• Download orpsocv2
– Ref: http://opencores.org/openrisc,orpsocv2
• File lists– sw
• Our test program location– Sim
• Our simulation result and Makefile location– rtl
• orpsocv2 rtl verilog code– Bench
• Systemc interface 2 orpsocv2– Boards
• Real board support (xilinx)– Backend
• Lib and pll define
![Page 18: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/18.jpg)
Top Platform
Host
Testprog
![Page 19: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/19.jpg)
How to write your test program?
– Instruction support• Assembly support
– Register type– Instruction set– Memory address /space– Control sequence– Exception
*.S Compiler
*.c
*.bin
void or32_exit (int i){asm("l.add r3,r0,%0": : "r" (i));asm("l.nop %0": :"K" (NOP_EXIT));while (1);}
![Page 20: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/20.jpg)
UART sample casevoid except vectors…
void syscall_except(){}
void dpf_except(){}
…
Void uart_print_str(char *);
Void uart_print_long(unsigned long);
Int main(){
uart_init();
uart_print_str(“Hello World.\n\t”);
report(0xdeaddead);
or32_exit(0);
}
Name: uart_init()
//set control register / status register
REG8(UART_BASE+UART_IER) = 0x00;
…
//set baud rate
devisor = IN_CLK/(16 * UART_BAUD_RATE);
REG8(UART_BASE+UART_LCR) |= UART_LCR_DLAB
….
Name : reset()
//reset register , status , interrupt , and DMA…
Name : main()
//pc pointer to main
Name : or32_exit()
![Page 21: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/21.jpg)
UART sample case0x000021b0 <main+0>: l.addi r1,r1,-80x000021b4 <main+4>: l.sw 4(r1),r20x000021b8 <main+8>: l.addi r2,r1,80x000021bc <main+12>: l.sw 0(r1),r90x000021c0 <main+16>: l.jal <uart_init> 0x000021c4 <main+20>: l.nop 00x000021c8 <main+24>: l.movhi r3,0x00x000021cc <main+28>: l.ori r3,r3,0x3da40x000021d0 <main+32>: l.jal <uart_print_str>0x000021d4 <main+36>: l.nop 00x000021d8 <main+40>: l.movhi r3,0xdead0x000021dc <main+44>: l.jal <report>0x000021e0 <main+48>: l.ori r3,r3,0xdead0x000021e4 <main+52>: l.jal <or32_exit>0x000021e8 <main+56>: l.addi r3,r0,00x000021ec <main+60>: l.lwz r9,0(r1)0x000021f0 <main+64>: l.lwz r2,4(r1)0x000021f4 <main+68>: l.jr r90x000021f8 <main+72>: l.addi r1,r1,8
store current PI (program pointer)2 main function
Call uart_init
![Page 22: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/22.jpg)
How to run and simulation ?
• Software image creation – ELF files– Verilog Memory (VMEM) files
• This is a hex format suitable for loading into Verilog simulations
– command • # or32-elf-objcopy -O binary myapp.or32elf myapp.
bin • #bin2vmem myapp.bin > myapp.vmem
![Page 23: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/23.jpg)
Event-driven simulation
• Default Icarus Verilog– The event-driven simulation tests are configured main
ly by a single command file for Icarus. This command file is generated for each test. Another generated file is a header file defining some things such as the name of the test
– Command• #vvp a.out• #vvp -M../../bench/verilog/vpi/c -mjp_vpi a.out
![Page 24: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/24.jpg)
Cycle-accurate simulation
• Load a program – #../vlt/Vorpsoc_top -f myapp.or32
• Enable debugging via GDB– #../vlt/Vorpsoc_top -r portNum
• Standard log file (human readable) – #../vlt/Vorpsoc_top --log executed.log
• Binary log file – #../vlt/Vorpsoc_top --binlog executed.binlog
• Reading a binary log file – #../../sw/utils/binlog2readable executed.binlog -o executed.log
![Page 25: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/25.jpg)
Cycle-accurate simulation
• Bus transactions log – #../vlt/Vorpsoc_top --bus-log
• VCD generation – VCD dump
• #../vlt/Vorpsoc_top --vcdfile mydump.vcd
– VCD dump with time set• #../vlt/Vorpsoc_top --vcdfile mydump.vcd --vcdstart
15000 --vcdstop 25000
![Page 26: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/26.jpg)
Cycle-accurate simulation
• Memory dump– dump memory area
• #../vlt/Vorpsoc_top --memdump memdump.bin 0x2000 0x10000
• Crash monitor – #../vlt/Vorpsoc_top -c
![Page 27: Virtual platform](https://reader034.vdocuments.us/reader034/viewer/2022052618/554f62feb4c905c8088b4b7c/html5/thumbnails/27.jpg)
References
• OpenRisc– http://opencores.org/openrisc,orpsocv2#own_
software
• embecosm– http://www.embecosm.com/