Skip to content
Snippets Groups Projects
Commit c97f2d80 authored by Byron Lathi's avatar Byron Lathi
Browse files

Merge branch 'board-io' into 'master'

Add board-io, replace sevenseg in sw

See merge request !8
parents 63b942e2 5c32fe80
No related branches found
No related tags found
1 merge request!8Add board-io, replace sevenseg in sw
Checking pipeline status
......@@ -5,7 +5,8 @@ module addr_decode(
output logic rom_cs,
output logic hex_cs,
output logic uart_cs,
output logic irq_cs
output logic irq_cs,
output logic board_io_cs
);
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 hex_cs = addr >= 16'h7ff0 && addr < 16'h7ff4;
assign uart_cs = addr >= 16'h7ff4 && addr < 16'h7ff6;
assign board_io_cs = addr == 16'h7ff6;
assign irq_cs = addr == 16'h7fff;
endmodule
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 rom_cs;
logic hex_cs;
logic board_io_cs;
logic uart_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(.*);
......@@ -44,6 +45,11 @@ initial begin : TEST_VECTORS
else
$error("Bad CS! addr=%4x should have uart_cs!", addr);
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
assert(irq_cs == '1)
else
......
......@@ -26,6 +26,9 @@ module super6502(
input logic UART_RXD,
output logic UART_TXD,
input [7:0] SW,
output [7:0] LED,
///////// SDRAM /////////
output DRAM_CLK,
output DRAM_CKE,
......@@ -57,6 +60,7 @@ logic [7:0] ram_data_out;
logic [7:0] sdram_data_out;
logic [7:0] uart_data_out;
logic [7:0] irq_data_out;
logic [7:0] board_io_data_out;
logic ram_cs;
logic sdram_cs;
......@@ -64,6 +68,7 @@ logic rom_cs;
logic hex_cs;
logic uart_cs;
logic irq_cs;
logic board_io_cs;
cpu_clk cpu_clk(
.inclk0(clk_50),
......@@ -88,7 +93,8 @@ addr_decode decode(
.rom_cs(rom_cs),
.hex_cs(hex_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;
else if (irq_cs)
cpu_data_out = irq_data_out;
else if (board_io_cs)
cpu_data_out = board_io_data_out;
else
cpu_data_out = 'x;
end
......@@ -157,6 +165,17 @@ SevenSeg segs(
.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;
uart uart(
......
#ifndef _SEVEN_SEG
#define _SEVEN_SEG
#ifndef _BOARD_IO_H
#define _BOARD_IO_H
#include <stdint.h>
......@@ -9,4 +9,8 @@ uint8_t hex_set_24(uint32_t val);
void hex_enable(uint8_t mask);
uint8_t sw_read();
void led_set(uint8_t val);
#endif
\ No newline at end of file
......@@ -6,6 +6,8 @@
.export _hex_set_16
.export _hex_set_24
.export _hex_enable
.export _sw_read
.export _led_set
.autoimport on
......@@ -52,4 +54,18 @@ _hex_set_24:
; Set the mask for seven seg enables
_hex_enable:
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
\ No newline at end of file
......@@ -5,4 +5,7 @@ UART_TXB = UART
UART_RXB = UART
UART_STATUS = UART + 1
LED = $7ff6
SW = LED
IRQ_STATUS = $7fff
......@@ -4,7 +4,6 @@
#include "interrupt.h"
#include "uart.h"
#include "sevenseg.h"
char lastchar;
......
#include <stdint.h>
#include <conio.h>
#include "sevenseg.h"
#include "board_io.h"
#include "uart.h"
int main() {
int i;
uint8_t sw;
char s[16];
s[15] = 0;
......@@ -13,6 +14,10 @@ int main() {
cprintf("Hello, world!\n");
while (1) {
sw = sw_read();
led_set(sw);
cscanf("%15s", s);
cprintf("\n");
for (i = 0; i < 16; i++)
......
#include <stdio.h>
#include "sevenseg.h"
#include "board_io.h"
#include "uart.h"
#include "interrupt.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment