This commit is contained in:
Alan Steremberg 2021-03-16 18:37:43 -07:00
parent 182ebfb2f5
commit 8bef3e8d39
5 changed files with 78 additions and 13 deletions

View File

@ -1,3 +1,9 @@
derive_pll_clocks
derive_clock_uncertainty
#**************************************************************
# Set Multicycle Path
#**************************************************************
#set_multicycle_path -from {hps_io:hps_io|rtc[*]} -to {dataController_top:dc0|rtc:pram|secs[*]} -setup 4
#set_multicycle_path -from {hps_io:hps_io|rtc[*]} -to {dataController_top:dc0|rtc:pram|secs[*]} -hold 3

View File

@ -333,7 +333,6 @@ wire [21:1] dio_a =
wire mouseData;
wire keyClk;
wire keyData;
wire [63:0] rtc;
wire [31:0] io_lba;
wire [1:0] io_rd;
@ -347,9 +346,10 @@ wire [21:1] dio_a =
wire [7:0] sd_buff_din;
wire ioctl_wait;
wire capslock;
wire [63:0] RTC;
wire [32:0] TIMESTAMP;
hps_io #(.STRLEN($size(CONF_STR)>>3),.PS2DIV(1000), .VDNUM(2),.PS2WE(0)) hps_io
@ -384,12 +384,13 @@ hps_io #(.STRLEN($size(CONF_STR)>>3),.PS2DIV(1000), .VDNUM(2),.PS2WE(0)) hps_io
.ioctl_wait(ioctl_wait),
.ps2_key(ps2_key),
//.ps2_key(ps2_key),
.ps2_kbd_led_use(3'b001),
.ps2_kbd_led_status({2'b00, capslock}),
.RTC(RTC),
.TIMESTAMP(TIMESTAMP),
.ps2_mouse(ps2_mouse),
//.ps2_mouse(ps2_mouse),
.ps2_kbd_clk_out ( keyClk ),
.ps2_kbd_data_out ( keyData ),
.ps2_mouse_clk_out ( mouseClk ),
@ -678,11 +679,13 @@ hps_io #(.STRLEN($size(CONF_STR)>>3),.PS2DIV(1000), .VDNUM(2),.PS2WE(0)) hps_io
// peripherals
.keyClk(keyClk),
.keyData(keyData),
.capslock(capslock),
.mouseClk(mouseClk),
.mouseData(mouseData),
.serialIn(serialIn),
.rtc(rtc),
.rtc(RTC),
.timestamp(TIMESTAMP),
// video
._hblank(_hblank),
._vblank(_vblank),
@ -803,7 +806,7 @@ sdram sdram (
// system interface
.clk ( clk64 ),
.sync ( clk8 ),
.sync ( clk8 ), // cpu_en_p?
//.clk_64 ( clk64 ),
//.clk_8 ( clk8 ),
.init ( !pll_locked ),
@ -818,5 +821,39 @@ sdram sdram (
.dout ( sdram_out )
);
/*
assign SDRAM_CKE = 1'b1;
assign SDRAM_CLK = clk64;
sdram sdram (
//.sd_clk ( SDRAM_CLK ),
// interface to the MT48LC16M16 chip
.sd_data ( SDRAM_DQ ),
.sd_addr ( SDRAM_A ),
.sd_dqm ( {SDRAM_DQMH, SDRAM_DQML} ),
.sd_cs ( SDRAM_nCS ),
.sd_ba ( SDRAM_BA ),
.sd_we ( SDRAM_nWE ),
.sd_ras ( SDRAM_nRAS ),
.sd_cas ( SDRAM_nCAS ),
// system interface
.clk_64 ( clk64 ),
.clk_8 ( clk8 ),
.init ( !pll_locked ),
// cpu/chipset interface
// map rom to sdram word address $200000 - $20ffff
.din ( sdram_din ),
.addr ( sdram_addr ),
.ds ( sdram_ds ),
.we ( sdram_we ),
.oe ( sdram_oe ),
.dout ( sdram_out )
);
*/
endmodule

View File

@ -40,7 +40,7 @@ module dataController_top(
// keyboard:
input keyClk,
input keyData,
output capslock,
// mouse:
input mouseClk,
input mouseData,
@ -51,7 +51,8 @@ module dataController_top(
// RTC
input [63:0] rtc,
input [32:0] timestamp,
// video:
output pixelOut,
input _hblank,
@ -277,6 +278,7 @@ module dataController_top(
.clk (clk32),
.reset (!_cpuReset),
.rtc (rtc),
.timestamp (timestamp),
._cs (_rtccs),
.ck (rtcck),
.dat_i (rtcdat_i),
@ -448,6 +450,8 @@ module dataController_top(
.data_out(kbd_out_data), // data from mac
.strobe_out(kbd_out_strobe),
.data_in(kbd_in_data), // data to mac
.strobe_in(kbd_in_strobe));
.strobe_in(kbd_in_strobe),
.capslock(capslock)
);
endmodule

View File

@ -14,7 +14,9 @@ module ps2_kbd( input sysclk,
input strobe_out,
output [7:0] data_in,
output strobe_in
output strobe_in,
output reg capslock
);
reg [8:0] keymac;
@ -23,7 +25,7 @@ module ps2_kbd( input sysclk,
reg inquiry_active;
reg extended;
reg keybreak;
reg capslock;
//reg capslock;
reg haskey;
wire got_key;
wire got_break;

View File

@ -5,6 +5,7 @@ module rtc (
input reset,
input [63:0] rtc, // sec, min, hour, date, month, year, day (BCD)
input [32:0] timestamp, // unix timestamp
input _cs,
input ck,
input dat_i,
@ -18,6 +19,7 @@ function [7:0] bcd2bin;
end
endfunction
reg [2:0] bit_cnt;
reg ck_d;
reg [7:0] din;
@ -26,6 +28,7 @@ reg [7:0] dout;
reg cmd_mode;
reg receiving;
reg [31:0] secs;
reg [31:0] secs2;
reg [7:0] ram[20];
initial begin
@ -51,6 +54,8 @@ initial begin
ram[5'h13] = 8'h6C;
end
`ifdef notdefined
integer sec_cnt;
wire [7:0] year = bcd2bin(rtc[47:40]);
@ -61,6 +66,7 @@ reg [10:0] doy; // day of year
reg [20:0] doe; // day of era
reg [23:0] days;
always @(*) begin
// Days from epoch (01/01/1904)
// y -= m <= 2;
@ -69,19 +75,25 @@ always @(*) begin
// const unsigned doy = (153*(m + (m > 2 ? -3 : 9)) + 2)/5 + d-1; // [0, 365]
// const unsigned doe = yoe * 365 + yoe/4 - yoe/100 + doy; // [0, 146096]
// return era * 146097 + static_cast<Int>(doe) - 719468;
yoe = (month <= 2) ? year - 1'd1 : year;
doy = (8'd153*(month + ((month > 2) ? -3 : 9)) + 4'd2)/4'd5 + day-1'd1;
doe = yoe * 9'd365 + yoe/4 - yoe/100 + doy;
days = 5 * 146097 + doe - 719468 + 24107;
end
`endif
always @(posedge clk) begin
if (reset) begin
bit_cnt <= 0;
receiving <= 1;
cmd_mode <= 1;
dat_o <= 1;
sec_cnt <= 0;
// sec_cnt <= 0;
end
else begin
@ -91,10 +103,14 @@ always @(posedge clk) begin
// secs <= secs + 1'd1;
// end
secs <= timestamp + 2082844800; // difference between unix epoch and mac epoch
`ifdef notdefined
secs <= bcd2bin(rtc[7:0]) +
bcd2bin(rtc[15:8]) * 60 +
bcd2bin(rtc[23:16]) * 3600 +
days * 3600*24;
`endif
if (_cs) begin
bit_cnt <= 0;