summaryrefslogtreecommitdiffstats
path: root/control_lib/simple_uart.v
diff options
context:
space:
mode:
authorjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>2008-09-08 01:00:12 +0000
committerjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>2008-09-08 01:00:12 +0000
commit61f2f0214c5999ea42a368a4fc99f03d8eb28d1e (patch)
treee7e24a9adc05ff1422fe3ada9926a51634741b47 /control_lib/simple_uart.v
downloaduhd-61f2f0214c5999ea42a368a4fc99f03d8eb28d1e.tar.gz
uhd-61f2f0214c5999ea42a368a4fc99f03d8eb28d1e.tar.bz2
uhd-61f2f0214c5999ea42a368a4fc99f03d8eb28d1e.zip
Merged r9433:9527 from features/gr-usrp2 into trunk. Adds usrp2 and gr-usrp2 top-level components. Trunk passes distcheck with mb-gcc installed, but currently not without them. The key issue is that when mb-gcc is not installed, the build system skips over the usrp2/firmware directory, and the firmware include files don't get put into the dist tarball. But we can't do the usual DIST_SUBDIRS method as the firmware is a subpackage.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9528 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'control_lib/simple_uart.v')
-rw-r--r--control_lib/simple_uart.v61
1 files changed, 61 insertions, 0 deletions
diff --git a/control_lib/simple_uart.v b/control_lib/simple_uart.v
new file mode 100644
index 000000000..22f0e70a2
--- /dev/null
+++ b/control_lib/simple_uart.v
@@ -0,0 +1,61 @@
+
+module simple_uart
+ #(parameter TXDEPTH = 1,
+ parameter RXDEPTH = 1)
+ (input clk_i, input rst_i,
+ input we_i, input stb_i, input cyc_i, output reg ack_o,
+ input [2:0] adr_i, input [31:0] dat_i, output reg [31:0] dat_o,
+ output rx_int_o, output tx_int_o, output tx_o, input rx_i, output baud_o);
+
+ // Register Map
+ localparam SUART_CLKDIV = 0;
+ localparam SUART_TXLEVEL = 1;
+ localparam SUART_RXLEVEL = 2;
+ localparam SUART_TXCHAR = 3;
+ localparam SUART_RXCHAR = 4;
+
+ wire wb_acc = cyc_i & stb_i; // WISHBONE access
+ wire wb_wr = wb_acc & we_i; // WISHBONE write access
+
+ reg [15:0] clkdiv;
+ wire [7:0] rx_char;
+ wire tx_fifo_full, rx_fifo_empty;
+ wire [7:0] tx_fifo_level, rx_fifo_level;
+
+ always @(posedge clk_i)
+ if (rst_i)
+ ack_o <= 1'b0;
+ else
+ ack_o <= wb_acc & ~ack_o;
+
+ always @(posedge clk_i)
+ if (rst_i)
+ clkdiv <= 0;
+ else if (wb_wr)
+ case(adr_i)
+ SUART_CLKDIV : clkdiv <= dat_i[15:0];
+ endcase // case(adr_i)
+
+ always @(posedge clk_i)
+ case (adr_i)
+ SUART_TXLEVEL : dat_o <= tx_fifo_level;
+ SUART_RXLEVEL : dat_o <= rx_fifo_level;
+ SUART_RXCHAR : dat_o <= rx_char;
+ endcase // case(adr_i)
+
+ simple_uart_tx #(.DEPTH(TXDEPTH)) simple_uart_tx
+ (.clk(clk_i),.rst(rst_i),
+ .fifo_in(dat_i[7:0]),.fifo_write(ack_o && wb_wr && (adr_i == SUART_TXCHAR)),
+ .fifo_level(tx_fifo_level),.fifo_full(tx_fifo_full),
+ .clkdiv(clkdiv),.baudclk(baud_o),.tx(tx_o));
+
+ simple_uart_rx #(.DEPTH(RXDEPTH)) simple_uart_rx
+ (.clk(clk_i),.rst(rst_i),
+ .fifo_out(rx_char),.fifo_read(ack_o && ~wb_wr && (adr_i == SUART_RXCHAR)),
+ .fifo_level(rx_fifo_level),.fifo_empty(rx_fifo_empty),
+ .clkdiv(clkdiv),.rx(rx_i));
+
+ assign tx_int_o = ~tx_fifo_full;
+ assign rx_int_o = ~rx_fifo_empty;
+
+endmodule // simple_uart