Line 99... |
Line 99... |
localparam PULL_REGISTER = 5'b11011;
|
localparam PULL_REGISTER = 5'b11011;
|
localparam DUMMY = 5'b11100;
|
localparam DUMMY = 5'b11100;
|
localparam RESET = 5'b11111;
|
localparam RESET = 5'b11111;
|
|
|
// OPCODES TODO: verify how this get synthesised
|
// OPCODES TODO: verify how this get synthesised
|
`include "T6507LP_Package.v"
|
`include "t6507lp_package.v"
|
|
|
// mem_rw signals
|
// mem_rw signals
|
localparam MEM_READ = 1'b0;
|
localparam MEM_READ = 1'b0;
|
localparam MEM_WRITE = 1'b1;
|
localparam MEM_WRITE = 1'b1;
|
|
|
Line 196... |
Line 196... |
{page_crossed, address_plus_index[7:0]} = temp_addr[7:0] + index;
|
{page_crossed, address_plus_index[7:0]} = temp_addr[7:0] + index;
|
address_plus_index[12:8] = temp_addr[12:8] + page_crossed;
|
address_plus_index[12:8] = temp_addr[12:8] + page_crossed;
|
end
|
end
|
end
|
end
|
|
|
|
reg [2:0] rst_counter; // a counter to preserve the cpu idle for six cycles
|
|
|
always @ (posedge clk or negedge reset_n) begin // sequencial always block
|
always @ (posedge clk or negedge reset_n) begin // sequencial always block
|
if (reset_n == 1'b0) begin
|
if (reset_n == 1'b0) begin
|
// all registers must assume default values
|
// all registers must assume default values
|
pc <= 0; // TODO: this is written somewhere. something about a reset vector. must be checked.
|
pc <= 0; // TODO: this is written somewhere. something about a reset vector. must be checked.
|
sp <= 9'b000000000; // the default is 'h100
|
sp <= 9'b000000000; // the default is 'h100
|
Line 209... |
Line 211... |
state <= RESET;
|
state <= RESET;
|
// registered outputs also receive default values
|
// registered outputs also receive default values
|
address <= 13'h0000;
|
address <= 13'h0000;
|
mem_rw <= MEM_READ;
|
mem_rw <= MEM_READ;
|
data_out <= 8'h00;
|
data_out <= 8'h00;
|
|
rst_counter <= 0;
|
end
|
end
|
else begin
|
else begin
|
state <= next_state;
|
state <= next_state;
|
|
|
case (state)
|
case (state)
|
RESET: begin // The processor was reset
|
RESET: begin // The processor was reset
|
|
rst_counter <= rst_counter + 1;
|
sp <= 9'b100000000; // this prevents flipflops with different drivers
|
sp <= 9'b100000000; // this prevents flipflops with different drivers
|
//$write("under reset");
|
//$write("under reset");
|
end
|
end
|
/*
|
/*
|
FETCH_OP: executed when the processor was reset or the last instruction could not fetch.
|
FETCH_OP: executed when the processor was reset or the last instruction could not fetch.
|
Line 578... |
Line 582... |
alu_enable = 1'b0;
|
alu_enable = 1'b0;
|
next_state = RESET; // these lines prevents latches
|
next_state = RESET; // these lines prevents latches
|
|
|
case (state)
|
case (state)
|
RESET: begin
|
RESET: begin
|
|
if (rst_counter == 6) begin
|
next_state = FETCH_OP;
|
next_state = FETCH_OP;
|
end
|
end
|
|
end
|
FETCH_OP: begin
|
FETCH_OP: begin
|
next_state = FETCH_LOW;
|
next_state = FETCH_LOW;
|
end
|
end
|
FETCH_OP_CALC_PARAM: begin
|
FETCH_OP_CALC_PARAM: begin
|
next_state = FETCH_LOW;
|
next_state = FETCH_LOW;
|