verilog中怎么调用ram,输入有clk,rst_n,uart_rx,输出是mem_data

2024-12-18 23:03:36
推荐回答(1个)
回答1:

#include
#include "../inc/sopc.h"
#include "system.h"
#include "string.h"

/*--------------------------------------------------------------- * Variable *---------------------------------------
*/
unsigned short * ram = (unsigned short *)(SDRAM_BASE+0x10000); //SDRAM地址
/*
* === FUNCTION ========================================
* Name: main * Description: 函数主程序 * =====================================================
*/
int main(void)
{
int i;
memset(ram,0,100); //向ram中写数据,当ram写完以后,ram的地址已经变为(SDRAM_BASE+0x10100)
for(i=0;i<100;i++){
*(ram++) = i;
}

//逆向读取ram中的数据
for(i=0;i<100;i++){
printf("%d\n",*(--ram));
}
return 0;
}