end
endmodule
-//module Switches(
-// input [15:0] address,
-// inout [7:0] data,
-// input clk,
-// input wr, rd,
-// input [7:0] switches,
-// output reg [7:0] ledout);
+module Switches(
+ input [15:0] address,
+ inout [7:0] data,
+ input clk,
+ input wr, rd,
+ input [7:0] switches,
+ output reg [7:0] ledout);
-// wire decode = address == 16'hFF51;
-// reg [7:0] odata;
-// wire idata = data;
-// assign data = (rd && decode) ? odata : 8'bzzzzzzzz;
+ wire decode = address == 16'hFF51;
+ reg [7:0] odata;
+ wire idata = data;
+ assign data = (rd && decode) ? odata : 8'bzzzzzzzz;
-// always @(negedge clk)
-// begin
-// if (decode && rd)
-// odata <= switches;
-// else if (decode && wr)
-// ledout <= data;
-// end
-//endmodule
+ always @(negedge clk)
+ begin
+ if (decode && rd)
+ odata <= switches;
+ else if (decode && wr)
+ ledout <= data;
+ end
+endmodule
module CoreTop(
- input iclk, xtal,
+ input xtal,
+ input [1:0] switches,
output wire [7:0] leds,
output serio,
output wire [3:0] digits,
wire [7:0] data;
wire wr, rd;
- assign leds = iclk?{rd,wr,addr[5:0]}:data[7:0];
+ wire [7:0] ledout;
+ assign leds = switches[1] ? (switches[0]?{rd,wr,addr[5:0]}:data[7:0])
+ : ledout;
GBZ80Core core(
.clk(clk),
AddrMon amon(
.addr(addr),
- .clk(xtal),
+ .clk(clk),
.digit(digits),
.out(seven)
);
-
- assign serio = 0;
+
+ Switches sw(
+ .address(addr),
+ .data(data),
+ .clk(clk),
+ .wr(wr),
+ .rd(rd),
+ .ledout(ledout),
+ .switches(0)
+ );
+
+ UART nouart (
+ .clk(clk),
+ .wr(wr),
+ .rd(rd),
+ .addr(addr),
+ .data(data),
+ .serial(serio)
+ );
endmodule
module TestBench();