`include "heron_states.v" module heron_ctrl( state, // ? ready, // ? ram_wr_en, // ? ram_rd_en, // ? alu_mode, // alu_set_z, // alu_set_c, // alu_set_s, // k0_to_b, // k1_to_b, // alu_res_to_a, // a_to_adr, a_to_i, // a_to_old_x, // a_to_s, // a_to_x, // b_to_adr, // ? din_to_a, // ? edb_to_din, // ? a_to_do, // ? div_to_b_shift_1, // ? i_to_a, // old_x_to_b, // s_to_b, // s_to_a_shift_1, // x_to_a, // x_to_b_shifted); // ? // readability parameter ON = 1'b1; parameter OFF = 1'b0; parameter MINUS = 1'b1; parameter PLUS = 1'b0; input [3:0] state; output ready; output ram_wr_en; output ram_rd_en; output alu_mode; output alu_set_z; output alu_set_c; output alu_set_s; output k0_to_b; output k1_to_b; output alu_res_to_a; output a_to_adr; output a_to_i; output a_to_old_x; output a_to_s; output a_to_x; output b_to_adr; output din_to_a; output edb_to_din; output a_to_do; output div_to_b_shift_1; output i_to_a; output old_x_to_b; output s_to_b; output s_to_a_shift_1; output x_to_a; output x_to_b_shifted; reg ready; reg ram_wr_en; reg ram_rd_en; reg rom_rd_en; reg alu_mode; reg alu_set_z; reg alu_set_c; reg alu_set_s; reg k0_to_b; reg k1_to_b; reg alu_res_to_a; reg a_to_adr; reg a_to_i; reg a_to_old_x; reg a_to_s; reg a_to_x; reg b_to_adr; reg din_to_a; reg edb_to_din; reg a_to_do; reg div_to_b_shift_1; reg i_to_a; reg old_x_to_b; reg s_to_b; reg s_to_a_shift_1; reg x_to_a; reg x_to_b_shifted; always @(state) begin ready = OFF; ram_wr_en = OFF; ram_rd_en = OFF; alu_mode = PLUS; alu_set_z = OFF; alu_set_c = OFF; alu_set_s = OFF; k0_to_b = OFF; k1_to_b = OFF; alu_res_to_a = OFF; a_to_adr = OFF; a_to_i = OFF; a_to_old_x = OFF; a_to_s = OFF; a_to_x = OFF; b_to_adr = OFF; din_to_a = OFF; edb_to_din = OFF; div_to_b_shift_1 = OFF; i_to_a = OFF; old_x_to_b = OFF; s_to_b = OFF; s_to_a_shift_1 = OFF; x_to_a = OFF; x_to_b_shifted = OFF; case (state) `IDLE: begin ready = ON; end `LD_N_1: begin k0_to_b = ON; b_to_adr = ON; edb_to_din = ON; ram_rd_en = ON; end `LD_N_2: begin din_to_a = ON; k0_to_b = ON; alu_mode = MINUS; alu_set_z = ON; end `I_GT_ZERO: begin alu_res_to_a = ON; a_to_i = ON; end `LD_S_1: begin i_to_a = ON; edb_to_din = ON; a_to_adr = ON; ram_rd_en = ON; end `LD_S_2: begin din_to_a = ON; a_to_s = ON; k1_to_b = ON; alu_mode = MINUS; alu_set_s = ON; alu_set_z = ON; end `S_GT_ONE:; // noop `X_1: begin s_to_a_shift_1 = ON; s_to_b = ON; a_to_old_x = ON; a_to_x = ON; end `DIV_1: begin x_to_a = ON; s_to_b = ON; end `DIV_2:; // noop `DIV_3:; // noop `DIV_4: begin x_to_a = ON; div_to_b_shift_1 = ON; end `OLD_X_LTE_X_1: begin alu_res_to_a = ON; a_to_x = ON; old_x_to_b = ON; alu_set_c = ON; end `OLD_X_LTE_X_2: begin x_to_a = ON; a_to_old_x = ON; end `STORE_X: begin x_to_b_shifted = ON; a_to_do = ON; ram_wr_en = ON; end `DEC_I: begin i_to_a = ON; k1_to_b = ON; alu_mode = MINUS; alu_set_z = ON; end endcase end endmodule