Revision 448
Added by markw over 9 years ago
ultimate_cart/veronica/slave_timing_6502.vhd | ||
---|---|---|
signal phi_edge_prev_next : std_logic;
|
||
signal phi_edge_prev_reg: std_logic;
|
||
|
||
signal delay_next : std_logic_vector(30 downto 0);
|
||
signal delay_reg : std_logic_vector(30 downto 0);
|
||
signal delay_next : std_logic_vector(60 downto 0);
|
||
signal delay_reg : std_logic_vector(60 downto 0);
|
||
|
||
signal bus_data_out_next : std_logic_vector(7 downto 0);
|
||
signal bus_data_out_reg : std_logic_vector(7 downto 0);
|
||
... | ... | |
|
||
signal state_reg : std_logic_vector(2 downto 0);
|
||
signal state_next : std_logic_vector(2 downto 0);
|
||
constant state_phi : std_logic_vector(2 downto 0) := "000";
|
||
constant state_write_request : std_logic_vector(2 downto 0) := "001";
|
||
constant state_read_request : std_logic_vector(2 downto 0) := "010";
|
||
constant state_wait_addrctl : std_logic_vector(2 downto 0) := "001";
|
||
constant state_write_request : std_logic_vector(2 downto 0) := "010";
|
||
constant state_read_output_start : std_logic_vector(2 downto 0) := "011";
|
||
constant state_read_output_end : std_logic_vector(2 downto 0) := "100";
|
||
|
||
... | ... | |
bus_s5_n_reg <= '1';
|
||
bus_ctl_n_reg <= '1';
|
||
|
||
state_reg <= state_phi;
|
||
state_reg <= state_wait_addrctl;
|
||
elsif (clk7x'event and clk7x='1') then
|
||
phi_edge_prev_reg <= phi_edge_prev_next;
|
||
delay_reg <= delay_next;
|
||
... | ... | |
bus_ctl_n_next <= bus_ctl_n_reg;
|
||
|
||
internal_memory_request <= '0';
|
||
delay_next <= delay_reg(29 downto 0)&'0';
|
||
delay_next <= delay_reg(59 downto 0)&(not(phi2_sync) and phi_edge_prev_reg);
|
||
bus_data_out_next <= bus_data_out_reg;
|
||
bus_drive_next <= bus_drive_reg;
|
||
|
||
... | ... | |
-- XXXXXXXXXXDDDD
|
||
state_next <= state_reg;
|
||
case (state_reg) is
|
||
when state_phi =>
|
||
if (phi2_sync = '1' and phi_edge_prev_reg='0') then -- falling edge (3 cycles delayed)
|
||
delay_next(0) <= '1';
|
||
|
||
when state_wait_addrctl =>
|
||
if (delay_reg(17)='1') then -- n+4 cycles
|
||
-- snap control signals, should be stable by now
|
||
bus_addr_in_next <= bus_addr;
|
||
bus_rw_n_next <= bus_rw_n;
|
||
... | ... | |
bus_ctl_n_next <= bus_ctl_n;
|
||
|
||
if (bus_rw_n='1') then -- read
|
||
state_next <= state_read_request;
|
||
state_next <= state_read_output_start;
|
||
internal_memory_request <= '1';
|
||
else
|
||
state_next <= state_write_request;
|
||
end if;
|
||
end if;
|
||
when state_write_request =>
|
||
if (delay_reg(19)='1') then -- n+4 cycles
|
||
if (delay_reg(45)='1') then -- n+4 cycles
|
||
bus_data_in_next <= bus_data;
|
||
end if;
|
||
if (delay_reg(20)='1') then -- n+4 cycles
|
||
if (delay_reg(46)='1') then -- n+4 cycles
|
||
internal_memory_request <= '1';
|
||
state_next <= state_phi;
|
||
state_next <= state_wait_addrctl;
|
||
end if;
|
||
when state_read_request =>
|
||
if (delay_reg(0)='1') then -- n+4 cycles
|
||
state_next <= state_read_output_start;
|
||
internal_memory_request <= '1';
|
||
end if;
|
||
when state_read_output_start =>
|
||
if (delay_reg(16)='1') then -- n+4 cycles
|
||
if (delay_reg(38)='1') then -- n+4 cycles
|
||
bus_data_out_next <= data_out;
|
||
bus_drive_next <= '1';
|
||
state_next <= state_read_output_start;
|
||
state_next <= state_read_output_end;
|
||
end if;
|
||
when state_read_output_end =>
|
||
if (delay_reg(30)='1') then -- n+4 cycles
|
||
if (delay_reg(56)='1') then -- n+4 cycles
|
||
bus_drive_next <= '0';
|
||
state_next <= state_phi;
|
||
state_next <= state_wait_addrctl;
|
||
end if;
|
||
when others =>
|
||
end case;
|
Also available in: Unified diff
Adjusted delays and verified in sim