Add basics for ACIA 6551:w

This commit is contained in:
Ariejan de Vroom 2014-08-17 16:49:22 +02:00
parent 7e5984cd6f
commit 90e248e745
2 changed files with 43 additions and 0 deletions

28
acia6551.go Normal file
View File

@ -0,0 +1,28 @@
package i6502
/*
ACIA 6551 Serial IO
*/
type Acia6551 struct {
rx chan byte // Reading (Acia Input) line
tx chan byte // Transmitting (Acia Output) line
}
func NewAcia6551(rx chan byte, tx chan byte) (*Acia6551, error) {
return &Acia6551{tx: tx, rx: rx}, nil
}
func (r *Acia6551) Size() uint16 {
// We have a only 4 addresses, RX, TX, Command and Control
return 0x04
}
/*
func (r *Rom) Read(address uint16) byte {
return r.data[address]
}
func (r *Rom) Write(address uint16, data byte) {
panic(fmt.Errorf("Trying to write to ROM at 0x%04X", address))
}
*/

15
acia6551_test.go Normal file
View File

@ -0,0 +1,15 @@
package i6502
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestNewAcia6551(t *testing.T) {
tx := make(chan byte)
rx := make(chan byte)
acia, err := NewAcia6551(rx, tx)
assert.Nil(t, err)
assert.Equal(t, 0x4, acia.Size())
}