Skip to content

Commit

Permalink
Add RTC support (WIP)
Browse files Browse the repository at this point in the history
This is part of issue #103.

Changes to CORE:
* Instantiate MiSTer file rtcF83 and connect to tape port.
  This is used by the GEOS software.

Changes to M2M:
* Add i2c_controller.vhd.
  This allows QNICE firmware to communicate with any I2C device,
  via the framework device ID C_DEV_I2C.

Interconnection between CORE and M2M:
With this commit, the CORE expects the current date/time to be
delivered via the QNICE general purpose register main_qnice_gp_reg_i.

TODO: The QNICE firmware should (after reset) read the current date/time
from the RTC device (the actual I2C address and register map is board
dependent), and then write the date/time value in this generic format:

-- Contents of RTC (see user_io.cpp in Main_MiSTer):
-- Bits  7 -  0 : Seconds    (BCD format, 0x00-0x60)
-- Bits 15 -  8 : Minutes    (BCD format, 0x00-0x59)
-- Bits 23 - 16 : Hours      (BCD format, 0x00-0x23)
-- Bits 31 - 24 : DayOfMonth (BCD format, 0x01-0x31)
-- Bits 39 - 32 : Month      (BCD format, 0x01-0x12)
-- Bits 47 - 40 : Year       (BCD format, 0x00-0x99)
-- Bits 55 - 48 : DayOfWeek  (0x00-0x06)
-- Bits 63 - 56 : 0x40
-- Bit       64 : Toggle flag. Flip whenever the values are changed
  • Loading branch information
MJoergen committed Nov 7, 2023
1 parent 49d0f82 commit dca597b
Show file tree
Hide file tree
Showing 13 changed files with 766 additions and 52 deletions.
61 changes: 43 additions & 18 deletions CORE/CORE-R3.xpr
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/C64_MiSTerMEGA65/rtl/rtcF83.sv">
<FileInfo>
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="implementation"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/controllers/MiSTer/scandoubler.v">
<FileInfo SFType="SVerilog">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down Expand Up @@ -319,12 +326,6 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/clock_counter.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/av_pipeline/analog_pipeline.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down Expand Up @@ -355,12 +356,6 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/controllers/HDMI/video_out_clock.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/controllers/HDMI/types_pkg.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down Expand Up @@ -535,6 +530,12 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/clock_counter.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/config.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
Expand All @@ -547,6 +548,12 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/i2c/cpu_to_i2c_master.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/crt_cacher.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down Expand Up @@ -625,6 +632,12 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/controllers/HDMI/video_out_clock.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/reset_manager.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down Expand Up @@ -727,6 +740,18 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/i2c/i2c_master.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/i2c/i2c_controller.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/framework.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down Expand Up @@ -757,37 +782,37 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/main.vhd">
<File Path="$PPRDIR/vhdl/reu_mapper.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/controllers/M65/max10.vhdl">
<File Path="$PPRDIR/vhdl/main.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/prg_loader.vhd">
<File Path="$PPRDIR/../M2M/vhdl/controllers/M65/max10.vhdl">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/sw_cartridge_csr.vhd">
<File Path="$PPRDIR/vhdl/prg_loader.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/sw_cartridge_wrapper.vhd">
<File Path="$PPRDIR/vhdl/sw_cartridge_csr.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/reu_mapper.vhd">
<File Path="$PPRDIR/vhdl/sw_cartridge_wrapper.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
Expand Down
25 changes: 25 additions & 0 deletions CORE/CORE-R4.xpr
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/C64_MiSTerMEGA65/rtl/rtcF83.sv">
<FileInfo>
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="implementation"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/controllers/MiSTer/scandoubler.v">
<FileInfo SFType="SVerilog">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down Expand Up @@ -547,6 +554,12 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/i2c/cpu_to_i2c_master.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/crt_cacher.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down Expand Up @@ -733,6 +746,18 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/i2c/i2c_master.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/i2c/i2c_controller.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/framework.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down
47 changes: 36 additions & 11 deletions CORE/CORE-R5.xpr
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/C64_MiSTerMEGA65/rtl/rtcF83.sv">
<FileInfo>
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="implementation"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/controllers/MiSTer/scandoubler.v">
<FileInfo SFType="SVerilog">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down Expand Up @@ -361,12 +368,6 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/controllers/HDMI/video_out_clock.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/controllers/HDMI/types_pkg.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down Expand Up @@ -553,6 +554,12 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/i2c/cpu_to_i2c_master.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/crt_cacher.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down Expand Up @@ -631,6 +638,12 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/controllers/HDMI/video_out_clock.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/reset_manager.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down Expand Up @@ -733,6 +746,18 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/i2c/i2c_master.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/i2c/i2c_controller.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/../M2M/vhdl/framework.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
Expand Down Expand Up @@ -763,31 +788,31 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/main.vhd">
<File Path="$PPRDIR/vhdl/reu_mapper.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/prg_loader.vhd">
<File Path="$PPRDIR/vhdl/main.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/sw_cartridge_csr.vhd">
<File Path="$PPRDIR/vhdl/prg_loader.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/sw_cartridge_wrapper.vhd">
<File Path="$PPRDIR/vhdl/sw_cartridge_csr.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/vhdl/reu_mapper.vhd">
<File Path="$PPRDIR/vhdl/sw_cartridge_wrapper.vhd">
<FileInfo SFType="VHDL2008">
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="simulation"/>
Expand Down
Loading

0 comments on commit dca597b

Please sign in to comment.