Spectrum test18

This commit is contained in:
antoniovillena 2016-04-28 14:28:13 +02:00
parent b8da4b137a
commit 3fa541497b
9 changed files with 287 additions and 27 deletions

View File

@ -37,12 +37,12 @@ module coreid (
text[i] = 8'h00;
text[ 0] = "T";
text[ 1] = "1";
text[ 2] = "7";
text[ 2] = "8";
text[ 3] = "-";
text[ 4] = "2";
text[ 5] = "9";
text[ 4] = "0";
text[ 5] = "3";
text[ 6] = "0";
text[ 7] = "6";
text[ 7] = "7";
text[ 8] = "2";
text[ 9] = "0";
text[10] = "1";

View File

@ -24,11 +24,11 @@ NET "audio_out_left" LOC="P8" | IOSTANDARD = LVCMOS33;
NET "audio_out_right" LOC="P9" | IOSTANDARD = LVCMOS33;
NET "ear" LOC="P105" | IOSTANDARD = LVCMOS33;
# Keyboard
NET "clkps2" LOC="P98" | IOSTANDARD = LVCMOS33 | PULLUP;
NET "dataps2" LOC="P97" | IOSTANDARD = LVCMOS33 | PULLUP;
#NET "clkmouse" LOC="P94" | IOSTANDARD = LVCMOS33 | PULLUP; # comprobar estos pines
#NET "datamouse" LOC="P95" | IOSTANDARD = LVCMOS33 | PULLUP; # los he asignado a voleo
# Keyboard and mouse
NET "clkps2" LOC="P98" | IOSTANDARD = LVCMOS33 | PULLUP; # pin 1 DIN
NET "dataps2" LOC="P97" | IOSTANDARD = LVCMOS33 | PULLUP; # pin 5 DIN
NET "mouseclk" LOC="P94" | IOSTANDARD = LVCMOS33 | PULLUP; # pin 6 DIN
NET "mousedata" LOC="P95" | IOSTANDARD = LVCMOS33 | PULLUP; # pin 2 DIN
# SRAM
NET "sram_addr<0>" LOC="P115" | IOSTANDARD = LVCMOS33;

View File

@ -86,6 +86,7 @@ module ps2_keyb(
ps2_port lectura_de_teclado (
.clk(clk),
.enable_rcv(~ps2busy),
.kb_or_mouse(1'b0),
.ps2clk_ext(clkps2),
.ps2data_ext(dataps2),
.kb_interrupt(nueva_tecla),

View File

@ -0,0 +1,116 @@
`timescale 1ns / 1ps
`default_nettype none
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 17:14:21 06/30/2015
// Design Name:
// Module Name: ps2_mouse_kempston
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module ps2_mouse_kempston (
input wire clk,
input wire rst_n,
inout wire clkps2,
inout wire dataps2,
//---------------------------------
input wire [15:0] a,
input wire iorq_n,
input wire rd_n,
output wire [7:0] kmouse_dout,
output wire oe_n_kmouse,
//---------------------------------
input wire [7:0] zxuno_addr,
input wire zxuno_regrd,
input wire zxuno_regwr,
input wire [7:0] din,
output wire [7:0] mousedata_dout,
output wire oe_n_mousedata,
output reg [7:0] mousestatus_dout,
output wire oe_n_mousestatus
);
parameter MOUSEDATA = 8'h09;
parameter MOUSESTATUS = 8'h0A;
assign oe_n_mousedata = ~(zxuno_addr == MOUSEDATA && zxuno_regrd == 1'b1);
assign oe_n_mousestatus = ~(zxuno_addr == MOUSESTATUS && zxuno_regrd == 1'b1);
wire [7:0] mousedata;
wire [7:0] kmouse_x, kmouse_y, kmouse_buttons;
wire ps2busy;
wire ps2error;
wire nuevo_evento;
wire [1:0] state_out;
assign mousedata_dout = mousedata;
wire kmouse_x_req_n = ~(!iorq_n && !rd_n && a[7:0]==8'hDF && a[8]==1'b1 && a[9]==1'b1 && a[10]==1'b0);
wire kmouse_y_req_n = ~(!iorq_n && !rd_n && a[7:0]==8'hDF && a[8]==1'b1 && a[9]==1'b1 && a[10]==1'b1);
wire kmouse_butt_req_n = ~(!iorq_n && !rd_n && a[7:0]==8'hDF && a[8]==1'b0);
assign kmouse_dout = (kmouse_x_req_n==1'b0)? kmouse_x :
(kmouse_y_req_n==1'b0)? kmouse_y :
(kmouse_butt_req_n==1'b0)? kmouse_buttons :
8'hZZ;
assign oe_n_kmouse = kmouse_x_req_n & kmouse_y_req_n & kmouse_butt_req_n;
/*
| BSY | x | x | x | ERR | RLS | EXT | PEN |
*/
reg reading_mousestatus = 1'b0;
always @(posedge clk) begin
mousestatus_dout[7:1] <= {ps2busy, 3'b000, ps2error, 2'b00};
if (nuevo_evento == 1'b1)
mousestatus_dout[0] <= 1'b1;
if (oe_n_mousestatus == 1'b0)
reading_mousestatus <= 1'b1;
else if (reading_mousestatus == 1'b1) begin
mousestatus_dout[0] <= 1'b0;
reading_mousestatus <= 1'b0;
end
end
ps2_port lectura_de_raton (
.clk(clk),
.enable_rcv(~ps2busy),
.kb_or_mouse(1'b1),
.ps2clk_ext(clkps2),
.ps2data_ext(dataps2),
.kb_interrupt(nuevo_evento),
.scancode(mousedata),
.released(),
.extended()
);
ps2mouse_to_kmouse traductor_raton (
.clk(clk),
.rst_n(rst_n),
.data(mousedata),
.data_valid(nuevo_evento),
.kmouse_x(kmouse_x),
.kmouse_y(kmouse_y),
.kmouse_buttons(kmouse_buttons)
);
ps2_host_to_kb escritura_a_raton (
.clk(clk),
.ps2clk_ext(clkps2),
.ps2data_ext(dataps2),
.data(din),
.dataload(zxuno_addr == MOUSEDATA && zxuno_regwr== 1'b1),
.ps2busy(ps2busy),
.ps2error(ps2error)
);
endmodule

View File

@ -23,6 +23,7 @@
module ps2_port (
input wire clk, // se recomienda 1 MHz <= clk <= 600 MHz
input wire enable_rcv, // habilitar la maquina de estados de recepcion
input wire kb_or_mouse, // 0: kb, 1: mouse
input wire ps2clk_ext,
input wire ps2data_ext,
output wire kb_interrupt, // a 1 durante 1 clk para indicar nueva tecla recibida
@ -55,7 +56,7 @@ module ps2_port (
always @(posedge clk) begin
negedgedetect <= {negedgedetect[14:0], ps2clk};
end
wire ps2clkedge = (negedgedetect == 16'hFF00)? 1'b1 : 1'b0;
wire ps2clkedge = (negedgedetect == 16'hF000)? 1'b1 : 1'b0;
// Paridad instantánea de los bits recibidos
wire paritycalculated = ^key;
@ -83,7 +84,6 @@ module ps2_port (
if (ps2data == 1'b0) begin
state <= `RCVDATA;
key <= 8'h80;
//rkb_interrupt <= 1'b0;
end
end
`RCVDATA: begin
@ -102,18 +102,23 @@ module ps2_port (
end
`RCVSTOP: begin
state <= `RCVSTART;
if (ps2data == 1'b1) begin
if (ps2data == 1'b1) begin
scancode <= key;
if (key == 8'hE0) begin
regextended <= 2'b01;
end
else if (key == 8'hF0) begin
regreleased <= 2'b01;
if (kb_or_mouse == 1'b1) begin
rkb_interrupt <= 1'b1; // no se requiere mirar E0 o F0
end
else begin
regextended <= {regextended[0], 1'b0};
regreleased <= {regreleased[0], 1'b0};
rkb_interrupt <= 1'b1;
if (key == 8'hE0) begin
regextended <= 2'b01;
end
else if (key == 8'hF0) begin
regreleased <= 2'b01;
end
else begin
regextended <= {regextended[0], 1'b0};
regreleased <= {regreleased[0], 1'b0};
rkb_interrupt <= 1'b1;
end
end
end
end

View File

@ -0,0 +1,82 @@
`timescale 1ns / 1ps
`default_nettype none
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 18:52:22 06/30/2015
// Design Name:
// Module Name: ps2mouse_to_kmouse
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module ps2mouse_to_kmouse (
input wire clk,
input wire rst_n,
input wire [7:0] data,
input wire data_valid,
output reg [7:0] kmouse_x,
output reg [7:0] kmouse_y,
output reg [7:0] kmouse_buttons
);
parameter FIRST_FRAME = 2'd0,
SECOND_FRAME = 2'd1,
THIRD_FRAME = 2'd2,
CALCULATE_NEWXY = 2'd3;
initial begin
kmouse_x = 8'h00;
kmouse_y = 8'h00;
kmouse_buttons = 8'hFF;
end
reg [7:0] deltax, deltay;
reg [1:0] state = FIRST_FRAME;
always @(posedge clk) begin
if (rst_n == 1'b0) begin
kmouse_x <= 8'h00;
kmouse_y <= 8'h00;
kmouse_buttons <= 8'hFF;
state <= FIRST_FRAME;
end
else begin
case (state)
FIRST_FRAME:
if (data_valid == 1'b1) begin
if (data[3] == 1'b1) begin
kmouse_buttons <= {5'b11111,~data[2],~data[0],~data[1]};
state <= SECOND_FRAME;
end
end
SECOND_FRAME:
if (data_valid == 1'b1) begin
deltax <= data;
state <= THIRD_FRAME;
end
THIRD_FRAME:
if (data_valid == 1'b1) begin
deltay <= data;
state <= CALCULATE_NEWXY;
end
CALCULATE_NEWXY:
begin
kmouse_x <= kmouse_x + deltax;
kmouse_y <= kmouse_y + deltay;
state <= FIRST_FRAME;
end
endcase
end
end
endmodule

View File

@ -31,6 +31,8 @@ module tld_zxuno (
input wire ear,
inout wire clkps2,
inout wire dataps2,
inout wire mouseclk,
inout wire mousedata,
output wire audio_out_left,
output wire audio_out_right,
output wire stdn,
@ -71,6 +73,7 @@ module tld_zxuno (
assign wssclk = 1'b0; // de momento, sin WSS
assign stdn = 1'b0; // fijar norma PAL
assign stdnb = 1'b1; // y conectamos reloj PAL
// pll reloj_maestro
// (// Clock in ports
// .CLK_IN1 (clk50mhz), // IN
@ -81,16 +84,24 @@ module tld_zxuno (
// .PROGDATA (1'b0), // IN
// .PROGEN (1'b0), // IN
// .PROGDONE ()); // OUT
//
// reg [2:0] divclk = 3'b000;
// always @(posedge sysclk)
// divclk <= divclk + 1;
// assign clk14 = divclk[0];
// assign clk7 = divclk[1];
// assign clk3d5 = divclk[2];
cuatro_relojes relojes_maestros
(// Clock in ports
.CLK_IN1 (clk50mhz), // IN
// Clock out ports
.CLK_OUT1 (sysclk), // OUT
.CLK_OUT1 (sysclk) , // OUT
.CLK_OUT2 (clk14), // OUT
.CLK_OUT3 (clk7), // OUT
.CLK_OUT4 (clk3d5)); // OUT
wire audio_out;
assign audio_out_left = audio_out;
assign audio_out_right = audio_out;
@ -129,7 +140,10 @@ module tld_zxuno (
.joydown(joydown),
.joyleft(joyleft),
.joyright(joyright),
.joyfire(joyfire)
.joyfire(joyfire),
.mouseclk(mouseclk),
.mousedata(mousedata)
);
assign testled = (!flash_cs_n || !sd_cs_n);

View File

@ -57,11 +57,15 @@ module zxuno (
input wire sd_miso,
// DB9 JOYSTICK
input wire joyup,
input wire joydown,
input wire joyleft,
input wire joyright,
input wire joyfire
input wire joyup,
input wire joydown,
input wire joyleft,
input wire joyright,
input wire joyfire,
// MOUSE
inout wire mouseclk,
inout wire mousedata
);
// Señales de la CPU
@ -142,6 +146,12 @@ module zxuno (
wire oe_n_nmievents;
wire nmispecial_n;
wire page_configrom_active;
// Kempston mouse
wire [7:0] kmouse_dout;
wire [7:0] mousedata_dout;
wire [7:0] mousestatus_dout;
wire oe_n_kmouse, oe_n_mousedata, oe_n_mousestatus;
// Asignación de dato para la CPU segun la decodificación de todos los dispositivos
// conectados a ella.
@ -156,6 +166,9 @@ module zxuno (
(oe_n_keymap==1'b0)? keymap_dout :
(oe_n_scratch==1'b0)? scratch_dout :
(oe_n_nmievents==1'b0)? nmievents_dout :
(oe_n_kmouse==1'b0)? kmouse_dout :
(oe_n_mousedata==1'b0)? mousedata_dout :
(oe_n_mousestatus==1'b0)? mousestatus_dout :
ula_dout;
tv80n_wrapper el_z80 (
@ -386,6 +399,27 @@ module zxuno (
.page_configrom_active(page_configrom_active)
);
ps2_mouse_kempston el_raton (
.clk(clk),
.rst_n(rst_n & mrst_n & power_on_reset_n),
.clkps2(mouseclk),
.dataps2(mousedata),
//---------------------------------
.a(cpuaddr),
.iorq_n(iorq_n),
.rd_n(rd_n),
.kmouse_dout(kmouse_dout),
.oe_n_kmouse(oe_n_kmouse),
//---------------------------------
.zxuno_addr(zxuno_addr),
.zxuno_regrd(zxuno_regrd),
.zxuno_regwr(zxuno_regwr),
.din(cpudout),
.mousedata_dout(mousedata_dout),
.oe_n_mousedata(oe_n_mousedata),
.mousestatus_dout(mousestatus_dout),
.oe_n_mousestatus(oe_n_mousestatus)
);
///////////////////////////////////
// AY-3-8912 SOUND

View File

@ -155,6 +155,14 @@
<association xil_pn:name="BehavioralSimulation"/>
<association xil_pn:name="Implementation"/>
</file>
<file xil_pn:name="ps2_mouse_kempston.v" xil_pn:type="FILE_VERILOG">
<association xil_pn:name="BehavioralSimulation"/>
<association xil_pn:name="Implementation"/>
</file>
<file xil_pn:name="ps2mouse_to_kmouse.v" xil_pn:type="FILE_VERILOG">
<association xil_pn:name="BehavioralSimulation"/>
<association xil_pn:name="Implementation"/>
</file>
</files>
<properties>