--------------------------------------------------------------------------------
--- Registers:
+-- host_ctrl - Generic host control interface for Nexys2 board
--
--- 0: CTRL
--- 1: MBOX_FLAGS
--- 2: MBOX_VALUE
--- 3: SW(R)/LED(W)
--- 4: SSEG0
--- 5: SSEG1
--- 6: SSEG2
--- 7: SSEG3
+-- Drop-in module that rovides host computer access to onboard memory, switches,
+-- LEDs, and signalling to any other device programmed to the FPGA
+--------------------------------------------------------------------------------
+-- Registers (Host EPP interface):
+--
+-- +---+---+---+---+---+---+---+---+
+-- | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+-- +---+---+---+---+---+---+---+---+
+-- 0x0 |RST|MEM| | CTRL
+-- +---+---+-----------------------+
+-- 0x1 | MBOX_FLAGS(W1S) |
+-- +-------------------------------+
+-- 0x2 | MBOX_VALUE |
+-- +-------------------------------+
+-- 0x3 | SW(R)/LED(W) |
+-- +-------------------------------+
+-- 0x4 | SSEG0 |
+-- +-------------------------------+
+-- 0x5 | SSEG1 |
+-- +-------------------------------+
+-- 0x6 | SSEG2 |
+-- +-------------------------------+
+-- 0x7 | SSEG3 |
+-- +---+---+---+---+---+---+---+---+
+-- 0x8 |FLS|FLS| | | |RAM|RAM|AUT| MEM_CTRL
+-- |RST|CS | | | |CS |CRE|CNT|
+-- +---+---+---+---+---+---+---+---+
+-- 0x9 | ADDR_L | (BIT 0 IGNORED)
+-- +-------------------------------+
+-- 0xa | ADDR_M |
+-- +-------------------------------+
+-- 0xb | ADDR_H |
+-- +-------------------------------+
+-- 0xc | DATA_L | (TRANSFER TRIGGER)
+-- +-------------------------------+
+-- 0xd | DATA_H |
+-- +-------------------------------+
+-- 0xe | (RESERVED) |
+-- +-------------------------------+
+-- 0xf | (RESERVED) |
+-- +-------------------------------+
+--
+-- CTRL
+-- Read-only
+-- RST - Active-high reset signal to device
+-- MEM - 1: Host computer controls onboard memory over USB-EPP interface
+-- 0: Device controls onboard memory
+--
+-- MBOX_FLAGS
+-- Write-one-to-clear
+-- Eight independant signalling bits from the host computer to the device,
+-- intended for use as interrupt signals
+--
+-- MBOX_VALUE
+-- Eight-bit value readable and writable by both host and device, intended for
+-- small data transfers and signalling between host and device
+--
+-- SW(R)/LED(W)
+-- Readable and writable by both host and device
+-- Reads return the current positions of the switches on the Nexys2 board
+-- Writes set the state of the LEDs above the switches on the Nexys2 board
+--
+-- SSEGn
+-- Readable and writable by both host and device
+-- SSEG0 is the right-most (least-significant) seven-segment display
+-- SSEG3 is the left-most (most-significant) seven-segment display
+-- Values are active-low (segment is turned on when written to 0)
+-- Bit to segment mapping:
+-- (0)
+-- ------
+-- | |
+-- (5)| |(1)
+-- | (6) |
+-- ------
+-- | |
+-- (4)| |(2)
+-- | |
+-- ------ o(7)
+-- (3)
+--
+-- MEM_CTRL
+-- FLS_RST - Wired to the onboard flash reset signal, active low
+-- FLS_CS - When clear, transfers go to the onboard flash
+-- RAM_CS - When clear, transfers go to the onboard RAM
+-- RAM_CRE - Wired to the onboard RAM's CRE signal, active high
+-- AUT_CNT - Address auto-count, when set, increments addr by 2 each transaction
+-- Behavior when both FLS_CS and RAM_CS are clear is undefined
+--
+-- ADDR_L/M/H
+-- 24-bit address used for the memory transaction, treated as a byte-address,
+-- ADDR_L(0) is ignored
+--
+-- DATA_L/H
+-- 16-bit value read from or written to memory
+-- Reads/writes to DATA_L trigger a transaction:
+-- - For reads, read DATA_L first then DATA_H
+-- - For writes, write DATA_H first then DATA_L
+--
+--------------------------------------------------------------------------------
+-- Registers (Device Wishbone interface):
+--
+-- +---+---+---+---+---+---+---+---+
+-- | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+-- +---+---+---+---+---+---+---+---+
+-- 0 |RST|MEM| | CTRL(RO)
+-- +---+---+-----------------------+
+-- 1 | MBOX_FLAGS(W1C) |
+-- +-------------------------------+
+-- 2 | MBOX_VALUE |
+-- +-------------------------------+
+-- 3 | SW(R)/LED(W) |
+-- +-------------------------------+
+-- 4 | SSEG0 |
+-- +-------------------------------+
+-- 5 | SSEG1 |
+-- +-------------------------------+
+-- 6 | SSEG2 |
+-- +-------------------------------+
+-- 7 | SSEG3 |
+-- +-------------------------------+
+--
+-- CTRL
+-- Read-only
+-- RST - Active-high reset signal to device
+-- MEM - 1: Host computer controls onboard memory over USB-EPP interface
+-- 0: Device controls onboard memory
+--
+-- MBOX_FLAGS
+-- Write-one-to-clear
+-- Eight independant signalling bits from the host computer to the device,
+-- intended for use as interrupt signals
+--
+-- MBOX_VALUE
+-- Eight-bit value readable and writable by both host and device, intended for
+-- small data transfers and signalling between host and device
+--
+-- SW(R)/LED(W)
+-- Readable and writable by both host and device
+-- Reads return the current positions of the switches on the Nexys2 board
+-- Writes set the state of the LEDs above the switches on the Nexys2 board
+--
+-- SSEGn
+-- Readable and writable by both host and device
+-- SSEG0 is the right-most (least-significant) seven-segment display
+-- SSEG3 is the left-most (most-significant) seven-segment display
+-- Values are active-low (segment is turned on when written to 0)
+-- Bit to segment mapping:
+-- (0)
+-- ------
+-- | |
+-- (5)| |(1)
+-- | (6) |
+-- ------
+-- | |
+-- (4)| |(2)
+-- | |
+-- ------ o(7)
+-- (3)
+--
+--------------------------------------------------------------------------------
+-- WISHBONE DATASHEET
+--
+-- Wishbone specification used: Rev B.3
+-- Interface type: device
+-- Port size: 8-bit
+-- Operand sizes: 8-bit
+-- Endianness: undefined (port size same as granularity)
+-- Data transfer sequence: undefined
+-- Clock constraints: none
+-- Signals:
+-- * rst_i
+-- * clk_i
+-- * d_cyc_i (CYC_I)
+-- * d_stb_i (STB_I)
+-- * d_we_i (WE_I)
+-- * d_ack_o (ACK_O)
+-- * d_adr_i (ADR_I, 3-bit)
+-- * d_dat_i (DAT_I, 8-bit)
+-- * d_dat_o (DAT_O, 8-bit)
--------------------------------------------------------------------------------
library ieee;
+--------------------------------------------------------------------------------
+-- host_regs - host control register file for Nexys2
+--
+-- Intended to be used by "host_ctrl" entity
+--------------------------------------------------------------------------------
+-- WISHBONE DATASHEET (Host-side)
+--
+-- Wishbone specification used: Rev B.3
+-- Interface type: device
+-- Port size: 8-bit
+-- Operand sizes: 8-bit
+-- Endianness: undefined (port size same as granularity)
+-- Data transfer sequence: undefined
+-- Clock constraints: none
+-- Signals:
+-- * rst_i
+-- * clk_i
+-- * h_cyc_i (CYC_I)
+-- * h_stb_i (STB_I)
+-- * h_we_i (WE_I)
+-- * h_ack_o (ACK_O)
+-- * h_adr_i (ADR_I, 3-bit)
+-- * h_dat_i (DAT_I, 8-bit)
+-- * h_dat_o (DAT_O, 8-bit)
+--------------------------------------------------------------------------------
+-- WISHBONE DATASHEET (Device-side)
+--
+-- Wishbone specification used: Rev B.3
+-- Interface type: device
+-- Port size: 8-bit
+-- Operand sizes: 8-bit
+-- Endianness: undefined (port size same as granularity)
+-- Data transfer sequence: undefined
+-- Clock constraints: none
+-- Signals:
+-- * rst_i
+-- * clk_i
+-- * d_cyc_i (CYC_I)
+-- * d_stb_i (STB_I)
+-- * d_we_i (WE_I)
+-- * d_ack_o (ACK_O)
+-- * d_adr_i (ADR_I, 3-bit)
+-- * d_dat_i (DAT_I, 8-bit)
+-- * d_dat_o (DAT_O, 8-bit)
+--------------------------------------------------------------------------------
+
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;