Skip to content

Commit 6133eee

Browse files
committed
chap 4 of ARM 9 Softcore in FPGA by Li Xinbing
this is the Uart top for Xilinx ISE
1 parent 39427e8 commit 6133eee

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

ARM9/uart_top.v

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*uart_top.v
2+
This is used to imply a BLOCK_RAM to buffer the TX and RX*/
3+
4+
module uart_top(
5+
CLOCK_50,
6+
KEY,
7+
START,
8+
UART_RXD,
9+
UART_TXD
10+
);
11+
12+
input CLOCK_50;
13+
input KEY;
14+
input START;
15+
input UART_RXD;
16+
input UART_TXD;
17+
18+
wire clk;
19+
pll u_pll (
20+
.CLKIN_IN(CLKIN_50),
21+
.CLKDV_OUT(clk),
22+
.CLKIN_IBUFG_OUT( ),
23+
.CLK0_OUT( )
24+
);
25+
26+
wire rst;
27+
assign rst = KEY;
28+
29+
rxtx u_rxtx (
30+
.clk ( clk ),
31+
.rst ( rst ),
32+
.rx ( RxD ),
33+
.tx_vld ( tx_vld ),
34+
.tx_data ( tx_data ),
35+
36+
.rx_vld ( rx_vld ),
37+
.rx_data ( rx_data ),
38+
.tx ( TxD ),
39+
.txrdy ( txrdy )
40+
);
41+
42+
/*here comes the Block_RAM*/
43+
44+
/*step 1: setup the flag for Block_RAM*/
45+
always @ (posedge clk or posedge rst)
46+
if (rst)
47+
rx_addr <= 10'b0;
48+
else if (rx_vld)
49+
rx_addr <= rx_addr + 1'b1;
50+
else;
51+
52+
/*step 2: define the RAM*/
53+
always @ (posedge clk)
54+
if (rx_vld)
55+
mem[rx_addr] <= rx_data;
56+
else;
57+
58+
/*setup the process to tx from Block_RAM to computer*/
59+
always @ (posedge clk or posedge rst)
60+
if (rst) begin
61+
start_dly0 <= 1'b0;
62+
start_dly1 <= 1'b0;
63+
start_ok <= 1'b0;
64+
end
65+
else begin
66+
start_dly0 <= START;
67+
start_dly1 <= start_dly0;
68+
start_ok <= start_dly1;
69+
end
70+
assign start_rising = (start_dly1 & ~start_ok) & txrrdy & (rx_addr != 10'b0);
71+

0 commit comments

Comments
 (0)