- 0
- 0
- 约1.74万字
- 约 75页
- 2019-01-02 发布于湖北
- 举报
Download to hardware-5 透過function OpenIntelCode(…)將test.hex的內容解讀並放置到WriteBuffer。 透過function WriteMemory(…)將WriteBuffer的資料寫入FPGA,目標記憶體為ROM,大小為0x200 Byte。 其實整的test.hex沒到0x200 Byte這麼大,只是個大概值以防少寫。 8051開始執行前要下達reset的指令,function P51_reset(…)。 Download to hardware-6 一切都準備好了,可以叫8051開工了;呼叫function P51_run開始執行,P51_stop停下來。 由於FPGA的特性,在執行和停止間並不知道中間已經執行了多少指令。 透過function DumpMemory(…)把xRAM的資料從FPGA讀取出來到ReadBuffer。 利用function PrintOut把ReadBuffer的資料列印在指令視窗。 Download to hardware-7 可以看到0x0的位值為變數count_up,0x10的位值為變數counter。 利用迴圈連續觀察counter上數的變化。 現在要將程式的行為改成下數。 Download to hardware-8 將count_up改成零,換句話說就是將xRAM的0x0的數值改成零。 利用WriteBuffer和function WriteMemory(…)做到這點。 Download to hardware-9 修改完count_up再觀察程式的行為 可以看到counter已經在做下數的行為了。 Download to hardware-10 程式結束前不要忘了釋放FPGA,function AppClose()。 Hardware Simulation with SystemC 從之前的Hardware Simulation的範例可以看出,Software端控制Hardware端的方式就是呼叫SIMIS提供的API。 如果想把Software端包成一個SystemC的Module,只要包含SIMIS提供的API即可。 SystemC example-1 以下用一個簡單的範例,將之前的Software端包成一個c++的class HW_P51,在SystemC module裡呼叫。 範例講解方式用兩個視點: SystemC module的呼叫和HW_P51 class裡的function做法交互介紹。 細節的function功能在之前的Hardware Simulation就已經講解過,故不再多述。 SystemC example-2 class HW_P51: 設定有四個public function: constructor,destructor,initialize和執行。 SystemC module: 要呼叫HW_P51,首先new一個HW_P51的實體並初始化。 SystemC example-3 class HW_P51: 這裡給的參數是設定成給予p51一個記憶體陣列(mem),和一個編號index。以下是HW_P51的constructor和初始化設定。 SystemC example-4 SystemC module: 初始化完成後接下來要執行。 class HW_P51: 執行的內容由使用者自行安排,讀寫記憶體或者給予8051指令可以透過以下這些指令。 SystemC example-5 SystemC module: 最後要delete p51 class HW_P51: class destructor如下: Data Transfer Operations Mnemonic Description Bytes Cycles MOV A,Rn Move register to A 1 1 MOV A,direct Move direct byte to A 2 1 MOV A,@Ri Move indirect RAM to A 1 1 MOV A,#data Move immediate data to A 2 1 MOV Rn,A Move A to register 1 1 MOV Rn,direct Move direct byte to register 2 2 MOV Rn,#data Move immediate data to register 2 1 MOV direct,A Move A to direct byte 2 1 MOV direct,Rn Move register to direct byte 2 2 MOV direc
原创力文档

文档评论(0)