您好,欢迎进入山西润盛进出口有限公司!

咨询服务热线

15383419322

Spoc CPU软核 Part 1-Hello world!

发布时间:2024-01-22 14:32人气:

Spoc 是一个 cpu...你猜怎么着?让我们用它来显示“Hello world!”。在本例中,您需要一个带有 RS-232 输出的 FPGA 板。

1. 软件

使用spoc_asm编译以下代码

// First set the stack pointer (required since we use a subroutine below) do #0x0C00 -> SPBeginString: do #GreetingString -> CSSendChar: sel CS.p do #0x1000 -> WA0 do.byte @ -> @ // transmit one byte out of RS-232 TX// check the RS-232 TX busy bit do #0x1000 -> RA0LoopTxD_ready: do.bit @ jmp.z=1 #LoopTxD_ready// check the end of string do CS-#GreetingStringEnd jmp.z=1 #SendChar// once the string is completely sent, delay before sending again jsr #Delay jmp #BeginString// delay subroutineDelay: do.dw #200000 -> ADelayLoop: dec.dw A jmp.z=1 #DelayLoop retGreetingString: data.byte "Hello world!", 13GreetingStringEnd:// that's all folks

2. 硬件

让我们将 Spoc 与 RS-232 TX 模块连接起来。合成以下代码(确保也获取async_transmitter)。

modulespoc_test(clk,TxD); inputclk; outputTxD; //firstinstantiateSpoc wirespoc_WriteData,spoc_WriteEnable,spoc_ReadData; wire[15:0]spoc_WriteAddress,spoc_ReadAddress; spocmy_first_spoc ( .clk(clk),.ExecuteOpcode_Enable(1'b1), .WriteAddress(spoc_WriteAddress),.WriteData(spoc_WriteData),.WriteEnable(spoc_WriteEnable), .ReadAddress(spoc_ReadAddress),.ReadData(spoc_ReadData) ); //secondhookituptoanRS-232TXmodule regTxD_start; reg[7:0]TxD_data;wireTxD_busy; async_transmitterasyncTX(.clk(clk),.TxD_start(TxD_start),.TxD_data(TxD_data),.TxD(TxD),.TxD_busy(TxD_busy)); always@(posedgeclk)if(spoc_WriteEnable)TxD_data[spoc_WriteAddress[2:0]]<=spoc_WriteData; always@(posedgeclk)TxD_start<=spoc_WriteEnable&(spoc_WriteAddress[2:0]==3'h7); assignspoc_ReadData=TxD_busy; endmodule

结果

如果您拥有 fpga4fun 开发板,请在配置 FPGA 后在 FPGAconf 中按 CTRL-T 以获取终端窗口。否则,只需使用您喜欢的终端软件即可!

上一篇:Spoc CPU软核(总)

下一篇:Spoc CPU软核 Part 2-主要特征

  • 联系方式
  • 传 真:
  • 手 机:15383419322
  • 电 话:15383419322
  • 地 址:山西太原市杏花岭区解放路 175 号万达中心 A 座 33 楼 3301 室
友情链接
plc控制器
自动化设备
自动化设备
伺服驱动器
在线咨询

咨询电话:

15383419322

  • 微信扫码 关注我们

Copyright © 2022-2024 山西润盛进出口有限公司 版权所有 晋ICP备2021008479号-14

晋公网安备 14010702070906号

扫一扫咨询微信客服
15383419322