aboutsummaryrefslogtreecommitdiffstats
path: root/control_lib/simple_uart_tx.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_tx.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_tx.v')
-rw-r--r--control_lib/simple_uart_tx.v60
1 files changed, 60 insertions, 0 deletions
diff --git a/control_lib/simple_uart_tx.v b/control_lib/simple_uart_tx.v
new file mode 100644
index 000000000..e11a347ed
--- /dev/null
+++ b/control_lib/simple_uart_tx.v
@@ -0,0 +1,60 @@
+
+module simple_uart_tx
+ #(parameter DEPTH=0)
+ (input clk, input rst,
+ input [7:0] fifo_in, input fifo_write, output [7:0] fifo_level, output fifo_full,
+ input [15:0] clkdiv, output baudclk, output reg tx);
+
+ reg [15:0] baud_ctr;
+ reg [3:0] bit_ctr;
+
+ wire read, empty;
+ wire [7:0] char_to_send;
+
+ medfifo #(.WIDTH(8),.DEPTH(DEPTH)) fifo
+ (.clk(clk),.rst(rst),
+ .datain(fifo_in),.write(fifo_write),.full(fifo_full),
+ .dataout(char_to_send),.read(read),.empty(empty),
+ .clear(0),.space(fifo_level),.occupied() );
+
+ always @(posedge clk)
+ if(rst)
+ baud_ctr <= 0;
+ else if (baud_ctr >= clkdiv)
+ baud_ctr <= 0;
+ else
+ baud_ctr <= baud_ctr + 1;
+
+ always @(posedge clk)
+ if(rst)
+ bit_ctr <= 0;
+ else if(baud_ctr == clkdiv)
+ if(bit_ctr == 9)
+ bit_ctr <= 0;
+ else if(bit_ctr != 0)
+ bit_ctr <= bit_ctr + 1;
+ else if(~empty)
+ bit_ctr <= 1;
+
+ always @(posedge clk)
+ if(rst)
+ tx <= 1;
+ else
+ case(bit_ctr)
+ 0 : tx <= 1;
+ 1 : tx <= 0;
+ 2 : tx <= char_to_send[0];
+ 3 : tx <= char_to_send[1];
+ 4 : tx <= char_to_send[2];
+ 5 : tx <= char_to_send[3];
+ 6 : tx <= char_to_send[4];
+ 7 : tx <= char_to_send[5];
+ 8 : tx <= char_to_send[6];
+ 9 : tx <= char_to_send[7];
+ default : tx <= 1;
+ endcase // case(bit_ctr)
+
+ assign read = (bit_ctr == 9) && (baud_ctr == clkdiv);
+ assign baudclk = (baud_ctr == 1); // Only for debug purposes
+
+endmodule // simple_uart_tx