]> Joshua Wise's Git repositories - fpgaboy.git/blobdiff - Uart.v
Dual boot ROM support, and the first proof that cellular ram works!
[fpgaboy.git] / Uart.v
diff --git a/Uart.v b/Uart.v
index a036c64e5ad7858422f27515730da6d13c15c9d0..07f996a6a475add8a984a934271bba2c36f25b56 100644 (file)
--- a/Uart.v
+++ b/Uart.v
@@ -1,5 +1,5 @@
 `define IN_CLK 8388608
-`define OUT_CLK 9600
+`define OUT_CLK 57600
 `define CLK_DIV `IN_CLK / `OUT_CLK
 `define MMAP_ADDR 16'hFF50
 
@@ -9,27 +9,28 @@ module UART(
        input rd,
        input [15:0] addr,
        inout [7:0] data,
-       output reg serial);
-       
+       output reg serial = 1);
+
+       reg rdlatch = 0;
        wire decode = (addr == `MMAP_ADDR);
        
        wire [7:0] odata;
-       assign data = (rd && decode) ? odata : 8'bzzzzzzzz;
+       assign data = rdlatch ? odata : 8'bzzzzzzzz;
 
        reg [7:0] data_stor = 0;
        reg [15:0] clkdiv = 0;
        reg have_data = 0;
-       reg data_end = 0;
        reg [3:0] diqing = 4'b0000;
        
-       wire new = (wr) && (!have_data) && decode;
+       wire newdata = (wr) && (!have_data) && decode;
        
        assign odata = have_data ? 8'b1 : 8'b0;
 
-       always @ (negedge clk)
+       always @ (posedge clk)
        begin
+               rdlatch <= rd && decode;
                /* deal with diqing */
-               if(new) begin
+               if(newdata) begin
                        data_stor <= data;
                        have_data <= 1;
                        diqing <= 4'b0000;
@@ -53,7 +54,7 @@ module UART(
                end
 
                /* deal with clkdiv */
-               if((new && !have_data) || clkdiv == `CLK_DIV)
+               if((newdata && !have_data) || clkdiv == `CLK_DIV)
                        clkdiv <= 0;
                else
                        clkdiv <= clkdiv + 1;
This page took 0.027691 seconds and 4 git commands to generate.