Commit Graph

359 Commits

Author SHA1 Message Date
Byron Lathi
a94b26dc3c Change code and data base to be pointers
These are technically pointers, so lets type them as such.
2022-04-16 19:24:21 -05:00
Byron Lathi
2786ec0940 Execute code read from the SD card
This will read the data from the sd card, copy it to the originally
linked address (no relocation), then execute it.

I am lazy and wrote it in C using weird function pointer casting but
this would probably be more efficient if it were to be written in
assembly instead.

The test program simply returns 'A', but that is enough to prove that it
is actually running.
2022-04-16 14:56:41 -05:00
Byron Lathi
585faa023f Remove compilation output files
These were used to help understand the o65 file format, but are not
needed and shouldn't have been commited anyway.
2022-04-16 14:30:34 -05:00
Byron Lathi
4be5366aee Do not track o65 files
These are object files still, which means we do not want to track them.
2022-04-16 14:28:40 -05:00
Byron Lathi
7e7bdd3b4a Use the system cl65, don't use verbose mode
I had used these to try and help figure out the structure of the o65
file but this is not needed anymore
2022-04-16 14:27:18 -05:00
Byron Lathi
016e9edee7 More o65 parsing
Prints out the options now too.
2022-04-16 14:22:26 -05:00
Byron Lathi
e30768d4c2 Rename o65_opt to o65_opt_t 2022-04-16 14:22:16 -05:00
Byron Lathi
f15b7876fe Add parsing of o65 files
Prints out information about the first file found on the SD card, if it
is an o65 file.
2022-04-16 14:10:54 -05:00
Byron Lathi
59da06c509 Add basic test program
This adds a test program which can be loaded and executed by the host.
It simply returns a value in the `a` register.

The linker script is modified so that it will output an o65 file, and
the memory sgments are changed as well. There is no STARTUP segment
defined, so it uses the default `none` crt0, which sets up the stack
and does initialization and deconstruction.

The Makefile is modified to not turn the output into an intel hex file,
and instead keep it as the o65 file.
2022-04-16 14:10:39 -05:00
Byron Lathi
0cecf166c7 Add definitions and structures for o65 files
These can be used to read and parse o65 files.
2022-04-16 14:02:57 -05:00
Byron Lathi
2c6f333966 Remove unused char c 2022-04-16 14:02:43 -05:00
Byron Lathi
7c2aab59dc Merge branch 'sdcard' into 'master'
Read data from a file

See merge request bslathi19/super6502!12
2022-04-14 22:16:28 +00:00
Byron Lathi
246d7a5e6f Print out more information, read a file
Prints out information about the drive, now inside its own function.

Also changes the read function to take in a 32 bit address instead of a
16 bit one.

Attempts to read the first file on the disk
2022-04-14 17:04:47 -05:00
Byron Lathi
380550c77d Add more struct definitions
Adds filesystem info struct and directory entry structs
2022-04-14 17:04:08 -05:00
Byron Lathi
7df0b67b12 Print out information about the sd card filesystem.
Prints out all of the parameter blocks for the SD card.
2022-04-14 13:50:14 -05:00
Byron Lathi
3c68e4584f Add some definitions for FAT32 file system
Adds some struct types for the FAT32 file system.

This just includes the information in the parameter blocks, not any
actual files.
2022-04-14 13:49:11 -05:00
Byron Lathi
d140928148 Add testing function for reading sd blocks
Add a simple function which reads a 512 block from the SD card and then
prints it to the console.
2022-04-14 11:23:44 -05:00
Byron Lathi
ee95a592cd Reset bit count upon entering RXDATA
The but count should be set to 7 when entering RXDATA. previously it was
not reset or left at 0, which caused the first byte to only have the lsb
set and all other bits to be read incorrectly.
2022-04-14 11:20:48 -05:00
Byron Lathi
3a59de2947 Change data count to have proper width (9)
This was probably an off-by-one mistage, with the width set to 10
instead of 9. The width should be 9 since the buffer is 512 bytes.
2022-04-14 11:19:08 -05:00
Byron Lathi
b025e90151 Merge branch 'sdcard' into 'master'
Add SD Card Controller

See merge request bslathi19/super6502!11
2022-04-11 22:38:48 +00:00
Byron Lathi
c9269b2fb8 Fix some warnings
Adds some missing cases, length specifiers.
2022-04-11 16:13:38 -05:00
Byron Lathi
68a422d5e3 Disable signal tap 2022-04-11 16:03:50 -05:00
Byron Lathi
f4e16c0c12 Add software interface for reading SD card data
Adds functions to wait for data to be read, and to read data form the sd
card controller.
2022-04-11 14:03:42 -05:00
Byron Lathi
87d1457d94 Add logic to store and readback data from SD card
After a data read (e.g. CMD17) the data received from the SD card is
stored into a buffer which can be read back one byte at a time by the
CPU through address 5.

