-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOTTER_Wrapper_v1_02.sv
85 lines (70 loc) · 2.94 KB
/
OTTER_Wrapper_v1_02.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
`timescale 1ns / 1ps
/////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer: J. Calllenes
// P. Hummel
//
// Create Date: 01/20/2019 10:36:50 AM
// Module Name: OTTER_Wrapper
// Target Devices: OTTER MCU on Basys3
// Description: OTTER_WRAPPER with Switches, LEDs, and 7-segment display
//
// Revision:
// Revision 0.01 - File Created
// Revision 0.02 - Updated MMIO Addresses, signal names
/////////////////////////////////////////////////////////////////////////////
module OTTER_Wrapper(
input CLK,
input BTNL,
input BTNC,
input [15:0] SWITCHES,
output logic [15:0] LEDS,
output [7:0] CATHODES,
output [3:0] ANODES
);
// INPUT PORT IDS ///////////////////////////////////////////////////////
// Right now, the only possible inputs are the switches
// In future labs you can add more MMIO, and you'll have
// to add constants here for the mux below
localparam SWITCHES_AD = 32'h11000000;
// OUTPUT PORT IDS //////////////////////////////////////////////////////
// In future labs you can add more MMIO
localparam LEDS_AD = 32'h11000020; //32'h11000020
localparam SSEG_AD = 32'h11000040; //32'h11000040
// Signals for connecting OTTER_MCU to OTTER_wrapper /////////////////////
logic clk_50 = 0;
logic [31:0] IOBUS_out, IOBUS_in, IOBUS_addr;
logic s_reset, IOBUS_wr;
// Registers for buffering outputs /////////////////////////////////////
logic [15:0] r_SSEG;
logic DB_BTN;
debounce_one_shot btnDB (.CLK(CLK), .BTN(BTNL), .DB_BTN(DB_BTN));
// Declare OTTER_CPU ////////////////////////////////////////////////////
OTTER_MCU CPU (.CPU_RST(s_reset), .CPU_INTR(DB_BTN), .CPU_CLK(clk_50),
.CPU_IOBUS_OUT(IOBUS_out), .CPU_IOBUS_IN(IOBUS_in),
.CPU_IOBUS_ADDR(IOBUS_addr), .CPU_IOBUS_WR(IOBUS_wr));
// Declare Seven Segment Display /////////////////////////////////////////
SevSegDisp SSG_DISP (.DATA_IN(r_SSEG), .CLK(CLK), .MODE(1'b0),
.CATHODES(CATHODES), .ANODES(ANODES));
// Clock Divider to create 50 MHz Clock //////////////////////////////////
always_ff @(posedge CLK) begin
clk_50 <= ~clk_50;
end
// Connect Signals ///////////////////////////////////////////////////////
assign s_reset = BTNC;
// Connect Board input peripherals (Memory Mapped IO devices) to IOBUS
always_comb begin
case(IOBUS_addr)
SWITCHES_AD: IOBUS_in = {16'b0,SWITCHES};
default: IOBUS_in = 32'b0; // default bus input to 0
endcase
end
// Connect Board output peripherals (Memory Mapped IO devices) to IOBUS
always_ff @ (posedge clk_50) begin
if(IOBUS_wr)
case(IOBUS_addr)
LEDS_AD: LEDS <= IOBUS_out[15:0];
SSEG_AD: r_SSEG <= IOBUS_out[15:0];
endcase
end
endmodule