#include <stdioh>
#include "/inc/sopch"
#include "systemh"
#include "stringh"
/--------------------------------------------------------------- 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;
}
你是要用非标的uart还是用标准的串口协议?
如果用非标的uart自己编写一个就是了,很简单的,当然接收和发送都要非标uart
如果还用标准串口, 32位数据按照字节顺序发四次不就成了,当然要用报文方式组织存储,这不是什么问题啊
1、硬件上FPGA板肯定要有RS232接口与PC连接才行,没有的话,一切免谈。 2、软件上写一个串口接收模块,设置好波特率和数据位宽。 就这两点东西。 我有验证过的串口verilog程序,可直接拿去用。
LIBRARY ieee;
USE ieeestd_logic_1164all;
USE ieeestd_logic_unsignedall;
ENTITY my_uart_rx IS
PORT (
clk : IN STD_LOGIC;
rst_n : IN STD_LOGIC;
rs232_rx : IN STD_LOGIC;
rx_data : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
rx_int : OUT STD_LOGIC;
clk_bps : IN STD_LOGIC;
bps_start : OUT STD_LOGIC
);
END my_uart_rx;
ARCHITECTURE trans OF my_uart_rx IS
SIGNAL rs232_rx0 : STD_LOGIC;
SIGNAL rs232_rx1 : STD_LOGIC;
SIGNAL rs232_rx2 : STD_LOGIC;
SIGNAL rs232_rx3 : STD_LOGIC;
SIGNAL neg_rs232_rx : STD_LOGIC;
SIGNAL bps_start_r : STD_LOGIC;
SIGNAL num : STD_LOGIC_VECTOR(3 DOWNTO 0);
SIGNAL rx_data_r : STD_LOGIC_VECTOR(7 DOWNTO 0);
SIGNAL rx_temp_data : STD_LOGIC_VECTOR(7 DOWNTO 0);
-- Declare intermediate signals for referenced outputs
SIGNAL rx_int_xhdl0 : STD_LOGIC;
BEGIN
-- Drive referenced outputs
rx_int <= rx_int_xhdl0;
PROCESS (clk, rst_n)
BEGIN
IF ((NOT(rst_n)) = '1') THEN
rs232_rx0 <= '0';
rs232_rx1 <= '0';
rs232_rx2 <= '0';
rs232_rx3 <= '0';
ELSIF (clk'EVENT AND clk = '1') THEN
rs232_rx0 <= rs232_rx;
rs232_rx1 <= rs232_rx0;
rs232_rx2 <= rs232_rx1;
rs232_rx3 <= rs232_rx2;
END IF;
END PROCESS;
neg_rs232_rx <= rs232_rx3 AND rs232_rx2 AND NOT(rs232_rx1) AND NOT(rs232_rx0);
PROCESS (clk, rst_n)
BEGIN
IF ((NOT(rst_n)) = '1') THEN
bps_start_r <= 'Z';
rx_int_xhdl0 <= '0';
ELSIF (clk'EVENT AND clk = '1') THEN
IF (neg_rs232_rx = '1') THEN
bps_start_r <= '1';
rx_int_xhdl0 <= '1';
ELSIF (num = "1100") THEN
bps_start_r <= '0';
rx_int_xhdl0 <= '0';
END IF;
END IF;
END PROCESS;
bps_start <= bps_start_r;
PROCESS (clk, rst_n)
BEGIN
IF ((NOT(rst_n)) = '1') THEN
rx_temp_data <= "00000000";
num <= "0000";
rx_data_r <= "00000000";
ELSIF (clk'EVENT AND clk = '1') THEN
IF (rx_int_xhdl0 = '1') THEN
IF (clk_bps = '1') THEN
num <= num + "0001";
CASE num IS
WHEN "0001" =>
rx_temp_data(0) <= rs232_rx;
WHEN "0010" =>
rx_temp_data(1) <= rs232_rx;
WHEN "0011" =>
rx_temp_data(2) <= rs232_rx;
WHEN "0100" =>
rx_temp_data(3) <= rs232_rx;
WHEN "0101" =>
rx_temp_data(4) <= rs232_rx;
WHEN "0110" =>
rx_temp_data(5) <= rs232_rx;
WHEN "0111" =>
rx_temp_data(6) <= rs232_rx;
WHEN "1000" =>
rx_temp_data(7) <= rs232_rx;
WHEN OTHERS =>
END CASE;
ELSIF (num = "1100") THEN
num <= "0000";
rx_data_r <= rx_temp_data;
END IF;
END IF;
END IF;
END PROCESS;
rx_data <= rx_data_r;
END trans;
如果需要转换verilog和vhdl可以使用x-hdl这个软件 添加文件之后点一下就行了 非常方便
module counter_24 ( input clk, input rst, input cnt_in ,output reg cnt_out );
reg [4:0] cnt;
always @ (posedge clk or posedge rst_n) begin
if (rst) cnt <= 5'b0;
else if (~cnt_in) cnt <= cnt;
else if (cnt == 5'b10110) cnt <= 5'b0;
else cnt <= cnt + 1'b1;
end
always @ (posedge clk or posedge rst) begin
if (rst) cnt_out <= 1'b0;
else if (cnt_in && cnt == 5'b10110) cnt_out <= 1'b1;
else cnt_out <= 1'b0;
end
endmodule
input add; //为1时加 *** 作
input dec; //为1时减 *** 作
output [5:0] counter;
reg [5:0] counter;
always @(add and dec) begin
if(add && !dec) begin
if(counter == 6'd38) begin
counter <= 6'd0;
扩展资料:
有一种记数系统便是24进制的,其中1~24有专门的符号来表示,大于24的数便可以像24进制那样写成多位数,如tokaputokapuŋgayepoko代表24进制中的P0(552)。malapu talusupuŋga talu代表24进制中的H2G(9856)。
为了避免混淆1和I,0和O,故跳过字母I、O,18~~23分别计作J、K、L、M、N、P。比如:16计作G、22计作N。
等于或大于24的数字计作:24→10、25→11、26→1225→11中标粗体的1代表24。同一个数字在不同的位置代表的值是不一样的。
参考资料来源:百度百科-二十四进制
以上就是关于verilog中怎么调用ram,输入有clk,rst_n,uart_rx,输出是mem_data全部的内容,包括:verilog中怎么调用ram,输入有clk,rst_n,uart_rx,输出是mem_data、verilog 怎么写一个串口能够一次性发送多个字节、fpga实现串口uart自收发怎么仿真等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)