There is also a flag which is set when data is received. This can be
checked by reading the CMD register, which doubles as the status
register.
2022-04-11 13:57:56 -05:00
Byron Lathi
51c348bc7c Increase sd card addr width by 1
Adds a new memory location for data accesses.
2022-04-11 13:57:07 -05:00
Byron Lathi
9eaa6c49f9 Add software support for sd response codes
Polls the sd controller until the read flag is set, at which point it
reads 32 bits of data from the controller.

long response codes (such as CID) are not supported in hw or sw.
2022-04-10 23:18:26 -05:00
Byron Lathi
f5f1d7ccc6 Add read flag to sd controller
Read flag is set when the sd controller reads response data in from the
sd card. When the cpu reads from the controller, the flag is reset.

This flag does not trigger an interrupt, it mmust be polled.
2022-04-10 23:16:10 -05:00
Byron Lathi
385efb2511 Read some data off of the sd card
These series of commands are enough to read the first 512b block off of
the sd card. The RCA is hard coded to the sd card that I have on hand,
since response codes are not supported
2022-04-10 19:34:38 -05:00
Byron Lathi
7092cc8f77 Add SD card software interface
Adds a function to send a command to the sd card.
2022-04-10 17:55:51 -05:00
Byron Lathi
cd11670fb1 Add sd controller to top level
Also adds the logic required for the bidirectional sd lines and attaches
the controller to the cpu.
2022-04-10 17:54:08 -05:00
Byron Lathi
1128b986eb Fix state transitions with regard to clock
The SD card expects data to transition on falling edges and be stable on
rising edges.

Additionally, writes from the CPU were not handled with correct timing.

Now, there is an extra state when writing to the command register so
that the command is properly latched before the CRC is calculated.
2022-04-10 17:52:07 -05:00
Byron Lathi
50b0860137 Update testbench with more realistic timings
Updates the testbench to simulate writes with more correct timings.
Writes take two clock cycles since the cpu runs at half speed.
2022-04-10 17:50:49 -05:00
Byron Lathi
09428c8875 Add sd card cs 2022-04-10 16:15:55 -05:00
Byron Lathi
31a4656cac Reduce sd_controller addr width from 4 to 3 2022-04-09 17:31:25 -05:00
Byron Lathi
38566f7b4a add testbench for SD command tx
Sends a few commands which we know the proper checksum for and makes
sure that the bits on the output are correct.
2022-04-08 12:29:15 -05:00
Byron Lathi
f89ecfa038 Add SD Card controller for sending commands
Adds the start of the SD card controller which is capable of sending
commands using the SD protocol.

It is accessed by writing the arguments first and triggered by writing
the command number.
2022-04-08 12:28:17 -05:00
Byron Lathi
552fe8b6f8 Have valid crc when valid signal is present
Previously the crc would be reset after 1 clock cycle while the valid
signal was still high. Now the data is preserved in the valid state
until the load signal is asserted.
2022-04-08 12:25:17 -05:00
Byron Lathi
3e69109474 Add tests for crc7
These are just some values that I found from an example program. This
does not test every possible value.
2022-04-08 00:56:14 -05:00
Byron Lathi
e828df0807 Add crc7 module
This module takes in a 40 bit word and generates the 7 bit crc7
appropriate for an SD card.

It does not use any fancy parallel algorithm, it does it 1 bit at a
time.
2022-04-08 00:50:28 -05:00
Byron Lathi
f276c5469e Fix indentation 2022-04-08 00:49:59 -05:00
Byron Lathi
7e1605b917 Merge branch 'mmu' into 'master'
Add memory mapper.

See merge request bslathi19/super6502!10
2022-04-07 17:52:41 +00:00
Byron Lathi
0752cc4b8c do a little test to see if memory mapping works
This code creates a shared mapping in high ram, makes sure that that
works, and also makes sure that the memory which is mapped over is left
unchanged.
2022-04-07 12:43:47 -05:00
Byron Lathi
2f79a00000 Decode physical addresses instead of virtual.
address decoding is now performed on the translated address which comes
from the memory mapper, instead of the address coming directly from the
cpu.

This means that you can access the full amount of ram at any address
that it is mapped to.
2022-04-07 12:32:51 -05:00
Byron Lathi
5548f9d02a Update mm_testbench 2022-04-07 10:48:10 -05:00
Byron Lathi
7434621209 Update cs_testbench.sv 2022-04-07 10:40:11 -05:00
Byron Lathi
35040860e7 Identity map memory upon reset
Upon reset the mapper is set to identity map and then enabled.
2022-04-07 10:36:50 -05:00
Byron Lathi
be497ecaa9 Add reset input to memory mapper
Upon reset the memory mapper is automatically disabled, but the mappings
are not cleared.
2022-04-07 10:35:16 -05:00
Byron Lathi
a15dde0e89 Add memory mapper software interface
Adds functions to read and write mappings, as well as enable and disable
the memory mapper.

This also moves increases the io space by 16 bytes.
2022-04-07 10:33:50 -05:00
Byron Lathi
3c44be8e6d Add mm_testbench to gitlab-ci 2022-04-05 17:31:24 -05:00
Byron Lathi
d9474df523 Update cs_testbench.sv 2022-04-05 17:27:28 -05:00