【iCore1S 双核心板_FPGA】例程十七:基于双口RAM的ARM+FPGA数据存取实验
实验现象:
核心代码:
- module DUAL_PORT_RAM(
- input CLK_12M,
- inout WR,
- input RD,
- input CS0,
- input [:]A,
- inout [:]DB,
- output FPGA_LEDR,
- output FPGA_LEDG,
- output FPGA_LEDB
- );
- //-------------------------------rst_n---------------------------------//
- reg rst_n;
- reg [:]cnt_rst;
- always@(posedge CLK_12M)
- begin
- if(cnt_rst=='d10)
- begin
- rst_n <= 'd1;
- cnt_rst <= 'd10;
- end
- else cnt_rst <= cnt_rst + 'd1;
- end
- //---------------------------------PLL--------------------------------//
- //实例化PLL
- my_pll u1(
- .inclk0(CLK_12M),
- .c0(PLL_48M)
- );
- //--------------------------------RAM---------------------------------//
- //实例化双口ram
- wire [:]a_dataout;
- wire [:]b_dataout;
- my_ram u2(
- .address_a(a_addr),
- .address_b(A),
- .data_a(a_datain),
- .data_b(DB),
- .clock_a(!a_clk),
- .clock_b(b_clk),
- .wren_a(a_wren),
- .wren_b('d0),
- .rden_a(a_rden),
- .rden_b(!rd),
- .q_a(a_dataout),
- .q_b(b_dataout)
- );
- //-------------------------------delay-------------------------------//
- //对CLK_12M做延时处理
- reg clk1,clk2;
- always@(posedge PLL_48M or negedge rst_n)
- begin
- if(!rst_n)
- begin
- clk1 <= 'd0;
- clk2 <= 'd0;
- end
- else
- begin
- {clk2,clk1} <= {clk1,CLK_12M};
- end
- end
- wire a_clk = (CLK_12M & clk2);
- //---------------------------------ram_cnt----------------------------//
- //ram地址数据计数器
- reg [:]cnt_addr;
- always@(posedge CLK_12M or negedge rst_n)
- begin
- if(!rst_n)
- begin
- cnt_addr <= 'd0;
- end
- else if(cnt_addr=='d511)
- begin
- cnt_addr <= 'd0;
- end
- else cnt_addr <= cnt_addr + 'd1;
- end
- //------------------------------ram_a wr&rd----------------------------//
- reg a_wren,a_rden;
- reg [:]a_datain;
- reg [:]a_addr;
- always@(posedge a_clk or negedge rst_n)
- begin
- if(!rst_n)
- begin
- a_wren <= 'd0;
- a_rden <= 'd0;
- a_datain <= 'd0;
- a_addr <= 'd0;
- end
- else if(cnt_addr >= 'd0 && cnt_addr <= 10'd255)
- begin
- a_wren <= 'd1;
- a_datain <= cnt_addr;
- a_addr <= cnt_addr;
- a_rden <= 'd0;
- end
- else if(cnt_addr>='d256 && cnt_addr <= 1'd511)
- begin
- a_rden <= 'd1;
- a_addr <= cnt_addr - 'd256;
- a_wren <= 'd0;
- end
- end
- //------------------------------a_ram_error---------------------------//
- //判断读取地址与输出数据是否相等。相等,绿灯亮;不相等,红灯亮。
- reg error;
- reg [:]led;
- always@(negedge clk1 or negedge rst_n)
- begin
- if(!rst_n)
- begin
- error <= 'd0;
- end
- else if(a_wren || a_dataout == a_addr)
- begin
- error <= 'd0;
- led <= 'b101;
- end
- else
- begin
- error <= 'd1;
- led <= 'b011;
- end
- end
- assign {FPGA_LEDR,FPGA_LEDG,FPGA_LEDB} = led;
- //-------------------------------b_ram_rd-----------------------------//
- //控制ram_b的读取功能,当读信号来临时,读取数据发送到FSMC总线上
- wire wr = (CS0 | WR );
- wire rd = (CS0 | RD);
- reg wr_clk1,wr_clk2;
- always@(posedge PLL_48M or negedge rst_n)
- begin
- if(!rst_n)
- begin
- wr_clk1 <= 'd1;
- wr_clk2 <= 'd1;
- end
- else
- begin
- {wr_clk2,wr_clk1} <= {wr_clk1,wr};
- end
- end
- wire b_clk = (!wr_clk2 | !rd);
- assign DB = !rd ? b_dataout : 'hzzzz;
- //------------------------------endmodule-----------------------------//
- endmodule
实验方法及指导书:
链接:http://pan.baidu.com/s/1hsEeYxe 密码:004h
【iCore1S 双核心板_FPGA】例程十七:基于双口RAM的ARM+FPGA数据存取实验的更多相关文章
- 【iCore1S 双核心板_FPGA】例程十二:基于单口RAM的ARM+FPGA数据存取实验
实验现象: 核心代码: module single_port_ram( input CLK_12M, input WR, input RD, input CS0, inout [:]DB, input ...
- 【iCore4 双核心板_FPGA】例程十五:基于单口RAM的ARM+FPGA数据存取实验
实验现象: 写RAM命令格式:write:地址(0-255),数据(0-65535)\cr\lf 读RAM命令格式:read:地址(0-255)\cr\lf 核心代码: int main(void) ...
- 【iCore3 双核心板_FPGA】实验十八:基于单口RAM的ARM+FPGA数据存取实验
实验指导书及代码包下载: http://pan.baidu.com/s/1i58Ssvz iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...
- 【iCore4 双核心板_FPGA】例程十六:基于双口RAM的ARM+FPGA数据存取实验
实验现象: 核心代码: int main(void) { /* USER CODE BEGIN 1 */ int i; int address,data; ; ]; ]; char *p; /* US ...
- 【iCore3 双核心板_FPGA】实验十九:基于双口RAM的ARM+FPGA数据存取实验
实验指导书及代码包下载: http://pan.baidu.com/s/1pLReIc7 iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...
- 【iCore4 双核心板_FPGA】例程十七:基于FIFO的ARM+FPGA数据存取实验
实验现象: 核心代码: int main(void) { /* USER CODE BEGIN 1 */ int i; int fsmc_read_data; ; ]; ]; char *p; /* ...
- 【iCore3 双核心板】例程十七:USB_MSC实验——读/写U盘(大容量存储器)
实验指导书及代码包下载: http://pan.baidu.com/s/1qXt1L0o iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...
- 【iCore3 双核心板_FPGA】实验二十:基于FIFO的ARM+FPGA数据存取实验
实验指导书及代码包下载: http://pan.baidu.com/s/1cmisnO iCore3 购买链接: https://item.taobao.com/item.htm?id=5242294 ...
- 【iCore1S 双核心板_FPGA】例程二:GPIO输入实验——识别按键输入
实验现象: iCore1s 双核心板上与FPGA相连的三色LED(PCB上标示为FPGA·LED),按键按下红灯点亮,松开按键红灯熄灭. 核心源代码: module KEY( input CLK_12 ...
随机推荐
- POJ1700----Crossing River
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> us ...
- SQL Server中变量的声明和使用方法
网址:http://blog.sina.com.cn/s/blog_63d0c97a0100qpy7.html 声明局部变量语法: DECLARE @variable_name DataType 其中 ...
- Python应用【PDF处理-pypdf2】
概述 Python处理PDF文件需要安装相应的库:[PyPDF2]库 使用场景 工作中可能会涉及处理pdf文件,PyPDF2就是这样一个库, 使用它可以轻松的处理 pdf 文件,它提供了读.写.分割. ...
- JavaScript基础笔记(四) JS式面向对象
JS式面向对象 一.理解对象 一)属性类型 ECMA-262 第 5 版在定义只有内部才用的特性(attribute)时,描述了属性(property)的各种特征. ECMA-262 定义这些特性是为 ...
- bootstrap datepicker显示日历
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...
- [Codeforces113C]Double Happiness(数论)
题意 给定闭区间[l,r] [l,r] [l,r],找出区间内满足t=a2+b2 t=a^{2}+b^{2} t=a2+b2的所有素数t t t的个数( a,b a,b a,b为任意正整数). 思路 ...
- mysql时间加减运算
一.MySQL 获得当前日期时间 函数 1.1 获得当前日期 + 时间(date + time) 函数:now() mysql> select now();+———————+| now() |+ ...
- show full processlist
mysql 显示哪些线程正在运行: show full processlist; 如果mysql 发生了锁表的情况,这个命令很容易知道是哪个表被什么操作锁住了
- C#_02.10_基础一_.NET框架
C#_02.10_基础一_.NET框架 一.概念: .NET框架是一个多语言组件开发和执行环境,它提供了一个跨语言的统一编程环境. 解读: 1..net框架是一个编程环境, 2.可以进行多语言的开发和 ...
- JSP(1)—基础知识
JSP(1)-基本知识 起源 在很多动态网页中绝大多数网页都是固定不变的只有局部内容需要动态产生和改变,如果使用Servlet程序来输出只有局部内容需要动态改变的网页,其中所有的的静态内容,也需要程序 ...