module uart_tx( input clk, input rst, input ssend, input [7:0] data, outputreg send = 0, outputreg dout = 1); reg [1:0] state = 2'h2; reg [7:0] sdata = 0; reg [3:0] i = 0; reg last_check = 0; reg check = 0; always @ (posedge ssend, negedge rst) begin if(~rst) begin sdata <= 0; check <= 0; end elsebegin sdata <= data; check <= ~check; end end always @ (posedge clk, negedge rst) begin if(~rst) begin i <= 0; dout = 1; state <= 2'h2; last_check = 0; end elsebegin if(check != last_check) begin state <= 2'h0; last_check = check; end case(state) 2'h0: begin send <= 1; dout = 0; state <= 2'h1; end
2'h1: begin dout = sdata[i]; if(i != 7) begin i <= i + 1; end elsebegin i <= 0; state <= 2'h2; end end 2'h2: begin dout = 1; send <= 0; end endcase end end endmodule
module nixietube( input [3:0] data, outputreg [6:0] show); alwaysbegin case(data[3:0]) 4'd0: show <= 7'b1000000; 4'd1: show <= 7'b1111001; 4'd2: show <= 7'b0100100; 4'd3: show <= 7'b0110000; 4'd4: show <= 7'b0011001; 4'd5: show <= 7'b0010010; 4'd6: show <= 7'b0000010; 4'd7: show <= 7'b1111000; 4'd8: show <= 7'b0000000; 4'd9: show <= 7'b0010000; 4'd10: show <= 7'b0001000; 4'd11: show <= 7'b0000011; 4'd12: show <= 7'b1000110; 4'd13: show <= 7'b0100001; 4'd14: show <= 7'b0000110; 4'd15: show <= 7'b0001110; default: show <= 7'b1000000; endcase end