1 `include "master_rom.v"
7 // s/192/3/ for 19200 baud uart
10 module master(input CLKin, output [4:0] led, output uart_tx, input uart_rx, output reg ready_out = 1, input ready_in);
14 //pll pll (.clock_in(CLKin), .clock_out(clk));
16 reg [20:0] counter = 0;
20 always @ (posedge CLKin) begin
21 if(counter == 5000) begin
26 counter <= counter + 1;
29 reg [4:0] program_counter = 0;
30 wire [63:0] rom_output;
32 master_rom master_rom (.clk(clk), .addr(program_counter), .data(rom_output));
36 `define STATE_WAIT_PROPAGATE 1
37 `define STATE_WAIT_NEWS 2
39 reg [5:0] state = `STATE_SEND;
40 reg [5:0] uart_ptr = 0;
45 reg [7:0] tx_byte = 0;
49 // 19200 (actually 300) baud uart
50 uart #(.CLOCK_DIVIDE(`UART_DIVIDE)) uart (.clk(clk), .rx(uart_rx), .tx(uart_tx), .received(received), .transmit(transmit), .tx_byte(tx_byte), .rx_byte(rx_byte), .is_receiving(is_receiving), .is_transmitting(is_transmitting));
52 always @(posedge clk) begin
57 end else if(uart_ptr == 4) begin
58 program_counter <= program_counter + 1;
60 state <= `STATE_WAIT_PROPAGATE;
61 end else if(!is_transmitting && ready_in) begin
62 tx_byte <= rom_output[uart_ptr * 8 +: 8];
64 uart_ptr <= uart_ptr + 1;
68 `STATE_WAIT_PROPAGATE: begin
74 `STATE_WAIT_NEWS: begin