From bcdc32a2e16087cecd11e6f018f4c5695d425919 Mon Sep 17 00:00:00 2001 From: WangXuan95 <629708558@qq.com> Date: Mon, 4 Apr 2022 19:07:30 +0800 Subject: [PATCH] update --- README.md | 12 ++++++------ example-selftest/{RTL => }/axi_self_test_master.sv | 0 example-selftest/ddr_test.qsf | 4 ++-- example-selftest/{RTL => }/top.sv | 0 .../UartSession.exe | Bin example-uart-read-write/ddr_test.qsf | 4 ++-- example-uart-read-write/{RTL => }/top.sv | 0 example-uart-read-write/{RTL => }/uart2axi4.sv | 3 ++- 8 files changed, 12 insertions(+), 11 deletions(-) rename example-selftest/{RTL => }/axi_self_test_master.sv (100%) rename example-selftest/{RTL => }/top.sv (100%) rename UartSession.exe => example-uart-read-write/UartSession.exe (100%) rename example-uart-read-write/{RTL => }/top.sv (100%) rename example-uart-read-write/{RTL => }/uart2axi4.sv (96%) diff --git a/README.md b/README.md index 93cbb5e..cc79be0 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ FPGA DDR-SDRAM 很多低端 FPGA 开发板使用 SDR-SDRAM 作为片外存储,而 DDR-SDRAM (DDR1) 比 SDR-SDRAM 容量更大,价格更低。且与SDR-SDRAM一样,DDR1也能使用低端FPGA的普通的IO管脚直接驱动。我编写了一个软核的 AXI4 接口的 DDR1 控制器。该控制器的特点有: -* **平台无关** :纯 RTL 编写,可以在 Altera 和 Xilinx 等各种 FPGA 上运行。 +* **平台无关** :纯 SystemVerilog 编写,可以在 Altera 和 Xilinx 等各种 FPGA 上运行。 * **兼容性强** :支持各种位宽和容量的 DDR1 (已在MICRON所有位宽和容量的DDR1型号上仿真通过)。 为了展示该控制器的使用方法,我提供了两个示例程序: @@ -343,8 +343,8 @@ AXI4 总线的地址(awaddr和araddr)统一是字节地址,模块会根据 | 文件名称 | 用途 | | :---- | :--- | -| example-selftest/RTL/top.sv | 顶层 | -| example-selftest/RTL/axi_self_test_master.sv | 是 AXI4 主机,通过 AXI4 先把有规律的数据写入 DDR1,然后读回,比较读回的数据是否符合规律,并对不匹配的情况进行计数。 | +| example-selftest/top.sv | 顶层 | +| example-selftest/axi_self_test_master.sv | 是 AXI4 主机,通过 AXI4 先把有规律的数据写入 DDR1,然后读回,比较读回的数据是否符合规律,并对不匹配的情况进行计数。 | | RTL/ddr_sdram_ctrl.sv | DDR1 控制器 | 该示例程序的行为是: @@ -367,13 +367,13 @@ AXI4 总线的地址(awaddr和araddr)统一是字节地址,模块会根据 | 文件名称 | 用途 | | :---- | :--- | -| example-uart-read-write/RTL/top.sv | 顶层 | -| example-uart-read-write/RTL/uart2axi4.sv | 是 AXI4 主机,能把 UART RX 收到的命令转换成 AXI4 读写操作,并把读操作读出的数据通过 UART TX 发送出去 | +| example-uart-read-write/top.sv | 顶层 | +| example-uart-read-write/uart2axi4.sv | 是 AXI4 主机,能把 UART RX 收到的命令转换成 AXI4 读写操作,并把读操作读出的数据通过 UART TX 发送出去 | | RTL/ddr_sdram_ctrl.sv | DDR1 控制器 | [FPGA+DDR1测试板](#硬件设计示例)上有一个 CH340E 芯片(USB 转 UART),因此插上 USB 线后就可以在电脑上看见 UART 对应的 COM 口(需要先在 [www.wch.cn/product/CH340.html](http://www.wch.cn/product/CH340.html) 下载安装 CH341 的驱动)。 -工程上传 FPGA 后,双击打开我编写的一个串口小工具 UartSession.exe ,根据提示打开板子对应的 COM 口,然后打如下的命令+回车,可以把 0x0123 0x4567 0x89ab 0xcdef 这 4 个数据写入起始地址 0x12345。(AXI4总线上会产生一个突发长度为 4 的写操作)。 +工程上传 FPGA 后,双击打开我编写的一个串口小工具 UartSession.exe (它在 example-uart-read-write 目录里),根据提示打开板子对应的 COM 口,然后打如下的命令+回车,可以把 0x0123 0x4567 0x89ab 0xcdef 这 4 个数据写入起始地址 0x12345。(AXI4总线上会产生一个突发长度为 4 的写操作)。 w12345 0123 4567 89ab cdef diff --git a/example-selftest/RTL/axi_self_test_master.sv b/example-selftest/axi_self_test_master.sv similarity index 100% rename from example-selftest/RTL/axi_self_test_master.sv rename to example-selftest/axi_self_test_master.sv diff --git a/example-selftest/ddr_test.qsf b/example-selftest/ddr_test.qsf index e51e1b5..d366114 100644 --- a/example-selftest/ddr_test.qsf +++ b/example-selftest/ddr_test.qsf @@ -130,8 +130,8 @@ set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_TRIGGER_LEVEL_PIP set_global_assignment -name SLD_NODE_PARAMETER_ASSIGNMENT "SLD_ENABLE_ADVANCED_TRIGGER=0" -section_id auto_signaltap_0 set_instance_assignment -name CONNECT_TO_SLD_NODE_ENTITY_PORT acq_clk -to "ddr_ctrl:ddr_ctrl_i|clk2" -section_id auto_signaltap_0 -set_global_assignment -name SYSTEMVERILOG_FILE RTL/top.sv -set_global_assignment -name SYSTEMVERILOG_FILE RTL/axi_self_test_master.sv +set_global_assignment -name SYSTEMVERILOG_FILE top.sv +set_global_assignment -name SYSTEMVERILOG_FILE axi_self_test_master.sv set_global_assignment -name SYSTEMVERILOG_FILE ../RTL/ddr_sdram_ctrl.sv set_global_assignment -name SIGNALTAP_FILE SignalTap/stp1.stp diff --git a/example-selftest/RTL/top.sv b/example-selftest/top.sv similarity index 100% rename from example-selftest/RTL/top.sv rename to example-selftest/top.sv diff --git a/UartSession.exe b/example-uart-read-write/UartSession.exe similarity index 100% rename from UartSession.exe rename to example-uart-read-write/UartSession.exe diff --git a/example-uart-read-write/ddr_test.qsf b/example-uart-read-write/ddr_test.qsf index 9873670..cb89b99 100644 --- a/example-uart-read-write/ddr_test.qsf +++ b/example-uart-read-write/ddr_test.qsf @@ -49,8 +49,8 @@ set_global_assignment -name ERROR_CHECK_FREQUENCY_DIVISOR 1 set_global_assignment -name NOMINAL_CORE_SUPPLY_VOLTAGE 1.2V set_global_assignment -name STRATIX_DEVICE_IO_STANDARD "2.5 V" -set_global_assignment -name SYSTEMVERILOG_FILE RTL/top.sv -set_global_assignment -name SYSTEMVERILOG_FILE RTL/uart2axi4.sv +set_global_assignment -name SYSTEMVERILOG_FILE top.sv +set_global_assignment -name SYSTEMVERILOG_FILE uart2axi4.sv set_global_assignment -name SYSTEMVERILOG_FILE ../RTL/ddr_sdram_ctrl.sv set_location_assignment PIN_23 -to clk50m diff --git a/example-uart-read-write/RTL/top.sv b/example-uart-read-write/top.sv similarity index 100% rename from example-uart-read-write/RTL/top.sv rename to example-uart-read-write/top.sv diff --git a/example-uart-read-write/RTL/uart2axi4.sv b/example-uart-read-write/uart2axi4.sv similarity index 96% rename from example-uart-read-write/RTL/uart2axi4.sv rename to example-uart-read-write/uart2axi4.sv index 45a0325..c0ddc04 100644 --- a/example-uart-read-write/RTL/uart2axi4.sv +++ b/example-uart-read-write/uart2axi4.sv @@ -82,9 +82,9 @@ reg wbuf_wen; reg [ 7:0] wbuf_waddr; reg [D_WIDTH-1:0] wbuf_wdata; reg [ 7:0] wbuf_raddr; -wire[ 7:0] wbuf_raddr_n = stat == AXI_W && wready ? wbuf_raddr + 8'd1 : wbuf_raddr; reg [D_WIDTH-1:0] wbuf_rdata; enum logic [3:0] {IDLE, INVALID, GADDR, GRLEN, GWDATA, AXI_AR, AXI_R, AXI_AW, AXI_W, AXI_B} stat; +wire[ 7:0] wbuf_raddr_n = stat == AXI_W && wready ? wbuf_raddr + 8'd1 : wbuf_raddr; assign awvalid = stat == AXI_AW; assign wvalid = stat == AXI_W; @@ -237,6 +237,7 @@ always @ (posedge clk or negedge rstn) if(~rstn) begin uart_rx_done <= 1'b0; uart_rx_data <= 8'h0; + uart_rx_supercnt<= 3'h0; uart_rx_status <= 6'h0; uart_rx_shift <= 6'h0; uart_rx_databuf <= 8'h0;