Merge branch 'board-io' into 'master'
Add board-io, replace sevenseg in sw See merge request bslathi19/super6502!8
This commit is contained in:
@@ -5,7 +5,8 @@ module addr_decode(
|
|||||||
output logic rom_cs,
|
output logic rom_cs,
|
||||||
output logic hex_cs,
|
output logic hex_cs,
|
||||||
output logic uart_cs,
|
output logic uart_cs,
|
||||||
output logic irq_cs
|
output logic irq_cs,
|
||||||
|
output logic board_io_cs
|
||||||
);
|
);
|
||||||
|
|
||||||
assign rom_cs = addr >= 16'h8000;
|
assign rom_cs = addr >= 16'h8000;
|
||||||
@@ -13,6 +14,7 @@ assign ram_cs = addr < 16'h4000;
|
|||||||
assign sdram_cs = addr >= 16'h4000 && addr < 16'h7ff0;
|
assign sdram_cs = addr >= 16'h4000 && addr < 16'h7ff0;
|
||||||
assign hex_cs = addr >= 16'h7ff0 && addr < 16'h7ff4;
|
assign hex_cs = addr >= 16'h7ff0 && addr < 16'h7ff4;
|
||||||
assign uart_cs = addr >= 16'h7ff4 && addr < 16'h7ff6;
|
assign uart_cs = addr >= 16'h7ff4 && addr < 16'h7ff6;
|
||||||
|
assign board_io_cs = addr == 16'h7ff6;
|
||||||
assign irq_cs = addr == 16'h7fff;
|
assign irq_cs = addr == 16'h7fff;
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|||||||
27
hw/fpga/board_io.sv
Normal file
27
hw/fpga/board_io.sv
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
module board_io(
|
||||||
|
input clk,
|
||||||
|
input rst,
|
||||||
|
|
||||||
|
input rw,
|
||||||
|
|
||||||
|
input [7:0] data_in,
|
||||||
|
input cs,
|
||||||
|
input [1:0] addr,
|
||||||
|
|
||||||
|
output logic [7:0] data_out,
|
||||||
|
|
||||||
|
output logic [7:0] led,
|
||||||
|
input [7:0] sw
|
||||||
|
);
|
||||||
|
|
||||||
|
assign data_out = sw;
|
||||||
|
|
||||||
|
|
||||||
|
always_ff @(posedge clk) begin
|
||||||
|
if (rst)
|
||||||
|
led = '0;
|
||||||
|
if (~rw & cs)
|
||||||
|
led <= data_in;
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule
|
||||||
@@ -9,10 +9,11 @@ logic ram_cs;
|
|||||||
logic sdram_cs;
|
logic sdram_cs;
|
||||||
logic rom_cs;
|
logic rom_cs;
|
||||||
logic hex_cs;
|
logic hex_cs;
|
||||||
|
logic board_io_cs;
|
||||||
logic uart_cs;
|
logic uart_cs;
|
||||||
logic irq_cs;
|
logic irq_cs;
|
||||||
|
|
||||||
int cs_count = ram_cs + sdram_cs + rom_cs + hex_cs + uart_cs;
|
int cs_count = ram_cs + sdram_cs + rom_cs + hex_cs + uart_cs + board_io_cs;
|
||||||
|
|
||||||
addr_decode dut(.*);
|
addr_decode dut(.*);
|
||||||
|
|
||||||
@@ -44,6 +45,11 @@ initial begin : TEST_VECTORS
|
|||||||
else
|
else
|
||||||
$error("Bad CS! addr=%4x should have uart_cs!", addr);
|
$error("Bad CS! addr=%4x should have uart_cs!", addr);
|
||||||
end
|
end
|
||||||
|
if (i == 16'h7ff6) begin
|
||||||
|
assert(board_io_cs == '1)
|
||||||
|
else
|
||||||
|
$error("Bad CS! addr=%4x should have board_io_cs!", addr);
|
||||||
|
end
|
||||||
if (i == 16'h7fff) begin
|
if (i == 16'h7fff) begin
|
||||||
assert(irq_cs == '1)
|
assert(irq_cs == '1)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ module super6502(
|
|||||||
input logic UART_RXD,
|
input logic UART_RXD,
|
||||||
output logic UART_TXD,
|
output logic UART_TXD,
|
||||||
|
|
||||||
|
input [7:0] SW,
|
||||||
|
output [7:0] LED,
|
||||||
|
|
||||||
///////// SDRAM /////////
|
///////// SDRAM /////////
|
||||||
output DRAM_CLK,
|
output DRAM_CLK,
|
||||||
output DRAM_CKE,
|
output DRAM_CKE,
|
||||||
@@ -57,6 +60,7 @@ logic [7:0] ram_data_out;
|
|||||||
logic [7:0] sdram_data_out;
|
logic [7:0] sdram_data_out;
|
||||||
logic [7:0] uart_data_out;
|
logic [7:0] uart_data_out;
|
||||||
logic [7:0] irq_data_out;
|
logic [7:0] irq_data_out;
|
||||||
|
logic [7:0] board_io_data_out;
|
||||||
|
|
||||||
logic ram_cs;
|
logic ram_cs;
|
||||||
logic sdram_cs;
|
logic sdram_cs;
|
||||||
@@ -64,6 +68,7 @@ logic rom_cs;
|
|||||||
logic hex_cs;
|
logic hex_cs;
|
||||||
logic uart_cs;
|
logic uart_cs;
|
||||||
logic irq_cs;
|
logic irq_cs;
|
||||||
|
logic board_io_cs;
|
||||||
|
|
||||||
cpu_clk cpu_clk(
|
cpu_clk cpu_clk(
|
||||||
.inclk0(clk_50),
|
.inclk0(clk_50),
|
||||||
@@ -88,7 +93,8 @@ addr_decode decode(
|
|||||||
.rom_cs(rom_cs),
|
.rom_cs(rom_cs),
|
||||||
.hex_cs(hex_cs),
|
.hex_cs(hex_cs),
|
||||||
.uart_cs(uart_cs),
|
.uart_cs(uart_cs),
|
||||||
.irq_cs(irq_cs)
|
.irq_cs(irq_cs),
|
||||||
|
.board_io_cs(board_io_cs)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -103,6 +109,8 @@ always_comb begin
|
|||||||
cpu_data_out = uart_data_out;
|
cpu_data_out = uart_data_out;
|
||||||
else if (irq_cs)
|
else if (irq_cs)
|
||||||
cpu_data_out = irq_data_out;
|
cpu_data_out = irq_data_out;
|
||||||
|
else if (board_io_cs)
|
||||||
|
cpu_data_out = board_io_data_out;
|
||||||
else
|
else
|
||||||
cpu_data_out = 'x;
|
cpu_data_out = 'x;
|
||||||
end
|
end
|
||||||
@@ -157,6 +165,17 @@ SevenSeg segs(
|
|||||||
.HEX0(HEX0), .HEX1(HEX1), .HEX2(HEX2), .HEX3(HEX3), .HEX4(HEX4), .HEX5(HEX5)
|
.HEX0(HEX0), .HEX1(HEX1), .HEX2(HEX2), .HEX3(HEX3), .HEX4(HEX4), .HEX5(HEX5)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
board_io board_io(
|
||||||
|
.clk(clk),
|
||||||
|
.rst(rst),
|
||||||
|
.rw(cpu_rwb),
|
||||||
|
.data_in(cpu_data_in),
|
||||||
|
.data_out(board_io_data_out),
|
||||||
|
.cs(board_io_cs),
|
||||||
|
.led(LED),
|
||||||
|
.sw(SW)
|
||||||
|
);
|
||||||
|
|
||||||
logic uart_irq;
|
logic uart_irq;
|
||||||
|
|
||||||
uart uart(
|
uart uart(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef _SEVEN_SEG
|
#ifndef _BOARD_IO_H
|
||||||
#define _SEVEN_SEG
|
#define _BOARD_IO_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@@ -9,4 +9,8 @@ uint8_t hex_set_24(uint32_t val);
|
|||||||
|
|
||||||
void hex_enable(uint8_t mask);
|
void hex_enable(uint8_t mask);
|
||||||
|
|
||||||
|
uint8_t sw_read();
|
||||||
|
|
||||||
|
void led_set(uint8_t val);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
.export _hex_set_16
|
.export _hex_set_16
|
||||||
.export _hex_set_24
|
.export _hex_set_24
|
||||||
.export _hex_enable
|
.export _hex_enable
|
||||||
|
.export _sw_read
|
||||||
|
.export _led_set
|
||||||
|
|
||||||
.autoimport on
|
.autoimport on
|
||||||
|
|
||||||
@@ -52,4 +54,18 @@ _hex_set_24:
|
|||||||
; Set the mask for seven seg enables
|
; Set the mask for seven seg enables
|
||||||
_hex_enable:
|
_hex_enable:
|
||||||
sta SEVEN_SEG+3
|
sta SEVEN_SEG+3
|
||||||
|
rts
|
||||||
|
|
||||||
|
; @out A: The Value of the switches
|
||||||
|
; Reads the current values of the switches.
|
||||||
|
_sw_read:
|
||||||
|
lda SW
|
||||||
|
ldx #$0
|
||||||
|
rts
|
||||||
|
|
||||||
|
; @in A: val
|
||||||
|
; @out A: 0 for success, 1 for failure
|
||||||
|
; Sets the LEDs
|
||||||
|
_led_set:
|
||||||
|
sta LED
|
||||||
rts
|
rts
|
||||||
@@ -5,4 +5,7 @@ UART_TXB = UART
|
|||||||
UART_RXB = UART
|
UART_RXB = UART
|
||||||
UART_STATUS = UART + 1
|
UART_STATUS = UART + 1
|
||||||
|
|
||||||
|
LED = $7ff6
|
||||||
|
SW = LED
|
||||||
|
|
||||||
IRQ_STATUS = $7fff
|
IRQ_STATUS = $7fff
|
||||||
|
|||||||
1
sw/irq.c
1
sw/irq.c
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include "interrupt.h"
|
#include "interrupt.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
#include "sevenseg.h"
|
|
||||||
|
|
||||||
char lastchar;
|
char lastchar;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
|
|
||||||
#include "sevenseg.h"
|
#include "board_io.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int i;
|
int i;
|
||||||
|
uint8_t sw;
|
||||||
char s[16];
|
char s[16];
|
||||||
s[15] = 0;
|
s[15] = 0;
|
||||||
|
|
||||||
@@ -13,6 +14,10 @@ int main() {
|
|||||||
cprintf("Hello, world!\n");
|
cprintf("Hello, world!\n");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
|
sw = sw_read();
|
||||||
|
led_set(sw);
|
||||||
|
|
||||||
cscanf("%15s", s);
|
cscanf("%15s", s);
|
||||||
cprintf("\n");
|
cprintf("\n");
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "sevenseg.h"
|
#include "board_io.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
#include "interrupt.h"
|
#include "interrupt.h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user