Permalink
Browse files

CF/PS2 support for Milkymist SoC

  • Loading branch information...
Takeshi Matsuya
Takeshi Matsuya committed Sep 20, 2010
1 parent a0421bd commit 8886e6385eebdccdbd7be792fc3ea2c52bbcfbac
View
@@ -33,9 +33,15 @@ wire dmx;
wire ir;
wire usb;
wire memtest;
+wire aceusb;
+wire ps2keyboard;
+wire ps2mouse;
assign capabilities = {
- 20'd0,
+ 17'd0,
+ ps2mouse,
+ ps2keyboard,
+ aceusb,
memtest,
usb,
ir,
@@ -122,4 +128,22 @@ assign memtest = 1'b1;
assign memtest = 1'b0;
`endif
+`ifdef ENABLE_ACEUSB
+assign aceusb = 1'b1;
+`else
+assign aceusb = 1'b0;
+`endif
+
+`ifdef ENABLE_PS2_KEYBOARD
+assign ps2keyboard = 1'b1;
+`else
+assign ps2keyboard = 1'b0;
+`endif
+
+`ifdef ENABLE_PS2_MOUSE
+assign ps2keymouse = 1'b1;
+`else
+assign ps2keymouse = 1'b0;
+`endif
+
endmodule
@@ -18,9 +18,12 @@
`define ENABLE_AC97
//`define ENABLE_PFPU
//`define ENABLE_TMU
-//`define ENABLE_ETHERNET
+`define ENABLE_ETHERNET
`define ENABLE_FMLMETER
`define ENABLE_USB
+`define ENABLE_ACEUSB
+`define ENABLE_PS2_KEYBOARD
+//`define ENABLE_PS2_MOUSE
/*
* System clock frequency in Hz.
@@ -74,13 +74,31 @@ module system(
output [7:0] vga_g,
output [7:0] vga_b,
output vga_clkout,
+
+ // SystemACE/USB
+ output [6:0] aceusb_a,
+ inout [15:0] aceusb_d,
+ output aceusb_oe_n,
+ output aceusb_we_n,
+ input ace_clkin,
+ output ace_mpce_n,
+ input ace_mpirq,
+ output usb_cs_n,
+ output usb_hpi_reset_n,
+ input usb_hpi_int,
// AC97
input ac97_clk,
input ac97_sin,
output ac97_sout,
output ac97_sync,
+ // PS2
+ inout ps2_clk1,
+ inout ps2_data1,
+ inout ps2_clk2,
+ inout ps2_data2,
+
// Ethernet
output phy_rst_n,
input phy_tx_clk,
@@ -238,7 +256,8 @@ wire cpuibus_ack,
wire [31:0] norflash_adr,
usb_adr,
brg_adr,
- csrbrg_adr;
+ csrbrg_adr,
+ aceusb_adr;
wire [2:0] brg_cti;
@@ -249,7 +268,9 @@ wire [31:0] norflash_dat_r,
brg_dat_r,
brg_dat_w,
csrbrg_dat_r,
- csrbrg_dat_w;
+ csrbrg_dat_w,
+ aceusb_dat_r,
+ aceusb_dat_w;
wire [3:0] norflash_sel,
usb_sel,
@@ -258,33 +279,38 @@ wire [3:0] norflash_sel,
wire norflash_we,
usb_we,
brg_we,
- csrbrg_we;
+ csrbrg_we,
+ aceusb_we;
wire norflash_cyc,
usb_cyc,
brg_cyc,
- csrbrg_cyc;
+ csrbrg_cyc,
+ aceusb_cyc;
wire norflash_stb,
usb_stb,
brg_stb,
- csrbrg_stb;
+ csrbrg_stb,
+ aceusb_stb;
wire norflash_ack,
usb_ack,
brg_ack,
- csrbrg_ack;
+ csrbrg_ack,
+ aceusb_ack;
//---------------------------------------------------------------------------
// Wishbone switch
//---------------------------------------------------------------------------
conbus #(
/* MSB (Bit 31) is ignored by conbus */
- .s_addr_w(2),
- .s0_addr(2'b00), // norflash 0x00000000 (shadow @0x80000000)
- .s1_addr(2'b01), // USB 0x20000000 (shadow @0xa0000000)
- .s2_addr(2'b10), // FML bridge 0x40000000 (shadow @0xc0000000)
- .s3_addr(2'b11) // CSR bridge 0x60000000 (shadow @0xe0000000)
+ .s_addr_w(3),
+ .s0_addr(3'b000), // norflash 0x00000000 (shadow @0x80000000)
+ .s1_addr(3'b010), // USB 0x20000000 (shadow @0xa0000000)
+ .s2_addr(3'b100), // FML bridge 0x40000000 (shadow @0xc0000000)
+ .s3_addr(3'b110), // CSR bridge 0x60000000 (shadow @0xe0000000)
+ .s4_addr(3'b111) // aceusb 0x70000000 (shadow @0xf0000000)
) conbus (
.sys_clk(sys_clk),
.sys_rst(sys_rst),
@@ -396,7 +422,15 @@ conbus #(
.s3_we_o(csrbrg_we),
.s3_cyc_o(csrbrg_cyc),
.s3_stb_o(csrbrg_stb),
- .s3_ack_i(csrbrg_ack)
+ .s3_ack_i(csrbrg_ack),
+ // Slave 4
+ .s4_dat_i(aceusb_dat_r),
+ .s4_dat_o(aceusb_dat_w),
+ .s4_adr_o(aceusb_adr),
+ .s4_we_o(aceusb_we),
+ .s4_cyc_o(aceusb_cyc),
+ .s4_stb_o(aceusb_stb),
+ .s4_ack_i(aceusb_ack)
);
//------------------------------------------------------------------
@@ -414,7 +448,9 @@ wire [31:0] csr_dr_uart,
csr_dr_tmu,
csr_dr_ethernet,
csr_dr_fmlmeter,
- csr_dr_usb;
+ csr_dr_usb,
+ csr_dr_ps2,
+ csr_dr_mouse;
//------------------------------------------------------------------
// FML master wires
@@ -554,6 +590,8 @@ csrbrg csrbrg(
|csr_dr_ethernet
|csr_dr_fmlmeter
|csr_dr_usb
+ |csr_dr_ps2
+ |csr_dr_mouse
)
);
@@ -612,13 +650,15 @@ wire tmu_irq;
wire ethernetrx_irq;
wire ethernettx_irq;
wire usb_irq;
+wire keyboard_irq;
+wire mouse_irq;
wire [31:0] cpu_interrupt;
assign cpu_interrupt = {14'd0,
usb_irq,
1'b0,
- 1'b0,
- 1'b0,
+ mouse_irq,
+ keyboard_irq,
1'b0,
ethernettx_irq,
ethernetrx_irq,
@@ -803,6 +843,45 @@ assign lcd_rs = gpio_outputs[8];
assign lcd_rw = gpio_outputs[9];
assign lcd_d = gpio_outputs[13:10];
+//---------------------------------------------------------------------------
+// SystemACE/USB interface
+//---------------------------------------------------------------------------
+`ifdef ENABLE_ACEUSB
+aceusb aceusb(
+ .sys_clk(sys_clk),
+ .sys_rst(sys_rst),
+
+ .wb_cyc_i(aceusb_cyc),
+ .wb_stb_i(aceusb_stb),
+ .wb_ack_o(aceusb_ack),
+ .wb_adr_i(aceusb_adr),
+ .wb_dat_i(aceusb_dat_w),
+ .wb_dat_o(aceusb_dat_r),
+ .wb_we_i(aceusb_we),
+
+ .aceusb_a(aceusb_a),
+ .aceusb_d(aceusb_d),
+ .aceusb_oe_n(aceusb_oe_n),
+ .aceusb_we_n(aceusb_we_n),
+ .ace_clkin(ace_clkin),
+ .ace_mpce_n(ace_mpce_n),
+ .ace_mpirq(ace_mpirq),
+ .usb_cs_n(usb_cs_n),
+ .usb_hpi_reset_n(usb_hpi_reset_n),
+ .usb_hpi_int(usb_hpi_int)
+);
+`else
+assign aceusb_a = 7'd0;
+assign aceusb_d = 16'bz;
+assign aceusb_oe_n = 1'b1;
+assign aceusb_we_n = 1'b1;
+assign ace_mpce_n = 1'b0;
+assign usb_cs_n = 1'b1;
+assign usb_hpi_reset_n = 1'b1;
+assign aceusb_ack = aceusb_cyc & aceusb_stb;
+assign aceusb_dat_r = 32'habadface;
+`endif
+
//---------------------------------------------------------------------------
// DDR SDRAM
//---------------------------------------------------------------------------
@@ -1030,6 +1109,56 @@ assign fml_tmuw_sel = 8'bx;
assign fml_tmuw_dw = 64'bx;
`endif
+//---------------------------------------------------------------------------
+// PS2 Interface
+//---------------------------------------------------------------------------
+`ifdef ENABLE_PS2_KEYBOARD
+ps2 #(
+ .csr_addr(4'hc),
+ .clk_freq(`CLOCK_FREQUENCY)
+) ps2_keyboard (
+ .sys_clk(sys_clk),
+ .sys_rst(sys_rst),
+
+ .csr_a(csr_a),
+ .csr_we(csr_we),
+ .csr_di(csr_dw),
+ .csr_do(csr_dr_ps2),
+
+ .ps2_clk(ps2_clk1),
+ .ps2_data(ps2_data1),
+
+ .irq(keyboard_irq)
+
+);
+`else
+assign csr_dr_ps2 = 32'd0;
+assign keyboard_irq = 1'd0;
+`endif
+`ifdef ENABLE_PS2_MOUSE
+ps2 #(
+ .csr_addr(4'hd),
+ .clk_freq(`CLOCK_FREQUENCY)
+) ps2_mouse (
+ .sys_clk(sys_clk),
+ .sys_rst(sys_rst),
+
+ .csr_a(csr_a),
+ .csr_we(csr_we),
+ .csr_di(csr_dw),
+ .csr_do(csr_dr_mouse),
+
+ .ps2_clk(ps2_clk2),
+ .ps2_data(ps2_data2),
+
+ .irq(mouse_irq)
+
+);
+`else
+assign csr_dr_mouse = 32'd0;
+assign mouse_irq = 1'd0;
+`endif
+
//---------------------------------------------------------------------------
// Ethernet
//---------------------------------------------------------------------------
@@ -62,5 +62,7 @@ TMU_SRC= \
ETHERNET_SRC=$(wildcard $(CORES_DIR)/minimac/rtl/*.v)
FMLMETER_SRC=$(wildcard $(CORES_DIR)/fmlmeter/rtl/*.v)
USB_SRC=$(wildcard $(CORES_DIR)/softusb/rtl/*.v)
+ACEUSB_SRC=$(wildcard $(CORES_DIR)/aceusb/rtl/*.v)
+PS2_SRC=$(wildcard $(CORES_DIR)/ps2/rtl/*.v)
-CORES_SRC=$(CONBUS_SRC) $(LM32_SRC) $(FMLARB_SRC) $(FMLBRG_SRC) $(CSRBRG_SRC) $(NORFLASH_SRC) $(UART_SRC) $(SYSCTL_SRC) $(HPDMC_SRC) $(VGAFB_SRC) $(AC97_SRC) $(PFPU_SRC) $(TMU_SRC) $(USB_SRC) $(ETHERNET_SRC) $(FMLMETER_SRC)
+CORES_SRC=$(CONBUS_SRC) $(LM32_SRC) $(FMLARB_SRC) $(FMLBRG_SRC) $(CSRBRG_SRC) $(NORFLASH_SRC) $(UART_SRC) $(SYSCTL_SRC) $(HPDMC_SRC) $(VGAFB_SRC) $(AC97_SRC) $(PFPU_SRC) $(TMU_SRC) $(USB_SRC) $(ETHERNET_SRC) $(FMLMETER_SRC) $(ACEUSB_SRC) $(PS2_SRC)
@@ -283,6 +283,52 @@ NET "vga_psave_n" LOC = M25 | IOSTANDARD = LVCMOS33 | SLEW = FAST | DRIVE = 8;
NET "vga_blank_n" LOC = M24 | IOSTANDARD = LVCMOS33 | SLEW = FAST | DRIVE = 8;
NET "vga_sync_n" LOC = L23 | IOSTANDARD = LVCMOS33 | SLEW = FAST | DRIVE = 8;
+# ==== SystemACE/USB ====
+
+# Shared signals
+NET "aceusb_a(0)" LOC = U22;
+NET "aceusb_a(1)" LOC = Y10;
+NET "aceusb_a(2)" LOC = AA10;
+NET "aceusb_a(3)" LOC = AC7;
+NET "aceusb_a(4)" LOC = Y7;
+NET "aceusb_a(5)" LOC = AA9;
+NET "aceusb_a(6)" LOC = Y9;
+NET "aceusb_a(*)" IOSTANDARD = LVCMOS33 | SLEW = SLOW | DRIVE = 4;
+NET "aceusb_d(0)" LOC = AB7;
+NET "aceusb_d(1)" LOC = AC9;
+NET "aceusb_d(2)" LOC = AB9;
+NET "aceusb_d(3)" LOC = AE6;
+NET "aceusb_d(4)" LOC = AD6;
+NET "aceusb_d(5)" LOC = AF9;
+NET "aceusb_d(6)" LOC = AE9;
+NET "aceusb_d(7)" LOC = AD8;
+NET "aceusb_d(8)" LOC = AC8;
+NET "aceusb_d(9)" LOC = AF4;
+NET "aceusb_d(10)" LOC = AE4;
+NET "aceusb_d(11)" LOC = AD3;
+NET "aceusb_d(12)" LOC = AC3;
+NET "aceusb_d(13)" LOC = AF6;
+NET "aceusb_d(14)" LOC = AF5;
+NET "aceusb_d(15)" LOC = AA7;
+NET "aceusb_d(*)" IOSTANDARD = LVCMOS33 | SLEW = SLOW | DRIVE = 4 | PULLDOWN;
+NET "aceusb_oe_n" LOC = AA8 | IOSTANDARD = LVCMOS33 | SLEW = SLOW | DRIVE = 4;
+NET "aceusb_we_n" LOC = Y8 | IOSTANDARD = LVCMOS33 | SLEW = SLOW | DRIVE = 4;
+
+# SystemACE signals
+NET "ace_clkin" LOC = AF11;
+NET "ace_clkin" IOSTANDARD = LVCMOS33;
+NET "ace_clkin" TNM_NET = "ace_clkin";
+# leave 1ns margin (as in the ML401 UCF from Xilinx)
+TIMESPEC "TSace" = PERIOD "ace_clkin" 29 ns HIGH 50%;
+
+NET "ace_mpce_n" LOC = AD5 | IOSTANDARD = LVCMOS33 | SLEW = SLOW | DRIVE = 4;
+NET "ace_mpirq" LOC = AD4 | IOSTANDARD = LVCMOS33 | PULLDOWN;
+
+# USB signals
+NET "usb_cs_n" LOC = AF10 | IOSTANDARD = LVCMOS33 | SLEW = SLOW | DRIVE = 4;
+NET "usb_hpi_reset_n" LOC = A7 | IOSTANDARD = LVCMOS25;
+NET "usb_hpi_int" LOC = V5 | IOSTANDARD = LVCMOS33 | PULLDOWN;
+
# ==== AC97 ====
NET "ac97_clk" LOC = AE10 | IOSTANDARD = LVCMOS33;
NET "ac97_sin" LOC = AD16 | IOSTANDARD = LVCMOS33; # codec to FPGA
@@ -293,6 +339,14 @@ NET "ac97_sync" LOC = D9 | IOSTANDARD = LVCMOS25;
NET "ac97_clk" TNM_NET = "clkac97";
TIMESPEC "TSclkac97" = PERIOD "clkac97" 80 HIGH 50%;
+# ==== PS/2 ====
+# "keyboard" connector
+NET "ps2_clk1" LOC = D2 | IOSTANDARD = LVCMOS25;
+NET "ps2_data1" LOC = G9 | IOSTANDARD = LVCMOS25;
+# "mouse" connector
+NET "ps2_clk2" LOC = B14 | IOSTANDARD = LVCMOS25;
+NET "ps2_data2" LOC = C14 | IOSTANDARD = LVCMOS25;
+
# ==== Ethernet ====
NET "phy_col" LOC = E3;
NET "phy_crs" LOC = D5;
Oops, something went wrong.

0 comments on commit 8886e63

Please sign in to comment.