2014-01-08 15:35:30 +00:00
|
|
|
`include "heron_states.v"
|
|
|
|
|
2014-01-02 12:01:07 +00:00
|
|
|
module heron_ctrl(
|
2014-01-10 12:22:11 +00:00
|
|
|
// data path
|
2014-01-13 08:08:21 +00:00
|
|
|
a_to_eab,
|
2014-01-10 12:22:11 +00:00
|
|
|
a_to_i,
|
|
|
|
a_to_old_x,
|
|
|
|
a_to_s,
|
|
|
|
a_to_x,
|
|
|
|
alu_mode,
|
|
|
|
alu_res_to_a,
|
|
|
|
alu_set_c,
|
|
|
|
alu_set_s,
|
|
|
|
alu_set_z,
|
|
|
|
din_to_a,
|
|
|
|
div_to_b_shift_1,
|
|
|
|
edb_to_din,
|
|
|
|
i_to_a,
|
|
|
|
k0_to_a,
|
|
|
|
k1_to_b,
|
|
|
|
old_x_to_b,
|
|
|
|
s_to_a_shift_1,
|
|
|
|
s_to_b,
|
|
|
|
x_to_a,
|
|
|
|
x_to_b_shifted,
|
|
|
|
// rest
|
|
|
|
state,
|
|
|
|
ready,
|
|
|
|
ram_rd_en,
|
|
|
|
ram_wr_en);
|
2014-01-08 15:35:30 +00:00
|
|
|
|
|
|
|
// readability
|
|
|
|
parameter ON = 1'b1;
|
|
|
|
parameter OFF = 1'b0;
|
|
|
|
parameter MINUS = 1'b1;
|
|
|
|
parameter PLUS = 1'b0;
|
2014-01-02 12:01:07 +00:00
|
|
|
|
2014-01-10 12:22:11 +00:00
|
|
|
// data path
|
2014-01-13 08:08:21 +00:00
|
|
|
output a_to_eab;
|
2014-01-08 15:35:30 +00:00
|
|
|
output a_to_i;
|
|
|
|
output a_to_old_x;
|
|
|
|
output a_to_s;
|
|
|
|
output a_to_x;
|
2014-01-10 12:22:11 +00:00
|
|
|
output alu_mode;
|
|
|
|
output alu_res_to_a;
|
|
|
|
output alu_set_c;
|
|
|
|
output alu_set_s;
|
|
|
|
output alu_set_z;
|
2014-01-08 15:35:30 +00:00
|
|
|
output din_to_a;
|
|
|
|
output div_to_b_shift_1;
|
2014-01-10 12:22:11 +00:00
|
|
|
output edb_to_din;
|
2014-01-08 15:35:30 +00:00
|
|
|
output i_to_a;
|
2014-01-10 12:22:11 +00:00
|
|
|
output k0_to_a;
|
|
|
|
output k1_to_b;
|
2014-01-08 15:35:30 +00:00
|
|
|
output old_x_to_b;
|
|
|
|
output s_to_a_shift_1;
|
2014-01-10 12:22:11 +00:00
|
|
|
output s_to_b;
|
2014-01-08 15:35:30 +00:00
|
|
|
output x_to_a;
|
|
|
|
output x_to_b_shifted;
|
|
|
|
|
2014-01-10 12:22:11 +00:00
|
|
|
input [3:0] state;
|
|
|
|
output ready;
|
|
|
|
output ram_rd_en;
|
|
|
|
output ram_wr_en;
|
|
|
|
|
|
|
|
// data path
|
2014-01-13 08:08:21 +00:00
|
|
|
reg a_to_eab;
|
2014-01-08 15:35:30 +00:00
|
|
|
reg a_to_i;
|
|
|
|
reg a_to_old_x;
|
|
|
|
reg a_to_s;
|
|
|
|
reg a_to_x;
|
2014-01-10 12:22:11 +00:00
|
|
|
reg alu_mode;
|
|
|
|
reg alu_res_to_a;
|
|
|
|
reg alu_set_c;
|
|
|
|
reg alu_set_s;
|
|
|
|
reg alu_set_z;
|
2014-01-08 15:35:30 +00:00
|
|
|
reg din_to_a;
|
|
|
|
reg div_to_b_shift_1;
|
2014-01-10 12:22:11 +00:00
|
|
|
reg edb_to_din;
|
2014-01-08 15:35:30 +00:00
|
|
|
reg i_to_a;
|
2014-01-10 12:22:11 +00:00
|
|
|
reg k0_to_a;
|
|
|
|
reg k1_to_b;
|
2014-01-08 15:35:30 +00:00
|
|
|
reg old_x_to_b;
|
2014-01-10 12:22:11 +00:00
|
|
|
reg rom_rd_en;
|
2014-01-08 15:35:30 +00:00
|
|
|
reg s_to_a_shift_1;
|
2014-01-10 12:22:11 +00:00
|
|
|
reg s_to_b;
|
2014-01-08 15:35:30 +00:00
|
|
|
reg x_to_a;
|
|
|
|
reg x_to_b_shifted;
|
2014-01-02 12:01:07 +00:00
|
|
|
|
2014-01-10 12:22:11 +00:00
|
|
|
reg ready;
|
|
|
|
reg ram_rd_en;
|
|
|
|
reg ram_wr_en;
|
|
|
|
|
2014-01-02 12:01:07 +00:00
|
|
|
always @(state) begin
|
2014-01-13 08:08:21 +00:00
|
|
|
a_to_eab = OFF;
|
2014-01-08 15:35:30 +00:00
|
|
|
a_to_i = OFF;
|
|
|
|
a_to_old_x = OFF;
|
|
|
|
a_to_s = OFF;
|
|
|
|
a_to_x = OFF;
|
2014-01-10 12:22:11 +00:00
|
|
|
alu_mode = PLUS;
|
|
|
|
alu_res_to_a = OFF;
|
|
|
|
alu_set_c = OFF;
|
|
|
|
alu_set_s = OFF;
|
|
|
|
alu_set_z = OFF;
|
2014-01-08 15:35:30 +00:00
|
|
|
din_to_a = OFF;
|
|
|
|
div_to_b_shift_1 = OFF;
|
2014-01-10 12:22:11 +00:00
|
|
|
edb_to_din = OFF;
|
2014-01-08 15:35:30 +00:00
|
|
|
i_to_a = OFF;
|
2014-01-10 12:22:11 +00:00
|
|
|
k0_to_a = OFF;
|
|
|
|
k1_to_b = OFF;
|
2014-01-08 15:35:30 +00:00
|
|
|
old_x_to_b = OFF;
|
|
|
|
s_to_a_shift_1 = OFF;
|
2014-01-10 12:22:11 +00:00
|
|
|
s_to_b = OFF;
|
2014-01-08 15:35:30 +00:00
|
|
|
x_to_a = OFF;
|
|
|
|
x_to_b_shifted = OFF;
|
|
|
|
|
2014-01-10 12:22:11 +00:00
|
|
|
ready = OFF;
|
|
|
|
ram_rd_en = OFF;
|
|
|
|
ram_wr_en = OFF;
|
|
|
|
|
2014-01-08 15:35:30 +00:00
|
|
|
case (state)
|
|
|
|
`IDLE: begin
|
|
|
|
ready = ON;
|
|
|
|
end
|
|
|
|
`LD_N_1: begin
|
2014-01-10 12:22:11 +00:00
|
|
|
k0_to_a = ON;
|
2014-01-13 08:08:21 +00:00
|
|
|
a_to_eab = ON;
|
2014-01-08 15:35:30 +00:00
|
|
|
edb_to_din = ON;
|
|
|
|
ram_rd_en = ON;
|
|
|
|
end
|
|
|
|
`LD_N_2: begin
|
|
|
|
din_to_a = ON;
|
2014-01-10 12:22:11 +00:00
|
|
|
k0_to_a = ON;
|
2014-01-08 15:35:30 +00:00
|
|
|
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;
|
2014-01-13 08:08:21 +00:00
|
|
|
a_to_eab = ON;
|
2014-01-08 15:35:30 +00:00
|
|
|
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;
|
2014-01-02 12:01:07 +00:00
|
|
|
|
2014-01-08 15:35:30 +00:00
|
|
|
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;
|
|
|
|
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
|
2014-01-02 12:01:07 +00:00
|
|
|
endmodule
|