Line 22... |
Line 22... |
// DA(2:0) 3bit binary coded adress
|
// DA(2:0) 3bit binary coded adress
|
// CS0- select command block registers
|
// CS0- select command block registers
|
// CS1- select control block registers
|
// CS1- select control block registers
|
|
|
`include "timescale.v"
|
`include "timescale.v"
|
|
`include "atahost_define.v"
|
|
|
module atahost_top (wb_clk_i, rst_nreset_i, wb_rst_i, wb_cyc_i, wb_stb_i, wb_ack_o, wb_err_o,
|
module atahost_top (wb_clk_i, arst_i, wb_rst_i, wb_cyc_i, wb_stb_i, wb_ack_o, wb_err_o,
|
wb_adr_i, wb_dat_i, wb_dat_o, wb_sel_i, wb_we_i, wb_inta_o,
|
wb_adr_i, wb_dat_i, wb_dat_o, wb_sel_i, wb_we_i, wb_inta_o,
|
ata_resetn_pad_o, ata_dd_pad_i, ata_dd_pad_o, ata_dd_pad_oe, ata_da_pad_o, ata_cs0n_pad_o,
|
resetn_pad_o, dd_pad_i, dd_pad_o, dd_padoen_o, da_pad_o, cs0n_pad_o,
|
ata_cs1n_pad_o, ata_diorn_pad_o, ata_diown_pad_o, ata_iordy_pad_i, ata_intrq_pad_i);
|
cs1n_pad_o, diorn_pad_o, diown_pad_o, iordy_pad_i, intrq_pad_i);
|
//
|
//
|
// Parameter declarations
|
// Parameter declarations
|
//
|
//
|
parameter TWIDTH = 8; // counter width
|
parameter TWIDTH = 8; // counter width
|
// PIO mode 0 settings (@100MHz clock)
|
// PIO mode 0 settings (@100MHz clock)
|
Line 43... |
Line 44... |
// inputs & outputs
|
// inputs & outputs
|
//
|
//
|
|
|
// WISHBONE SYSCON signals
|
// WISHBONE SYSCON signals
|
input wb_clk_i; // master clock in
|
input wb_clk_i; // master clock in
|
input rst_nreset_i; // asynchronous active low reset
|
input arst_i; // asynchronous reset
|
input wb_rst_i; // synchronous active high reset
|
input wb_rst_i; // synchronous reset
|
|
|
// WISHBONE SLAVE signals
|
// WISHBONE SLAVE signals
|
input wb_cyc_i; // valid bus cycle input
|
input wb_cyc_i; // valid bus cycle input
|
input wb_stb_i; // strobe/core select input
|
input wb_stb_i; // strobe/core select input
|
output wb_ack_o; // strobe acknowledge output
|
output wb_ack_o; // strobe acknowledge output
|
Line 62... |
Line 63... |
input [ 3:0] wb_sel_i; // Byte select signals
|
input [ 3:0] wb_sel_i; // Byte select signals
|
input wb_we_i; // Write enable input
|
input wb_we_i; // Write enable input
|
output wb_inta_o; // interrupt request signal
|
output wb_inta_o; // interrupt request signal
|
|
|
// ATA signals
|
// ATA signals
|
output ata_resetn_pad_o;
|
output resetn_pad_o;
|
input [15:0] ata_dd_pad_i;
|
input [15:0] dd_pad_i;
|
output [15:0] ata_dd_pad_o;
|
output [15:0] dd_pad_o;
|
output ata_dd_pad_oe;
|
output dd_padoen_o;
|
output [ 2:0] ata_da_pad_o;
|
output [ 2:0] da_pad_o;
|
output ata_cs0n_pad_o;
|
output cs0n_pad_o;
|
output ata_cs1n_pad_o;
|
output cs1n_pad_o;
|
|
|
output ata_diorn_pad_o;
|
output diorn_pad_o;
|
output ata_diown_pad_o;
|
output diown_pad_o;
|
input ata_iordy_pad_i;
|
input iordy_pad_i;
|
input ata_intrq_pad_i;
|
input intrq_pad_i;
|
|
|
//
|
//
|
// constant declarations
|
// constant declarations
|
//
|
//
|
parameter [3:0] DeviceId = 4'h1;
|
parameter [3:0] DeviceId = 4'h1;
|
Line 107... |
Line 108... |
|
|
/////////////////
|
/////////////////
|
// Module body //
|
// Module body //
|
/////////////////
|
/////////////////
|
|
|
|
// generate asynchronous reset level
|
|
// arst_signal is either a wire or a NOT-gate
|
|
wire arst_signal = arst_i ^ `ARST_LVL;
|
|
|
// generate bus cycle / address decoder
|
// generate bus cycle / address decoder
|
wire w_acc = &wb_sel_i[1:0]; // word access
|
wire w_acc = &wb_sel_i[1:0]; // word access
|
wire dw_acc = &wb_sel_i; // double word access
|
wire dw_acc = &wb_sel_i; // double word access
|
|
|
// bus error
|
// bus error
|
Line 123... |
Line 128... |
wire CONsel = wb_cyc_i & wb_stb_i & !(`ATA_ATA_ADR) & dw_acc;
|
wire CONsel = wb_cyc_i & wb_stb_i & !(`ATA_ATA_ADR) & dw_acc;
|
|
|
// generate registers
|
// generate registers
|
|
|
// generate register select signals
|
// generate register select signals
|
wire sel_ctrl = CONsel & wb_we_i & (wb_adr_i[5:2] == `ATA_CTRL_REG);
|
wire sel_ctrl = CONsel & wb_we_i & (wb_adr_i == `ATA_CTRL_REG);
|
wire sel_stat = CONsel & wb_we_i & (wb_adr_i[5:2] == `ATA_STAT_REG);
|
wire sel_stat = CONsel & wb_we_i & (wb_adr_i == `ATA_STAT_REG);
|
wire sel_PIO_cmdport = CONsel & wb_we_i & (wb_adr_i[5:2] == `ATA_PIO_CMD);
|
wire sel_PIO_cmdport = CONsel & wb_we_i & (wb_adr_i == `ATA_PIO_CMD);
|
// reserved 0x03-0x0f --
|
// reserved 0x03-0x0f --
|
|
|
// generate control register
|
// generate control register
|
always@(posedge wb_clk_i or negedge rst_nreset_i)
|
always@(posedge wb_clk_i or negedge arst_signal)
|
if (~rst_nreset_i)
|
if (~arst_signal)
|
begin
|
begin
|
CtrlReg[31:1] <= 0;
|
CtrlReg[31:1] <= 0;
|
CtrlReg[0] <= 1'b1; // set reset bit (ATA-RESETn line)
|
CtrlReg[0] <= 1'b1; // set reset bit (ATA-RESETn line)
|
end
|
end
|
else if (wb_rst_i)
|
else if (wb_rst_i)
|
Line 152... |
Line 157... |
|
|
|
|
// generate status register clearable bits
|
// generate status register clearable bits
|
reg dirq, int;
|
reg dirq, int;
|
|
|
always@(posedge wb_clk_i or negedge rst_nreset_i)
|
always@(posedge wb_clk_i or negedge arst_signal)
|
if (~rst_nreset_i)
|
if (~arst_signal)
|
begin
|
begin
|
int <= 1'b0;
|
int <= 1'b0;
|
dirq <= 1'b0;
|
dirq <= 1'b0;
|
end
|
end
|
else if (wb_rst_i)
|
else if (wb_rst_i)
|
Line 179... |
Line 184... |
// to read the status register and access the PIO registers at the same time.
|
// to read the status register and access the PIO registers at the same time.
|
assign stat[0] = int;
|
assign stat[0] = int;
|
|
|
|
|
// generate PIO compatible / command-port timing register
|
// generate PIO compatible / command-port timing register
|
always@(posedge wb_clk_i or negedge rst_nreset_i)
|
always@(posedge wb_clk_i or negedge arst_signal)
|
if (~rst_nreset_i)
|
if (~arst_signal)
|
begin
|
begin
|
PIO_cmdport_T1 <= PIO_mode0_T1;
|
PIO_cmdport_T1 <= PIO_mode0_T1;
|
PIO_cmdport_T2 <= PIO_mode0_T2;
|
PIO_cmdport_T2 <= PIO_mode0_T2;
|
PIO_cmdport_T4 <= PIO_mode0_T4;
|
PIO_cmdport_T4 <= PIO_mode0_T4;
|
PIO_cmdport_Teoc <= PIO_mode0_Teoc;
|
PIO_cmdport_Teoc <= PIO_mode0_Teoc;
|
Line 209... |
Line 214... |
// hookup controller section
|
// hookup controller section
|
//
|
//
|
atahost_controller #(TWIDTH, PIO_mode0_T1, PIO_mode0_T2, PIO_mode0_T4, PIO_mode0_Teoc)
|
atahost_controller #(TWIDTH, PIO_mode0_T1, PIO_mode0_T2, PIO_mode0_T4, PIO_mode0_Teoc)
|
u1 (
|
u1 (
|
.clk(wb_clk_i),
|
.clk(wb_clk_i),
|
.nReset(rst_nreset_i),
|
.nReset(arst_signal),
|
.rst(wb_rst_i),
|
.rst(wb_rst_i),
|
.irq(irq),
|
.irq(irq),
|
.IDEctrl_rst(IDEctrl_rst),
|
.IDEctrl_rst(IDEctrl_rst),
|
.IDEctrl_IDEen(IDEctrl_IDEen),
|
.IDEctrl_IDEen(IDEctrl_IDEen),
|
.PIO_cmdport_T1(PIO_cmdport_T1),
|
.PIO_cmdport_T1(PIO_cmdport_T1),
|
Line 225... |
Line 230... |
.PIOack(PIOack),
|
.PIOack(PIOack),
|
.PIOa(wb_adr_i[5:2]),
|
.PIOa(wb_adr_i[5:2]),
|
.PIOd(wb_dat_i[15:0]),
|
.PIOd(wb_dat_i[15:0]),
|
.PIOq(PIOq),
|
.PIOq(PIOq),
|
.PIOwe(wb_we_i),
|
.PIOwe(wb_we_i),
|
.RESETn(ata_resetn_pad_o),
|
.RESETn(resetn_pad_o),
|
.DDi(ata_dd_pad_i),
|
.DDi(dd_pad_i),
|
.DDo(ata_dd_pad_o),
|
.DDo(dd_pad_o),
|
.DDoe(ata_dd_pad_oe),
|
.DDoe(dd_padoen_o),
|
.DA(ata_da_pad_o),
|
.DA(da_pad_o),
|
.CS0n(ata_cs0n_pad_o),
|
.CS0n(cs0n_pad_o),
|
.CS1n(ata_cs1n_pad_o),
|
.CS1n(cs1n_pad_o),
|
.DIORn(ata_diorn_pad_o),
|
.DIORn(diorn_pad_o),
|
.DIOWn(ata_diown_pad_o),
|
.DIOWn(diown_pad_o),
|
.IORDY(ata_iordy_pad_i),
|
.IORDY(iordy_pad_i),
|
.INTRQ(ata_intrq_pad_i)
|
.INTRQ(intrq_pad_i)
|
);
|
);
|
|
|
//
|
//
|
// generate WISHBONE interconnect signals
|
// generate WISHBONE interconnect signals
|
//
|
//
|
Line 266... |
Line 271... |
// assign DAT_O output
|
// assign DAT_O output
|
assign wb_dat_o = `ATA_ATA_ADR ? {16'h0000, PIOq} : Q;
|
assign wb_dat_o = `ATA_ATA_ADR ? {16'h0000, PIOq} : Q;
|
|
|
endmodule
|
endmodule
|
|
|
No newline at end of file
|
No newline at end of file
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|